1. 查找系统默认值
adb shell cmd overlay lookup android android:TYPE/NAME //查看系统framework字符资源值
adb shell cmd overlay lookup package package:TYPE/NAME //查看包的字符资源值
eg
adb shell cmd overlay lookup android android:bool/config_flipToScreenOffEnabled
2. Settings相关属性操作
adb shell settings get global use_volume_key_for_ring
adb shell settings put system sound_effects_enabled 0
adb shell settings delete global use_volume_key_for_ring
3. 模拟按键操作
adb shell input keyevent 4
adb shell input keyevent --longpress 26
常用Key值
3 --> "KEYCODE_HOME"
4 --> "KEYCODE_BACK"
5 --> "KEYCODE_CALL"
6 --> "KEYCODE_ENDCALL"
19 --> "KEYCODE_DPAD_UP"
20 --> "KEYCODE_DPAD_DOWN"
21 --> "KEYCODE_DPAD_LEFT"
22 --> "KEYCODE_DPAD_RIGHT"
23 --> "KEYCODE_DPAD_CENTER"
24 --> "KEYCODE_VOLUME_UP"
25 --> "KEYCODE_VOLUME_DOWN"
26 --> "KEYCODE_POWER"
27 --> "KEYCODE_CAMERA"
82 --> "KEYCODE_MENU"
91 --> "KEYCODE_MUTE"
4. 发送广播
通过命令行执行adb shell am broadcast发送广播通知。
adb shell am broadcast 后面的参数有:
[-a <ACTION>]
[-d <DATA_URI>]
[-t <MIME_TYPE>]
[-c <CATEGORY> [-c <CATEGORY>] ...]
[-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
[--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
[-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
[-n <COMPONENT>]
[-f <FLAGS>] [<URI>]
eg.
adb shell am broadcast -a com.Android.test --es test_string "this is test string" --ei test_int 100 --ez test_boolean true
5. 打开Home App
adb shell am start -W -c android.intent.category.HOME -a android.intent.action.MAIN
6. App权限
adb shell pm reset-permissions -p your.app.package
adb shell pm grant [packageName] [ Permission] // Grant a permission to an app.
adb shell pm revoke [packageName] [ Permission] // Revoke a permission from an app.
7. 查询修改屏幕分辨率
查询:
adb shell wm size
设置:
adb shell wm size 2048x1536
adb shell wm density 288
复位:
adb shell wm size reset
adb shell wm density reset
8. Battery相关操作
adb shell dumpsys battery set level (change the level from 0 to 100)
adb shell dumpsys battery set status (change the level to unknown, charging, discharging, not charging or full)
adb shell dumpsys battery reset (reset the battery)
adb shell dumpsys battery set usb (change the status of USB connection. ON or OFF)