zsmith.co

Useful ADB Commands

Revision 7
© 2019 by Zack Smith. All rights reserved.

The Android Debugger (ADB) offers surprisingly extensive access to the innards of an Android phone. The following are some useful adb commands for exploring and twiddling.

Phone characteristics

Get make and model

 getprop ro.product.brand
 getprop ro.product.model

Get CPU chip name

 getprop ro.hardware.chipname
 getprop ro.hardware

Determine GPU name

 getprop SurfaceFlinger | grep GLES

Get RAM available to apps

 free -h
 grep MemTotal /proc/meminfo

Get the maximum core frequencies of the CPU:

 cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_max_freq

Get flash storage information

 df -h

Display

Show display characteristics

Size:

 wm size

FPS and DPI:

 dumpsys display | grep DeviceInfo

Hide/unhide the notch

Note, a hidden notch will reappear after a reboot and after using SmartView (i.e. Wifi screen share).

 settings put secure display_cutout_hide_notch 1
 settings put secure display_cutout_hide_notch 0

Hide/unhide the statusbar and navigation bar

Immersive mode allows auto-hiding these.

 # Hide both
 settings put global policy_control immersive.full=*
 # Hide status bar
 settings put global policy_control immersive.status=*
 # Hide neither
 settings put global policy_control immersive.null=*

Set the navigation bar color

If you are not in immersive mode and you are not using full-screen gestures, you can change the navbar's background color.

 # Orange
 settings put global navigationbar_color -24576

Note that many apps and the home screen override this setting.

Screenshot

 screencap /sdcard/screenshot.png

Screen recording

 screenrecord /sdcard/capture.mp4

Options:

  • --time-limit (seconds)
  • --rotate
  • --bit-rate (Mb/sec)

Screen mirroring to your computer

This is possible with screenrecord and mplayer.

adb exec-out screenrecord --bit-rate=16m --output-format=h264 - | mplayer -framedrop -cache 512 -demuxer h264es -fps 6000 -

Networks

Show IP address

 ifconfig wlan0

Turn the Wifi on/off

 svc wifi enable
 svc wifi disable

Get/set the phone's Wifi name

 settings get global device_name
 settings put global device_name iPhone9

Turn NFC data on/off

 svc nfc enable
 svc nfc disable

Turn cellular data on/off

 svc data enable
 svc data disable

Display current network connections

 netstat -e | grep -e tcp -e udp

Apps

Print running apps

 ps -fA | grep u0_ | sort

Disable built-in Facebook apps

 for s in `pm list packages | grep faceboo | sed s/package://`; do
  pm disable-user $s
 done

Or cut and paste commands for removing common facebook packages:

 pm uninstall --user 0 com.facebook.services
 pm uninstall --user 0 com.facebook.system
 pm uninstall --user 0 com.facebook.appmanager
 pm uninstall --user 0 com.facebook.katana

Samsung Bixby

Prevent swipe-right from Home into Bixby screen

 pm disable-user com.samsung.android.app.spage

Remove Bixby

 pm uninstall --user 0 com.samsung.android.app.spage
 pm uninstall --user 0 com.samsung.android.bixby.service

Remove other bloatware

Besides Facebook and Bixby, Android phones are often loaded down with a ton of additional stuff that you probably don't need.

Samsung account

  • pm uninstall --user 0 com.osp.app.signin # Sign in
  • pm uninstall --user 0 com.sec.spp.push # Samsung Push service
  • pm uninstall --user 0 com.samsung.android.beaconmanager # Samsung Connect
  • pm uninstall --user 0 com.samsung.android.bbc.bbcagent
  • pm uninstall --user 0 com.samsung.android.samsungpass
  • pm uninstall --user 0 com.samsung.android.samsungpassautofill
  • pm uninstall --user 0 com.samsung.android.fmm # Find My Mobile

Samsung apps and accessories

  • pm uninstall --user 0 com.samsung.android.email.provider
  • pm uninstall --user 0 com.samsung.android.app.reminder
  • pm uninstall --user 0 com.samsung.android.app.watchmanagerstub # Samsung Watch
  • pm uninstall --user 0 com.samsung.android.smartswitchassistant
  • pm uninstall --user 0 com.samsung.android.oneconnect # Samsung SmartThings
  • pm uninstall --user 0 com.samsung.android.mobileservice # Samsung Experience
  • pm uninstall --user 0 com.sec.android.app.magnifier # Smart Magnifier
  • pm uninstall --user 0 com.samsung.android.smartfitting # Smart Fit

