# Android™ Debug Bridge (adb)
Your journey to mastering adb shell begins here
https://www.nr1.nu/android
Android™ Source Code
Android™ Issue Tracker
Android™ SDK Tools
Open Android™ Default Applications
- Click to Open - ADB Settings
- Click to Open - Calculator
- Click to Open - Home Launcher
- Click to Open - Screen Smartlock
- Click to Open - Settings
- Click to Open - USB Settings
Open Android™ Applications
- Click to Open - Alliance Shield X (Galaxy Store)
- Click to Open - Alliance Shield X (Application)
Open Android™ Samsung Applications
- Click to Open - Samsung Apps
- Click to Open - Samsung Biometrics Fingerprint ID
- Click to Open - Samsung Dialer Call
- Click to Open - Samsung My Files
- Click to Open - Samsung Knox Secure Folder
.knox.securefolder/#Intent;scheme=android-app;end)
- Click to Open - Samsung Galaxy Store
- Click to Open - Samsung Secure Folder
- Click to Open - Samsung Smart Switch
- Click to Open - Samsung Smart Switch
- Click to Open - Samsung Touch ID
Open Android™ Google Applications
- Click to Open - Google Assistant
- Click to Open - Google Chrome Browser
- Click to Open - Google Gmail
- Click to Open - Google Login Account
- Click to Open - Google Maps
- Click To Open - Google Quicksearchbox
- Click to Open - Youtube
Open Android™ Motorola Applications
- Click to Open - Motorola Default Launcher
Open Android™ Xiaomi Applications
- Click to Open Mi Manager
Open Android™ Secret Codes
- Click to Open USSD Code - Show IMEI - #06
- Click to Open USSD Code - Show Secret Diagnostic Mode - #0#
Download Android™ Google Account Manager
- Google Account Manager Android 4.0.3
- Google Account Manager Android 4.4.4
- Google Account Manager Android 5.0.1
- [Google Account Manager Android 6.0](https://www.nr1.nu/archive/android/google_account_manager/google
_account_manager.v6.0.apk)
Download Android™ apks for FRP Bypass
Secret Codes™ Samsung Latest Models
Secret Code | Description | ADB Activity |
---|---|---|
*#06# |
IMEI number | com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.ShowIMEI |
*#0228# |
Battery status | com.sec.android.app.factorykeystring/com.sec.android.app.status.BatteryStatus |
*#0*# |
HW Module Test | com.sec.android.app.hwmoduletest/com.sec.android.app.hwmoduletest.HwModuleTest |
*#2222# |
Service Mode | com.sec.android.RilServiceModeApp/com.sec.android.RilServiceModeApp.ServiceModeApp |
*#2222# |
WiFi Info | com.sec.android.app.servicemodeapp/com.sec.android.app.servicemodeapp.WifiInfoActivity |
*#2663 |
Touch Firmware | com.sec.android.app.factorykeystring/com.sec.android.app.status.touch_firmware |
*#1234 |
Firmware info | com.sec.android.app.factorykeystring/com.sec.android.app.version.SimpleVersion |
Secret USSD short codes for AT&T
Code | Description |
---|---|
*61 |
Block individual unwanted inbound calls |
*80 |
Turn off call blocking |
*78# |
Do Not Disturb mode (blocks all incoming calls). Callers will hear a busy signal |
*79# |
Turn off Do Not Disturb mode |
*67+Phone number+# |
Blocks outgoing Caller ID on a per-call basis. Information still visible to toll-free numbers and 911 |
*370# |
Disable call waiting |
` |
*371#` | Reactivate call waiting |
Android™ Default paths
Paths | Description |
---|---|
/data/data/<package>/databases |
Default storage for .db files |
/data/data/<package>/shared_prefs/ |
Default storage for shared preferences |
/data/app |
Default storage for third-party apps |
/system/app |
Default storage for system apks |
/mmt/asec |
Default storage for encrypted files |
/mmt/emmc |
Default storage for internal storage |
/mmt/sdcard |
Default storage for external mmc/sdcard |
Android Versions
Version | API/SDK | Version Code | Codename | Release Year |
---|---|---|---|---|
Android 13 |
Level 33 | TIRAMISU | Tiramisu 2 | 2022 |
Android 12 |
Level 32 | S _V2 | Snow Cone 2 | 2022 |
Android 12 |
Level 31 | S | Snow Cone | 2021 |
Android 11 |
Level 30 | R | Red Velvet Cake | 2020 |
Android 10 |
Level 29 | Q | Quince Tart | 2019 |
Android 9 |
Level 28 | P | Pie | 2018 |
Android 8.1 |
Level 27 | O_MR1 | Oreo | 2017 |
Android 8.0 |
Level 26 | O | Oreo | 2017 |
Android 7.1 |
Level 25 | N_MR1 | Nougat | 2016 |
Android 7.0 |
Level 24 | N | Nougat | 2016 |
Android 6 |
Level 23 | M | Marshmallow | 2015 |
Android 5.1 |
Level 22 | LOLLIPOP_MR1 | LOLLIPOP | 2015 |
Android 5.0 |
Level 21 | LOLLIPOP, L | LOLLIPOP | 2014 |
Android 4.4W |
Level 20 | KITKAT_WATCH | KitKat | 2014 |
Android 4.4 |
Level 19 | KITKAT | KitKat | 2013 |
Android 4.3 |
Level 18 | JELLY_BEAN_MR2 | Jelly Bean | 2012 |
Android 4.2 |
Level 17 | JELLY_BEAN_MR1 | Jelly Bean | 2012 |
Android 4.1 |
Level 16 | JELLY_BEAN | Jelly Bean | 2012 |
Android 4.0.3 –> 4.0.4 |
Level 15 | ICE_CREAM_SANDWICH_MR1 | Ice Cream Sandwich | 2011 |
Android 4.0.1 –> 4.0.2 |
Level 14 | ICE_CREAM_SANDWICH | Ice Cream Sandwich | 2011 |
`Android 3. |
2| Level 13 | HONEYCOMB_MR2 Honeycomb | Honeycomb | 2011 | |
Android 3.1| Level 12 | HONEYCOMB_MR1 | Honeycomb | 2011 | |
Android 3.0| Level 11 | HONEYCOMB | Honeycomb | 2011 | |
Android 2.3.3 –> 2.3.7| Level 10 | GINGERBREAD_MR1 | Gingerbread | 2011 | |
Android 2.3.0 –> 2.3.2| Level 9 | GINGERBREAD | Gingerbread | 2010 | |
Android 2.2| Level 8 | FROYO | Froyo | 2010 | |
Android 2.1| Level 7 | ECLAIR_MR1 | Eclair | 2010 | |
Android 2.0.1| Level 6 | ECLAIR_0_1 | Eclair | 2010 | |
Android 2.0| Level 5 | ECLAIR | Eclair | 2010 | |
Android 1.6| Level 4 | DONUT Donut | Donut | 2009 | |
Android 1.5| Level 3 | CUPCAKE Cupcake | Cupcake | 2009 | |
Android 1.1| Level 2 | BASE_1_1 | Petit Four | 2009 | |
Android 1.0` | Level 1 | BASE | N/A | 2008 |
ADB Shell / Fastboot install
Arch Linux (pacman)
pacman -S android-tools
Debian Linux (apt)
apt install adb fastboot -y
Gentoo Linux (portage)
emerge --ask dev-util/android-sdk-update-manager dev-util/android-tools
Fedora Linux (dnf)
dnf install adb
GNU/Linux (source)
1) Download the Android SDK Platform Tools ZIP file for Linux.
2) Extract the ZIP to an easily-accessible location (like the Desktop for example).
3) Open a Terminal window.
4) Enter the following command: cd /path/to/extracted/folder/
5) This will change the directory to where you extracted the ADB files.
6) So for example: cd /Users/Doug/Desktop/platform-tools/
7) Connect your device to your Linux machine with your USB cable.
Change the connection mode to “file transfer (MTP)” mode.
This is not always necessary for every device, but it’s recommended so you don’t run into any issues.
8) Once the Terminal is in the same folder your ADB tools are in, you can execute the following command to launch the ADB daemon: ./adb devices
9) Back on your smartphone or tablet device, you’ll see a prompt asking you to allow USB debugging. Go ahead and grant it.
Windows (source)
1) Download: https://dl.google.com/android/repository/platform-tools-latest-windows.zip
2) Extract the contents of this ZIP file into an
easily accessible folder (such as C:\platform-tools)
3) Open Windows explorer and browse to where you extracted the contents of this ZIP file
4) Then open up a Command Prompt from the same directory as this ADB binary. This can be done by holding
Shift and Right-clicking within the folder then click the “Open command window here” option.
5) Connect your smartphone or tablet to your computer with a USB cable.
Change the USB mode to “file transfer (MTP)” mode. Some OEMs may or may not require this,
but it’s best to just leave it in this mode for general compatibility.
6) In the Command Prompt window, enter the following command to launch the ADB daemon: adb devices
7) On your phone’s screen, you should see a prompt to allow or deny USB Debugging access. Naturally,
you will want to grant USB Debugging access when prompted (and tap the always allow check box if you never want to see that prompt again).
8) Finally, re-enter the command from step #6. If everything was successful,
you should now see your device’s serial number in the command prompt (or the PowerShell window).
Awesome Aliases For ADB
Copy and paste to add the below aliases in ~/.bashrc
cat <<! >> ~/.bashrc
function startintent() {
adb devices \
|tail -n +2 \
|cut -sf 1 \
|xargs -I X adb -s X shell am start $(1)
}
function apkinstall() {
adb devices \
|tail -n +2 \
|cut -sf 1 \
|xargs -I X \
adb -s X install -r $(1)
}
function rmapp() {
adb devices \
|tail -n +2 \
|cut -sf 1 \
|xargs -I X adb -s X uninstall $(1)
}
function clearapp() {
adb devices \
|tail -n +2 \
|cut -sf 1 \
|xargs -I X adb -s X shell cmd package clear $(1)
}
Simple for loop for dump global, secure, and system settings in one command
for options in system security global; do
settings list ${options};
done
Setup and connect to the device via WiFi
This requires that the USB cable is connected until you connect. Once connected via USB, copy and paste the following:
#!/bin/bash
# Author: wuseman
port="5555"
interface=$(adb shell ip addr | awk '/state UP/ {print $2}' | sed 's/.$//'; )
ip=$(adb shell ifconfig ${interface} \
|egrep -o '(\<([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>\.){3}\<([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>' 2> /dev/null \
|head -n 1)
adb tcpip ${port};sleep 0.5
adb connect $ip:${port}; sleep 1.0
adb devices; adb shell
Grab all activities that are available via am start
#!/bin/bash
# Author: wuseman
for package in $(cmd package list packages|cut -d: -f2); do
cmd package dump $package \
|grep -i "activ" \
|grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+.*/[^[:space:]]+" \
|grep -oE "[^[:space:]]+$";
done > /tmp/full_activity_package_list.txt
Enter Termux environment via ADB
Source: rewida17 - termux
#!/system/xbin/bash
# Author: rewida17
# Modded by: wuseman
if [[ $(id -u) -ne "0" ]]; then
echo "root is required";
exit
else
export PREFIX='/data/data/com.termux/files/usr'
export HOME='/data/data/com.termux/files/home'
export LD_LIBRARY_PATH='/data/data/com.termux/files/usr/lib'
export PATH="/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:$PATH"
export LANG='en_US.UTF-8'
export SHELL='/data/data/com.termux/files/usr/bin/bash'
export BIN='/data/data/com.termux/files/usr/bin'
export TERM=vt220
export AR="arm-linux-androideabi-ar"
export CPP="arm-linux-androideabi-cpp"
export GCC="arm-linux-androideabi-gcc"
export LD="arm-linux-androideabi-ld"
export
NM="arm-linux-androideabi-nm"
export OBJDUMP="arm-linux-androideabi-objdump"
export RANLIB="arm-linux-androideabi-ranlib"
export READELF="arm-linux-androideabi-readelf"
export STRIP="arm-linux-androideabi-strip"
export TERMUX="/data/data/com.termux/"
resize
cd "$HOME"
exec "$SHELL" -l
fi
Print esim via uiautomator
Read the screen via uiautomator and print IMEI for all active esim/sim cards on the device.
#!/bin/bash
# Author: wuseman
### Launch IMEI (same result if you type in the caller app: *#06#)
#### and dump screen to /tmp/read_screen.txt via uiautomator and parse esim IMEI:
adb shell input keyevent KEYCODE_CALL;
sleep 1;
input text '*#06#';
uiautomator dump --compressed /dev/stdout\
|tr ' ' '\n'\
|awk -F'"' '{print $2}'|grep "^[0-9]\{15\}$" \
|nl -w 1 -s':'\
|sed 's/^/IMEI/g'
Print Device screen state
screenState="$(adb shell dumpsys input_method \
|grep -i "mSystemReady=true mInteractive=" \
|awk -F= '{print $3}')"
if [[ $screenState = "true" ]]; then
echo "Screen is on";
else
echo "Screen is off";
fi
How reboot works on Android
Reboot Commands:
- Reboot to Bootloader:
adb reboot bootloader
- Reboot to Fastboot:
adb reboot fastboot
- Reboot to Recovery:
adb reboot recovery
- Reboot to System:
adb reboot
What is a hot and warm reboot?
In order to answer your question, we need to define what a hot (or warm) reboot is on an Android device. Terms cold (or hard) boot and warm (or soft) boot are more associated with PCs, particularly Windows. For mobile phones or embedded devices, it's difficult to draw a clear line between cold and warm boot. In the case of a cold reboot, power is usually cut to CPUs, RAM, and even the whole motherboard. A soft reboot only kills and starts the processes while retaining power to hardware components. Power management is part of the open-source ACPI/UEFI/BIOS standard on PCs, while on phones, PMIC firmware is usually used with SoCs.
How does reboot really work on Android?
On (re)boot, SoC firmware loads bootloaders in memory which then load executable binaries and start processes (the actual OS). Android is based on the Linux kernel, which is the very first executable of the operating system that runs during the boot process. The kernel initializes necessary hardware and prepares a basic environment before executing init
, the very first userspace process we can see. It's init
that then starts and takes care of all services and processes.
A civilized way to reboot or shutdown is to let all processes terminate themselves, saving any pending work, unmounting filesystem
s, and then ask the kernel to reverse the boot process. init
can handle this on modern OSes, or you can do it manually through the /proc/sysrq-trigger
interface. Alternatively, we can ask the kernel to perform a quick reboot by killing everything. However, this may cause data loss, particularly due to filesystem corruption.
A brutal way is the long press of the power button (handled by PMIC), which is a cold reboot (or shutdown) in the true sense because the power to CPUs (and RAM) is suddenly cut without waiting for userspace processes and the kernel to terminate gracefully.
Does Android really perform a cold reboot?
On Android phones (and on other systems as well), a normal reboot is not completely cold as power is not cut, at least to RAM because it holds an area where kernel panic logs are stored, which can be accessed on the next boot (refer to ramoops used for last_kmsg or pstore). Similarly, some other memory regions allocated to SoC components and signed firmware that are isolated from the application processor (AP on which the main OS runs) may also not be erased. They include the Baseband Processor (modem), Digital Signal Processor (DSP), WiFi/BT module, etc.
However, a normal reboot isn't a warm reboot either. During reboot, the kernel kills itself and hands over control to bootloaders, which may boot the device in different possible modes (fastboot/bootloader, recovery, or normal boot). The low-level details are vendor and hardware-specific, whether a device performs a complete power-on reset (PoR) or if the hardware is not reset at all. Which components are powered down during different types of reboots depends on the interaction between the kernel, bootloader, SoC, PMIC, watchdog hardware, etc.
How to do a hot reboot?
The Linux kernel also supports another form of warm reboot: kexec
. The kernel can terminate userspace processes and itself, executing a new kernel which can then start a new userspace environment without doing a hardware reset, POST, and re-initialization by BIOS. This approach is theoretically possible on Android too, i.e., the kernel re-executes itself with the proper command line and then starts init
. However, it requires some device-specific changes to the kernel and ROM.
Stock Android doesn't provide a soft reboot functionality, but some custom ROMs implement this feature by triggering the restart method of the activity service. However, init
itself and other core daemons like ueventd, vold, installd, surfaceflinger, logd, servicemanager, healthd, and a long list of vendor daemons aren't restarted.
To restart the device, you can use the following commands:
- On Android 9, the code for the restart method is
179
:
adb shell service call activity 179
- It's also possible to ask
init
to restartzygote
and dependent services. However, SELinux won't let the property be set, so root access is required:
adb shell setprop ctl.restart zygote
acpi
Show help for acpi
:
adb shell acpi --help
Print Battery Percentage:
adb shell acpi 2> /dev/null
Show Cooling Device State:
adb shell 'su -c acpi -c'
Show Temperatures:
adb shell acpi -t 2> /dev/null
Just print everything from acpi
:
adb shell acpi -V
adb
Environment variables:
Variable | Description |
---|---|
$ADB_TRACE |
List of debug info to log |
$ADB_VENDOR_KEYS |
Colon Separated list of keys |
$ANDROID_SERIAL |
Serial number to connect to |
$ANDROID_LOG_TAGS |
Tags to be used by logcat |
$ADB_LOCAL_TRANSPORT_MAX_PORT |
Max emulator scan port |
$ADB_MDNS_AUTO_CONNECT |
Comma Separated list of mdns services to allow auto-connect |
Debug Commands:
Create bugreport.zip
in /sdcard
path:
adb bugreport /sdcard
List pids of processes hosting a JDWP transport:
adb jdwp
Show device log (logcat --help for more):
adb logcat
Sideload the given full OTA package:
adb sideload OTAPACKAGE
Restart adbd
with root permissions:
adb root
Restart adbd
without root permissions:
adb unroot
Restart adbd
listening on USB:
adb usb
Restart adbd
listening on TCP on PORT
:
adb tcpip <port>
Restart userspace:
adb reboot userspace
Internal debugging:
Start adb
server:
adb start-server
Kill adb
server:
adb kill-server
Stop adb
server:
adb stop-server
Kick connection from the host side to force reconnect:
adb reconnect
Kick connection from the device side to force reconnect:
adb reconnect device
Reset offline/unauthorized devices to force reconnect:
adb reconnect offline
USB Commands:
Attach a detached USB device:
adb attach
Detach from a USB device to allow use by others:
adb detach
Shell Commands:
Enter the device shell
:
adb shell
Choose escape character or "none"
(default '~
'):
adb shell -e
Don't read from stdin
:
adb shell -n
Disable pty allocation:
adb shell -T
Allocate a pty
if on a tty
:
adb shell -t
Force allocate a pty
if on a tty
:
adb shell -tt
Disable remote exit codes and stdout/stderr
separation:
adb shell -x
Run emulator
console command:
adb shell emu COMMAND
Enter the device shell when there is more than one device connected:
- USB connected:
adb -s <serial> shell
- Network connected:
adb -s <ip:port> shell
Print connection status:
adb devices -l
Print adb help:
adb help
Print the currend:
adb version
Network Commands
Connect to a device via TCP/IP:
adb connect <ip:port>
Disconnect all connected devices:
adb disconnect all
Disconnect from a given TCP/IP device:
adb disconnect <ip:port>
Pair with a device for secure TCP/IP communication:
adb pair <ip:port> <pairing code>
List all forward socket connections:
adb forward --list
Forward socket connection:
- Port 0 = Any port
adb forward tcp:<port>
adb forward localabstract:<socket name>
adb forward localreserved:<socket name>
adb forward localfilesystem:<socket name>
adb forward jdwp:<process pid> (remote only)
adb forward vsock:<CID>:<port> (remote only)
adb forward acceptfd:<fd> (listen only)
Remove a specific forward socket connection:
adb forward --remove 'local/remote'
Remove all forward socket connections:
adb forward --remove-all
Run PPP over USB:
adb ppp TTY <parameter>
List all reverse socket connections:
adb reverse --list
Reverse socket connection using:
adb reverse tcp:<port>
adb reverse localabstract:<socket name>
adb reverse localreserved:<socket name>
adb reverse localfilesystem:<socket name>
Remove a specific reverse socket connection:
adb reverse --remove 'LOCAL/REMOTE'
Remove all reverse socket connections:
adb reverse --remove-all
Check if mdns discovery is available:
adb mdns check
List all discovered services:
adb mdns services
Security Commands
Disable dm-verity checking on userdebug builds:
adb disable-verity
Re-enable dm-verity checking on userdebug builds:
adb enable-verity
Generate adb public/private key:
adb keygen <filename>
Scripting Commands
Wait for the device to be in a given state:
- STATE:
device
,recovery
,rescue
,sideload
,bootloader
, ordisconnect
- TRANSPORT:
usb
,local
, or any[default=any]
adb wait-for[-TRANSPORT]-STATE...
Print the device state (offline|bootloader|device):
adb get-state
Print the device serial number:
adb get-serialno
Print dev path:
adb get-devpath
Remount partitions read-write:
adb remount -R
am (Activity Manager) Commands
Print all activities that we can launch for the preferred application:
#!/bin/bash
# Author: wuseman
dumpsys package com.android.settings \
|grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+com.android.settings/[^[:space:]]+Activity" \
|grep -io
com.* \
|sed "s/^/am start -n '/g" \
|sed "s/$/'/g"
Print all activities that we can launch for all installed applications on the device:
#!/bin/bash
# Author: wuseman
for packages in $(cmd package list packages|awk -F':' '{print $2}'|sort); do
dumpsys package ${packages} \
|grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+${packages}/[^[:space:]]+Activity" \
|grep -io com.* \
|sed "s/^/am start -n '/g" \
|sed "s/$/'/g" \
|awk '!seen[$0]++'
done
Dump all activities for all packages enabled on the device and store it in a file:
for packages in $(cmd package list packages|awk -F':' '{print $2}'|sort); do
dumpsys package ${packages} \
|grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+${packages}/[^[:space:]]+Activity" \
|grep -io com.* \
|sed "s/^/am start -n '/g" \
|sed "s/$/'/g" \
|awk '!seen[$0]++'
done > /sdcard/wuseman/all_activitys_for_am.txt
Launch an application and enter the activity section of the application's settings:
am start -n 'com.android.settings/.Settings$ApnSettingsActivity'
Launch sysdump menu:
adb shell am start com.sec.android.app.servicemodeapp/.SysDump
Launch cp debug menu:
adb shell am start com.sec.android.app.servicemodeapp/.CPDebugLevel
Launch rtn view menu:
adb shell am start com.sec.android.app.servicemodeapp/.RTN_View
Launch RAMDUMP settings:
adb shell am start com.sec.android.app.servicemodeapp/.CPDebugLevel
Launch reset call time:
adb shell am start com.sec.android.app.servicemodeapp/.ResetTotalCallTime
Launch total call menu:
adb shell am start com.sec.android.app.servicemodeapp/.TotalCallTime
Launch wifi menu:
adb shell am start com.sec.android.app.servicemodeapp/.WifiInfoActivity
Launch NAND Flash:
adb shell am start com.sec.android.app.servicemodeapp/.NandFlashHeaderRead
Launch modemui activities:
adb shell am start com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.PhoneUtil
Launch ESC settings:
adb shell am start com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.PhoneUtil_ESC
Launch UART USBC TC settings:
adb shell am start com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.SetPortUartUSBCTCModel
Launch SGLTE settings:
adb shell am start com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.PhoneUtil_SGLTE
Launch TD settings:
adb shell am start com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.PhoneUtil_TD
Launch MarvellVIA settings:
adb shell am start
com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.PhoneUtil_MarvellVIA
Launch BCOM settings:
adb shell am start com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.PhoneUtil_Bcom
Launch and show IMEI activity:
adb shell am start com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.ShowIMEI
Launch UART USB MSM8960 Port settings:
adb shell am start com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.SetPortUartUsbMSM8960
Launch MDM 9x15 settings:
adb shell am start com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.PhoneUtil_MDM9x15
Launch USB Settings:
adb shell am start com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.USBSettings
Launch auto answer settings:
adb shell am start com.sec.android.app.servicemodeapp/com.sec.android.app.modemui.activities.AutoAnswer
adb Shell Commands
Enter the device shell:
adb shell
Choose an escape character or "none" (default: '~'):
adb shell -e
Don't read from stdin:
adb shell -n
Disable pty allocation:
adb shell -T
Allocate a pty if on a tty:
adb shell -t
Force allocate a pty if on a tty:
adb shell -tt
Disable remote exit codes and stdout/stderr separation:
adb shell -x
Run emulator console command:
adb shell emu COMMAND
Enter the device shell when there is more than one device connected:
- USB connected:
adb -s <serial> shell
- Network connected:
adb -s <ip:port> shell
Print the connection status:
adb devices -l
Print adb help:
adb help
Print the current adb version installed:
adb version
The provided commands allow you to perform various actions related to the com.google.android.gms
package, launch different settings and activities, and interact with other applications. Here are the commands:
Launch Find My Device settings:
adb shell am start -n com.google.android.gms/.mdm.settings.FindMyDeviceSettingsActivity
Launch Nearby Sharing settings:
adb shell am start -n com.google.android.gms/.nearby.sharing.ReceiveSurfaceActivity
Launch Personal Google Setup (requires root):
adb shell su -c am start com.google.android.gms/.accountsettings.mg.ui.main.MainActivity
Launch hidden settings for SMS verification codes (requires root):
adb shell su -c am start com.google.android.gms/.auth.api.phone.ui.AutofillSettingsCollapsingActivity
Set wallpaper for the current image opened:
adb shell am start -a android.intent.action.SET_WALLPAPER
Open SIM ID settings for APN:
adb shell am start -a android.intent.action.INSERT -d content://telephony/carriers --ei simId
Launch default action view:
adb shell am start -a android.intent.action.VIEW
Open the default browser and visit a URL:
adb shell am start -a android.intent.action.VIEW -d https://www.example.com
Launch Google Maps with fixed coordinates:
adb shell am start -a android.intent.action.VIEW -d "geo:46.457398,-119.407305"
Launch Facebook inbox URI:
adb shell am start -a android.intent.action.VIEW -d facebook://facebook.com/inbox
Open a vCard file from the SD card:
adb shell am start -a android.intent.action.VIEW -d file:///sdcard/me.vcard -t text/x-vcard
Launch the default music player and play a file:
adb shell am start -a android.intent.action.VIEW -d file:////storage/9A8A-1069/wuseman/ringtones/<mp3_track>.mp3 -t audio/mp3
Launch the default video player and play a file:
adb shell am start -a android.intent.action.VIEW -d file:///sdcard/sound.ogg -t audio/ogg
Launch the default video player and play a video file:
adb shell am start -a android.intent.action.VIEW -d file:///sdcard/video.mkv -t video/mkv
Launch Android settings:
adb shell am start -n com.android.settings/com.android.settings.Settings
Launch Android sub-settings:
adb shell am start com.android.settings/com.android.settings.SubSettings
Open the camera in photo mode:
adb shell am start -a android.media.action.IMAGE_CAPTURE
Open the camera app in video mode:
adb shell am start -a android.media.action.VIDEO_CAMERA
Open the camera app in QR mode:
adb shell am start -n 'com.sec.android.app.camera/.QrScannerActivity'
Open My Files (file manager):
adb shell am start com.sec.android.app.myfiles/com.sec.android.app.myfiles.external.ui.MainActivity
Open SIM card settings from the setup wizard:
su -c am start -n 'com.sec.android.app.SecSetupWizard/.UI.SimTssSetupActivity'
Open the last page in the setup wizard that indicates everything has been done:
su -c am start -n '
com.sec.android.app.SecSetupWizard/.UI.OutroActivity'
Open the last page in the setup wizard with the spinning bar:
su -c am start -n 'com.sec.android.app.SecSetupWizard/.kme.B2bDeviceCheckActivity'
Open Samsung Features window from the setup wizard:
su -c am start -n 'com.sec.android.app.SecSetupWizard/.UI.AlternativePermissionActivity'
Open Take Care of Your Device window from the setup wizard:
su -c am start -n 'com.sec.android.app.SecSetupWizard/.UI.NoticeActivity'
Open the language window from the setup wizard:
su -c am start -n 'com.sec.android.app.SecSetupWizard/.UI.LanguageSelectionActivity'
Send a simple notification:
adb shell am broadcast -n your.package.name/com.google.firebase.iid.FirebaseInstanceIdReceiver -c your.package.name -a com.google.android.c2dm.intent.RECEIVE
Send a notification:
adb shell am broadcast -n com.android.google.youtube/com.google.firebase.iid.FirebaseInstanceIdReceiver -a "com.google.android.c2dm.intent.RECEIVE" -es "title" "Title" --es "body" "Body"
Broadcast a push notification locally using ADB without a network connection:
adb shell am broadcast -n com.your.app/com.google.firebase.iid.FirebaseInstanceIdReceiver -a "com.google.android.c2dm.intent.RECEIVE" --es "extra1" "65" --es "guid" "1f400184-9215-479c-b19a-a9cd9a1d9dc9" --es "extra3" "VALUE" --es "extra4" "'Long string with spaces'"
Add a value to the default shared preferences:
adb shell am broadcast -a org.example.app.sp.PUT --es key key_name --es value "hello world!"
Remove a value from the default shared preferences:
adb shell am broadcast -a org.example.app.sp.REMOVE --es key key_name
Clear all default shared preferences:
adb shell am broadcast -a org.example.app.sp.CLEAR --es key key_name
Restart the application process after making changes:
adb shell am broadcast -a org.example.app.sp.CLEAR --ez restart true
Set default preferences for an app:
adb shell am broadcast -a org.example.app.sp.CLEAR --es key key_name
Factory reset your device after the next reboot:
adb shell am broadcast -a android.intent.action.MASTER_CLEAR
reboot
Launch the Launcher activities (requires root):
adb shell am start com.sec.android.app.launcher/com.sec.android.app.launcher.activities.LauncherActivity
Launch the homescreen (requires root):
adb shell am start com.sec.android.app.launcher/com.android.launcher3.uioverrides.QuickstepLauncher
Here are some additional ADB shell commands:
Open hidden menu and select "enable":
adb shell "su -c am broadcast -a android.provider.Telephony.SECRET_CODE -d android_secret_code://HIDDENMENUENABLE"
Open internal operation test menu:
adb shell "su -c am broadcast -a android.provider.Telephony.SECRET_CODE -d android_secret_code://IOTHIDDENMENU"
Open a dialog box followed by another dialog asking for the unlock key code:
adb shell "su -c am broadcast -a android.provider.Telephony.SECRET_CODE -d android_secret_code://UNLOCKKERNEL"
Send an SMS:
adb shell am broadcast -a com.whereismywifeserver.intent.TEST --es sms_body "test from adb"
Trigger test GSM cell broadcasts:
adb shell am broadcast -a com.android.internal.telephony.gsm.TEST_TRIGGER_CELL_BROADCAST --es pdu_string <pdu_string>
Simulate wake mode:
adb shell am set-inactive <packageName>
adb shell am set-inactive <packageName> false
Enable Demo Mode:
adb shell settings put global sysui_demo_allowed 1
Enable car dialer:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb -es "action" "connect"
Make a call:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "addCall" --es "id" "4085524874"
Receive an incoming call:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "rcvCall" --es "id" "4085524874"
Merge calls:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "unholdCall"
Hold a call:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "holdCall"
Unhold a call:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "unholdCall"
End a call:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "endCall" --es "id" "4085524874"
Clear call history:
adb shell am broadcast -a com.android.car.dialer.intent.action.adb --es "action" "clearAll"
Press home and print call status:
adb shell am start -W -c android.intent.category.HOME -a android.intent.action.MAIN
Display time in hhmm
format:
adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm 1200
Print network data type:
adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e level 4 -e datatype false
Hide notifications:
adb shell am broadcast -a com.android.systemui.demo -e command notifications -e visible false
Restart the system service:
adb shell am startservice -n com.android.systemui/.SystemUIService
Open Google Camera (Pixel 4):
adb shell am start com.google.android.GoogleCamera
Find all available modes to launch in GUI (Samsung):
adb shell cmd package dump com.samsung.android.app.telephonyui | grep "Activity filter" | awk '{print $2}' | awk '!seen[$0]++'
Launch Samsung Dialer:
adb shell am start com.samsung.android.dialer/.DialtactsActivity
Launch Samsung SMS application:
adb shell am start com.samsung.android.messaging/com.samsung.android.messaging.ui.view.setting.MainSettingActivity
Launch Samsung Messenger conversation composer:
adb shell am start com.samsung.android.messaging/com.android.mms.ui.ConversationComposer
Launch Samsung Messenger in contacts view:
adb shell am start com.samsung.android.messaging/com.samsung.android.messaging.ui.view.recipientspicker.PickerActivity
Launch Samsung Messenger with recent activity:
adb shell am start com.samsung.android.dialer/com.samsung.android.dialer.calllog.view.picker.CallLogPickerActivity
Launch Samsung Gallery:
adb shell am start com.sec.android.gallery3d/com.samsung.android.gallery.app.activity.GalleryActivity
Launch secret project menu (Huawei only):
adb shell am start com.huawei.android.projectmenu/com.huawei.android.projectmenu.ProjectMenuActivity
Set the application run in the background behavior:
adb shell cmd appops set <package_name> RUN_IN_BACKGROUND ignore
Set any application run in the background behavior:
adb shell cmd appops set <package_name> RUN_ANY_IN_BACKGROUND ignore
Set the application to launch in the foreground:
adb shell cmd appops set <package_name> START_FOREGROUND ignore
Set the application settings for instant launch in the foreground:
adb shell cmd appops set <package_name> INSTANT_APP_START_FOREGROUND ignore
Set application permission for clipboard:
adb shell cmd appops set <packagename> READ_CLIPBOARD allow
Paste clipboard:
adb shell input keyevent PASTE
Set application with read permissions for the clipboard:
adb cmd appops set com.bankid.bus READ_CLIPBOARD allow
Add text to clipboard:
am broadcast -a clipper.set -e text "text"
Get airplane mode status:
adb shell cmd connectivity airplane-mode
Set airplane mode (enable/disable):
adb shell cmd connectivity airplane-mode enable|disable
Send notify and push notice to the notification bar:
adb shell su -lp 2000 -c "cmd notification post -S bigtext -t 'adb pwnz' 'Tag' 'it rly does'"
Set resume on reboot provider package:
adb shell cmd lock_settings set-resume-on-reboot-provider-package <package_name>
Remove cached unified challenge for the managed profile:
adb shell cmd lock_settings remove-cache --user 0
Verify the lock credentials:
adb shell cmd lock_settings verify --old 1234 --user 0
Clear the lock credentials:
adb shell cmd lock_settings clear --old 1234 --user 0
Enable/disable synthetic password:
adb shell cmd lock_settings sp --old 1234 --user 0 <1|0>
Get whether synthetic password is enabled:
adb shell cmd lock_settings sp --old 1234 --user 0
Set the lock screen as a password using the given password to unlock:
adb shell cmd lock_settings set-password --old 1234 --user 0
'newPassword'
Set the lock screen as a PIN using the given PIN to unlock:
adb shell cmd lock_settings set-pin --old 1234 --user 0 'newPin'
Set the lock screen as a pattern using the given pattern to unlock:
adb shell cmd lock_settings set-pattern --old 1234 --user 0 'newPattern'
When true, disable lock screen:
adb shell cmd lock_settings set-disabled --old 1234 --user 0 true|false
Check whether the lock screen is disabled:
adb shell cmd lock_settings get-disabled --old 1234 --user 0
Print stats:
adb shell cmd stats print-stats
Send a broadcast that triggers the subscriber to fetch metrics:
adb shell cmd stats send-broadcast uid name
Flush all data in memory to disk:
adb shell cmd stats write-to-disk
Print the UID, app name, version mapping:
adb shell cmd stats print-uid-map
Log a binary push state changed event:
adb shell cmd stats log-binary-push NAME VERSION STAGING ROLLBACK_ENABLED LOW_LATENCY STATE EXPERIMENT_IDS
Hide all notification icons on the status bar:
adb shell cmd statusbar send-disable-flag notification-icons
Reset all flags to default:
adb shell cmd statusbar send-disable-flag none
Print status bar icons:
adb shell cmd statusbar get-status-icons
Print preferences for the status bar:
adb shell cmd statusbar prefs list-prefs
Expand the status bar:
adb shell cmd statusbar expand-notifications
Collapse the status bar:
adb shell cmd statusbar collapse
Expand full settings:
adb shell cmd statusbar expand-settings
Get the auth user:
adb shell cmd user list
Here are some additional commands related to UI mode, Wi-Fi, media session, package management, and app operations:
Enable night mode (Dark Mode):
adb shell cmd uimode night yes
Disable night mode:
adb shell cmd uimode night no
Enable car mode:
adb shell cmd uimode car yes
Disable car mode:
adb shell cmd uimode car no
Scan for nearby SSIDs and fetch Wi-Fi data:
#!/bin/bash
adb shell cmd -w wifi start-scan
sleep 7
adb shell cmd -w wifi list-scan-results
Sets whether we are in the middle of an emergency call:
adb shell cmd -w wifi set-emergency-call-state enabled|disabled
Sets whether Emergency Callback Mode (ECBM) is enabled:
adb shell cmd -w wifi set-emergency-callback-mode enabled|disabled
Lists the suggested networks from the app:
adb shell cmd -w wifi list-suggestions-from-app com.app.example
Lists all suggested networks on this device:
adb shell cmd -w wifi list-all-suggestions
Queries whether network requests from the app are approved or not:
adb shell cmd -w wifi network-requests-has-user-approved com.app.example
Sets whether network requests from the app are approved or not:
adb shell cmd -w wifi network-requests-set-user-approved com.app.example yes|no
Lists the requested networks added via the shell:
adb shell cmd -w wifi list-requests
Removes all active requests added via the shell:
adb shell cmd -w wifi remove-all-requests
Remove a network request with the provided SSID of the network:
adb shell cmd -w wifi remove-request <ssid>
Add a network request with the provided parameters:
adb shell cmd -w wifi add-request <ssid> open|owe|wpa2|wpa3 [<passphrase>] [-b <bssid>]
Initiates Wi-Fi settings reset:
adb shell cmd -w wifi settings-reset
Gets soft AP supported features:
adb shell cmd -w wifi get-softap-supported-features
Sets whether Wi-Fi watchdog should trigger recovery:
adb shell cmd -w wifi set-wifi-watchdog enabled|disabled
Sets country code to <two-letter code>
or left for normal value:
adb shell cmd -w wifi force-country-code enabled <two-letter code> | disabled
Manually triggers a link probe:
adb shell cmd -w wifi send-link-probe
Clears the user-disabled networks list:
adb shell cmd -w wifi clear-user-disabled-networks
Removes all user-approved network requests for the app:
adb shell cmd -w wifi network-requests-remove-user-approved-access-points com.app.example
Clear the user choice on Imsi protection exemption for the carrier:
adb shell cmd -w wifi imsi-protection-exemption-clear-user-approved-for-carrier <carrier id>
Queries whether Imsi protection exemption for the carrier is approved or not:
adb shell cmd -w wifi imsi-protection-exemption-has-user-approved-for-carrier <carrier id>
Sets whether Imsi protection exemption for the carrier is approved or not:
adb shell cmd -w wifi imsi-protection-exemption-set-user-approved-for
-carrier <carrier id> yes|no
Print all available apps that can be manually started from the activity manager:
adb shell cmd package dump com.android.com | grep "Activity filter" | awk '{print $2}'
List UID owner of a package:
adb shell cmd package list packages -U
Print all applications sorted by alpha:
adb shell cmd package list packages | awk -F: '{print $2}' | sort
List packages:
adb shell cmd package list packages -l
List disabled packages:
adb shell cmd package list packages -d
Filter to only show enabled packages:
adb shell cmd package list packages -e
Filter to only show third-party packages:
adb shell cmd package list packages -3
Set the default home activity (aka launcher):
adb shell cmd package set-home-activity [--user USER_ID] TARGET-COMPONENT
Print all features of the system:
adb shell cmd package list features
Print briefs:
adb shell cmd package resolve-activity --brief com.facebook.katana
Connect to AudioService:
adb shell cmd media_session volume
Set the volume of media to a value (0-15):
adb shell media volume --show --stream 3 --set N
Set fine volume in Samsung devices (0-150):
adb shell cmd media_session volume --show --setfine 150
Control the stream (3=STREAM_MUSIC) and set the volume index to 11:
adb shell cmd media_session volume --show --stream 3 --set 11
Print the current volume from all streams:
adb shell cmd media_session volume --get
Print the current volume range from stream 3:
adb shell cmd media_session volume --stream 3 --get
Print the current fine volume:
adb shell cmd media_session volume --getfine
Increase media volume:
adb shell cmd media_session volume --show --adj raise
Decrease media volume:
adb shell cmd media_session volume --show --adj lower
Print the current volume (1-15):
adb shell cmd media_session volume --get
Print a list of current media sessions:
adb shell cmd media_session list-sessions
Monitor updates to the specified session (use tag output from list-sessions):
cmd media_session monitor spotify-media-session
Set application run-in-background behavior:
cmd appops set <package_name> RUN_IN_BACKGROUND ignore
Set any application run-in-background behavior:
cmd appops set <package_name> RUN_ANY_IN_BACKGROUND ignore
Set application to launch in the foreground:
cmd appops set <package_name> START_FOREGROUND ignore
Set application settings for instant launch in the foreground:
cmd appops set <package_name> INSTANT_APP_START_FOREGROUND ignore
Set application permission for clipboard:
cmd appops set <packagename> READ_CLIPBOARD allow
Please note that some commands may require root access or specific privileges.
Here are some additional commands related to media dispatch and content management:
Dispatch media commands:
Press play
key:
adb shell cmd media_session dispatch play
Dispatch pause
:
adb shell cmd media_session dispatch pause
Dispatch play-pause
:
adb shell cmd media_session dispatch play-pause
Dispatch mute
:
adb shell cmd media_session dispatch mute
Dispatch headsethook
:
adb shell cmd media_session dispatch headsethook
Dispatch stop
:
adb shell cmd media_session dispatch stop
Dispatch next
:
adb shell cmd media_session dispatch next
Dispatch previous
:
adb shell cmd media_session dispatch previous
Dispatch rewind
:
adb shell cmd media_session dispatch rewind
Dispatch record
:
adb shell cmd media_session dispatch record
Dispatch fast-forward
:
adb shell cmd media_session dispatch fast-forward
Content management:
Find contents in SDK map and create samples for this cheatsheet:
rg . | rg 'content://.*"' -o | cut -d '"' -f1 | sed 's/^/adb shell content query --uri /g' | sed 'i### Print\''
Find contents in SDK map and create samples for this cheatsheet:
adb shell "su -c content query --uri content://com.samsung.rcs.autoconfigurationprovider/root/* | tr ' ' '\n'"
Print device number:
adb shell "su -c content query --uri content://com.samsung.rcs.autoconfigurationprovider/root/application/1/im/fthttpcsuser"
Delete a certain setting:
adb shell content delete --uri content://settings/secure --where "name='new_setting'"
Insert a setting and value to foo:
adb shell content insert --uri content://settings/secure --bind name:s:user_setup_complete --bind value:s:1
Change setting to another setting:
adb shell content update --uri content://settings/secure --bind value:s:newer_value --where "name='new_setting'"
Select "name" and "value" columns from secure settings where "name" is equal to "new_setting" and sort the result by name in ascending order:
adb shell content query --uri content://settings/secure --projection name:value --where "name='new_setting'" --sort "name ASC"
Read and redirect file:
adb shell 'content read --uri content://settings/system/ringtone_cache' > foo.ogg
Set ringtone:
adb shell 'content write --uri content://settings/system/ringtone_cache' < host.ogg
Print current type for a content:
adb shell content gettype --uri content://media/internal/audio/media/
Print cell broadcasts, call logs, downloads, contacts, MMS, and more:
Print cell broadcasts:
adb shell content query --uri content://cellbroadcasts
Print call logs:
adb shell content query --uri content://call_log/calls
Print downloads:
adb shell content query --uri content://downloads/my_downloads
Print contacts:
adb shell content query --uri content://contacts/people
Print MMS:
adb shell content query --uri content://mms
Print SMS:
adb shell content query --uri content://sms
Print device carriers:
adb shell su -c content query --uri content://telephony/carriers
Here is the continuation of the Markdown cheatsheet you provided:
## ffplay
FFplay works, but it seems to take a few seconds to decide to start and ends up lagging well behind the entire time.
### Stream via FFplay
FFPlay Default - No Settings
```bash
adb shell screenrecord --Example Output-format=h264 - | ffplay -
FFplay Customized
adb exec-out screenrecord | --Example Output-format=h264 - | |ffplay | -framerate 60 | -probesize 32 | -sync video -
adb shell screenrecord | --bit-rate=16m | --Example Output-format=h264 | --size 800x600 - | |ffplay | -framerate 60 | -framedrop | -bufsize 16M -
FFplay Customized - Stream in 1080p quality
adb exec-out screenrecord | --bit-rate=16m | --Example Output-format=h264 | --size 1920x1080 -
getprop
Use the getprop
command to get system properties.
Example Usage
adb shell getprop | egrep "model|version.sdk|manufacturer|hardware|platform|revision|serialno|product.name|brand" 2>/dev/null
Print CPU ABI
adb shell getprop ro.product.cpu.abi
Get info if OEM Unlock is Allowed
1 = Enabled
0 = Disabled
adb shell getprop sys.oem_unlock_allowed
Is System boot completed
adb shell getprop sys.boot_completed
input
Simulate input events using the input
command.
Erase all text
adb shell input keyevent KEYCODE_MOVE_END
adb shell input keyevent | --longpress $(printf 'KEYCODE_DEL %.0s' {1..250})
Start Calculator via Keyevent
adb shell input keyevent KEYCODE_CALCULATOR
Start Calendar via Keyevent
adb shell input keyevent KEYCODE_CALENDAR
Start Call Application via Keyevent
adb shell input keyevent KEYCODE_CALL
Start Camera via Keyevent
adb shell input keyevent KEYCODE_CAMERA
Press Caps Lock via Keyevent
adb shell input keyevent KEYCODE_CAPS_LOCK
Start Captions via Keyevent
adb shell input keyevent KEYCODE_CAPTIONS
Open Contacts Application via Keyevent
adb shell input keyevent KEYCODE_CONTACTS
Copy via Keyevent
adb shell input keyevent KEYCODE_COPY
Cut via Keyevent
adb shell input keyevent KEYCODE_CUT
Delete via Keyevent
adb shell input keyevent KEYCODE_DEL
EndCall via Keyevent
adb shell input keyevent KEYCODE_ENDCALL
Press END via Keyevent
adb shell input keyevent KEYCODE_END
Jump to the beginning of the line
adb shell input keyevent KEYCODE_DPAD_UP
Jump to the end of the line
adb shell input keyevent KEYCODE_DPAD_DOWN
Move the cursor one step to the left/right
adb shell input keyevent KEYCODE_DPAD_LEFT
adb shell input keyevent KEYCODE_DPAD_RIGHT
Press Home Button
adb shell input keyevent KEYCODE_HOME
Press + and - buttons
adb shell input keyevent KEYCODE_MINUS
adb shell input keyevent KEYCODE_PLUS
Press + in the numpad
adb shell input keyevent KEYCODE_NUMPAD_ADD
Press * button
adb shell input keyevent KEYCODE_NUMPAD_MULTIPLY
Press search key
adb shell input keyevent KEYCODE_SEARCH
Open Settings
adb shell input keyevent KEYCODE_SETTINGS
Press # button
adb shell input keyevent KEYCODE_NUMPAD_MULTIPLY
Start default music app
adb shell input keyevent KEYCODE_POUND
Mute Volume
adb shell input keyevent KEYCODE_MUTE
Open the notification bar and close
adb shell input keyevent KEYCODE_NOTIFICATION
adb shell input keyevent KEYCODE_NOTIFICATION
Cancel long press
adb shell input keyevent FLAG_CANCELED_LONG_PRESS
Open App Switch for changing applications
adb shell input keyevent KEYCODE_APP_SWITCH
Open Default Assistant
adb shell input keyevent KEYCODE_BRIGHTNESS_DOWN
adb shell input keyevent KEYCODE_BRIGHTNESS_UP
Select
adb shell input keyevent KEYCODE_BUTTON_SELECT
Swipe from top to bottom
adb shell input swipe 0 0 0 1000
Swipe from bottom to top
adb shell input swipe 0 1000 0 0
adb shell input swipe 100 4000 200 400
Swipe slower from bottom to top
adb shell input swipe 500 1000 0 0
Pinch out slowly
adb shell input swipe 100 100 20 20
Pinch out harder
adb shell input swipe 100 100 20 1000
Swipe your finger up and move window down
adb shell input swipe 100 1000 20 100
Simulate a swipe down for notification bar
adb shell input swipe 0 0 0 300
Swipe and unlock the screen
adb shell input swipe 300 1000 300 500
Erase all text
adb shell input keyevent KEYCODE_MOVE_END
adb shell input keyevent | --longpress $(printf 'KEYCODE_DEL %.0s' {1..250})
Start Calculator via Keyevent
adb shell input keyevent KEYCODE_CALCULATOR
Start Calendar via Keyevent
adb shell input keyevent KEYCODE_CALENDAR
Start Call Application via Keyevent
adb shell input keyevent KEYCODE_CALL
Start Camera via Keyevent
adb shell input keyevent KEYCODE_CAMERA
Press Caps Lock via Keyevent
adb shell input keyevent KEYCODE_CAPS_LOCK
Start Captions via Keyevent
adb shell input keyevent KEYCODE_CAPTIONS
Open Contacts Application via Keyevent
adb shell input keyevent KEYCODE_CONTACTS
Copy via Keyevent
adb shell input keyevent KEYCODE_COPY
Cut via Keyevent
adb shell input keyevent KEYCODE_CUT
Delete via Key
event
adb shell input keyevent KEYCODE_DEL
EndCall via Keyevent
adb shell input keyevent KEYCODE_ENDCALL
Press END via Keyevent
adb shell input keyevent KEYCODE_END
Jump to the beginning of the line
adb shell input keyevent KEYCODE_DPAD_UP
Jump to the end of the line
adb shell input keyevent KEYCODE_DPAD_DOWN
Move the cursor one step to the left/right
adb shell input keyevent KEYCODE_DPAD_LEFT
adb shell input keyevent KEYCODE_DPAD_RIGHT
Press the Grave (`) key
adb shell input keyevent KEYCODE_GRAVE
Press Home Button
adb shell input keyevent KEYCODE_HOME
Press + and - buttons
adb shell input keyevent KEYCODE_MINUS
adb shell input keyevent KEYCODE_PLUS
Press + in the numpad
adb shell input keyevent KEYCODE_NUMPAD_ADD
Press * button
adb shell input keyevent KEYCODE_NUMPAD_MULTIPLY
Press search key
adb shell input keyevent KEYCODE_SEARCH
Open Settings
adb shell input keyevent KEYCODE_SETTINGS
Press # button
adb shell input keyevent KEYCODE_NUMPAD_MULTIPLY
Start default music app
adb shell input keyevent KEYCODE_POUND
Mute Volume
adb shell input keyevent KEYCODE_MUTE
Open the notification bar and close
adb shell input keyevent KEYCODE_NOTIFICATION
adb shell input keyevent KEYCODE_NOTIFICATION
Cancel long press
adb shell input keyevent FLAG_CANCELED_LONG_PRESS
Open App Switch for changing applications
adb shell input keyevent KEYCODE_APP_SWITCH
Open Default Assistant
adb shell input keyevent KEYCODE_BRIGHTNESS_DOWN
adb shell input keyevent KEYCODE_BRIGHTNESS_UP
Select
adb shell input keyevent KEYCODE_BUTTON_SELECT
Add a Contact, fill info, and press save on the device
adb shell am start -a android.intent.action.INSERT -t vnd.android.cursor.dir/contact -e name 'wuseman' -e phone '+467777701' -e email '[email protected]' -e postal 'Street 10, New York'
Press save contact via shell from the above command
adb shell input keyevent 4
adb shell input keyevent 4
adb shell am start -a android.intent.action.INSERT -t vnd.android.cursor.dir/contact -e name 'wuseman' -e phone '+46728999329' -e email '[email protected]'
keytool
Keytool is a command-line tool for managing keys and certificates.
Generate hash from keystore (typically used in Facebook)
keytool -exportcert -alias your_alias -keystore debug.keystore | openssl sha1 -binary | openssl base64
Typically used in Google Maps
keytool -list -v -keystore ~/.android/debug.keystore -alias your_alias
logcat
Use the logcat
command to view logs generated by the system and applications.
Tag | Description |
---|---|
V | Verbose (lowest |
priority) | | D | Debug | | I | Info (default priority) | | W | Warning | | E | Error | | F | Fatal | | S | Silent (highest priority, on which nothing is ever printed) |
Print the most recent lines since the specified time
adb logcat -t '01-26 20:52:41.820'
Print log only from a specific process ID
adb logcat --pid=<pid>
Log multiple options
adb logcat -b main -b radio -b events
Run all options at once
adb logcat -v brief \
-v long \
-v process \
-v raw \
-v tag \
-v thread \
-v threadtime \
-v time \
-v color
Print log from lock_settings
only
adb logcat | grep "LockSettingsService|LockPatternUtilsKeyStorage|vold|vold|keystore2|keymaster_tee|LockSettingsService|vold_prepare_subdirs"
pm
The pm
command is used to manage packages on the device.
Disable AutoUpdate for any Package
adb shell pm disable-user --user 0 <package_name>
Disable AutoUpdate for all applications
adb shell pm disable-user com.android.vending
Print all applications in use
adb shell pm list packages | sed -e "s/package://" | while read x; do cmd package resolve-activity --brief $x | tail -n 1 | grep -v "No activity found"; done
List all packages installed on the device
adb shell pm list packages
List enabled packages
adb shell pm list packages -e
List disabled packages
adb shell pm list packages -d
List third-party packages installed by the user
adb shell pm list packages -3
List users
adb shell pm list users
List permission groups
adb shell pm list permission-groups
List features
adb shell pm list features
Uninstall any installed package
adb shell pm uninstall --user 0 com.package.name
Uninstall multiple apps
for packages in com.package1 com.package2; do
adb shell pm uninstall --user 0 "${packages}"
done
Clear application data
adb shell pm clear PACKAGE_NAME
Grant permission to an app
adb shell pm grant com.application android.permission.READ_LOGS
Revoke permission from an app
adb shell pm revoke com.application android.permission.READ_LOGS
Reset all permissions for an app
adb shell pm reset-permissions -p your.app.package
reboot
Reboot system
adb reboot
Reboot to recovery
adb reboot recovery
Reboot to bootloader
adb reboot bootloader
Reboot to fastboot (some brands)
adb reboot fastboot
screencap
Take a screenshot
adb shell screencap /storage/emulated/0/Pictures/screenshot.png
screenrecord
Record screen for 10 seconds
adb shell screenrecord --time-limit 10 /storage/emulated/0/Video/record.mp4
service
Expand status bar
adb shell service call statusbar 1
Expand status bar (full)
adb shell service call statusbar 2
Collapse status bar
adb shell service call statusbar 0
IMEI Related
Slot 1
Print IMEI - Example 1
adb shell service call iphonesubinfo 1 | cut -d "'" -f2 | grep -Eo '[0-9]' | xargs | sed 's/\ //g'
Print IMEI - Example 2
adb shell service call iphonesubinfo 3 i32 1 || grep -oE '[0-9a-f]{8} ' | while read hex; do
echo -ne "\u${hex:4:4}\u${hex:0:4}";
done;
echo
Print IMEI - Example 3
adb shell echo "[device.imei]: [$(service call iphonesubinfo 1 | awk -F "'" '{print $2}' | sed '1 d' | tr -d '\n' | tr -d '.' | tr -d ' ')]"
Print IMEI - Example 4
adb shell service call iphonesubinfo 1 | awk -F"'" 'NR>1 { gsub(/\./,"",$2); imei=imei $2 } END {print imei}'
Print IMEI - Example 5
adb shell service call iphonesubinfo 1 | cut -c 52-66 | tr -d '.[:space:]'"
Print IMEI - Example 6
adb shell service call iphonesubinfo 1 | awk -F "'" '{print }' | sed '1 d' | tr -d '.' | awk '{print}' ORS=
Slot 2
Print IMEI - Slot 2
adb shell service call iphonesubinfo 3 i32
2 \
| grep -oE '[0-9a-f]{8} ' | while read hex; do
echo -ne "\u${hex:4:4}\u${hex:0:4}";
done; echo
monkey
Test any app by simulating pressing 10,000 times at once
monkey -p com.example.myapp -v 10000
setprop
Auto answer any call after 2 seconds
adb shell setprop persist.sys.tel.autoanswer.ms 2000
Turn off auto answer
adb shell setprop persist.sys.tel.autoanswer.ms 0
Set adb USB enabled
adb shell settings put global adb_enabled 1
Set adb WiFi enabled
adb shell settings put global adb_wifi_enabled 1
Set allowed connection timeout for adb
adb shell settings put global adb_allowed_connection_time 1
Set airplane mode status
adb shell settings put global airplane_mode_on 0
Set airplane mode radios
adb shell settings put global airplane_mode_radios cell,bluetooth,wifi,nfc,wimax
Set airplane mode toggle settings
adb shell settings put global airplane_mode_toggleable_radios cell,bluetooth,wifi,nfc
Enable secure WiFi backup exist
adb shell settings put global SecureWifiBackupExist 1
Set notification sound for low battery
adb shell settings put global low_battery_sound_timeout 0
Set default video quality
adb shell settings put global video_quality 1080
Set user setup complete to 0 for optimizing apps at boot
adb shell settings put secure user_setup_complete 1
Lock screen settings
adb shell settings put secure lock_screen_allow_private_notifications 1
adb shell settings put secure lock_screen_lock_after_timeout 5000
Enable mock location (required for fake GPS)
adb shell settings put secure mock_location 1
Enable backup
adb shell settings put secure backup_enabled 1
Protect battery
adb shell settings put global protect_battery 1
Enable biometrics face
adb shell settings put global biometrics_disclaimer_face 1
Enable biometrics fingerprint
adb shell settings put global biometrics_disclaimer_fingerprint 1
Enable/disable rotation of the screen
adb shell settings put system accelerometer_rotation 0
Disable lock screen
adb shell settings put secure lockscreen.disabled 1
Enable speak password
adb shell settings put secure speak_password 1
List secure settings
adb shell settings list | grep "secure"
List global settings
adb shell settings list | grep "global"
List system settings
adb shell settings list | grep "system"
List secure, global, and system settings
for options in global secure system; do
adb shell settings list | grep "${options}"
done
Disable developer mode
adb shell settings put global development_settings_enabled 0
Enable developer mode
adb shell settings put global development_settings_enabled 1
Doze Device Idle State Transition
Inspect any customized Doze settings. It returns null if
none has been set.
adb shell settings get global device_idle_constants
Configure customized Doze settings:
To ignore Deep Doze and discard any motion by increasing inactive_to (and motion_inactive_to) timeout to a very large number (e.g., 30 days) so that Deep Doze never goes into its IDLE state and only Light Doze can manage its IDLE state.
adb shell settings put global device_idle_constants inactive_to=2592000000,motion_inactive_to=2592000000
To ignore Deep Doze and use Light Doze to mimic Deep Doze timing.
adb shell settings put global device_idle_constants inactive_to=2592000000,motion_inactive_to=2592000000,light_after_inactive_to=3000000,light_max_idle_to=21600000,light_idle_to=3600000,light_idle_maintenance_max_budget=600000,min_light_maintenance_time=30000
To idle casually at the beginning and increasingly keep idle as much as possible without taking motion into account by ignoring the real Deep Doze and tuning Light Doze so that it will begin idle less than one minute after the phone is inactive and stay idle from 30 minutes to 24 hours with an increasing factor of 1.5; Maintenance tasks would be performed for a maximum of 30 seconds, and any alarm allowed to wake up Doze from idle would have less effect.
adb shell settings put global device_idle_constants inactive_to=2592000000,motion_inactive_to=2592000000,light_after_inactive_to=20000,light_pre_idle_to=30000,light_max_idle_to=86400000,light_idle_to=1800000,light_idle_factor=1.5,light_idle_maintenance_max_budget=30000,light_idle_maintenance_min_budget=10000,min_time_to_alarm=60000
To idle as much as possible without taking motion into account by ignoring the real Deep Doze and tuning Light Doze so that it will be trapped in the IDLE state as long as possible. Maintenance tasks would be performed about twice a day for a maximum of 30 seconds, and any alarm allowed to wake up Doze from idle would have less effect.
adb shell settings put global device_idle_constants inactive_to=2592000000,motion_inactive_to=2592000000,light_after_inactive_to=15000,light_pre_idle_to=30000,light_max_idle_to=86400000,light_idle_to=43200000,light_idle_maintenance_max_budget=30000,light_idle_maintenance_min_budget=10000,min_time_to_alarm=60000
Reset customized Doze settings to default.
adb shell settings delete global device_idle_constants
List how many times the device has started
adb shell settings list global | grep "boot_count=" | cut -d= -f2 | head -n 1 | xargs echo "Booted:" | sed 's/$/ times/g'
Hide status bar
adb shell settings put global policy_control immersive.status=*
Hide navigation bar
adb shell settings put global policy_control immersive.navigation=*
The commands you provided are related to Android debugging and system management. Here's a breakdown of each command:
- Hide both status and navigation bars:
adb shell settings put global policy_control immersive.full=*
This command hides both the status bar (the bar at the top of the screen) and the navigation bar (the bar at the bottom of the screen) using the immersive mode.
- Revert bars to stock configuration:
adb shell settings put global policy_control null*
This command reverts the changes made by the previous command and restores the stock configuration of the status and navigation bars.
- Specify immersive behavior for a specific application:
adb shell settings put global policy_control immersive.full=com.honeywell.enterprisebrowser
This command specifies that the immersive mode (hiding status and navigation bars) should be applied to the specified application, in this case, "com.honeywell.enterprisebrowser" (Enterprise Browser).
- Adopting USB-Drive:
adb shell sm set-force-adoptable true
This command sets the system to force the adoption of USB drives as internal storage.
-
SQLite3 commands:
- Read Lock Settings:
sqlite3 -line /data/user_de/0/com.android.providers.telephony/databases/telephony.db 'select * from locksettings;'
This command reads lock settings from the telephony database.
- Read SIM Card info:
sqlite3 -line /data/user_de/0/com.android.providers.telephony/databases/telephony.db 'select * from siminfo'
This command reads SIM card information from the telephony database.
- Print ICCID:
sqlite3 /data/vendor/radio/qcril.db 'select ICCID from qcril_manual_prov_table'
This command prints the ICCID (Integrated Circuit Card Identifier) from the qcril_manual_prov_table.
-
Other miscellaneous commands:
- System Server:
adb shell svc system-server wait-for-crash
This command waits for the system server to crash.
- Near-field communication (NFC):
adb shell svc nfc [enable|disable]
This command enables or disables NFC (Near-field communication).
- Power:
adb shell svc power stayon [true|false|usb|ac|wireless]
This command sets the power state to stay on under different conditions.
- USB:
adb shell svc usb [setFunctions|setScreenUnlockedFunctions|getFunctions|resetUsbGadget|getUsbSpeed|getGadgetHalVersion|getUsbHalVersion|resetUsbPort]
These commands are related to USB functionality, such as setting USB functions, getting the enabled functions, resetting the USB gadget, etc.
- Find:
find / -maxdepth 1
This command finds files with a folder depth of 1 (i.e., only in the root directory).
- tcpdump:
adb shell su -c tcpdump -nn -i wlan0 -U -s0 -w - | wireshark -k -i -
This command captures network traffic using tcpdump and sends it to Wireshark on the PC for analysis.
- telecom:
adb shell telecom [get-system-dialer|get-default-dialer|set-system-dialer|get-max-phones|set-phone-account-enabled|set-phone-account-disabled|register-phone-account
|set-user-selected-outgoing-phone-account|set-test-call-redirection-app|set-test-call-screening-app|set-phone-acct-suggestion-component|add-or-remove-call-companion-app|register-sim-phone-account|unregister-phone-account|set-call-diagnostic-service|wait-on-handlers|set-sim-count|get-sim-config|get-max-phones|stop-block-suppression|cleanup-stuck-calls|set-emer-phone-account-filter]
These commands are related to telephony functions, such as setting the system dialer, registering phone accounts, setting call diagnostic service, etc.
- uiautomator:
```bash
adb shell uiautomator dump --compressed /dev/stdout | tr ' ' '\n' | awk -F'"' '{print $2}' | grep "^[0-9]\{15\}$" | nl -w 1 -s':' | sed 's/^/IMEI/g'
This command launches the IMEI screen on the device, captures the screen using uiautomator, and parses the IMEI numbers.
- wm:
adb shell wm [size|overscan]
These commands are related to managing the window manager, such as setting screen size and overscan.
These are just brief explanations of the commands you provided. Each command serves a specific purpose related to Android system management, debugging, or customization.
Android Shell Resources
Reboot on Android
The source for how reboot works on Android is from Irfan Latif on Stack Exchange.
Cool Resources for Working with Android Shell
- Android™ Developer - Emulator Console
- Android™ Developer - Write your app
- Android™ Google Source - Source Code
- Android™ Google Source - CMD Command
- Android™ Generic Project
- Android™ GDB
- Android™ Source - Understand Logging
- Android™ Source - Network Connectivity Tests
- Android™ Platform Tools
- Github Randorise - Mobile Hacking CheatSheet
- Mazhuang - Awesome ADB - Another Cheatsheet Wiki
- Jfsso - Preferences Editor
- Nahamsec - Resources For Beginner - Bug Bounty Hunters
- Raywenderlich - Forensic Artifacts
- Noobsec - Bypass Fingerprint Lock In Just 1 Second
- Noobsec - Cara Reverse Engineering
- Oracle - JVMS
- Tjtech - Analyze OEM Unlocking Under Android
- U'Smile - How to change the IMEI on Android devices
- Android™ Q Navigation - Gesture Controls
- Good review for clipboard control
- Utilizing adb for daily tasks
For more information, please refer to the LICENSE.md file.
Greetings
To all my loyal friends who believe in me and give me this opportunity to hack so many devices, I love you! You know who you are.
Wiki Author
wuseman ([email protected])
Get in touch
If you have problems, questions, ideas, or suggestions, please contact me by posting to [email protected].