What is ADB?
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.
How to install ADB?
ADB Command
adb devices
1
2
3
$ 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-serveradb 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 logadb logcat -c: clear the log buffer in devicesadb logcat _KEYWORD*: print the KEYWORD log onlyadb logcat -f _FILENAME: cat the log to specifc fileadb logcat | grep -e <string_name>: to grep the keyword in linux bashadb logcat | select-string <string_name>: to grep the keyword in windows powershelladb logcat -v time >.\\logcat.log: to save the log with timestamp
adb logcat Debug fatal error
adb logcat *:F: Print all fatal logsadb logcat *:F <tag1>:E <tag2>: Print all fatal logs + error logs for+ all logs for
Others
adb root: run as rootadb remount: remount the devices/daemonadb shell setenforce 0: turn off selinux firewall in shell domainadb shell su 0 setenforce 0: run the setenforce in su domainadb 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 -
adb shell setprop persist.vendor.camera.MIAWBlibName ""
adb shell setprop persist.vendor.camera.offlineImageDumpOnly 1: 只有拍照时才会dump图像adb shell setprop persist.vendor.camera.rawDump 1: Dump raw图像adb shell setprop persist.vendor.camera.mfnrDump 1: Dump多帧图像