VisualTree

Register the native Android VisualTree tool suite to inspect the view hierarchy, capture screenshots, and manage diagnostic overlays.

Install

Published artifact: ai.ansight:ansight-tools-visualtree-android.

dependencies {
    debugImplementation("ai.ansight:ansight-tools-visualtree-android:1.0.2-preview.1")
}

Register the Suite

import ai.ansight.runtime.AnsightOptions
import ai.ansight.tools.visualtree.withVisualTreeTools

val options = AnsightOptions.createBuilder()
    .withVisualTreeTools()
    .withReadOnlyToolAccess()
    .build()

Registration API

  • withVisualTreeTools(): registers the visual tree, screenshot, and diagnostic overlay suite.
  • AndroidVisualTreeTools.create(): creates the suite tools for lower-level registration.
  • withReadOnlyToolAccess(): exposes visual tree, screenshot, node inspection, and read-only overlay tools.
  • withReadWriteToolAccess(): also exposes overlay creation and update.
  • withAllToolAccess(): also exposes overlay removal and clearing.

Specific Concerns

  • The tools inspect the active Android view hierarchy.
  • Screenshot capture exports rendered UI content.
  • ui.get_screenshot streams bytes over the binary transfer channel.
  • Overlay deletion tools are delete-scoped on Android.

Important: Calling screenshot tools will result in an FPS drop while the current frame is captured, encoded, and transferred. Avoid screenshot-heavy investigations during performance measurements unless visual evidence is required.

Tool Matrix

NameIdScopeDescriptionSecurity
Get Visual Treeui.get_visual_treeReadReturns the current visual hierarchy for the requested source.High
Get Screenshotui.get_screenshotReadCaptures a screenshot and streams bytes over binary transfer.High
Inspect Nodeui.inspect_nodeReadReturns one node from the current visual tree.High
Show Overlayui.show_overlayWriteShows a rectangular diagnostic overlay.Critical
Get Overlayui.get_overlayReadReturns one diagnostic overlay.High
Query Overlaysui.query_overlaysReadLists active diagnostic overlays.High
Update Overlayui.update_overlayWriteUpdates a diagnostic overlay.Critical
Remove Overlayui.remove_overlayDeleteRemoves a diagnostic overlay.Critical
Clear Overlaysui.clear_overlaysDeleteClears diagnostic overlays.Critical

Tool Details

Use read tools for inspection and screenshots. Use write tools to draw or update overlays. Use delete tools only when the session needs to remove overlays remotely.