Device Interactions

Execute an adb shell command on an Android device

Runs an adb shell command on the device and returns stdout. This command is not available for iOS devices. The adbShellCommand should be the shell command without the 'adb shell' prefix (e.g., 'ls /' not 'adb shell ls /'). Use for checking device properties, listing packages, granting permissions, or any operation available through adb.

On a private device any adb shell command runs. On a public device, which is shared infrastructure, commands are restricted to an allowlist and anything outside it comes back as a 400. The allowlist is published in the mobile FAQ.

post/sessions/{sessionId}/device/executeShellCommand

Request

Path parameters

sessionIdstring required

The id of the device session

Request body

adbShellCommandstring required

The shell command to execute on the device. Note: you do not need to prefix your command with 'adb shell' to run.

Example request

{
  "adbShellCommand": "ls /"
}

Response

Command executed successfully

stdoutstring

The stdout of your shell command.

Example response

{
  "stdout": "acct                debug_ramdisk      keyrefuge       sdcard\napex                default.prop       linkerconfig    sepolicy_version\naudit_filter_table  dev                lost+found      spu\nbin                 dpolicy            mnt             storage\n"
}

Changes

No recorded changes to this operation across all 1 revision of this API.