summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYabin Cui2015-08-11 15:40:42 -0500
committerYabin Cui2015-08-11 16:00:15 -0500
commit661327e8e40f95076e0e8abe86193da16b061bd8 (patch)
tree5aba1378141ee7d0ece252ac23af2dc16d6f06f5
parentf71590ffbc5b611a7c45fcddc7db3c1915fe3cd5 (diff)
downloadplatform-system-core-661327e8e40f95076e0e8abe86193da16b061bd8.tar.gz
platform-system-core-661327e8e40f95076e0e8abe86193da16b061bd8.tar.xz
platform-system-core-661327e8e40f95076e0e8abe86193da16b061bd8.zip
Remove confusing variable HOST.
First, HOST is always 0 in adbd, which matches ADB_HOST=0. Second, HOST is always 1 when adb_main is called, which matches ADB_HOST=1. For adb client that doesn't call adb_main, it never touches local_init(), init_transport_registration() and fdevent_loop(). So the changes in adb.cpp, services.cpp and transport_local.cpp do nothing with it. As a conclusion, I think we can remove HOST and use ADB_HOST instead. Change-Id: Ide0e0eca7468b6c3c130f6b50974406280678b2e
-rw-r--r--adb/adb.cpp14
-rw-r--r--adb/adb.h1
-rw-r--r--adb/client/main.cpp2
-rw-r--r--adb/services.cpp4
-rw-r--r--adb/transport_local.cpp61
-rw-r--r--adb/transport_usb.cpp6
6 files changed, 39 insertions, 49 deletions
diff --git a/adb/adb.cpp b/adb/adb.cpp
index 821b785df..1f538c090 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -55,8 +55,6 @@
55 55
56ADB_MUTEX_DEFINE(D_lock); 56ADB_MUTEX_DEFINE(D_lock);
57 57
58int HOST = 0;
59
60#if !ADB_HOST 58#if !ADB_HOST
61const char* adb_device_banner = "device"; 59const char* adb_device_banner = "device";
62static android::base::LogdLogger gLogdLogger; 60static android::base::LogdLogger gLogdLogger;
@@ -416,7 +414,9 @@ void handle_packet(apacket *p, atransport *t)
416 case A_SYNC: 414 case A_SYNC:
417 if(p->msg.arg0){ 415 if(p->msg.arg0){
418 send_packet(p, t); 416 send_packet(p, t);
419 if(HOST) send_connect(t); 417#if ADB_HOST
418 send_connect(t);
419#endif
420 } else { 420 } else {
421 t->connection_state = kCsOffline; 421 t->connection_state = kCsOffline;
422 handle_offline(t); 422 handle_offline(t);
@@ -433,12 +433,16 @@ void handle_packet(apacket *p, atransport *t)
433 t->update_version(p->msg.arg0, p->msg.arg1); 433 t->update_version(p->msg.arg0, p->msg.arg1);
434 parse_banner(reinterpret_cast<const char*>(p->data), t); 434 parse_banner(reinterpret_cast<const char*>(p->data), t);
435 435
436 if (HOST || !auth_required) { 436#if ADB_HOST
437 handle_online(t);
438#else
439 if (!auth_required) {
437 handle_online(t); 440 handle_online(t);
438 if (!HOST) send_connect(t); 441 send_connect(t);
439 } else { 442 } else {
440 send_auth_request(t); 443 send_auth_request(t);
441 } 444 }
445#endif
442 break; 446 break;
443 447
444 case A_AUTH: 448 case A_AUTH:
diff --git a/adb/adb.h b/adb/adb.h
index b0e53f026..906ec2cf6 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -379,7 +379,6 @@ int adb_commandline(int argc, const char **argv);
379ConnectionState connection_state(atransport *t); 379ConnectionState connection_state(atransport *t);
380 380
381extern const char *adb_device_banner; 381extern const char *adb_device_banner;
382extern int HOST;
383#if !ADB_HOST 382#if !ADB_HOST
384extern int SHELL_EXIT_NOTIFY_FD; 383extern int SHELL_EXIT_NOTIFY_FD;
385#endif // !ADB_HOST 384#endif // !ADB_HOST
diff --git a/adb/client/main.cpp b/adb/client/main.cpp
index 73acbb0b8..60b487c64 100644
--- a/adb/client/main.cpp
+++ b/adb/client/main.cpp
@@ -133,8 +133,6 @@ static void setup_daemon_logging(void) {
133} 133}
134 134
135int adb_main(int is_daemon, int server_port, int ack_reply_fd) { 135int adb_main(int is_daemon, int server_port, int ack_reply_fd) {
136 HOST = 1;
137
138#if defined(_WIN32) 136#if defined(_WIN32)
139 SetConsoleCtrlHandler(ctrlc_handler, TRUE); 137 SetConsoleCtrlHandler(ctrlc_handler, TRUE);
140#else 138#else
diff --git a/adb/services.cpp b/adb/services.cpp
index 63a0a76fe..68545d8bd 100644
--- a/adb/services.cpp
+++ b/adb/services.cpp
@@ -465,9 +465,9 @@ int service_to_fd(const char *name)
465 ret = create_service_thread(framebuffer_service, 0); 465 ret = create_service_thread(framebuffer_service, 0);
466 } else if (!strncmp(name, "jdwp:", 5)) { 466 } else if (!strncmp(name, "jdwp:", 5)) {
467 ret = create_jdwp_connection_fd(atoi(name+5)); 467 ret = create_jdwp_connection_fd(atoi(name+5));
468 } else if(!HOST && !strncmp(name, "shell:", 6)) { 468 } else if(!strncmp(name, "shell:", 6)) {
469 ret = create_subproc_thread(name + 6, true); 469 ret = create_subproc_thread(name + 6, true);
470 } else if(!HOST && !strncmp(name, "exec:", 5)) { 470 } else if(!strncmp(name, "exec:", 5)) {
471 ret = create_subproc_thread(name + 5); 471 ret = create_subproc_thread(name + 5);
472 } else if(!strncmp(name, "sync:", 5)) { 472 } else if(!strncmp(name, "sync:", 5)) {
473 ret = create_service_thread(file_sync_service, NULL); 473 ret = create_service_thread(file_sync_service, NULL);
diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp
index 650e5eab9..6a174973a 100644
--- a/adb/transport_local.cpp
+++ b/adb/transport_local.cpp
@@ -120,10 +120,9 @@ int local_connect_arbitrary_ports(int console_port, int adb_port, std::string* e
120 return -1; 120 return -1;
121} 121}
122 122
123 123#if ADB_HOST
124static void *client_socket_thread(void *x) 124static void *client_socket_thread(void *x)
125{ 125{
126#if ADB_HOST
127 D("transport: client_socket_thread() starting\n"); 126 D("transport: client_socket_thread() starting\n");
128 while (true) { 127 while (true) {
129 int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT; 128 int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT;
@@ -135,10 +134,11 @@ static void *client_socket_thread(void *x)
135 } 134 }
136 sleep(1); 135 sleep(1);
137 } 136 }
138#endif
139 return 0; 137 return 0;
140} 138}
141 139
140#else // ADB_HOST
141
142static void *server_socket_thread(void * arg) 142static void *server_socket_thread(void * arg)
143{ 143{
144 int serverfd, fd; 144 int serverfd, fd;
@@ -175,7 +175,6 @@ static void *server_socket_thread(void * arg)
175} 175}
176 176
177/* This is relevant only for ADB daemon running inside the emulator. */ 177/* This is relevant only for ADB daemon running inside the emulator. */
178#if !ADB_HOST
179/* 178/*
180 * Redefine open and write for qemu_pipe.h that contains inlined references 179 * Redefine open and write for qemu_pipe.h that contains inlined references
181 * to those routines. We will redifine them back after qemu_pipe.h inclusion. 180 * to those routines. We will redifine them back after qemu_pipe.h inclusion.
@@ -287,31 +286,29 @@ static const char _ok_resp[] = "ok";
287void local_init(int port) 286void local_init(int port)
288{ 287{
289 void* (*func)(void *); 288 void* (*func)(void *);
289 const char* debug_name = "";
290 290
291 if(HOST) {
292 func = client_socket_thread;
293 } else {
294#if ADB_HOST 291#if ADB_HOST
295 func = server_socket_thread; 292 func = client_socket_thread;
293 debug_name = "client";
296#else 294#else
297 /* For the adbd daemon in the system image we need to distinguish 295 /* For the adbd daemon in the system image we need to distinguish
298 * between the device, and the emulator. */ 296 * between the device, and the emulator. */
299 char is_qemu[PROPERTY_VALUE_MAX]; 297 char is_qemu[PROPERTY_VALUE_MAX];
300 property_get("ro.kernel.qemu", is_qemu, ""); 298 property_get("ro.kernel.qemu", is_qemu, "");
301 if (!strcmp(is_qemu, "1")) { 299 if (!strcmp(is_qemu, "1")) {
302 /* Running inside the emulator: use QEMUD pipe as the transport. */ 300 /* Running inside the emulator: use QEMUD pipe as the transport. */
303 func = qemu_socket_thread; 301 func = qemu_socket_thread;
304 } else { 302 } else {
305 /* Running inside the device: use TCP socket as the transport. */ 303 /* Running inside the device: use TCP socket as the transport. */
306 func = server_socket_thread; 304 func = server_socket_thread;
307 }
308#endif // !ADB_HOST
309 } 305 }
306 debug_name = "server";
307#endif // !ADB_HOST
310 308
311 D("transport: local %s init\n", HOST ? "client" : "server"); 309 D("transport: local %s init\n", debug_name);
312
313 if (!adb_thread_create(func, (void *) (uintptr_t) port)) { 310 if (!adb_thread_create(func, (void *) (uintptr_t) port)) {
314 fatal_errno("cannot create local socket %s thread", HOST ? "client" : "server"); 311 fatal_errno("cannot create local socket %s thread", debug_name);
315 } 312 }
316} 313}
317 314
@@ -323,17 +320,15 @@ static void remote_kick(atransport *t)
323 adb_close(fd); 320 adb_close(fd);
324 321
325#if ADB_HOST 322#if ADB_HOST
326 if(HOST) { 323 int nn;
327 int nn; 324 adb_mutex_lock( &local_transports_lock );
328 adb_mutex_lock( &local_transports_lock ); 325 for (nn = 0; nn < ADB_LOCAL_TRANSPORT_MAX; nn++) {
329 for (nn = 0; nn < ADB_LOCAL_TRANSPORT_MAX; nn++) { 326 if (local_transports[nn] == t) {
330 if (local_transports[nn] == t) { 327 local_transports[nn] = NULL;
331 local_transports[nn] = NULL; 328 break;
332 break;
333 }
334 } 329 }
335 adb_mutex_unlock( &local_transports_lock );
336 } 330 }
331 adb_mutex_unlock( &local_transports_lock );
337#endif 332#endif
338} 333}
339 334
@@ -404,7 +399,7 @@ int init_socket_transport(atransport *t, int s, int adb_port, int local)
404 t->adb_port = 0; 399 t->adb_port = 0;
405 400
406#if ADB_HOST 401#if ADB_HOST
407 if (HOST && local) { 402 if (local) {
408 adb_mutex_lock( &local_transports_lock ); 403 adb_mutex_lock( &local_transports_lock );
409 { 404 {
410 t->adb_port = adb_port; 405 t->adb_port = adb_port;
diff --git a/adb/transport_usb.cpp b/adb/transport_usb.cpp
index 2c975a9a7..96ccdad23 100644
--- a/adb/transport_usb.cpp
+++ b/adb/transport_usb.cpp
@@ -91,12 +91,6 @@ void init_usb_transport(atransport *t, usb_handle *h, ConnectionState state)
91 t->connection_state = state; 91 t->connection_state = state;
92 t->type = kTransportUsb; 92 t->type = kTransportUsb;
93 t->usb = h; 93 t->usb = h;
94
95#if ADB_HOST
96 HOST = 1;
97#else
98 HOST = 0;
99#endif
100} 94}
101 95
102#if ADB_HOST 96#if ADB_HOST