blob: d9aa09c38636551a5f8881df898e5704c3431345 [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001This file tries to document all requests a client can make
2to the ADB server of an adbd daemon. See the OVERVIEW.TXT document
3to understand what's going on here.
4
5HOST SERVICES:
6
7host:version
8 Ask the ADB server for its internal version number.
9
10 As a special exception, the server will respond with a 4-byte
11 hex string corresponding to its internal version number, without
12 any OKAY or FAIL.
13
14host:kill
15 Ask the ADB server to quit immediately. This is used when the
16 ADB client detects that an obsolete server is running after an
17 upgrade.
18
19host:devices
Scott Andersone109d262012-04-20 11:21:14 -070020host:devices-l
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080021 Ask to return the list of available Android devices and their
Scott Andersone109d262012-04-20 11:21:14 -070022 state. devices-l includes the device paths in the state.
23 After the OKAY, this is followed by a 4-byte hex len,
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080024 and a string that will be dumped as-is by the client, then
25 the connection is closed
26
27host:track-devices
28 This is a variant of host:devices which doesn't close the
29 connection. Instead, a new device list description is sent
30 each time a device is added/removed or the state of a given
31 device changes (hex4 + content). This allows tools like DDMS
32 to track the state of connected devices in real-time without
33 polling the server repeatedly.
34
35host:emulator:<port>
36 This is a special query that is sent to the ADB server when a
37 new emulator starts up. <port> is a decimal number corresponding
38 to the emulator's ADB control port, i.e. the TCP port that the
39 emulator will forward automatically to the adbd daemon running
40 in the emulator system.
41
42 This mechanism allows the ADB server to know when new emulator
43 instances start.
44
45host:transport:<serial-number>
46 Ask to switch the connection to the device/emulator identified by
47 <serial-number>. After the OKAY response, every client request will
48 be sent directly to the adbd daemon running on the device.
49 (Used to implement the -s option)
50
51host:transport-usb
52 Ask to switch the connection to one device connected through USB
53 to the host machine. This will fail if there are more than one such
54 devices. (Used to implement the -d convenience option)
55
56host:transport-local
57 Ask to switch the connection to one emulator connected through TCP.
58 This will fail if there is more than one such emulator instance
59 running. (Used to implement the -e convenience option)
60
61host:transport-any
62 Another host:transport variant. Ask to switch the connection to
63 either the device or emulator connect to/running on the host.
64 Will fail if there is more than one such device/emulator available.
65 (Used when neither -s, -d or -e are provided)
66
67host-serial:<serial-number>:<request>
68 This is a special form of query, where the 'host-serial:<serial-number>:'
69 prefix can be used to indicate that the client is asking the ADB server
70 for information related to a specific device. <request> can be in one
71 of the format described below.
72
73host-usb:<request>
74 A variant of host-serial used to target the single USB device connected
75 to the host. This will fail if there is none or more than one.
76
77host-local:<request>
78 A variant of host-serial used to target the single emulator instance
Brian Carlstrom23d2df52010-04-26 09:33:47 -070079 running on the host. This will fail if there is none or more than one.
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080080
81host:<request>
82 When asking for information related to a device, 'host:' can also be
83 interpreted as 'any single device or emulator connected to/running on
84 the host'.
85
86<host-prefix>:get-product
87 XXX
88
89<host-prefix>:get-serialno
90 Returns the serial number of the corresponding device/emulator.
91 Note that emulator serial numbers are of the form "emulator-5554"
92
Scott Andersone109d262012-04-20 11:21:14 -070093<host-prefix>:get-devpath
94 Returns the device path of the corresponding device/emulator.
95
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080096<host-prefix>:get-state
97 Returns the state of a given device as a string.
98
99<host-prefix>:forward:<local>;<remote>
100 Asks the ADB server to forward local connections from <local>
101 to the <remote> address on a given device.
102
103 There, <host-prefix> can be one of the
104 host-serial/host-usb/host-local/host prefixes as described previously
105 and indicates which device/emulator to target.
106
107 the format of <local> is one of:
108
109 tcp:<port> -> TCP connection on localhost:<port>
110 local:<path> -> Unix local domain socket on <path>
111
112 the format of <remote> is one of:
113
114 tcp:<port> -> TCP localhost:<port> on device
115 local:<path> -> Unix local domain socket on device
116 jdwp:<pid> -> JDWP thread on VM process <pid>
117
118 or even any one of the local services described below.
119
120
121
122LOCAL SERVICES:
123
124All the queries below assumed that you already switched the transport
125to a real device, or that you have used a query prefix as described
126above.
127
128shell:command arg1 arg2 ...
129 Run 'command arg1 arg2 ...' in a shell on the device, and return
130 its output and error streams. Note that arguments must be separated
131 by spaces. If an argument contains a space, it must be quoted with
132 double-quotes. Arguments cannot contain double quotes or things
133 will go very wrong.
134
135 Note that this is the non-interactive version of "adb shell"
136
137shell:
138 Start an interactive shell session on the device. Redirect
139 stdin/stdout/stderr as appropriate. Note that the ADB server uses
140 this to implement "adb shell", but will also cook the input before
141 sending it to the device (see interactive_shell() in commandline.c)
142
143remount:
144 Ask adbd to remount the device's filesystem in read-write mode,
145 instead of read-only. This is usually necessary before performing
146 an "adb sync" or "adb push" request.
147
148 This request may not succeed on certain builds which do not allow
149 that.
150
151dev:<path>
152 Opens a device file and connects the client directly to it for
153 read/write purposes. Useful for debugging, but may require special
Brian Carlstrom23d2df52010-04-26 09:33:47 -0700154 privileges and thus may not run on all devices. <path> is a full
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800155 path from the root of the filesystem.
156
157tcp:<port>
158 Tries to connect to tcp port <port> on localhost.
159
160tcp:<port>:<server-name>
161 Tries to connect to tcp port <port> on machine <server-name> from
162 the device. This can be useful to debug some networking/proxy
163 issues that can only be revealed on the device itself.
164
165local:<path>
166 Tries to connect to a Unix domain socket <path> on the device
167
168localreserved:<path>
169localabstract:<path>
170localfilesystem:<path>
171 Variants of local:<path> that are used to access other Android
172 socket namespaces.
173
174log:<name>
175 Opens one of the system logs (/dev/log/<name>) and allows the client
176 to read them directly. Used to implement 'adb logcat'. The stream
177 will be read-only for the client.
178
179framebuffer:
180 This service is used to send snapshots of the framebuffer to a client.
Brian Carlstrom23d2df52010-04-26 09:33:47 -0700181 It requires sufficient privileges but works as follow:
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800182
183 After the OKAY, the service sends 16-byte binary structure
184 containing the following fields (little-endian format):
185
186 depth: uint32_t: framebuffer depth
187 size: uint32_t: framebuffer size in bytes
188 width: uint32_t: framebuffer width in pixels
189 height: uint32_t: framebuffer height in pixels
190
191 With the current implementation, depth is always 16, and
192 size is always width*height*2
193
194 Then, each time the client wants a snapshot, it should send
195 one byte through the channel, which will trigger the service
196 to send it 'size' bytes of framebuffer data.
197
Brian Carlstrom23d2df52010-04-26 09:33:47 -0700198 If the adbd daemon doesn't have sufficient privileges to open
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800199 the framebuffer device, the connection is simply closed immediately.
200
201dns:<server-name>
202 This service is an exception because it only runs within the ADB server.
203 It is used to implement USB networking, i.e. to provide a network connection
204 to the device through the host machine (note: this is the exact opposite of
Brian Carlstrom23d2df52010-04-26 09:33:47 -0700205 network tethering).
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800206
207 It is used to perform a gethostbyname(<address>) on the host and return
208 the corresponding IP address as a 4-byte string.
209
210recover:<size>
211 This service is used to upload a recovery image to the device. <size>
212 must be a number corresponding to the size of the file. The service works
213 by:
214
215 - creating a file named /tmp/update
216 - reading 'size' bytes from the client and writing them to /tmp/update
Brian Carlstrom23d2df52010-04-26 09:33:47 -0700217 - when everything is read successfully, create a file named /tmp/update.start
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800218
219 This service can only work when the device is in recovery mode. Otherwise,
220 the /tmp directory doesn't exist and the connection will be closed immediately.
221
222jdwp:<pid>
223 Connects to the JDWP thread running in the VM of process <pid>.
224
225track-jdwp
226 This is used to send the list of JDWP pids periodically to the client.
227 The format of the returned data is the following:
228
229 <hex4>: the length of all content as a 4-char hexadecimal string
230 <content>: a series of ASCII lines of the following format:
231 <pid> "\n"
232
233 This service is used by DDMS to know which debuggable processes are running
234 on the device/emulator.
235
236 Note that there is no single-shot service to retrieve the list only once.
237
238sync:
239 This starts the file synchronisation service, used to implement "adb push"
240 and "adb pull". Since this service is pretty complex, it will be detailed
241 in a companion document named SYNC.TXT