Android Device Commands
Android Device Commands
Device Commands
Android ADB Device commands are commands that you can use to control the Android device over USB from a computer. You can use them to list all devices, restart server and reboot!
-
adb devices
- List all connected devices.adb devices -l
- Query additional information from devices.adb get-state
- Information on the device state.adb get-serialno
- Query the device serial number.
-
adb root
- Launch module adbd with root permission.- Error 1:
adbd cannot run as root in production builds
- Resolution:
- Error 1:
-
adb start-server
- Start the adb server. -
adb kill-server
- Terminate the adb server. -
adb reboot
- Restart the current device. -
adb help
- Display additional information.
Shell
Warning: Shell commands can brick your operating system, so make sure to double check them before running.
ADB shell is a command-line interface that you can use to access the shell and run various commands on your Android device. You can use ADB shell commands to perform actions such as changing the resolution of your device display, uninstalling bloatware or system apps, enabling and disabling features, modifying the system files, ect..
Remember to keep a backup of the commands that you run via shell, I recommend creating a
log.txt
file and output all the commands to that file.
adb shell
- Launch the shell terminal for the device.adb -s $deviceString $deviceCommand
- Send the $deviceCommand to a specific device named $deviceStringadb shell pwd
- Command to list current directory.adb shell ls
- Command to list all the directory contents of the device.adb shell ls -s
- Additional size information.adb shell ls -R
- Recursion of the folders.
adb shell netstat
- Query the TCP informationadb shell dumpsys
- An android tool that dumps information related to system services.adb shell dumpsys iphonesybinfo
- Query the IMEI information.adb shell dumpsys battery
- Query battery information.adb shell dumpsys battery set level $v
- Device battery level from 0 to 100.adb shell dumpsys battery reset
- Reset the device battery.
adb shell dumpsys activity $package
- Query activity of package.
adb shell pm list features
- Query device features.adb shell service list
- Query device services.adb shell wm
- ◈Nulladb shell wm size
- Current device screen resolution.adb shell wm size $WxH
- Change device screen resolution.adb shell wm size reset
- Reset device screen resolution.
adb shell wm density
- ◈Nulladb shell wm density reset
- Reset device density.
adb shell ps
- Query process status on the device.exit
- To exit ADB.
Key Events
Android Key Events - A quick breakdown for each event and how the operating system handles them.
Generic Android Keyevents:
-
adb shell input keyevent
adb shell input keyevent 0
- Keycode 0adb shell input keyevent 1
- Soft Leftadb shell input keyevent 2
- Soft Rightadb shell input keyevent 3
- Home Button Event.adb shell input keyevent 4
- Back Button Event.adb shell input keyevent 5
- Call Event.adb shell input keyevent 6
- End Call / Hangup Event.- Events 7 to 18 are generic cell phone events.
adb shell input keyevent 7
- Keycode 0adb shell input keyevent 8
- Keycode 1 aka Number 1adb shell input keyevent 9
- Keycode 2 aka Number 2adb shell input keyevent 10
- Keycode 3 aka Number 3adb shell input keyevent 11
- Keycode 4 aka Number 4adb shell input keyevent 12
- Keycode 5 aka Number 5adb shell input keyevent 13
- Keycode 6 aka Number 6adb shell input keyevent 14
- Keycode 7 aka Number 7adb shell input keyevent 15
- Keycode 8 aka Number 8adb shell input keyevent 16
- Keycode 9 aka Number 9adb shell input keyevent 17
- STAR Keyadb shell input keyevent 18
- Pound Key
-
Koltin:
open class KeyEvent: InputEvent, Parcelable
-
Java:
pulibc class KeyEvent extends InputEvent implements Parcelable