Adb App Control Extended Key
Combine extended keys with adb shell am and adb shell dumpsys for powerful automation.
Example: Create a "Smart Remote" Bash Script
#!/bin/bash
case "$1" in
play)
adb shell input keyevent 85 ;;
next)
adb shell input keyevent 87 ;;
prev)
adb shell input keyevent 88 ;;
volup)
adb shell input keyevent 24 ;;
voldown)
adb shell input keyevent 25 ;;
torch)
adb shell input keyevent 212 ;;
power)
adb shell input keyevent 26 ;;
*)
echo "Usage: $0 torch" ;;
esac
Save as remote.sh and run:
./remote.sh next
Before diving into the "extended key," let's recap standard ADB. Using commands like adb shell pm list packages or adb shell pm disable-user --user 0 <package>, you can control applications at a system level—disabling, enabling, uninstalling (for the current user), or clearing data. adb app control extended key
However, standard controls have limitations:
This is where the concept of an "Extended Key" enters.
cmd app set-app-suspended --user 0 $PACKAGE true && Combine extended keys with adb shell am and
To simulate a long press (e.g., holding the Power button to bring up the power menu), use the --longpress flag.
# Long press the Power button (usually brings up Power Off/Restart menu)
adb shell input keyevent --longpress KEYCODE_POWER
App control isn't just about disabling; it's about interacting. AM extensions allow you to simulate user behavior, bypass UI restrictions, and test deep links.
Combined extended key command:
adb shell am start -S -W --user 0 -a android.intent.action.VIEW -d "https://example.com" com.android.browser
This force-stops the browser, waits for it to load the URL, and does so on user 0. This level of control is impossible with a simple tap on the screen.
adb shell input keyevent 26


