sleep 1
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 volup" ;;
esac
Save as remote.sh and run:
./remote.sh next
adb shell input keyevent 20 adb shell input keyevent 20
Solution: Some system apps are protected. Use adb shell pm disable --user 0 com.android.app first. If that fails, you need root or adb shell pm uninstall -k --user 0 (which doesn't remove the app but hides it for the user).
These control the audio stream regardless of the foreground app, though the specific stream (Media, Ringtone, Call) depends on the context. adb app control extended key
| Key Code (String) | Integer Code | Function |
| :--- | :--- | :--- |
| KEYCODE_VOLUME_UP | 24 | Increases volume. |
| KEYCODE_VOLUME_DOWN | 25 | Decreases volume. |
| KEYCODE_VOLUME_MUTE | 164 | Mutes/Unmutes audio. |
A game constantly runs background tracking services. Instead of uninstalling (which loses data), you suspend it.
adb shell pm suspend --user 0 com.tencent.mobilegame
When you want to play again:
adb shell pm unsuspend --user 0 com.tencent.mobilegame
No data loss, no re-login.
ADB is the universal remote control for any Android device with debugging enabled. It operates on a client-server model, allowing a host computer to send shell commands directly to the Android kernel. While standard commands like adb install or adb logcat are well-known, the true power resides in the input command.
The standard adb shell input tap x y or adb shell input swipe x1 y1 x2 y2 mimics basic touch. However, these commands are fragile; they depend on screen resolution and UI element positions. Extended key control solves this by shifting from coordinate-based actions to semantic event injection. sleep 1 Combine extended keys with adb shell
To internalize this knowledge, maintain a personal cheat sheet:
| Action | Command (Extended Key in bold) |
|--------|-----------------------------------|
| Disable app for user 0 | adb shell pm **disable-user** --**user 0** com.package |
| Suspend app | adb shell pm **suspend** --**user 0** com.package |
| Block background runs | adb shell appops set com.package **RUN_IN_BACKGROUND ignore** |
| Block wake locks | adb shell appops set com.package **WAKE_LOCK ignore** |
| Grant permission | adb shell pm **grant** com.package android.permission.CAMERA |
| Set standby bucket | adb shell cmd appops set com.package **STANDBY_BUCKET rare** |
| Query disabled packages | adb shell pm list packages **-d** |
| Query suspended packages | adb shell pm list packages **-s** |