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