Skip to content

Control Extended Key //free\\ | Adb App

Report: ADB App Control and Extended Keys

Building Your Own ADB Extended Key Cheat Sheet

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** |

The Most Useful Extended Keys for App Control

Here is a curated table of extended keys that will supercharge your ADB automation. adb app control extended key

| Function | Keyevent Code | Command Example | |----------|---------------|------------------| | Media Play/Pause | KEYCODE_MEDIA_PLAY_PAUSE (85) | adb shell input keyevent 85 | | Media Stop | KEYCODE_MEDIA_STOP (86) | adb shell input keyevent 86 | | Media Next Track | KEYCODE_MEDIA_NEXT (87) | adb shell input keyevent 87 | | Media Previous Track | KEYCODE_MEDIA_PREVIOUS (88) | adb shell input keyevent 88 | | Media Rewind | KEYCODE_MEDIA_REWIND (89) | adb shell input keyevent 89 | | Media Fast Forward | KEYCODE_MEDIA_FAST_FORWARD (90) | adb shell input keyevent 90 | | Camera Shutter | KEYCODE_CAMERA (27) | adb shell input keyevent 27 | | Power Button (Toggle screen) | KEYCODE_POWER (26) | adb shell input keyevent 26 | | Long Press Power (Assistant/Menu) | --longpress with POWER | adb shell input keyevent --longpress 26 | | Volume Up | KEYCODE_VOLUME_UP (24) | adb shell input keyevent 24 | | Volume Down | KEYCODE_VOLUME_DOWN (25) | adb shell input keyevent 25 | | Volume Mute | KEYCODE_VOLUME_MUTE (164) | adb shell input keyevent 164 | | Notification Shade | KEYCODE_NOTIFICATION (83) | adb shell input keyevent 83 | | Quick Settings | KEYCODE_SETTINGS (176) | adb shell input keyevent 176 | | Toggle Torch (Flashlight) | KEYCODE_TORCH (212) | adb shell input keyevent 212 | | DPad Up/Down/Left/Right | KEYCODE_DPAD_UP/DOWN/LEFT/RIGHT (19-22) | adb shell input keyevent 20 | | DPad Center (OK/Select) | KEYCODE_DPAD_CENTER (23) | adb shell input keyevent 23 | | Home | KEYCODE_HOME (3) | adb shell input keyevent 3 | | Back | KEYCODE_BACK (4) | adb shell input keyevent 4 | | App Switch (Recents) | KEYCODE_APP_SWITCH (187) | adb shell input keyevent 187 | | Keyboard Enter | KEYCODE_ENTER (66) | adb shell input keyevent 66 | | Keyboard Delete | KEYCODE_DEL (67) | adb shell input keyevent 67 |

💡 Pro tip: You can use the integer value (e.g., 85 instead of KEYCODE_MEDIA_PLAY_PAUSE) for faster scripts. Report: ADB App Control and Extended Keys Building


The --grant and --revoke Flags with pm grant

Instead of navigating Settings > Apps > Permissions, use extended keys:

adb shell pm grant com.example.app android.permission.CAMERA
adb shell pm revoke com.example.app android.permission.ACCESS_FINE_LOCATION

Commentary on "ADB App Control Extended Key"

Screen on (if device locked, shows lock screen)

adb shell input keyevent 26

4. Implementation and Usage Scenarios

Select item

adb shell input keyevent 23


Go back

adb shell input keyevent 88