ADB commands

Time: Jul 2017

Complete references: https://developer.android.com/studio/command-line/adb.html

Cautions

    • some adb commands are different in Android 4, 5, 6 or 7

    • some commands may require root permission to be effective

Get information about the phone

Android ID

https://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID

Description: A 64-bit number (as a hex string) that is randomly generated when the user first sets up the device and should remain constant for the lifetime of the user's device. The value may change if a factory reset is performed on the device.

Example: 0a1b2c3d4e5f6g7

adb shell settings get secure android_id

Hardware Serial Number

Example: 0a1b2c3d4e5f6g7

adb shell getprop ro.serialno

Bluetooth

adb shell settings get secure bluetooth_address

MAC address

adb shell cat /sys/class/net/wlan0/address

Options

-s <device_id> directs commands to the device or emulator with the given serial number or qualifiers

Airplane mode

adb shell settings put global airplane_mode_on 1 # set airplane mode on
adb shell settings put global airplane_mode_on 0 # set airplane mode off
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE # broadcast the mode and make it active

adb shell settings get global airplane_mode_on  # check airplane mode status

Brightness

adb shell settings put system screen_brightness 200

Launch an app

adb shell monkey -p <packageName> -c android.intent.category.LAUNCHER 1

Orientation

adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:<opt>
# opt: 1 is portrait, 0 is unlock

Go back to homescreen

adb shell input keyevent 3

Which app is running

adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

WiFi control

adb shell su -c "svc wifi <c>"
# c: enable or disable

adb shell dumpsys wifi | grep "Wi-Fi" 
# check status

Extract APK

adb shell pm path {package}
adb pull /data/app/{package}-1.apk .

results matching ""

    No results matching ""