Useful adb commands

Android

Get battery status
adb shell dumpsys battery

Broadcast intent
adb shell am broadcast -a com.company.intent.NAME --es key "value"

Get current user
adb shell dumpsys trust

Power key
adb shell keyevent 26

Switch user
adb shell am switch-user [userid]

Check if screen is turned on
adb shell dumpsys input_method | grep Interactive

Swipe action to unlock
adb shell input touchscreen swipe 0 500 2000 500

Lock a task
adb shell dumpsys activity | grep mFocusedActivity
the tTASKID is what we are interested at
am lock-task TASKID

Start an activity
adb shell am start -n packagename/.activityname
e.g. start a settings activity
adb shell am start -n com.android.settings/.Settings

Stop an activity
adb shell am force-stop packagename

Start a service
adb shell am startservice packagename/.servicename

Screen record adb shell screenrecord /sdcard/video.mp4

Clear package data
adb shell pm clear packagename

Configure network
adb shell netcfg

Show properties
adb shell getprop

Get device name
adb shell settings get global device_name

Change settings
adb shell settings put global usb_mass_storage_enabled 0

Show Log With Time
adb logcat -v time -s PkgName:*

Clear Log
adb logcat -c

Shutdown Device
adb shell reboot -p


Post a Comment

Previous Post Next Post