Cloud and potential spyware

  • pm uninstall --user 0 com.samsung.android.mdm # Mobile device management
  • pm uninstall --user 0 com.samsung.aasaservice
  • pm uninstall --user 0 com.google.android.webview
  • pm uninstall --user 0 com.google.android.ext.shared
  • pm uninstall --user 0 com.android.sharedstoragebackup
  • pm uninstall --user 0 com.samsung.android.shortcutbackupservice
  • pm uninstall --user 0 com.samsung.android.allshare.service.fileshare
  • pm uninstall --user 0 com.samsung.android.allshare.service.mediashare
  • pm uninstall --user 0 com.samsung.android.rubin.app
  • pm uninstall --user 0 com.samsung.android.scloud
  • pm uninstall --user 0 com.sec.enterprise.knox.cloudmdm.smdms
  • pm uninstall --user 0 com.google.android.syncadapters.contacts
  • pm uninstall --user 0 com.google.android.syncadapters.calendar
  • pm uninstall --user 0 com.sec.epdg
  • pm uninstall --user 0 com.sec.location.nsflp2
  • pm uninstall --user 0 com.sec.imslogger
  • pm uninstall --user 0 com.android.calllogbackup
  • pm uninstall --user 0 com.google.android.backuptransport
  • pm uninstall --user 0 com.samsung.storyservice
  • pm uninstall --user 0 com.wssyncmldm

Face recognition

  • pm uninstall --user 0 com.samsung.android.bio.face.service
  • pm uninstall --user 0 com.samsung.faceservice

Samsung themes and wallpapers

  • pm uninstall --user 0 com.samsung.android.a20.d01.wallpapermulti
  • pm uninstall --user 0 com.android.wallpaperbackup
  • pm uninstall --user 0 com.samsung.android.wallpaper.res

Gaming stuff

  • pm uninstall --user 0 com.enhance.gameservice
  • pm uninstall --user 0 com.samsung.android.game.gamehome
  • pm uninstall --user 0 com.samsung.android.game.gametools
  • pm uninstall --user 0 com.samsung.android.game.gos

Stores/offers

  • pm uninstall --user 0 com.sec.android.app.samsungapps
  • pm uninstall --user 0 com.sec.android.app.billing
  • pm uninstall --user 0 com.google.android.apps.subscriptions.red

Microsoft

  • pm uninstall --user 0 com.microsoft.office.officehubhl

Stickers

  • pm uninstall --user 0 com.samsung.android.app.camera.sticker.stamp.preload
  • pm uninstall --user 0 com.samsung.android.app.camera.sticker.facear.preload
  • pm uninstall --user 0 com.samsung.android.stickercenter
  • pm uninstall --user 0 com.samsung.android.provider.stickerprovider

Other

  • pm uninstall --user 0 com.sec.android.emergencylauncher
  • pm uninstall --user 0 com.sec.vsim.ericssonnsds.webapp
  • pm uninstall --user 0 com.android.providers.partnerbookmarks
  • pm uninstall --user 0 com.android.internal.display.cutout.emulation.corner
  • pm uninstall --user 0 com.android.internal.display.cutout.emulation.double
  • pm uninstall --user 0 com.android.internal.display.cutout.emulation.tall

Carrier stuff

  • pm uninstall --user 0 com.tmobile.pr.adapt
  • pm uninstall --user 0 com.privacystar.android.metro
  • pm uninstall --user 0 com.nuance.nmc.sihome.metropcs

Calling

  • pm uninstall --user 0 com.sec.unifiedwfc # Disables Wifi Calling
  • pm uninstall --user 0 com.hiya.star # Caller ID

Keyboards

  • pm uninstall -k --user -0 com.sec.android.inputmethod # Remove Samsung keyboard

Haptics

Cause the phone to vibrate

 cmd vibrator vibrate 100 (milliseconds)

Input

Go to Home screen

 input keyevent 3

Go back

 input keyevent 4

Press power key

 input keyevent 26

Launch camera

 input keyevent 27

Phone

 input keyevent 5 (launch phone app)
 input keyevent 6 (hang up)

Google search

 input keyevent 84

Scrolling

 input keyevent 92 (page up)
 input keyevent 93 (page down)
 input keyevent 122 (home)
 input keyevent 123 (end)

Media players

To start playing the current song:

 media dispatch play

To stop playing the current song:

 media dispatch stop
 input keyevent 127

To launch the media player and play a video:

 am start -a android.intent.action.VIEW -d file:///sdcard/video.mkv -t video/mkv

To launch the media player and play a sound:

 am start -a android.intent.action.VIEW -d file:///sdcard/sound.ogg -t audio/ogg

Power

Reboot

 reboot

Crashing

I've discovered that the following command causes the UI to crash and restart and after a while adb disconnects.

 settings put global navigationbar_current_color 0xff0000ff