Android adb debugging principle - yellowcong

AndroidDebug Bridge is generally referred to as adb, it is a very powerful command line tool, through the adb tool, you can communicate with your android device. adb is a program based on C/S mode, including the following three components: 1. adb client (running on the mobile phone); 2. adb server (running on the pc); 3. adb daemon (running on the mobile phone, this is Component to run the command). The port range of the connection is 5555-5585. For each adb connection, two ports will be opened. Such a mobile phone can only establish 16 connections. But that's far enough.

Structure diagram

write picture description here

adb client

The client runs on the PC side, this component sends commands, and the client can be invoked from the command line terminal by issuing the adb command. Whenever we issue an adb command, a client program is started. Of course, when we turn on DDMS or ADT, the client will also be created automatically. When we start a client, it will first detect whether there is a server program running in the background, otherwise it will start an adb-server process. All clients communicate with adb-server through port 5037.

adb daemon (adbd daemon)

Daemon, this component runs as a background process in the emulator/real Android device, running commands on the device. The range of ports used by the daemon is 5554-5585. When each simulator/device is connected to the PC, such a background process will always be started and assigned two consecutive ports, for example:

Emulator1, console: 5554

Emulator1, adb: 5555

Because each device is divided into a group of two ports, the maximum number of adb connected phones is 16.
The role of the port. Among these two ports, the even-numbered ports are used for the server to interact with the device, allowing the server to read data directly from the device, while the odd-numbered ports are used to communicate with the adbd of the device.

adb server

Server, this component manages the communication between the client and the background program, running on the PC side as a background program. When a server is started, it will automatically bind and listen to port 5037, and receive commands sent by the client through this port. At the same time, the server will also scan the odd-numbered ports between 5555 and 5585 to locate the connected devices.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325119751&siteId=291194637