Table of contents
1. Commonly used simple adb commands:
Second, adb shell pm basic commands:
3. The basic commands of adb shell am:
4. Close a certain process, take monkey as an example:
5. Resource situation in the last 12 hours:
9. Information about obtaining the current page:
10. Generate the xml text of the current page:
11. Print the log information of the page:
12. System Operation Instructions
Thirteen, more reference to the following blog
1. Commonly used simple adb commands:
1. adb devices: Get the list of devices and the status of the device
2. adb get-state: Get the status of the device (there are three types of device status: device, the device is connected normally; offline, the connection is abnormal, and the device does not respond; unknown, the device is not Connect;)
3. adb kill-server, adb start-server: end, start the adb service
4. adb install -r: overwrite the installation application (apk)
5. adb uninstall: uninstall the application (application package name)
6. adb pull: Copy the files on the device to the computer
7. adb push: copy the files on the computer to the device
8. adb reboot: restart the device
9. adb connect: connect the device remotely
10. adb disconnect: disconnect the device
Second, adb shell pm basic commands:
1. List the apps installed on the device
# adb shell pm list package -s lists system applications
# adb shell pm list package -3 lists third-party applications
# adb shell pm list package -i lists sources
# adb shell pm list package -f lists package names and paths
2. List the location of the application apk
# adb shell pm path packagename List the location of the application apk
3. List the detailed information of the application
# adb shell pm dump packagename List application-related information
4. Clear application cache data
# adb shell pm clear packagename Clear application cache data
5. Install and uninstall mobile application:
First push the test.apk file to the phone directory such as /data/local/tmp
# adb shell pm install /data/local/tmp/test.apk installation
# adb shell pm install –r /data/local/tmp/test. Reinstall apk
# adb shell pm uninstall -k packagename Uninstall, add k to keep cached data
# adb shell pm install -d apk Allow downgrade installation
3. The basic commands of adb shell am:
1. Start an Activity:
# adb shell am start -n activityname Start an Activity
2. Wait for the page startup to complete:
# adb shell am start -W activityname Wait for the page startup to complete
3. Stop the application before starting:
# adb shell am start -S activityname Stop the application first and then start it
4. End the application:
# am force-stop packagename end application
1. Monitoring application data:
# adb shell dumpsys cpuinfo cpu information
# adb shell dumpsys meminfo memory information
# adb shell dumpsys power power supply information
# adb shell dumpsys battery battery information
# adb shell dumpsys wifi wifi information
# adb shell dumpsys notification notification information
# adb shell dumpsys activity Get page information
4. Close a certain process, take monkey as an example:
Kill the monkey process:
# ps | grep monkey View the pid of the monkey process
# kill pid kill the monkey process
5. Resource situation in the last 12 hours:
# dumpsys procstats --hours 12 Resource status in the last 12 hours
6. Record screen command:
# adb shell screenrecord /sdcard/demo.mp4 Video recording command
Optional parameters:
1. Limit recording time:
parameter: --time-limit
2. Specify the video resolution size:
parameter: --size
3. Specify the bit rate of the video:
parameter: --bit-rate
4. Display log on the command line:
parameter: --verbose
7. Screenshot command:
# adb shell screencap -p /sdcard/screen.png Take a screenshot and save it to the specified location
Eight, input command:
adb shell input:
<optional parameter>
#text input text
#keyevent input event
#tap click
#swipe swipe <coordinates> <coordinates are in place, long press>
9. Information about obtaining the current page:
# adb shell dumpsys activity top | findstr ACTIVITY Get the activity of the current interface
# adb shell dumpsys activity | findstr mFocusedActivity Get the activity of the current page
10. Generate the xml text of the current page:
# adb shell uiautomator dump [file] Get the xml information of the current page
Text content displayed in the text control
class Control type
package package name
content-desc Description
checkable check
checked check status
clickable click
enabled control status
focusable whether to allow acquisition Focused
Whether to get the focus
scrollable Whether to allow scrolling
long-clickable Whether to allow Chang'an
password Whether it is a password control
Selected select state
bounds The length, width and position drawn by the control are divided into two groups, which are the upper left coordinates and the lower right coordinates
11. Print the log information of the page:
# logcat -s ActivityManager print page log information
12. System Operation Instructions
adb shell getprop ro.product.model Get device model
adb shell getprop ro.build.version.release Get the Android system version of the device
adb get-serialno Get the serial number (device number) of the device
adb shell wm size Get device screen resolution
adb shell dumpsys activity |find "mFocusedActivity" View the package name of the foreground application, applicable to Android 7.0 and below, the app must be started first
adb shell dumpsys activity |find "mResumedActivity" View the foreground application package name, applicable to Android 8.0 and above, the app must be started first
Thirteen, more reference to the following blog
Detailed Explanation and Usage of ADB Operation Commands - Lucas__liu's Blog - CSDN Blog