blob: fba3c82b3ebaaf7900a74ae2dafcb78849d093a0 [file] [log] [blame]
Vladimir Chtchetkined86c7242011-12-09 15:45:46 -08001ADB COMMUNICATION OVER QEMUD SERVICE
2
3I. Overview:
4------------
5
6In certain cases ADB communication over TCP port forwarding might be unreliable.
7For instance, connection manager in the guest system may decide to reset all
8network connections, in which case connection between the ADB host, and ADB
9daemon running in the guest will be broken, and will not be reestablish until ADB
10host is killed, and then restarted. To address this issue ADB communication has
11been moved to use QEMUD pipe to transfer data between the emulator, and the
12ADB daemon running in the guest.
13
14
15II. Implementation:
16-------------------
17
18There are two major components implemented in the emulator to support ADB
19communication over QEMUD pipe:
20
211. ADB server.
222. ADB QEMUD service (or ADB client).
23
24ADB server is implemented as a socket server that is bound to the ADB port (which
25is the 'base port' + 1), and is responsible for accepting connections coming from
26the ADB host, and associatiating accepted connections with an ADB client.
27
28ADB client is implemented as QEMUD service (named 'adb'), and is responsible for
29accepting connections coming from the ADB daemon running in the guest, and
30associating accepted connections with ADB server.
31
32Essentially, ADB server, and ADB client serve as a bridge between ADB running on
33the host, and ADB running on the guest: ADB server receives data from ADB host,
34and channels them through ADB client to the ADB guest. Likewise, ADB client
35receives data from the ADB guest, and channels them through ADB server to the ADB
36host. The only tricky part here is establishing the connection. Once connection
37is established, everything is straight forward.
38
39II.III Establishing the connection:
40-----------------------------------
41
42The connection between ADB host and ADB guest is considered to be established,
43when there is an association between ADB socket connection in the ADB server, and
44QEMUD pipe connection in the ADB client, and ADB guest is ready to receive data
45from the ADB host.
46
47Since there is no particular order, in which ADB server, and ADB client
48connections are made, ADB server runs a list of pending host and guest
49connections. Every time either connection is made, that connection goes into a
50pending list on condition that there is no pending connection on the other side.
51If, however, there is already a pending connection from the other side, that
52pending connection is removed from the pending list, and gets associated with the
53new connection.