Adb App Control Extended Key
To fully test a music player without touching the screen, a developer can script a sequence of ADB commands.
Command Sequence:
# Start the app (package name hypothetical)
adb shell am start -n com.example.musicplayer/.MainActivity
Manufacturer apps (e.g., Samsung’s Game Launcher, Xiaomi’s MSA) often respawn. An extended key control can run a recurring ADB script every 6 hours to re-disable or suspend them—something a standard pm disable can’t sustain alone.
ADB allows for more complex interactions than a simple button press. You can simulate long presses and multiple key presses simultaneously.
Instead of typing letter-by-letter, you can dump a whole string of text into the active input field. adb app control extended key
adb shell input text "Hello,World"
Note: Spaces are usually handled by %s or quoted carefully depending on the shell environment.
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 play" ;;
esac
Save as remote.sh and run:
./remote.sh next
Goal: Disable Samsung's Bixby or Microsoft's LinkedIn preinstalled app.
Standard approach (fails on many devices): adb uninstall com.samsung.android.bixby.wakeup (often returns DELETE_FAILED_INTERNAL_ERROR)
Extended key solution:
adb shell pm disable-user --user 0 com.samsung.android.bixby.wakeup
To re-enable:
adb shell pm enable com.samsung.android.bixby.wakeup
Using a script (Python/Bash) with ADB extended keys, you can provision 100 tablets for a retail store in minutes.
Sample Bash loop:
for package in $(cat bloatware_list.txt); do
adb -s $device_id shell pm disable-user --user 0 $package
adb -s $device_id shell appops set $package RUN_IN_BACKGROUND ignore
done
Here, each flag (disable-user, --user, RUN_IN_BACKGROUND) is an extended key in the loop.












