Android TVADBAutomation
Android TV Wireless ADB Setup
Enable developer options on the TV (Settings → Device Preferences → About → Build, select repeatedly), then turn on Wireless debugging.
Pair and connect
Pairing and connection ports are different. The pairing port and six-digit code are temporary — find them under Pair device with pairing code.
# One-time pairing
adb pair TV_IP:PAIRING_PORT
# Enter the six-digit code shown on the TV.
# Connect (use the CONNECTION port, not the pairing port)
adb connect TV_IP:CONNECTION_PORT
adb devices -l
adb -s TV_IP:CONNECTION_PORT shell getprop ro.product.model
Connection ports change when debugging is toggled or the TV restarts. Always use the value currently displayed on the TV.
Inspect and control
# Dump the UI tree
adb -s TV_IP:PORT shell uiautomator dump /sdcard/ui-dump.xml
adb -s TV_IP:PORT shell cat /sdcard/ui-dump.xml
# Screenshot
adb -s TV_IP:PORT exec-out screencap -p > screenshot.png
# Remote control
adb -s TV_IP:PORT shell input keyevent KEYCODE_HOME
adb -s TV_IP:PORT shell input keyevent DPAD_UP
adb -s TV_IP:PORT shell input keyevent DPAD_DOWN
adb -s TV_IP:PORT shell input keyevent DPAD_CENTER
adb -s TV_IP:PORT shell input keyevent BACK
adb -s TV_IP:PORT shell input keyevent MENU
adb -s TV_IP:PORT shell input keyevent --longpress DPAD_CENTER
# List third-party apps with installer info
adb -s TV_IP:PORT shell pm list packages -3 -i
Inspect before acting, then verify. Animations produce stale UI Automator output — use screenshots when the XML looks wrong. Do not batch key presses based on an old screen dump.