ADB is a client-server program, and there are three components that make up the entire process. ADB stands for “Android Debug Bridge,” and it is a command line tool that is used to communicate with a smartphone, tablet, smartwatch, set-top box, or any other device that can run the Android operating system (even an emulator).
Client, the computer you have connected to your Android device.
Daemon (also known as adbd), and this is a service that is currently running on both the computer as well as the Android device and allows the latter to accept and execute commands.
Server, a piece of software that actually manages the communication between the client and the daemon. It’s the server that is running as a background process on your computer that sends those command to the daemon.
$ adb devices
List of devices attached
DU2SSE1467010378 device
adb shell
1
2
3
4
5
6
7
8
// use adb shell to interact with devices(Daemon)
$ adb shell
kona:/ #
// use `exit` to go back the client
$ adb shell
kona:/ # exit
$
adb install/uninstall
1
2
3
4
5
6
7
8
9
// assign the path of apk file when installing
$ adb install ~/Downloads/mobileqq_android.apk
[100%] /data/local/tmp/mobileqq_android.apk
pkg: /data/local/tmp/mobileqq_android.apk
Success
// assign the name of apk package when uninstalling
$ adb uninstall com.tencent.mobileqq
Success
adb shell dumpsys
Dump the system info from devices/daemon, could get following info by using ‘adb shell dumpsys xxx’
activiy: application info
alarm: alarm info
cpuinfo: cpu usage info
meminfo: memory usage info
diskstats: stats of disk usage
window: current window info
package: package info
adb start/kill server
Restart the server
adb kill-server
adb start-server
adb pull/push
1
2
3
4
5
6
7
// push the _file(local) to device path
$ adb push ~/tester /data/local/tmp/
[100%] /data/local/tmp/tester
// pull the file(devices) to local path
$ adb pull /data/local/tmp/tester ~/
[100%] /data/local/tmp/tester
adb logcat
adb logcat: print the log
adb logcat -c: clear the log buffer in devices
adb logcat _KEYWORD*: print the KEYWORD log only
adb logcat -f _FILENAME: cat the log to specifc file
adb logcat | grep -e <string_name>: to grep the keyword in linux bash
adb logcat | select-string <string_name>: to grep the keyword in windows powershell
adb logcat -v time >.\\logcat.log: to save the log with timestamp
adb logcat Debug fatal error
adb logcat *:F: Print all fatal logs
adb logcat *:F <tag1>:E <tag2>: Print all fatal logs + error logs for + all logs for
Others
adb root: run as root
adb remount: remount the devices/daemon
adb shell setenforce 0: turn off selinux firewall in shell domain
adb shell su 0 setenforce 0: run the setenforce in su domain
adb shell getenforce: get the status of SELinux firewall
where does image saves
default android raw image: /data/vendor/camera
default android jpeg /sdcard/DCIM/Camera
setproperty, 每次都需要额外运行adb root
adb shell getprop, 获取本地设定
adb shell getprop | select-string "xxx", output the specific item