ADB tools
-
- Introduction to ADB
- Environment configuration
- Common commands
-
- 1. Log in to the device
- 2. Get root privileges
- 3. View connected devices
- 4. Send files from PC to device
- 5. Pull files from the device to the PC
- 6. View third-party applications
- 7. Get the application version number
- 8. List system applications
- 9. View cpu architecture information and GPU information
- 10. Check the operating system of the device
- 11. View memory information
- 12. getprop command
- 13. View log
- 14. Check the kernel version
- 15. Settings command in adb shell
- 16. Grab the kernel log
- 17. Enter fastboot mode
- 18 Install and uninstall apps
- 19. dumpsys command
- 20. View Android system version and api
- 21. View the application name and package name of the currently launched APP
- 22. Screenshot
- 23. Kill the process
- 24. adb simulated key event
- 25. Start the process
- 26. View application version
- 27. Send Broadcast
- Adb network connection equipment method
- Use busybox
- execute binary file in adb
Introduction to ADB
In order to debug and operate the Android device through the shell , you need the ADB tool (Android Debug Bridge) as a bridge to connect the Android device and the PC.
Environment configuration
Install the ADB software on the PC. After the installation is complete, set the path of the adb main program to the environment variable to facilitate the direct use of the adb command in cmd ; set the Android device to be connected to be in developer mode.
Common commands
1. Log in to the device
adb shell
adb -s device name shell
2. Get root privileges
Sometimes you need root
permission to operate the Android system, such as when using the chmod command. Use the adb shell
command to connect to the Android device and execute the following commands in order to obtain root
permission.
adb root
adb disable-verity
adb reboot
adb root
adb remount
- It should be noted that the
user
version of the Android system cannot obtainroot
permission!
3. View connected devices
adb devices
4. Send files from PC to device
adb push local file path remote file path
5. Pull files from the device to the PC
adb pull remote file path local file path
6. View third-party applications
adb shell pm list packages -3
7. Get the application version number
adb shell pm dump com.android.dialer | findstr “versionName”
- Need to know the package name of the application
8. List system applications
adb shell pm list packages -s
9. View cpu architecture information and GPU information
adb shell cat /proc/cpuinfo
adb shell dumpsys | findstr GLES // Get GPU information
10. Check the operating system of the device
adb shell uname
-r View the version of the
operating system -m View the number of bits of the operating system
11. View memory information
dumpsys meminfo
12. getprop command
ro.product.model------equipment model
ro.product.brand------equipment brand
ro.product.name------equipment name
13. View log
adb shell logcat
14. Check the kernel version
adb shell cat proc/version
15. Settings command in adb shell
View screen standby time:
settings get system screen_off_timeout
View wifi switch status:
settings get global wifi_on
current backlight brightness:
settings get system screen_brightness
16. Grab the kernel log
adb shell dmesg> /data/local/tmp/dmesg.txt
or:
cat proc/kmsg
17. Enter fastboot mode
adb reboot bootloader //You
can use the following methods to burn afterwards:
fastboot flash partition name burn file name
18 Install and uninstall apps
adb install the path of the apk in the computer//install the apk in the computer to the phone
Sometimes there will be a Read-only error, we can use the mandatory installation command to install the apk
adb install -r the path of the apk in the computer
// For some apk only used for testing, you need to use the -t option
View installed applications
adb shell pm list packages
Uninstall application
adb uninstall apk full package name
Whether it is installed or uninstalled, it will eventually display the Success
-t parameter for the test package
First: adb shell pm list packages -s find the package name
to be deleted. Get the address of the package name: adb shell pm path com.xx.xx.
Mount the system read and write permissions: adb remount
delete the package: adb shell rm /system/app/ OldDriver/OldDriver.apk and
finally adb reboot will be OK
19. dumpsys command
adb shell dumpsys package com.examle.xx
// versionName in the output information is the application version number
adb shell dumpsys power
// view the number of WakeLock locks, etc.
20. View Android system version and api
Get the system version: adb shell getprop ro.build.version.release
Get the system api version: adb shell getprop ro.build.version.sdk
You can also view the configuration file: cat system/build.prop
21. View the application name and package name of the currently launched APP
dumpsys window -w | grep "name="
For example, the following result:
mSurface=Surface(name=com.xxx.elauncher/com.xxx.elauncher.activity.MainActivity)/@0xcc80e9b
22. Screenshot
adb shell screencap -p /sdcard/01.png
// Capture the current screen
23. Kill the process
Know the process number: adb shell kill pid
adb shell am force-stop package name
24. adb simulated key event
This command is equivalent to pressing the device's Backkey key
adb shell input keyevent 4
to unlock the screen
adb shell input keyevent 82
25. Start the process
For example, start the calculator
adb shell am start -n com.android.calculator2/com.android.calculator2.Calculator
26. View application version
adb shell dumpsys com.seewo.elauncher | findstr version
27. Send Broadcast
adb shell am broadcast -a com.XXXX
Adb network connection equipment method
- method one
- To download the "Wireless ADB" tool on the Android device, root permissions are required
- Method Two
- No root permission required
- Turn on the developer mode on the phone, and then turn on USB debugging
- Use USB data cable to connect mobile phone and computer
- Open the cmd command window on the PC and enter adb devices, you can see the connected devices
- Enter adb tcpip 8888 (set the port number to 8888)
- Disconnect the phone and computer
- Enter adb connect device IP address: 8888, the connection is successful
Use busybox
In order to use Linux commands on the adb shell side, you can install the busybox
tool to the Android system; go to the official website to download the compiled busybox tool, push to the Android side, enter the corresponding directory of the shell and execute the following command
chmod 775 busybox-armv8l
./busybox-armv8l --install
execute binary file in adb
Need to copy the bin file to the ##/data/local/tmp## directory, modify the file permissions: chmod 777