ADB Cheat Sheet

Lists all settings

adb shell settings list global


enables "show taps" on the UI

adb shell settings put system show_touches 1


set the battery state as unplugged

adb shell dumpsys battery unplug


To set the battery percentage

adb shell dumpsys battery set level 65

http://mikepalarz.me/2019/04/dumpsys-battery


set the battery state as what is original(not so sure about this, you can try it out)

adb shell dumpsys battery reset


Return 1 if device is in battery saver mode, else returns 0

adb shell settings get global battery_saver_mode


To show list of activities in backstack. I have discovered this command with lot of research.

adb shell settings put global zen_mode 1
adb shell "pidof com.google.android.wearable.sysui | xargs kill"
adb shell dumpsys activity activities| grep "* Hist"


Command for accessibility

https://gist.github.com/mrk-han/67a98616e43f86f8482c5ee6dd3faabe


Enable wifi

adb shell svc wifi enable


This is not working.Haven't found a right solution to this.

adb shell svc wifi disable


Take Screenshot of current emulator and show it

adb exec-out screencap -p > screen.png && open screen.png


List all the installed packages:

adb shell pm list packages -f


Start find my phone activity from adb

adb shell am start -n "com.google.android.gms/.mdm.RingMyPhoneActivity"


Disable watch tutorial and need for companion.Use both the following commands.

While you are in the "Tap to begin" screen(before the language selection screen), run the following command. Run the first command and

wait till tutorials screen appears then run the second command.

adb shell am broadcast -a com.google.android.clockwork.action.TEST_MODE
adb shell am broadcast -a com.google.android.clockwork.action.TUTORIAL_SKIP


Turn off talkback

adb shell settings put secure enabled_accessibility_services com.android.talkback/com.google.android.marvin.talkback.TalkBackService


Turn on talkback

adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService


Click the home button

adb shell input keyevent 3


Swipe on the screen from (x1,y1) to (x2,y2) for t duration

adb shell input touchscreen swipe x1 y1 x2 y2 t

Example of a single finger horizontal swipe for 500ms:
adb shell input touchscreen swipe 356 186 10 186 500

For Vertical upwards swipe:

adb shell input touchscreen swipe 356 186 356 0 500


Changing language of device:

adb shell "setprop persist.sys.locale hi;"

adb reboot


This website has a great collection of adb commands:

Comments

Popular posts from this blog

Install Git on Windows