name: adb-android-control
description: Comprehensive Android device control via ADB (Android Debug Bridge). Use when user asks about: Android device management, app installation/uninstallation, APK operations, package management, file transfer (push/pull), screenshots, screen recording, input simulation (tap/swipe/text/keyevents), shell commands, logcat viewing, device info (battery/memory/storage), automation scripts, wireless ADB connection, scrcpy mirroring. Keywords: adb, android, phone, tablet, device, apk, install app, uninstall app, screenshot, screen record, tap, swipe, type text, keyevent, logcat, push file, pull file, shell, package, activity, intent, broadcast, dumpsys, getprop, settings, input, sendevent, monkey, am start, pm list, device info, battery status, wireless adb, connect device.
ADB Android Control Skill
Complete Android device control and automation via ADB (Android Debug Bridge) for Claude Code.
When to Use This Skill
Use this skill when user asks about:
- Device Management: Connect, disconnect, check status, device info
- App Operations: Install, uninstall, list packages, clear data, force stop
- File Transfer: Push/pull files between host and device
- Screen Control: Screenshots, screen recording, mirroring
- Input Simulation: Taps, swipes, text input, key events
- Shell Access: Run commands on device
- Debugging: Logcat, dumpsys, process info
- Automation: Scripted workflows, batch operations
Quick Reference
Device Connection
adb devices
adb connect <device-ip>:<port>
adb disconnect <device-ip>:<port>
adb kill-server && adb start-server
App Management
adb shell pm list packages
adb shell pm list packages -3
adb shell pm list packages | grep -i "keyword"
adb install /path/to/app.apk
adb install -r app.apk
adb install -d app.apk
adb install -g app.apk
adb uninstall com.example.app
adb uninstall -k com.example.app
adb shell pm clear com.example.app
adb shell am force-stop com.example.app
adb shell dumpsys package com.example.app
adb shell pm path com.example.app
adb pull $(adb shell pm path com.example.app | cut -d: -f2) ./app.apk
adb shell pm disable-user com.example.app
adb shell pm enable com.example.app
adb shell pm list packages -d
File Operations
adb push local_file.txt /sdcard/
adb push ./local_dir /sdcard/
adb pull /sdcard/file.txt ./
adb pull /sdcard/DCIM ./photos
adb shell ls -la /sdcard/
adb shell mkdir -p /sdcard/MyFolder
adb shell rm /sdcard/file.txt
adb shell rm -rf /sdcard/MyFolder
adb shell df -h
adb shell find /sdcard -name "*.jpg" -type f
Screenshots & Screen Recording
adb shell screencap /sdcard/screenshot.png
adb exec-out screencap -p > screenshot.png
adb shell screenrecord /sdcard/video.mp4
adb shell screenrecord --time-limit 30 --size 720x1280 --bit-rate 4000000 /sdcard/video.mp4
adb pull /sdcard/video.mp4 ./
Input Simulation
adb shell input tap 500 1000
adb shell input swipe 500 1500 500 500 300
adb shell input swipe 500 1500 500 500 200
adb shell input swipe 500 500 500 1500 200
adb shell input swipe 800 1000 200 1000 200
adb shell input swipe 200 1000 800 1000 200
adb shell input swipe 500 1000 500 1000 1000
adb shell input text "HelloWorld"
adb shell input text "Hello%sWorld"
adb shell input keyevent KEYCODE_HOME
adb shell input keyevent KEYCODE_BACK
adb shell input keyevent KEYCODE_MENU
adb shell input keyevent KEYCODE_POWER
adb shell input keyevent KEYCODE_VOLUME_UP
adb shell input keyevent KEYCODE_VOLUME_DOWN
adb shell input keyevent KEYCODE_ENTER
adb shell input keyevent KEYCODE_DEL
adb shell input keyevent KEYCODE_TAB
adb shell input keyevent KEYCODE_ESCAPE
adb shell input keyevent 3
adb shell input keyevent 4
adb shell input keyevent 26
adb shell input keyevent 24
adb shell input keyevent 25
adb shell input keyevent 66
adb shell input keyevent 67
adb shell input keyevent 82
adb shell input keyevent KEYCODE_WAKEUP
adb shell input keyevent KEYCODE_SLEEP
adb shell input keyevent KEYCODE_POWER
adb shell input keyevent KEYCODE_APP_SWITCH
adb shell input keyevent KEYCODE_SYSRQ
Activity & Intent Management
adb shell am start -n com.package.name/.ActivityName
adb shell am start -a android.intent.action.VIEW -d "https://google.com"
adb shell am start -a android.intent.action.VIEW -d "https://example.com"
adb shell am start -a android.settings.SETTINGS
adb shell am start -a android.settings.WIFI_SETTINGS
adb shell am start -a android.settings.BLUETOOTH_SETTINGS
adb shell am start -a android.settings.DISPLAY_SETTINGS
adb shell am start -a android.settings.SOUND_SETTINGS
adb shell am start -a android.settings.APPLICATION_SETTINGS
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
adb shell am startservice -n com.package.name/.ServiceName
adb shell am kill-all
adb shell am kill-all
Device Information
adb shell getprop ro.product.model
adb shell getprop ro.build.version.release
adb shell getprop ro.build.version.sdk
adb shell getprop ro.serialno
adb shell getprop
adb shell dumpsys battery
adb shell dumpsys meminfo
adb shell dumpsys cpuinfo
adb shell dumpsys display | grep -i "mBaseDisplayInfo"
adb shell wm size
adb shell wm density
adb shell dumpsys wifi | grep -i "mWifiInfo"
adb shell ip addr show wlan0
adb shell dumpsys netstats
adb shell ps -A
adb shell top -n 1
adb shell df -h
Logcat (System Logs)
adb logcat
adb logcat -c
adb logcat -d
adb logcat -s "MyTag:*"
adb logcat "*:E"
adb logcat "*:W"
adb logcat --pid=$(adb shell pidof -s com.example.app)
adb logcat -d > logs.txt
adb logcat -v time
adb logcat -v threadtime
adb logcat -b crash
adb logcat -b events
adb logcat -b main
adb logcat -b system
System Settings
adb shell settings get system screen_brightness
adb shell settings get global airplane_mode_on
adb shell settings get secure android_id
adb shell settings put system screen_brightness 128
adb shell settings put global airplane_mode_on 1
adb shell settings list system
adb shell settings list global
adb shell settings list secure
adb shell settings put system screen_brightness 200
adb shell settings put system screen_off_timeout 60000
adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0
Network Operations
adb shell svc wifi enable
adb shell svc wifi disable
adb shell svc data enable
adb shell svc data disable
adb shell settings put global airplane_mode_on 1
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE
adb shell dumpsys wifi | grep "SSID"
adb forward tcp:8080 tcp:8080
adb reverse tcp:8080 tcp:8080
adb forward --remove tcp:8080
adb forward --list
Power & Reboot
adb reboot
adb reboot recovery
adb reboot bootloader
adb shell reboot -p
adb shell svc power stayon usb
adb shell svc power stayon false
adb shell dumpsys battery | grep level
adb shell dumpsys battery | grep status
Advanced Operations
adb shell
adb shell run-as com.example.app
adb shell dumpsys activity activities | grep "mResumedActivity"
adb shell dumpsys window windows | grep -E "mCurrentFocus|mFocusedApp"
adb shell uiautomator dump /sdcard/ui.xml
adb pull /sdcard/ui.xml ./
adb exec-out uiautomator dump /dev/tty
adb shell monkey -p com.example.app -v 500
adb shell pm grant com.example.app android.permission.CAMERA
adb shell pm revoke com.example.app android.permission.CAMERA
adb shell pm list permissions -g
adb shell dumpsys package com.example.app | grep "permission"
adb backup -apk -shared -all -f backup.ab
adb restore backup.ab
Automation Workflows
Workflow 1: App Testing Automation
#!/bin/bash
APP_PACKAGE="com.example.app"
APK_PATH="./app.apk"
echo "Installing app..."
adb install -r "$APK_PATH"
echo "Launching app..."
adb shell am start -n "$APP_PACKAGE/.MainActivity"
sleep 3
echo "Taking initial screenshot..."
adb exec-out screencap -p > screenshot_initial.png
echo "Performing test actions..."
adb shell input tap 540 960
sleep 1
adb shell input swipe 540 1500 540 500 300
sleep 1
adb shell input tap 540 500
echo "Taking final screenshot..."
adb exec-out screencap -p > screenshot_final.png
echo "Collecting logs..."
adb logcat -d --pid=$(adb shell pidof -s "$APP_PACKAGE") > app_logs.txt
echo "Test complete!"
Workflow 2: Device Health Check
#!/bin/bash
echo "=== DEVICE HEALTH CHECK ==="
echo ""
echo "Device Info:"
echo " Model: $(adb shell getprop ro.product.model)"
echo " Android: $(adb shell getprop ro.build.version.release)"
echo " SDK: $(adb shell getprop ro.build.version.sdk)"
echo ""
echo "Battery Status:"
adb shell dumpsys battery | grep -E "level|status|temperature"
echo ""
echo "Storage:"
adb shell df -h /data | tail -1
echo ""
echo "Memory:"
adb shell cat /proc/meminfo | head -3
echo ""
echo "Running Apps:"
adb shell ps -A | wc -l
echo ""
echo "=== END HEALTH CHECK ==="
Workflow 3: Bulk Screenshot
#!/bin/bash
COUNT=${1:-5}
DELAY=${2:-2}
OUTPUT_DIR="./screenshots_$(date +%Y%m%d_%H%M%S)"
mkdir -p "$OUTPUT_DIR"
for i in $(seq 1 $COUNT); do
echo "Taking screenshot $i of $COUNT..."
adb exec-out screencap -p > "$OUTPUT_DIR/screen_$i.png"
sleep $DELAY
done
echo "Screenshots saved to $OUTPUT_DIR"
Workflow 4: App Data Extraction
#!/bin/bash
PACKAGE="$1"
OUTPUT_DIR="./app_data_$(date +%Y%m%d_%H%M%S)"
if [ -z "$PACKAGE" ]; then
echo "Usage: $0 <package_name>"
exit 1
fi
mkdir -p "$OUTPUT_DIR"
echo "Getting APK..."
APK_PATH=$(adb shell pm path "$PACKAGE" | cut -d: -f2 | tr -d '\r')
adb pull "$APK_PATH" "$OUTPUT_DIR/app.apk"
echo "Dumping package info..."
adb shell dumpsys package "$PACKAGE" > "$OUTPUT_DIR/package_info.txt"
echo "Dumping permissions..."
adb shell dumpsys package "$PACKAGE" | grep "permission" > "$OUTPUT_DIR/permissions.txt"
echo "Done! Data saved to $OUTPUT_DIR"
Termux Auto-Connect & Monitoring
Persistent ADB connections with automatic port scanning, connection monitoring, and multi-network support.
Quick Setup
cd ~/.claude/skills/adb-android-control/termux
./setup.sh ZFOLD7 <DEVICE_IP_HOME>:<ADB_PORT_HOME>
This installs:
- Auto-connect service (reconnects every 30s)
- Boot script (starts on Termux launch)
- Connection monitor (detects port changes)
- Control script (
adb-control)
adb-control Command
Main control interface for all ADB automation:
adb-control status
adb-control start
adb-control stop
adb-control restart
adb-control scan
adb-control log 50
adb-control monitor
Configuration Files
~/.adb_devices - Device addresses:
ZFOLD7=<DEVICE_IP_HOME>:33467
PIXEL=192.168.1.104:5555
device.env - Device specs and multi-network config:
DEVICE_SERIAL="<DEVICE_SERIAL>"
DEVICE_ANDROID_ID="<ANDROID_ID>"
ADB_HOME_IP="<DEVICE_IP_HOME>"
ADB_RECONNECT_INTERVAL="30"
Auto Port Scanning
Android Wireless Debugging changes port on:
- WiFi disconnect/reconnect
- Screen lock/unlock
- Wireless debugging toggle
The system automatically:
- Detects connection failure
- Pings IP to check if host reachable
- Scans ports 30000-50000 for ADB
- Updates config with new port
- Reconnects automatically
Manual scan:
python3 scripts/adb_port_scan.py <DEVICE_IP_HOME> 30000 50000
Connection Monitor
Continuous monitoring of ADB and WiFi state:
python3 scripts/connection_monitor.py status
python3 scripts/connection_monitor.py check
python3 scripts/connection_monitor.py run 30
Detects:
- Connection drops
- Port changes
- Network switches
- Signal strength changes (>10dB)
Actions:
- Auto-updates config on port change
- Sends Termux notification on important events
- Logs all events to
~/.adb_monitor.log
Radio Scanner
WiFi and Bluetooth status with signal metrics:
python3 scripts/radio_scan.py
python3 scripts/radio_scan.py wifi
python3 scripts/radio_scan.py bluetooth
python3 scripts/radio_scan.py caps
Output includes:
- SSID, BSSID, RSSI (dBm), frequency, channel
- Link speed (TX/RX Mbps)
- WiFi standard (802.11ac/ax)
- MIMO support, 6GHz capability
- Bluetooth state, connected devices
USB Device Detection
Identify USB devices connected via OTG:
termux-usb -l
termux-usb -r -e scripts/usb_identify.py /dev/bus/usb/001/002
Log Files
| File | Contents |
|---|
| ~/.adb_connect.log | Connection events, port changes |
| ~/.adb_monitor.log | Monitor events, signal changes |
| ~/.adb_state.json | Last known connection state |
| ~/.adb_devices | Device configuration |
Service Control
sv status adb-autoconnect
sv restart adb-autoconnect
sv down adb-autoconnect
cat ~/.adb_monitor.pid
kill $(cat ~/.adb_monitor.pid)
Boot Sequence
On Termux startup (~/.termux/boot/adb-autoconnect):
- Wake lock acquired
- Load device config
- Try connecting with saved port
- If fails → scan for new port
- Start auto-connect service
- Start connection monitor
- Send "ADB Ready" notification
Python Scripts
Core Scripts
| Script | Purpose |
|---|
| adb_controller.py | ADB operations with error handling |
| adb_automation.py | UI automation, app testing |
| adb_monitor.py | Logcat streaming, metrics |
Termux Integration
| Script | Purpose |
|---|
| connection_monitor.py | ADB/WiFi state monitoring |
| adb_port_scan.py | Port scanner for wireless ADB |
| radio_scan.py | WiFi/Bluetooth scanner |
| usb_identify.py | USB device identification |
| adb-control.sh | Unified control interface |
Common Key Event Codes
| Key | Code | Name |
|---|
| Home | 3 | KEYCODE_HOME |
| Back | 4 | KEYCODE_BACK |
| Call | 5 | KEYCODE_CALL |
| End Call | 6 | KEYCODE_ENDCALL |
| Volume Up | 24 | KEYCODE_VOLUME_UP |
| Volume Down | 25 | KEYCODE_VOLUME_DOWN |
| Power | 26 | KEYCODE_POWER |
| Camera | 27 | KEYCODE_CAMERA |
| Menu | 82 | KEYCODE_MENU |
| Enter | 66 | KEYCODE_ENTER |
| Backspace | 67 | KEYCODE_DEL |
| Tab | 61 | KEYCODE_TAB |
| Space | 62 | KEYCODE_SPACE |
| Escape | 111 | KEYCODE_ESCAPE |
| Recent Apps | 187 | KEYCODE_APP_SWITCH |
| Mute | 164 | KEYCODE_VOLUME_MUTE |
Error Handling
Common Issues
Device not found:
adb kill-server && adb start-server
adb devices
Device offline:
adb disconnect <device-ip>:<port>
adb connect <device-ip>:<port>
Permission denied:
adb root
Connection refused:
adb pair <device-ip>:PORT PAIRING_CODE
Current Device
Connected device: <device-ip>:<port>
To verify connection:
adb -s <device-ip>:<port> shell getprop ro.product.model
Keywords for Detection
adb, android, phone, tablet, mobile device, apk, install app, uninstall, package, screenshot, screencap, screen recording, screenrecord, tap, swipe, touch, input, keyevent, key press, type text, logcat, logs, push file, pull file, transfer, shell command, device info, battery, storage, wifi, settings, activity, intent, broadcast, dumpsys, getprop, monkey test, ui automator, automation, wireless adb, connect device, app management, force stop, clear data, permissions