those things about adb

Foreword:

Write an article to briefly talk about adb.

text:

1. About adb.

adb, that is, Android Debug Bridge, that is, Android Debug Bridge.

adb is a C/S command line tool. It mainly consists of 3 parts:

  1. Client running on the PC side: Android applications can be installed, uninstalled and debugged through it. For example, adb.exe in AndroidStudio.
  2. Service running on the PC side: it manages the connection between the client and the adb background process on the Android device. After the adb service starts, Windows can find the adb.exe process in the task manager.
  3. The adb background process running on Android devices.

The default port number used by adb is: 5037. We can view the port number of adb through the adb command adb nodemon server.

Second, the adb command. Regarding adb commands, we can divide them into adb commands and adb shell commands.

adb command:

1. Obtain the device list and device status:

adb devices

2. Obtain the device status:

adb get-state (this can only be used when there is only one device currently)

3. Print the Android system log:

adb logcat >d:\test\logcat.log

4. Print the output of dumpsys, dumpstate, and logcat, which is also used to analyze the error output into the text:

adb bugreport >d:\test\bugreport.log

5. Use the adb command to view/display the application log directly on the terminal (console)

adb logcat AppLog:I *:S

Display all logs in the application whose log label is AppLog and whose log level is not lower than I on the terminal.

6. Install the application:

adb install apk full path

7. Uninstall the application:

adb uninstall application package name

8. Restart the Android device:

adb reboot

9. Perform adb debugging through tcpip:

adb connect ip:port

Disconnect:

adb disconnect

Let a port of the device be in the listening state:

adb tcpip port (you must first connect the device with a USB data cable)

......

adb shell command:

1. View the currently running Activity:

adb shell logcat | findstr ActivityManager

2. View all applications:

adb shell pm -l

3. View memory information:

adb shell dumpsys meminfo application package name

4. Press the main screen button to return to the desktop (return to the desktop)

adb shell input keyevent 3

5. Return to the previous interface (simulate the physical return key)

adb shell input keyevent 4

6. Kill the process

(1) Stop the APP process and clear all the data generated by the APP process, which is equivalent to reset

adb shell pm clear package

After executing the command, the output success means that the command is executed successfully, the app process is killed, and all

Data, which is equivalent to the effect of uninstalling and reinstalling, is generally not recommended.

(2) Forcibly stopping the APP process will not clear the data generated by the APP process in the system

adb shell am force-stop package

After executing this command, there is no output, and the corresponding process of the mobile phone has been killed.

7. View process

adb shell ps|findstr package

8. Hide virtual keys only

adb shell settings put global policy_control immersive.navigation=*

9. Restore virtual keys

adb shell settings put global policy_control null

10. Check the cpu processor architecture

adb shell getprop ro.product.cpu.abi

11. View the build.prop file of the system (the build.prop file contains a series of information such as the device model)

adb shell

After entering the shell, enter cat /system/build.prop

12. Exit the adb shell

exit

13. Transfer the files on the computer to the mobile phone through the adb shell

adb push the directory of the file on the computer the directory on the mobile phone

比如 adb push C:\Users\dell\Desktop\data /storage/emulated/0/xxx/xxx_xxxxxx/

14. Locate the directory and view the directory

adb shell

After entering the shell, enter the cd directory

For example cd /storage/emulated/0

cd xxx/xxx_xxxxxx/

Then enter ls (ls is used to print out the list of the current directory)

15. Display the full path of the current working directory

adb shell

After entering the shell, enter pwd

16. Copy the files on the phone to the computer

adb pull directory on the phone directory on the computer

17. Take a screenshot and export it to the computer

Screenshot: adb shell screencap /sdcard/1.png (Note: You need to ensure that you have write permission to the folder before executing this command)

Export: adb pull directory on the device directory on the computer (for example: adb pull /sdcard/1.png E:\charts)

18. Delete files

adb shell rm /sdcard/1.png (delete the file named 1.png in the root directory of sdcard)

adb shell rm /sdcard/*.png (delete all files with the suffix .png in the root directory of the sdcard)

19. View the package name and Activity of the currently running application

adb shell dumpsys window w |findstr \/ |findstr name=

20. View the width and height of the device

adb shell wm size

21. Check the window of the device to display relevant information

adb shell dumpsys window displays

22. View device cpu information

First enter the adb shell,

Then execute cat /proc/cpuinfo

23. View detailed memory information

First enter the adb shell,

Then execute cat /proc/meminfo

24. View folder size

First enter the adb shell, and go to the corresponding folder,

Then execute du -sh

Among them, -s the parameter means to display the total size, and -h the parameter means to display the size in human-readable form.

25. View the number of files

First enter the adb shell,

Then execute adb shell ls -l /path/directory | wc -l

/path/directory is the path to the folder to view.

This command displays the number of files contained in the current directory.

......

Guess you like

Origin blog.csdn.net/zdj_Develop/article/details/122400720
Recommended