Autoenable USB debugging on user builds

After flashing a user build onto a device, you need to re-enable USB debugging. Android Test Station can automate this step using AOA device actions, which send a series of simple UI commands to a device.

Record the AOA commands

First, use the WebAOA command editing tool to record the list of commands to enable USB debugging.

WebAOA Link

Figure 1. Link to the WebAOA command editing tool in Android Test Station.

It is also accessible at http://localhost:8000/webaoa by default.

WebAOA lets you manipulate a local device using a simulated touchscreen and record your UI interactions.

WebAOA Editor

Figure 2. Editing the commands for enabling USB debugging in WebAOA.

Four types of commands are supported:

  • Clicking and swiping on the touchscreen (click X Y and swipe X1 Y1 DURATION X2 Y2)

  • Pressing device buttons (back, home, and wake)

  • Writing text and pressing key combinations (write TEXT and key [KEY ...])

  • Waiting for a specified duration (sleep DURATION)

When you are finished recording commands, you can copy them to your clipboard or save them to a file.

Create an AOA device action

To automatically re-enable USB debugging, the recorded commands need to be added to a device action.

Create a new device action and add a TF Target Preparer with its class name set to Copy the commands recorded in WebAOA into its action option.

AOA Device Action

Figure 3. AOA device action for enabling USB debugging on Android 10 GSI.

Use an AOA device action

When scheduling a test run, add your AOA device action and place it directly after your device-flashing action.

AOA Device Action Selection

Figure 4. Scheduling a run to flash a user build and re-enable USB debugging.