Loading adb/adb.cpp +8 −8 Original line number Diff line number Diff line Loading @@ -838,10 +838,10 @@ int handle_forward_request(const char* service, transport_type ttype, char* seri } } const char* err; transport = acquire_one_transport(CS_ANY, ttype, serial, &err); std::string error_msg; transport = acquire_one_transport(CS_ANY, ttype, serial, &error_msg); if (!transport) { sendfailmsg(reply_fd, err); sendfailmsg(reply_fd, error_msg.c_str()); return 1; } Loading Loading @@ -910,14 +910,14 @@ int handle_host_request(char *service, transport_type ttype, char* serial, int r serial = service; } const char* error_string = "unknown failure"; transport = acquire_one_transport(CS_ANY, type, serial, &error_string); std::string error_msg = "unknown failure"; transport = acquire_one_transport(CS_ANY, type, serial, &error_msg); if (transport) { s->transport = transport; adb_write(reply_fd, "OKAY", 4); } else { sendfailmsg(reply_fd, error_string); sendfailmsg(reply_fd, error_msg.c_str()); } return 1; } Loading adb/services.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -559,12 +559,12 @@ static void wait_for_state(int fd, void* cookie) D("wait_for_state %d\n", sinfo->state); const char* err = "unknown error"; atransport *t = acquire_one_transport(sinfo->state, sinfo->transport, sinfo->serial, &err); std::string error_msg = "unknown error"; atransport* t = acquire_one_transport(sinfo->state, sinfo->transport, sinfo->serial, &error_msg); if (t != 0) { WriteFdExactly(fd, "OKAY", 4); } else { sendfailmsg(fd, err); sendfailmsg(fd, error_msg.c_str()); } if (sinfo->serial) Loading adb/sockets.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -827,12 +827,11 @@ static int smart_socket_enqueue(asocket *s, apacket *p) } #else /* !ADB_HOST */ if (s->transport == NULL) { const char* error_string = "unknown failure"; s->transport = acquire_one_transport (CS_ANY, kTransportAny, NULL, &error_string); std::string error_msg = "unknown failure"; s->transport = acquire_one_transport(CS_ANY, kTransportAny, NULL, &error_msg); if (s->transport == NULL) { sendfailmsg(s->peer->fd, error_string); sendfailmsg(s->peer->fd, error_msg.c_str()); goto fail; } } Loading adb/transport.cpp +22 −24 Original line number Diff line number Diff line Loading @@ -801,21 +801,19 @@ static int qual_match(const char *to_test, } atransport* acquire_one_transport(int state, transport_type ttype, const char* serial, const char** error_out) const char* serial, std::string* error_out) { atransport *t; atransport *result = NULL; int ambiguous = 0; retry: if (error_out) *error_out = "device not found"; if (error_out) *error_out = "device not found"; adb_mutex_lock(&transport_lock); for (t = transport_list.next; t != &transport_list; t = t->next) { if (t->connection_state == CS_NOPERM) { if (error_out) *error_out = "insufficient permissions for device"; if (error_out) *error_out = "insufficient permissions for device"; continue; } Loading @@ -827,8 +825,7 @@ retry: qual_match(serial, "model:", t->model, true) || qual_match(serial, "device:", t->device, false)) { if (result) { if (error_out) *error_out = "more than one device"; if (error_out) *error_out = "more than one device"; ambiguous = 1; result = NULL; break; Loading @@ -838,8 +835,7 @@ retry: } else { if (ttype == kTransportUsb && t->type == kTransportUsb) { if (result) { if (error_out) *error_out = "more than one device"; if (error_out) *error_out = "more than one device"; ambiguous = 1; result = NULL; break; Loading @@ -847,8 +843,7 @@ retry: result = t; } else if (ttype == kTransportLocal && t->type == kTransportLocal) { if (result) { if (error_out) *error_out = "more than one emulator"; if (error_out) *error_out = "more than one emulator"; ambiguous = 1; result = NULL; break; Loading @@ -856,8 +851,7 @@ retry: result = t; } else if (ttype == kTransportAny) { if (result) { if (error_out) *error_out = "more than one device and emulator"; if (error_out) *error_out = "more than one device and emulator"; ambiguous = 1; result = NULL; break; Loading @@ -870,29 +864,33 @@ retry: if (result) { if (result->connection_state == CS_UNAUTHORIZED) { if (error_out) *error_out = "device unauthorized. Please check the confirmation dialog on your device."; if (error_out) { *error_out = "device unauthorized.\n"; char* ADB_VENDOR_KEYS = getenv("ADB_VENDOR_KEYS"); *error_out += "This adbd's $ADB_VENDOR_KEYS is "; *error_out += ADB_VENDOR_KEYS ? ADB_VENDOR_KEYS : "not set"; *error_out += "; try 'adb kill-server' if that seems wrong.\n"; *error_out += "Otherwise check for a confirmation dialog on your device."; } result = NULL; } /* offline devices are ignored -- they are either being born or dying */ if (result && result->connection_state == CS_OFFLINE) { if (error_out) *error_out = "device offline"; if (error_out) *error_out = "device offline"; result = NULL; } /* check for required connection state */ if (result && state != CS_ANY && result->connection_state != state) { if (error_out) *error_out = "invalid device state"; if (error_out) *error_out = "invalid device state"; result = NULL; } } if (result) { /* found one that we can take */ if (error_out) *error_out = NULL; if (error_out) *error_out = "success"; } else if (state != CS_ANY && (serial || !ambiguous)) { adb_sleep_ms(1000); goto retry; Loading adb/transport.h +3 −10 Original line number Diff line number Diff line Loading @@ -17,14 +17,11 @@ #ifndef __TRANSPORT_H #define __TRANSPORT_H #include <stdbool.h> #include <sys/types.h> #include "adb.h" #include <string> #ifdef __cplusplus extern "C" { #endif #include "adb.h" #if ADB_TRACE void dump_hex(const unsigned char* ptr, size_t len); Loading @@ -37,7 +34,7 @@ void dump_hex(const unsigned char* ptr, size_t len); * If no suitable transport is found, error is set. */ atransport* acquire_one_transport(int state, transport_type ttype, const char* serial, const char** error_out); const char* serial, std::string* error_out); void add_transport_disconnect(atransport* t, adisconnect* dis); void remove_transport_disconnect(atransport* t, adisconnect* dis); void kick_transport(atransport* t); Loading Loading @@ -74,8 +71,4 @@ void send_packet(apacket* p, atransport* t); asocket* create_device_tracker(void); #ifdef __cplusplus } #endif #endif /* __TRANSPORT_H */ Loading
adb/adb.cpp +8 −8 Original line number Diff line number Diff line Loading @@ -838,10 +838,10 @@ int handle_forward_request(const char* service, transport_type ttype, char* seri } } const char* err; transport = acquire_one_transport(CS_ANY, ttype, serial, &err); std::string error_msg; transport = acquire_one_transport(CS_ANY, ttype, serial, &error_msg); if (!transport) { sendfailmsg(reply_fd, err); sendfailmsg(reply_fd, error_msg.c_str()); return 1; } Loading Loading @@ -910,14 +910,14 @@ int handle_host_request(char *service, transport_type ttype, char* serial, int r serial = service; } const char* error_string = "unknown failure"; transport = acquire_one_transport(CS_ANY, type, serial, &error_string); std::string error_msg = "unknown failure"; transport = acquire_one_transport(CS_ANY, type, serial, &error_msg); if (transport) { s->transport = transport; adb_write(reply_fd, "OKAY", 4); } else { sendfailmsg(reply_fd, error_string); sendfailmsg(reply_fd, error_msg.c_str()); } return 1; } Loading
adb/services.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -559,12 +559,12 @@ static void wait_for_state(int fd, void* cookie) D("wait_for_state %d\n", sinfo->state); const char* err = "unknown error"; atransport *t = acquire_one_transport(sinfo->state, sinfo->transport, sinfo->serial, &err); std::string error_msg = "unknown error"; atransport* t = acquire_one_transport(sinfo->state, sinfo->transport, sinfo->serial, &error_msg); if (t != 0) { WriteFdExactly(fd, "OKAY", 4); } else { sendfailmsg(fd, err); sendfailmsg(fd, error_msg.c_str()); } if (sinfo->serial) Loading
adb/sockets.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -827,12 +827,11 @@ static int smart_socket_enqueue(asocket *s, apacket *p) } #else /* !ADB_HOST */ if (s->transport == NULL) { const char* error_string = "unknown failure"; s->transport = acquire_one_transport (CS_ANY, kTransportAny, NULL, &error_string); std::string error_msg = "unknown failure"; s->transport = acquire_one_transport(CS_ANY, kTransportAny, NULL, &error_msg); if (s->transport == NULL) { sendfailmsg(s->peer->fd, error_string); sendfailmsg(s->peer->fd, error_msg.c_str()); goto fail; } } Loading
adb/transport.cpp +22 −24 Original line number Diff line number Diff line Loading @@ -801,21 +801,19 @@ static int qual_match(const char *to_test, } atransport* acquire_one_transport(int state, transport_type ttype, const char* serial, const char** error_out) const char* serial, std::string* error_out) { atransport *t; atransport *result = NULL; int ambiguous = 0; retry: if (error_out) *error_out = "device not found"; if (error_out) *error_out = "device not found"; adb_mutex_lock(&transport_lock); for (t = transport_list.next; t != &transport_list; t = t->next) { if (t->connection_state == CS_NOPERM) { if (error_out) *error_out = "insufficient permissions for device"; if (error_out) *error_out = "insufficient permissions for device"; continue; } Loading @@ -827,8 +825,7 @@ retry: qual_match(serial, "model:", t->model, true) || qual_match(serial, "device:", t->device, false)) { if (result) { if (error_out) *error_out = "more than one device"; if (error_out) *error_out = "more than one device"; ambiguous = 1; result = NULL; break; Loading @@ -838,8 +835,7 @@ retry: } else { if (ttype == kTransportUsb && t->type == kTransportUsb) { if (result) { if (error_out) *error_out = "more than one device"; if (error_out) *error_out = "more than one device"; ambiguous = 1; result = NULL; break; Loading @@ -847,8 +843,7 @@ retry: result = t; } else if (ttype == kTransportLocal && t->type == kTransportLocal) { if (result) { if (error_out) *error_out = "more than one emulator"; if (error_out) *error_out = "more than one emulator"; ambiguous = 1; result = NULL; break; Loading @@ -856,8 +851,7 @@ retry: result = t; } else if (ttype == kTransportAny) { if (result) { if (error_out) *error_out = "more than one device and emulator"; if (error_out) *error_out = "more than one device and emulator"; ambiguous = 1; result = NULL; break; Loading @@ -870,29 +864,33 @@ retry: if (result) { if (result->connection_state == CS_UNAUTHORIZED) { if (error_out) *error_out = "device unauthorized. Please check the confirmation dialog on your device."; if (error_out) { *error_out = "device unauthorized.\n"; char* ADB_VENDOR_KEYS = getenv("ADB_VENDOR_KEYS"); *error_out += "This adbd's $ADB_VENDOR_KEYS is "; *error_out += ADB_VENDOR_KEYS ? ADB_VENDOR_KEYS : "not set"; *error_out += "; try 'adb kill-server' if that seems wrong.\n"; *error_out += "Otherwise check for a confirmation dialog on your device."; } result = NULL; } /* offline devices are ignored -- they are either being born or dying */ if (result && result->connection_state == CS_OFFLINE) { if (error_out) *error_out = "device offline"; if (error_out) *error_out = "device offline"; result = NULL; } /* check for required connection state */ if (result && state != CS_ANY && result->connection_state != state) { if (error_out) *error_out = "invalid device state"; if (error_out) *error_out = "invalid device state"; result = NULL; } } if (result) { /* found one that we can take */ if (error_out) *error_out = NULL; if (error_out) *error_out = "success"; } else if (state != CS_ANY && (serial || !ambiguous)) { adb_sleep_ms(1000); goto retry; Loading
adb/transport.h +3 −10 Original line number Diff line number Diff line Loading @@ -17,14 +17,11 @@ #ifndef __TRANSPORT_H #define __TRANSPORT_H #include <stdbool.h> #include <sys/types.h> #include "adb.h" #include <string> #ifdef __cplusplus extern "C" { #endif #include "adb.h" #if ADB_TRACE void dump_hex(const unsigned char* ptr, size_t len); Loading @@ -37,7 +34,7 @@ void dump_hex(const unsigned char* ptr, size_t len); * If no suitable transport is found, error is set. */ atransport* acquire_one_transport(int state, transport_type ttype, const char* serial, const char** error_out); const char* serial, std::string* error_out); void add_transport_disconnect(atransport* t, adisconnect* dis); void remove_transport_disconnect(atransport* t, adisconnect* dis); void kick_transport(atransport* t); Loading Loading @@ -74,8 +71,4 @@ void send_packet(apacket* p, atransport* t); asocket* create_device_tracker(void); #ifdef __cplusplus } #endif #endif /* __TRANSPORT_H */