Android ADB和相关命令原理和使用.ppt
Android ADB and related Commands
Jacky Cai – 2017/12/27
adb Overview
Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate with a device. The adb command facilitates a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device. It is a client-server program that includes three components:
A client (adb) - which sends commands. The client runs on your development machine. You can invoke a client from a command-line terminal by issuing an adb command.
A daemon (adbd) - which runs commands on a device. The daemon runs as a background process on each device.
A server (adb) - which manages communication between the client and the daemon. The server runs as a background process on your development machine.
How adb work?
Above figure is adb server startup process. Adb server locates emulators by scanning odd-numbered ports in the range 5555 to 5585. each emulator uses a pair of sequential ports, an even-numbered port for console connections and an odd-numbered port for adb connections. For example: console: 5554, adb: 5555
Enable adb on device
To use adb with a device connected over USB, you must enable USB debugging in the device system settings, under Developer options.
On Android 4.2 and higher, the Developer options screen is hidden by default. To make it visible, go to Settings > About phone and tap Build number 7 times and then return to the previous screen to find Developer options at the bottom.
You can now connect your device with USB. You can verify that your device is connected by executing adb devices -l. If connected, you'll see the device name listed as a "device."
In response, adb prints following status information for each device:
Serial number: A string created by adb to uniquely identify the device by its port number. E.g. emulator-5554
State: The connection state of the device can be one of the following:
Offline - The