adb various commands

adb introduction:
Android Debug Bridge (Android Debug Bridge) tools. It is a command line window used to interact with the emulator or device through the computer.
ADB is a C/S architecture application program, composed of three parts:
adb client running on the PC side: the
command line program "adb" is used to run adb commands from a shell or script. First, the "adb" program tries to locate the ADB server on the host. If the ADB server cannot be found, the "adb" program automatically starts an ADB server. Next, when the adbd of the device and the adb server on the pc side are connected, the adb client can send service requests to the ADB servcer;
adb server running on the pc side:
ADB Server is a background process running on the host. Its function is to detect the connection and removal of the USB port sensing device, as well as the start or stop of the emulator instance. ADB Server also needs to send the adb client request to the corresponding adbd via usb or tcp; the routine
running on the device side Resident process adb demon (adbd): The
program "adbd" runs as a background process in the Android device or emulator system. Its function is to connect to the ADB server and provide some services for the client running on the host.

View version
adb version
Insert picture description here
query connected devices
adb devices
Insert picture description here
open adb service
adb start-server
Insert picture description here
close adb service
adb kill-server
Insert picture description here

Install apk
adb install path
uninstall
adb uninstall [packagename]
query package name
list of all applications: adb shell pm list packages
Insert picture description here

系统应用:adb shell pm list packages -s

第三方应用:adb shell pm list packages -3

Query the package name and startup item of the current application
adb shell dumpsys window w |findstr V |findstr name=
Transfer files from the mobile terminal to the computer
adb pull Mobile terminal path Computer path
Transfer computer files to the mobile terminal
adb push Computer path Mobile terminal path
View the adb command help information
adb help
screenshot
adb shell screencap -p path
log printing
adb logcat *:E>C:\log\e.texAndroid logs are divided into the following levels:
V — Verbose (lowest, most output)
D — Debug
I — Info
W — Warning
E — Error
F — Fatal
S — Silent (the highest, nothing is output)

Practical function:
save the screenshot to the computer: adb exec-out screencap -p> sc.png
and then export the png file to the computer: adb pull /sdcard/sc.png
Record screen: save the recorded screen in mp4 format to /sdcard: adb shell screenrecord /sdcard/filename.mp4 Press Ctrl-C when you need to stop, the default recording time and maximum recording time are both 180 seconds.
If you need to export to a computer: adb pull /sdcard/filename.mp4
mount, view the connected WiFi password, turn on/off WiFi, set the system date and time, all require root privileges, so I won't say more.

Use Monkey for stress testing: Monkey can generate pseudo-random user events to simulate clicks, touches, gestures and other operations, and can perform random stress tests on programs under development.
Simple usage: adb shell monkey -p <packagename> -v 500 means to send 500 pseudo-random events to the specified application.

View process: adb shell ps
view real-time resource usage: adb shell top
view process UID: adb shell dumpsys package | grep userId=

Guess you like

Origin blog.csdn.net/CHINA_2000chn/article/details/108364728