blob: 4f3e1f51b3afb7b285ffaa3d386f54b2cb5f4f4e [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Yabin Cuiaed3c612015-09-22 15:52:57 -070017#define TRACE_TAG TRANSPORT
Dan Albert33134262015-03-19 15:21:08 -070018
19#include "sysdeps.h"
20#include "transport.h"
21
Dan Albert76649012015-02-24 15:51:19 -080022#include <errno.h>
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080023#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
Dan Albert76649012015-02-24 15:51:19 -080026#include <sys/types.h>
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080027
Elliott Hughes4f713192015-12-04 22:00:26 -080028#include <android-base/stringprintf.h>
Elliott Hughes381cfa92015-07-23 17:12:58 -070029#include <cutils/sockets.h>
Elliott Hughesab52c182015-05-01 17:04:38 -070030
Dan Albert76649012015-02-24 15:51:19 -080031#if !ADB_HOST
32#include "cutils/properties.h"
33#endif
Dan Albert33134262015-03-19 15:21:08 -070034
35#include "adb.h"
36#include "adb_io.h"
Elliott Hughes381cfa92015-07-23 17:12:58 -070037#include "adb_utils.h"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080038
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080039#if ADB_HOST
Josh Gao9fe74262016-05-06 02:37:24 -070040
41// Android Wear has been using port 5601 in all of its documentation/tooling,
42// but we search for emulators on ports [5554, 5555 + ADB_LOCAL_TRANSPORT_MAX].
43// Avoid stomping on their port by limiting the number of emulators that can be
44// connected.
45#define ADB_LOCAL_TRANSPORT_MAX 16
46
47ADB_MUTEX_DEFINE(local_transports_lock);
48
Stefan Hilzingerd9d1ca42010-04-26 10:17:43 +010049/* we keep a list of opened transports. The atransport struct knows to which
50 * local transport it is connected. The list is used to detect when we're
51 * trying to connect twice to a given local transport.
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080052 */
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080053static atransport* local_transports[ ADB_LOCAL_TRANSPORT_MAX ];
54#endif /* ADB_HOST */
55
56static int remote_read(apacket *p, atransport *t)
57{
Dan Albertcc731cc2015-02-24 21:26:58 -080058 if(!ReadFdExactly(t->sfd, &p->msg, sizeof(amessage))){
Yabin Cui7a3f8d62015-09-02 17:44:28 -070059 D("remote local: read terminated (message)");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080060 return -1;
61 }
62
Tamas Berghammer3d2904c2015-07-13 19:12:28 +010063 if(check_header(p, t)) {
Yabin Cui7a3f8d62015-09-02 17:44:28 -070064 D("bad header: terminated (data)");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080065 return -1;
66 }
67
Dan Albertcc731cc2015-02-24 21:26:58 -080068 if(!ReadFdExactly(t->sfd, p->data, p->msg.data_length)){
Yabin Cui7a3f8d62015-09-02 17:44:28 -070069 D("remote local: terminated (data)");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080070 return -1;
71 }
72
73 if(check_data(p)) {
Yabin Cui7a3f8d62015-09-02 17:44:28 -070074 D("bad data: terminated (data)");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080075 return -1;
76 }
77
78 return 0;
79}
80
81static int remote_write(apacket *p, atransport *t)
82{
83 int length = p->msg.data_length;
84
Dan Albertcc731cc2015-02-24 21:26:58 -080085 if(!WriteFdExactly(t->sfd, &p->msg, sizeof(amessage) + length)) {
Yabin Cui7a3f8d62015-09-02 17:44:28 -070086 D("remote local: write terminated");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080087 return -1;
88 }
89
90 return 0;
91}
92
Elliott Hughes381cfa92015-07-23 17:12:58 -070093void local_connect(int port) {
94 std::string dummy;
95 local_connect_arbitrary_ports(port-1, port, &dummy);
Stefan Hilzingerd9d1ca42010-04-26 10:17:43 +010096}
97
Elliott Hughes381cfa92015-07-23 17:12:58 -070098int local_connect_arbitrary_ports(int console_port, int adb_port, std::string* error) {
99 int fd = -1;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800100
101#if ADB_HOST
Yabin Cui0e2c1942015-07-31 14:10:54 -0700102 if (find_emulator_transport_by_adb_port(adb_port) != nullptr) {
103 return -1;
104 }
105
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800106 const char *host = getenv("ADBHOST");
107 if (host) {
Elliott Hughes381cfa92015-07-23 17:12:58 -0700108 fd = network_connect(host, adb_port, SOCK_STREAM, 0, error);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800109 }
110#endif
111 if (fd < 0) {
Spencer Low5200c662015-07-30 23:07:55 -0700112 fd = network_loopback_client(adb_port, SOCK_STREAM, error);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800113 }
114
115 if (fd >= 0) {
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700116 D("client: connected on remote on fd %d", fd);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800117 close_on_exec(fd);
118 disable_tcp_nagle(fd);
Elliott Hughesab52c182015-05-01 17:04:38 -0700119 std::string serial = android::base::StringPrintf("emulator-%d", console_port);
Yabin Cui0e2c1942015-07-31 14:10:54 -0700120 if (register_socket_transport(fd, serial.c_str(), adb_port, 1) == 0) {
121 return 0;
122 }
123 adb_close(fd);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800124 }
125 return -1;
126}
127
Yabin Cui661327e2015-08-11 13:40:42 -0700128#if ADB_HOST
Josh Gaod9db09c2016-02-12 14:31:15 -0800129static void client_socket_thread(void* x) {
Siva Velusamy49ee7cf2015-08-28 16:37:29 -0700130 adb_thread_setname("client_socket_thread");
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700131 D("transport: client_socket_thread() starting");
Yabin Cui0e2c1942015-07-31 14:10:54 -0700132 while (true) {
133 int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT;
134 int count = ADB_LOCAL_TRANSPORT_MAX;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800135
Yabin Cui0e2c1942015-07-31 14:10:54 -0700136 // Try to connect to any number of running emulator instances.
137 for ( ; count > 0; count--, port += 2 ) {
138 local_connect(port);
139 }
140 sleep(1);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800141 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800142}
143
Yabin Cui661327e2015-08-11 13:40:42 -0700144#else // ADB_HOST
145
Josh Gaod9db09c2016-02-12 14:31:15 -0800146static void server_socket_thread(void* arg) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800147 int serverfd, fd;
Erik Kline7e16cc12015-12-01 17:27:59 +0900148 sockaddr_storage ss;
149 sockaddr *addrp = reinterpret_cast<sockaddr*>(&ss);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800150 socklen_t alen;
Elliott Hughesccecf142014-01-16 10:53:11 -0800151 int port = (int) (uintptr_t) arg;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800152
Siva Velusamy49ee7cf2015-08-28 16:37:29 -0700153 adb_thread_setname("server socket");
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700154 D("transport: server_socket_thread() starting");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800155 serverfd = -1;
156 for(;;) {
157 if(serverfd == -1) {
Spencer Low5200c662015-07-30 23:07:55 -0700158 std::string error;
159 serverfd = network_inaddr_any_server(port, SOCK_STREAM, &error);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800160 if(serverfd < 0) {
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700161 D("server: cannot bind socket yet: %s", error.c_str());
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800162 adb_sleep_ms(1000);
163 continue;
164 }
165 close_on_exec(serverfd);
166 }
167
Erik Kline7e16cc12015-12-01 17:27:59 +0900168 alen = sizeof(ss);
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700169 D("server: trying to get new connection from %d", port);
Erik Kline7e16cc12015-12-01 17:27:59 +0900170 fd = adb_socket_accept(serverfd, addrp, &alen);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800171 if(fd >= 0) {
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700172 D("server: new connection on fd %d", fd);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800173 close_on_exec(fd);
174 disable_tcp_nagle(fd);
Mike Lockwoodff196702009-08-24 15:58:40 -0700175 register_socket_transport(fd, "host", port, 1);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800176 }
177 }
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700178 D("transport: server_socket_thread() exiting");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800179}
180
Vladimir Chtchetkinec4f37ee2011-12-13 12:19:29 -0800181/* This is relevant only for ADB daemon running inside the emulator. */
Vladimir Chtchetkinec13daef2011-12-09 15:49:47 -0800182/*
183 * Redefine open and write for qemu_pipe.h that contains inlined references
184 * to those routines. We will redifine them back after qemu_pipe.h inclusion.
185 */
186#undef open
187#undef write
188#define open adb_open
189#define write adb_write
190#include <hardware/qemu_pipe.h>
191#undef open
192#undef write
193#define open ___xxx_open
194#define write ___xxx_write
195
196/* A worker thread that monitors host connections, and registers a transport for
197 * every new host connection. This thread replaces server_socket_thread on
198 * condition that adbd daemon runs inside the emulator, and emulator uses QEMUD
199 * pipe to communicate with adbd daemon inside the guest. This is done in order
200 * to provide more robust communication channel between ADB host and guest. The
201 * main issue with server_socket_thread approach is that it runs on top of TCP,
202 * and thus is sensitive to network disruptions. For instance, the
203 * ConnectionManager may decide to reset all network connections, in which case
204 * the connection between ADB host and guest will be lost. To make ADB traffic
205 * independent from the network, we use here 'adb' QEMUD service to transfer data
206 * between the host, and the guest. See external/qemu/android/adb-*.* that
207 * implements the emulator's side of the protocol. Another advantage of using
208 * QEMUD approach is that ADB will be up much sooner, since it doesn't depend
209 * anymore on network being set up.
210 * The guest side of the protocol contains the following phases:
211 * - Connect with adb QEMUD service. In this phase a handle to 'adb' QEMUD service
212 * is opened, and it becomes clear whether or not emulator supports that
213 * protocol.
214 * - Wait for the ADB host to create connection with the guest. This is done by
215 * sending an 'accept' request to the adb QEMUD service, and waiting on
216 * response.
217 * - When new ADB host connection is accepted, the connection with adb QEMUD
218 * service is registered as the transport, and a 'start' request is sent to the
219 * adb QEMUD service, indicating that the guest is ready to receive messages.
220 * Note that the guest will ignore messages sent down from the emulator before
221 * the transport registration is completed. That's why we need to send the
222 * 'start' request after the transport is registered.
223 */
Josh Gaod9db09c2016-02-12 14:31:15 -0800224static void qemu_socket_thread(void* arg) {
225 /* 'accept' request to the adb QEMUD service. */
226 static const char _accept_req[] = "accept";
227 /* 'start' request to the adb QEMUD service. */
228 static const char _start_req[] = "start";
229 /* 'ok' reply from the adb QEMUD service. */
230 static const char _ok_resp[] = "ok";
Vladimir Chtchetkinec13daef2011-12-09 15:49:47 -0800231
Elliott Hughesccecf142014-01-16 10:53:11 -0800232 const int port = (int) (uintptr_t) arg;
bohu8ac1b042016-02-29 13:13:19 -0800233 int fd;
Vladimir Chtchetkinec13daef2011-12-09 15:49:47 -0800234 char tmp[256];
235 char con_name[32];
236
Siva Velusamy49ee7cf2015-08-28 16:37:29 -0700237 adb_thread_setname("qemu socket");
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700238 D("transport: qemu_socket_thread() starting");
Vladimir Chtchetkinec13daef2011-12-09 15:49:47 -0800239
240 /* adb QEMUD service connection request. */
241 snprintf(con_name, sizeof(con_name), "qemud:adb:%d", port);
242
243 /* Connect to the adb QEMUD service. */
244 fd = qemu_pipe_open(con_name);
245 if (fd < 0) {
246 /* This could be an older version of the emulator, that doesn't
247 * implement adb QEMUD service. Fall back to the old TCP way. */
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700248 D("adb service is not available. Falling back to TCP socket.");
Elliott Hughes9b0f3542015-05-05 13:41:21 -0700249 adb_thread_create(server_socket_thread, arg);
Josh Gaod9db09c2016-02-12 14:31:15 -0800250 return;
Vladimir Chtchetkinec13daef2011-12-09 15:49:47 -0800251 }
252
253 for(;;) {
254 /*
255 * Wait till the host creates a new connection.
256 */
257
258 /* Send the 'accept' request. */
bohu8ac1b042016-02-29 13:13:19 -0800259 if (WriteFdExactly(fd, _accept_req, strlen(_accept_req))) {
Vladimir Chtchetkinec13daef2011-12-09 15:49:47 -0800260 /* Wait for the response. In the response we expect 'ok' on success,
261 * or 'ko' on failure. */
bohu8ac1b042016-02-29 13:13:19 -0800262 if (!ReadFdExactly(fd, tmp, 2) || memcmp(tmp, _ok_resp, 2)) {
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700263 D("Accepting ADB host connection has failed.");
Vladimir Chtchetkinec13daef2011-12-09 15:49:47 -0800264 adb_close(fd);
265 } else {
266 /* Host is connected. Register the transport, and start the
267 * exchange. */
Prathmesh Prabhu251d46e2016-03-09 13:51:30 -0800268 std::string serial = android::base::StringPrintf("host-%d", fd);
269 register_socket_transport(fd, serial.c_str(), port, 1);
bohu8ac1b042016-02-29 13:13:19 -0800270 if (!WriteFdExactly(fd, _start_req, strlen(_start_req))) {
271 adb_close(fd);
272 }
Vladimir Chtchetkinec13daef2011-12-09 15:49:47 -0800273 }
274
275 /* Prepare for accepting of the next ADB host connection. */
276 fd = qemu_pipe_open(con_name);
277 if (fd < 0) {
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700278 D("adb service become unavailable.");
Josh Gaod9db09c2016-02-12 14:31:15 -0800279 return;
Vladimir Chtchetkinec13daef2011-12-09 15:49:47 -0800280 }
281 } else {
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700282 D("Unable to send the '%s' request to ADB service.", _accept_req);
Josh Gaod9db09c2016-02-12 14:31:15 -0800283 return;
Vladimir Chtchetkinec13daef2011-12-09 15:49:47 -0800284 }
285 }
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700286 D("transport: qemu_socket_thread() exiting");
Josh Gaod9db09c2016-02-12 14:31:15 -0800287 return;
Vladimir Chtchetkinec13daef2011-12-09 15:49:47 -0800288}
Vladimir Chtchetkinec4f37ee2011-12-13 12:19:29 -0800289#endif // !ADB_HOST
Vladimir Chtchetkinec13daef2011-12-09 15:49:47 -0800290
Mike Lockwoodff196702009-08-24 15:58:40 -0700291void local_init(int port)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800292{
Josh Gaod9db09c2016-02-12 14:31:15 -0800293 adb_thread_func_t func;
Yabin Cui661327e2015-08-11 13:40:42 -0700294 const char* debug_name = "";
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800295
Vladimir Chtchetkinec4f37ee2011-12-13 12:19:29 -0800296#if ADB_HOST
Yabin Cui661327e2015-08-11 13:40:42 -0700297 func = client_socket_thread;
298 debug_name = "client";
Vladimir Chtchetkinec4f37ee2011-12-13 12:19:29 -0800299#else
Yabin Cui661327e2015-08-11 13:40:42 -0700300 /* For the adbd daemon in the system image we need to distinguish
301 * between the device, and the emulator. */
302 char is_qemu[PROPERTY_VALUE_MAX];
303 property_get("ro.kernel.qemu", is_qemu, "");
304 if (!strcmp(is_qemu, "1")) {
305 /* Running inside the emulator: use QEMUD pipe as the transport. */
306 func = qemu_socket_thread;
307 } else {
308 /* Running inside the device: use TCP socket as the transport. */
309 func = server_socket_thread;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800310 }
Yabin Cui661327e2015-08-11 13:40:42 -0700311 debug_name = "server";
312#endif // !ADB_HOST
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800313
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700314 D("transport: local %s init", debug_name);
Elliott Hughes9b0f3542015-05-05 13:41:21 -0700315 if (!adb_thread_create(func, (void *) (uintptr_t) port)) {
Yabin Cui661327e2015-08-11 13:40:42 -0700316 fatal_errno("cannot create local socket %s thread", debug_name);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800317 }
318}
319
320static void remote_kick(atransport *t)
321{
322 int fd = t->sfd;
323 t->sfd = -1;
Mike Lockwood8cf0d592009-10-11 23:04:18 -0400324 adb_shutdown(fd);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800325 adb_close(fd);
326
327#if ADB_HOST
Yabin Cui661327e2015-08-11 13:40:42 -0700328 int nn;
329 adb_mutex_lock( &local_transports_lock );
330 for (nn = 0; nn < ADB_LOCAL_TRANSPORT_MAX; nn++) {
331 if (local_transports[nn] == t) {
332 local_transports[nn] = NULL;
333 break;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800334 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800335 }
Yabin Cui661327e2015-08-11 13:40:42 -0700336 adb_mutex_unlock( &local_transports_lock );
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800337#endif
338}
339
340static void remote_close(atransport *t)
341{
Spencer Low3abd31d2015-06-09 12:32:17 -0700342 int fd = t->sfd;
343 if (fd != -1) {
344 t->sfd = -1;
345 adb_close(fd);
346 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800347}
348
Stefan Hilzingerd9d1ca42010-04-26 10:17:43 +0100349
350#if ADB_HOST
351/* Only call this function if you already hold local_transports_lock. */
352atransport* find_emulator_transport_by_adb_port_locked(int adb_port)
353{
354 int i;
355 for (i = 0; i < ADB_LOCAL_TRANSPORT_MAX; i++) {
356 if (local_transports[i] && local_transports[i]->adb_port == adb_port) {
357 return local_transports[i];
358 }
359 }
360 return NULL;
361}
362
363atransport* find_emulator_transport_by_adb_port(int adb_port)
364{
365 adb_mutex_lock( &local_transports_lock );
366 atransport* result = find_emulator_transport_by_adb_port_locked(adb_port);
367 adb_mutex_unlock( &local_transports_lock );
368 return result;
369}
370
371/* Only call this function if you already hold local_transports_lock. */
372int get_available_local_transport_index_locked()
373{
374 int i;
375 for (i = 0; i < ADB_LOCAL_TRANSPORT_MAX; i++) {
376 if (local_transports[i] == NULL) {
377 return i;
378 }
379 }
380 return -1;
381}
382
383int get_available_local_transport_index()
384{
385 adb_mutex_lock( &local_transports_lock );
386 int result = get_available_local_transport_index_locked();
387 adb_mutex_unlock( &local_transports_lock );
388 return result;
389}
390#endif
391
392int init_socket_transport(atransport *t, int s, int adb_port, int local)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800393{
394 int fail = 0;
395
Yabin Cuia28918c2016-04-18 11:22:34 -0700396 t->SetKickFunction(remote_kick);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800397 t->close = remote_close;
398 t->read_from_remote = remote_read;
399 t->write_to_remote = remote_write;
400 t->sfd = s;
401 t->sync_token = 1;
Dan Albertdcd78a12015-05-18 16:43:57 -0700402 t->connection_state = kCsOffline;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800403 t->type = kTransportLocal;
Stefan Hilzingerd9d1ca42010-04-26 10:17:43 +0100404 t->adb_port = 0;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800405
406#if ADB_HOST
Yabin Cui661327e2015-08-11 13:40:42 -0700407 if (local) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800408 adb_mutex_lock( &local_transports_lock );
409 {
Stefan Hilzingerd9d1ca42010-04-26 10:17:43 +0100410 t->adb_port = adb_port;
411 atransport* existing_transport =
412 find_emulator_transport_by_adb_port_locked(adb_port);
413 int index = get_available_local_transport_index_locked();
414 if (existing_transport != NULL) {
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700415 D("local transport for port %d already registered (%p)?",
Stefan Hilzingerd9d1ca42010-04-26 10:17:43 +0100416 adb_port, existing_transport);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800417 fail = -1;
Stefan Hilzingerd9d1ca42010-04-26 10:17:43 +0100418 } else if (index < 0) {
419 // Too many emulators.
Yabin Cui7a3f8d62015-09-02 17:44:28 -0700420 D("cannot register more emulators. Maximum is %d",
Stefan Hilzingerd9d1ca42010-04-26 10:17:43 +0100421 ADB_LOCAL_TRANSPORT_MAX);
422 fail = -1;
423 } else {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800424 local_transports[index] = t;
Stefan Hilzingerd9d1ca42010-04-26 10:17:43 +0100425 }
426 }
427 adb_mutex_unlock( &local_transports_lock );
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800428 }
429#endif
430 return fail;
431}