Run an adb shell command
android_shellExecutes adb shell commands for device inspection, covering tasks like dumpsys, pm, settings, getprop when dedicated tools are unavailable.
Instructions
Run an arbitrary command on the device via adb shell, for anything the dedicated tools do not cover.
Arguments are passed as an array and are not interpreted by a host shell, so quoting is not a concern. Note that the device's shell still applies its own semantics to things like redirection.
Prefer a dedicated tool when one exists — they parse output and explain failures. Reach for this for one-off inspection: dumpsys, pm, settings, getprop and similar.
Args:
command (string[]): command and arguments, e.g. ["dumpsys", "battery"]
serial (string, optional): target device
timeout_ms (number): command timeout (default: 30000)
Returns: { "stdout": string, "command": string, "serial": string }
Examples:
Use when: reading battery state -> command=["dumpsys", "battery"]
Use when: listing installed packages -> command=["pm", "list", "packages", "-3"]
Use when: checking a system setting -> command=["settings", "get", "global", "window_animation_scale"]
Don't use when: a dedicated tool covers it (android_logcat, android_dump_ui, android_tap)
Error Handling:
The device shell's own error text is returned verbatim
Commands needing root fail on production builds; there is no workaround on a locked device
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serial | No | Device serial from android_list_devices. Optional when exactly one device is connected; required when several are. | |
| command | Yes | Command and arguments as separate array elements. | |
| timeout_ms | No | Timeout in milliseconds. |