ADB is very powerful, remember some ADB commands can help improve work efficiency.
-
Get the serial number:
adb get-serialno
-
View the device that connects the computer:
adb devices
-
Restart the machine:
adb reboot
-
Restart to bootloader, brush mode:
adb reboot bootloader
-
Restart to recovery, i.e. recovery mode:
adb reboot recovery
-
View log:
adb logcat
-
Terminate the adb service process:
adb kill-server
-
Restart the adb service process:
adb start-server
-
Get the MAC address of the machine:
adb shell cat /sys/class/net/wlan0/address
-
Get the CPU serial number:
adb shell cat /proc/cpuinfo
-
Install APK:
adb install <apkfile> //For example: adb install baidu.apk
-
Reserve data and cache files and reinstall apk:
adb install -r <apkfile> //For example: adb install -r baidu.apk
-
Install apk to sd card:
adb install -s <apkfile> // For example: adb install -s baidu.apk
-
Unload APK:
adb uninstall <package> //For example: adb uninstall com.baidu.search
-
Unload app but keep data and cached files:
adb uninstall -k <package> //For example: ADB uninstall-k com.baidu.search
-
Start the application:
adb shell am start -n <package_name>/.<activity_class_name>
-
Check device cpu and memory usage:
adb shell top
-
View app s that occupy the first 6 memory:
adb shell top -m 6
-
Refresh the memory information once, and then return:
adb shell top -n 1
-
Query the memory usage of each process:
adb shell procrank
-
Kill a process:
adb shell kill [pid]
-
View the process list:
adb shell ps
-
View the specified process status:
adb shell ps -x [PID]
-
View background services information:
adb shell service list
-
View the current memory footprint:
adb shell cat /proc/meminfo
-
View IO memory partitions:
adb shell cat /proc/iomem
-
Remount the system partition as a read-write partition:
adb remount
-
From local copy files to devices:
adb push <local> <remote>
-
Copy files from device to local:
adb pull <remote> <local>
-
List the files and folders in the directory, which is equivalent to the dir command in dos:
adb shell ls
-
Entering a folder is equivalent to the cd command in dos:
adb shell cd <folder>
-
Rename the file:
adb shell rename path/oldfilename path/newfilename
-
Delete system/avi.apk:
adb shell rm /system/avi.apk
-
Delete folders and all files below them:
adb shell rm -r <folder>
-
Mobile files:
adb shell mv path/file newpath/file
-
Set file permissions:
adb shell chmod 777 /system/fonts/DroidSansFallback.ttf
-
New folder:
adb shell mkdir path/foldelname
-
View the file contents:
adb shell cat <file>
-
Check the wifi password:
adb shell cat /data/misc/wifi/*.conf
-
Clear log cache:
adb logcat -c
-
View bug reports:
adb bugreport
-
Get device name:
adb shell cat /system/build.prop
-
See ADB Help:
adb help
-
Running monkey:
adb shell monkey -v -p your.package.name 500
Usually we can get the setprop settings from the command getprop; before using these two commands, we first look at what's in build.prop.
adb shell cat /system/build.prop
The results are as follows: (Listed only in part)
ro.build.id=KOT49H ro.build.display.id=KOT49H.20140814 test-keys ro.build.version.incremental=20140814 ro.build.version.sdk=19 ro.build.version.codename=REL ro.build.version.release=4.4.2 ro.build.date=2014-08-14 16:50:37 ro.product.model=K1 ro.product.brand=MBX ro.product.name=K1 ro.product.device=K1 ro.product.board=K1 ro.product.cpu.abi=armeabi-v7a ro.product.cpu.abi2=armeabi ro.product.manufacturer=MBX ro.product.locale.language=zh
Obviously, the data stored in this file is stored in this form of equal sign, and they appear in pairs of key values.
Now let's look at the results of getprop: (List only a few)
[ro.build.characteristics]: [mbx] [ro.build.date.utc]: [1407987033] [ro.build.date]: [2014-08-14 16:50:37] [ro.build.description]: [k200-user 4.4.2 KOT49H 20140814 test-keys] [ro.build.display.id]: [KOT49H.20140814 test-keys] [ro.build.id]: [KOT49H] [ro.build.product]: [K1] [ro.build.version.codename]: [REL] [ro.build.version.incremental]: [20140814] [ro.build.version.release]: [4.4.2] [ro.product.board]: [K1] [ro.product.brand]: [MBX] [ro.product.cpu.abi2]: [armeabi] [ro.product.cpu.abi]: [armeabi-v7a [ro.product.device]: [K1] [ro.product.locale.language]: [zh] [ro.product.locale.region]: [cn] [ro.product.model]: [K1] [ro.product.name]: [K1]
Therefore, getprop is to read out the information in the configuration file and display it to the user in the form of a dictionary.
Its format is as follows:
getprop [key] Gets the attribute value of the corresponding key
getprop lists all configuration property values
If you want to modify attributes, it's very simple. You just need to modify dictionary values, such as:
setprop [key] [value] sets the attribute value of the specified key;
watchprops monitors changes in system attributes and displays the changed values if the attributes of the system change during the period.
In fact, these three commands are all subcommands of toolbox. If you are interested, you can see the corresponding source code in the android source code: system/core/toolbox./
getprop looks at all the information parameters of the machine
getprop ro.serialno looks at the serial number of the machine
getprop ro.carrier to view the CID number of the machine
getprop ro.hardware view machine board code
getprop ro.bootloader view SPL(Hboot) version number