A simple webapp and API for managing and manipulating connected Android devices via the Android Device Bridge (ABD).
The following are required on the host machine running Web ADB:
- Python 2.7
- Android SDK
- Clone this project to the host machine
- Run
python <path-to-web-adb>/server.py --port=8888 --adb-path=<path-to-android-sdk>/platform-tools/adb
- Open
https://localhost:8888
in a browser
- Connected devices are listed in the table
- Selecting a device will display a panel below the table with more capabilities.
- The action buttons/images have hover text to help you guess what they do.
- Clicking on a screenshot will send a
tap
to the device and refresh the screeshot.
I tried to keep this as minimal as possible. A single Python file acts as a very simple API server. In addition to several API routes, hiting the root will return a simple single-page webapp.
--port
the local port to bind the server (defaults to8080
)--adb-path
the path to theADB
binary--cert-file
the path to aPEM
file you want to use to enableHTTPS
support
returns the single-page webapp
returns a JSON
array containing a JSON
device
object each connected device
[
{
"id": "<device-id>",
"network": {
"connected": (true|false),
"ssid": "<wifi-name>"
},
"battery": {
"status": "<range: 1 to 5>",
"level": "<charge level>",
"health": "<range: 1 to 7>",
"plugged": "(USB|AC)"
},
"screen": {
"width": "<XXXpx>",
"height": "<YYYpx>",
"density": "<integer density>",
"orientation": "0|1"
},
"model": "<model-name>",
"manufacturer": "<manufacturer-name>",
"sdk": "<integer SDK level>"
},
{...}
]
returns a PNG of the device screen
returns a simple text dump of the logcat
returns a JSON
device
object for the given device
executes a keypress on the given device. takes a JSON
object and returns a plain text status
{
"device": "<device-id>",
"key": "<key-code>"
}
executes a tap on the given device at the given coords. takes a JSON
object and returns a plain text status
{
"device": "<device-id>",
"x": "<x-location>",
"y": "<y-location>"
}
executes a shell command on the given device. takes a JSON
object and returns a plain text status
{
"device": "<device-id>",
"command": "<shell-command>"
}
reboots the given device. takes a JSON
object and returns a plain text status
{
"device": "<device-id>"
}
I threw this project together quickly to scratch a specific itch. Here are some ideas I'd like to think about for the future:
- Heartbeat monitoring to check the device status and connection. Maybe a health ping every 10 seconds.
- Start/Stop monitor for CPU, Network, and Memory usage. Use a simple chart for visualizing it.
- Wrap a few more ADB commands, like pull/push files and APK management.
- Capture video.
- Add swipe support.
Even though I try to minimize dependencies in the server code, I do use some 3rd party libraries in the single-page webapp, pulled in via CDN links:
- JQuery
- Bootstrap
- Handlebars
- Font Awesome