Skip to content

Commit

Permalink
Updating adb documentation with minor word-smithing.
Browse files Browse the repository at this point in the history
Bug: 202323776
Test: Not applicable.

Signed-off-by: Shaju Mathew <[email protected]>
Change-Id: I1bec5a7635395aeb70da96ba0efffbf64d941ee5
  • Loading branch information
shaju-mv committed Oct 8, 2021
1 parent f2d06db commit 2e19bd1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions OVERVIEW.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ As a whole, everything works through the following components:
Host Services:
These services run within the ADB Server and thus do not need to
communicate with a device at all. A typical example is "adb devices"
which is used to return the list of currently known devices and their
states. They are a few other services though.
that is used to return the list of currently known devices and their
states. There are a few other services, though.

Local Services:
These services either run within the adbd daemon, or are started by
Expand All @@ -77,7 +77,7 @@ II. Protocol details:

1. Client <-> Server protocol:

This details the protocol used between ADB clients and the ADB
This section details the protocol used between ADB clients and the ADB
server itself. The ADB server listens on TCP:localhost:5037.

A client sends a request using the following format:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ The Client and the Server are contained in the same executable and both run on t

A smart socket is a simple TCP socket with a smart protocol built on top of it. This is what Clients connect onto from the Host side. The Client must always initiate communication via a human readable request but the response format varies. The smart protocol is documented in [SERVICES.TXT](SERVICES.TXT).

On the other side, the Server communicate with a device via a Transport. adb initially targeted devices connecting over USB, which is restricted to a fixed number of data streams. Therefore, adb multiplexes multiple byte streams over a single pipe via Transport. When devices connecting over other mechanisms (e.g. emulators over TCP) were introduced, the existing transport protocol was maintained.
On the other side, the Server communicates with a device via a Transport. adb initially targeted devices connecting over USB, which is restricted to a fixed number of data streams. Therefore, adb multiplexes multiple byte streams over a single pipe via Transport. When devices connecting over other mechanisms (e.g. emulators over TCP) were introduced, the existing transport protocol was maintained.

## THREADING MODEL and FDEVENT system

At the heart of both the Server and Daemon is a main thread running an fdevent loop, which is an platform-independent abstraction over poll/epoll/WSAPoll monitoring file descriptors events. Requests and services are usually server from the main thread but some service requests result in new threads being spawned.
At the heart of both the Server and Daemon is a main thread running an fdevent loop, which is a platform-independent abstraction over poll/epoll/WSAPoll monitoring file descriptors events. Requests and services are usually served from the main thread but some service requests result in new threads being spawned.

To allow for operations to run on the Main thread, fdevent features a RunQueue combined with an interrupt fd to force polling to return.

Expand All @@ -61,7 +61,7 @@ To allow for operations to run on the Main thread, fdevent features a RunQueue c

The asocket, apacket, and amessage constructs exist only to wrap data while it transits on a Transport. An asocket handles a stream of apackets. An apacket consists in a amessage header featuring a command (`A_SYNC`, `A_OPEN`, `A_CLSE`, `A_WRTE`, `A_OKAY`, ...) followed by a payload (find more documentation in [protocol.txt](protocol.txt). There is no `A_READ` command because an asocket is unidirectional. To model a bi-directional stream, asocket have a peer which go in the opposite direction.

An asocket features a buffer where the elemental unit is an apacket. Is traffic is inbound, the buffer stores apacket until they are consumed. If the traffic is oubound, the buffer store apackets until they are sent down the wire (with `A_WRTE` commands).
An asocket features a buffer where the elemental unit is an apacket. If traffic is inbound, the buffer stores the apacket until it is consumed. If the traffic is oubound, the buffer stores apackets until they are sent down the wire (with `A_WRTE` commands).

```
+---------------------ASocket------------------------+
Expand Down
16 changes: 8 additions & 8 deletions SYNC.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ SERVICES.TXT sets the connection in sync mode. This mode is a binary mode that
differs from the regular adb protocol. The connection stays in sync mode until
explicitly terminated (see below).

After the initial "sync:" command is sent the server must respond with either
"OKAY" or "FAIL" as per usual.
After the initial "sync:" command is sent, the server must respond with either
"OKAY" or "FAIL" as per the usual protocol.

In sync mode both the server and the client will frequently use eight-byte
packets to communicate. In this document these are called sync requests and sync
responses. The first four bytes are an id that specifies the sync request. It is
represented by four utf-8 characters. The last four bytes are a Little-Endian
integer, with various uses. This number will be called "length" below. In fact
all binary integers are Little-Endian in the sync mode. Sync mode is
implicitly exited after each sync request, and normal adb communication
follows as described in SERVICES.TXT.
responses. The first four bytes constitute an id that specifies the sync request.
It is represented by four ASCII bytes in order to make them more human-readable
when debugging. The last four bytes are a Little-Endian integer, with various
uses. This number shall be called "length" below. In fact, all binary integers
are Little-Endian in the sync mode. Sync mode is implicitly exited after each
sync request, and normal adb communication follows as described in SERVICES.TXT.

The following sync requests are accepted:
LIST - List the files in a folder
Expand Down

0 comments on commit 2e19bd1

Please sign in to comment.