Android ADB
Using Helper Scripts vs. Raw ADB
Use the scripts in scripts/ as the primary interface for device workflows.
References to scripts/... in this skill are relative to this skill directory.
They encapsulate solutions to common Android and Wear OS platform quirks:
- Automatic circular display masking and density scaling for Wear OS screenshots
- Device wake-up and keyguard dismissal prior to capture
- Clipboard integration on macOS
- Sensible default filenames and robust error handling
When to use raw adb: For general diagnostic inspection not covered by
these scripts (e.g. adb logcat, adb shell pm list), or when building custom
pipelines, standard adb commands are appropriate. If a helper script fails or
lacks a specific flag you need, inspect its source in scripts/ to understand
the underlying dumpsys or input sequence and adapt it.
Quick Start
When multiple devices are connected, pass -s SERIAL or --serial SERIAL
before other arguments to any skill script. The flag overrides ANDROID_SERIAL;
the environment variable remains available for persistent or inherited device
selection.
Highest-Value Commands
- Screenshot (auto-masks circular Wear OS displays):
scripts/adb-screenshot
- Wear OS Tile Debugging Workflow:
scripts/adb-tile-add com.example/.MyTileService -> output gives INDEX
scripts/adb-tile-switch INDEX
- Inspect Wear OS Data Layer:
adb exec-out dumpsys activity service WearableService
- Pair Phone & Wear OS Emulators (Data Layer Bridge):
scripts/adb-wear-pair (or scripts/adb-wear-pair --status to inspect
pairing state)
- Package Information:
scripts/packagename tiles PACKAGE_NAME,
scripts/packagename dumpsys PACKAGE_NAME (manifest components),
scripts/packagename services PACKAGE_NAME (active/running services)
- Device Info:
scripts/adb-device-properties
- Discover Activities:
scripts/adb-activities [PACKAGE](find launcher,
TV, settings activities across user apps or for a specific package)
Script Index
See references/command-index.md for detailed usage.
Device Basics
scripts/adb-device-properties: Show key device properties (model,
manufacturer, API level, display size, etc.).
scripts/adb-log: Write a message to the system log.
For simple one-shot operations (listing device serials, waking or sleeping the
device, filtering logcat by tag, sending VIEW intents, toggling "Show touches"),
use raw adb commands. See
references/command-index.md for
the exact invocations, including non-obvious flags.
Media Capture
scripts/adb-screenshot: Take a screenshot. **Always use this instead of raw
adb shell screencap.** Features: auto-detects square Wear OS displays and
applies circular mask, wakes device before capture by default (pass
--no-wake to preserve Wear OS Ambient / Always-On Display state), copies to
macOS clipboard, generates timestamped filenames by default.
scripts/adb-screenrecord: Record the screen to a file. Automatically detects
devices that require raw frame streaming (e.g., Samsung Wear OS watches) and
uses ffmpeg for capture, while defaulting to scrcpy for standard devices.
Tile Management (Wear OS)
scripts/adb-tile-add: Add a tile component for debugging. Supports
--type FULLSCREEN|LARGE|SMALL (default LARGE) for services declaring
BIND_WIDGET_PROVIDER (Glance widgets); FULLSCREEN produces a full-screen
tile.
scripts/adb-tile-switch: Switch the active tile.scripts/adb-tile-remove: Remove a tile byCOMPONENT_NAMEfrom the SysUI
carousel, or remove tray widgets by ID, component, or --all with
--vertical.
scripts/adb-tiles: List installed tiles and indicate which are in the
carousel.
scripts/adb-tile-dump: Export a tray widget's Remote Compose document
(.rc) and print its rendering context as JSON.
scripts/adb-watchface-set: Set the current watch face.scripts/adb-complication-update: Trigger a complication update on Wear OS
via DEBUG_SYSUI.
With --vertical, adb-tile-add, adb-tile-remove, and adb-tiles target the
standalone renderer's vertical carousel (WidgetTrayActivity, .emu, .exp,
and .dev renderer flavors) instead of the SysUI carousel (--vertical
supports only LARGE and SMALL container types). Tray widgets are addressed
by numeric widget ID (starting at 10001, up to 25 widgets) or component
name:
scripts/adb-tile-add --vertical --type LARGE com.example/.MyWidgetService
scripts/adb-tiles --vertical # => 10001 LARGE com.example/.MyWidgetService
scripts/adb-tile-remove --vertical --all # reset the tray before a capture
scripts/adb-tile-dump -o widget.rc 10001 > widget.meta.json
- Renderer version and root guards:
adb-tile-add --verticaland
adb-tile-remove --vertical <ID|COMPONENT> work on all tray-capable renderer
builds (including the 1.6.5.41.* .emu renderer bundled in the Wear OS 7.1
Beta RC1 emulator; on .emu builds where Log.d is stripped by ProGuard,
adb-tile-add --vertical checks for post-render Log.e / crash failures
without timing out on Log.d). By contrast, adb-tiles --vertical,
adb-tile-remove --vertical --all, and adb-tile-dump require a renderer
build with GET_WIDGETS / DUMP_RC_DOC (>= 1.6.6.13) and exit with a clear
version message on older .emu builds. adb-tile-dump also requires root
(adb root on userdebug emulators or su on userdebug devices) to read
the cached .rc file; user builds cannot export .rc files.
[!NOTE] Tile Indexing (
Index=[0]): When adding a new tile using
scripts/adb-tile-add, the output often indicatesIndex=[0]. This means the
tile was added to the first position in the carousel, pushing existing
tiles down. It does _not_ mean it has overwritten previous tiles.
Verifying Installed Tiles: Use
scripts/adb-tilesto list all installed
tiles and see which ones are currently in the carousel. The output uses
prefixes like
UTWCwhereCindicates it is in the carousel.
Activity Discovery
scripts/adb-activities: List activities tagged by category (Launcher, Home,
TV/Leanback, Settings), optionally filtered to a single PACKAGE. Use
--launcher-only, --tv-only, --settings-only to filter by category, or
--all to include system apps.
scripts/adb-uihierarchy: Dump the UI hierarchy to an XML file with bounded
timeout and --compressed fallback so animated screens do not hang.
scripts/adb-currentfocus: Display the focused package, activity, or detected
UI toolkit (--toolkit, --details, --json).
Package Operations
scripts/packagename: Comprehensive package tool (launch,force-stop,
uninstall, clear-cache, pull, tiles, dumpsys for manifest
components, services for running services, logcat, jobscheduler).
scripts/adb-packages: List installed packages.
System & Dumpsys
scripts/adb-battery-stats: Display battery-related information and settings.scripts/adb-wear-pair: Headlessly pair a running phone emulator
(google_apis / google_apis_ps16k userdebug) with a Wear OS emulator over
TCP port 5601, or inspect current pairing status (--status).
Display & Demo Mode
scripts/adb-demo: Toggle Android demo mode (on/off): clean status bar,
fixed clock, show touches, long screen timeout.
scripts/adb-fontscale: Get or set the system font scale (get/
set default|large|NUMBER).
scripts/adb-theme: Get or set system theme customization (e.g., set to
'lemongrass'). Requires Wear OS 6+ (API 36+).
scripts/adb-settings-theme: Open system theme settings (requires
root/debuggable build).
Safety Notes
- Debug Broadcasts & Shell UID (
uid=2000): Tile management relies on Wear
OS debug broadcasts (com.google.android.wearable.app.DEBUG_SURFACE) which
may not work on production builds without developer options or specific system
images. Standard unrooted adb shell runs as uid=2000
(com.android.shell), so non-exported components and
signature/signatureOrSystem-protected receivers reject am broadcast
unless elevated via adb root or su 0.
- USB Debugging: Requires
adbauthorization. - Destructive Actions: Scripts like
adb-tile-remove(including
--vertical --all, which empties the widget tray) or packagename uninstall
modify device state.
Reference Material
- Command Reference: Detailed usage and arguments for all scripts. See
- Bug Report Capture: How to record markers, logcat, and screen captures for
bug reports. See
references/bug-report-capture.md.
- Troubleshooting: Solutions for connection issues, missing dependencies,
and Wear OS quirks. See