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