Loading adb/adb.cpp +36 −27 Original line number Diff line number Diff line Loading @@ -253,6 +253,19 @@ void send_connect(atransport* t) { send_packet(cp, t); } #if ADB_HOST void SendConnectOnHost(atransport* t) { // Send an empty message before A_CNXN message. This is because the data toggle of the ep_out on // host and ep_in on device may not be the same. apacket* p = get_apacket(); CHECK(p); send_packet(p, t); send_connect(t); } #endif // qual_overwrite is used to overwrite a qualifier string. dst is a // pointer to a char pointer. It is assumed that if *dst is non-NULL, it // was malloc'ed and needs to freed. *dst will be set to a dup of src. Loading Loading @@ -299,29 +312,29 @@ void parse_banner(const std::string& banner, atransport* t) { const std::string& type = pieces[0]; if (type == "bootloader") { D("setting connection_state to kCsBootloader"); t->connection_state = kCsBootloader; t->SetConnectionState(kCsBootloader); update_transports(); } else if (type == "device") { D("setting connection_state to kCsDevice"); t->connection_state = kCsDevice; t->SetConnectionState(kCsDevice); update_transports(); } else if (type == "recovery") { D("setting connection_state to kCsRecovery"); t->connection_state = kCsRecovery; t->SetConnectionState(kCsRecovery); update_transports(); } else if (type == "sideload") { D("setting connection_state to kCsSideload"); t->connection_state = kCsSideload; t->SetConnectionState(kCsSideload); update_transports(); } else { D("setting connection_state to kCsHost"); t->connection_state = kCsHost; t->SetConnectionState(kCsHost); } } static void handle_new_connection(atransport* t, apacket* p) { if (t->connection_state != kCsOffline) { t->connection_state = kCsOffline; if (t->GetConnectionState() != kCsOffline) { t->SetConnectionState(kCsOffline); handle_offline(t); } Loading Loading @@ -355,10 +368,10 @@ void handle_packet(apacket *p, atransport *t) if (p->msg.arg0){ send_packet(p, t); #if ADB_HOST send_connect(t); SendConnectOnHost(t); #endif } else { t->connection_state = kCsOffline; t->SetConnectionState(kCsOffline); handle_offline(t); send_packet(p, t); } Loading @@ -372,7 +385,9 @@ void handle_packet(apacket *p, atransport *t) switch (p->msg.arg0) { #if ADB_HOST case ADB_AUTH_TOKEN: t->connection_state = kCsUnauthorized; if (t->GetConnectionState() == kCsOffline) { t->SetConnectionState(kCsUnauthorized); } send_auth_response(p->data, p->msg.data_length, t); break; #else Loading @@ -391,7 +406,7 @@ void handle_packet(apacket *p, atransport *t) break; #endif default: t->connection_state = kCsOffline; t->SetConnectionState(kCsOffline); handle_offline(t); break; } Loading Loading @@ -1032,7 +1047,6 @@ static int SendOkay(int fd, const std::string& s) { SendProtocolString(fd, s); return 0; } #endif int handle_host_request(const char* service, TransportType type, const char* serial, int reply_fd, asocket* s) { Loading @@ -1051,7 +1065,6 @@ int handle_host_request(const char* service, TransportType type, android::base::quick_exit(0); } #if ADB_HOST // "transport:" is used for switching transport with a specified serial number // "transport-usb:" is used for switching transport to the only USB transport // "transport-local:" is used for switching transport to the only local transport Loading Loading @@ -1096,16 +1109,10 @@ int handle_host_request(const char* service, TransportType type, if (!strcmp(service, "reconnect-offline")) { std::string response; close_usb_devices([&response](const atransport* transport) { switch (transport->connection_state) { switch (transport->GetConnectionState()) { case kCsOffline: case kCsUnauthorized: response += "reconnecting "; if (transport->serial) { response += transport->serial; } else { response += "<unknown>"; } response += "\n"; response += "reconnecting " + transport->serial_name() + "\n"; return true; default: return false; Loading @@ -1129,7 +1136,6 @@ int handle_host_request(const char* service, TransportType type, return 0; } #if ADB_HOST if (!strcmp(service, "host-features")) { FeatureSet features = supported_features(); // Abuse features to report libusb status. Loading @@ -1139,7 +1145,6 @@ int handle_host_request(const char* service, TransportType type, SendOkay(reply_fd, FeatureSetToString(features)); return 0; } #endif // remove TCP transport if (!strncmp(service, "disconnect:", 11)) { Loading Loading @@ -1209,15 +1214,19 @@ int handle_host_request(const char* service, TransportType type, } if (!strcmp(service, "reconnect")) { if (s->transport != nullptr) { kick_transport(s->transport); std::string response; atransport* t = acquire_one_transport(type, serial, nullptr, &response, true); if (t != nullptr) { kick_transport(t); response = "reconnecting " + t->serial_name() + " [" + t->connection_state_name() + "]\n"; } return SendOkay(reply_fd, "done"); return SendOkay(reply_fd, response); } #endif // ADB_HOST int ret = handle_forward_request(service, type, serial, reply_fd); if (ret >= 0) return ret - 1; return -1; } #endif // ADB_HOST adb/adb.h +4 −1 Original line number Diff line number Diff line Loading @@ -139,7 +139,7 @@ int adb_server_main(int is_daemon, const std::string& socket_spec, int ack_reply int get_available_local_transport_index(); #endif int init_socket_transport(atransport *t, int s, int port, int local); void init_usb_transport(atransport *t, usb_handle *usb, ConnectionState state); void init_usb_transport(atransport* t, usb_handle* usb); std::string getEmulatorSerialString(int console_port); #if ADB_HOST Loading Loading @@ -222,6 +222,9 @@ void handle_online(atransport *t); void handle_offline(atransport *t); void send_connect(atransport *t); #if ADB_HOST void SendConnectOnHost(atransport* t); #endif void parse_banner(const std::string&, atransport* t); Loading adb/adb_client.cpp +4 −7 Original line number Diff line number Diff line Loading @@ -136,8 +136,7 @@ int _adb_connect(const std::string& service, std::string* error) { return -2; } if ((memcmp(&service[0],"host",4) != 0 || service == "host:reconnect") && switch_socket_transport(fd, error)) { if (memcmp(&service[0], "host", 4) != 0 && switch_socket_transport(fd, error)) { return -1; } Loading @@ -147,12 +146,10 @@ int _adb_connect(const std::string& service, std::string* error) { return -1; } if (service != "reconnect") { if (!adb_status(fd, error)) { adb_close(fd); return -1; } } D("_adb_connect: return fd %d", fd); return fd; Loading adb/adb_trace.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -155,7 +155,7 @@ void adb_trace_init(char** argv) { } #endif #if !defined(_WIN32) #if ADB_HOST && !defined(_WIN32) // adb historically ignored $ANDROID_LOG_TAGS but passed it through to logcat. // If set, move it out of the way so that libbase logging doesn't try to parse it. std::string log_tags; Loading @@ -168,7 +168,7 @@ void adb_trace_init(char** argv) { android::base::InitLogging(argv, &AdbLogger); #if !defined(_WIN32) #if ADB_HOST && !defined(_WIN32) // Put $ANDROID_LOG_TAGS back so we can pass it to logcat. if (!log_tags.empty()) setenv("ANDROID_LOG_TAGS", log_tags.c_str(), 1); #endif Loading adb/adb_trace.h +3 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,9 @@ extern int adb_trace_mask; void adb_trace_init(char**); void adb_trace_enable(AdbTrace trace_tag); // Include <atomic> before stdatomic.h (introduced in cutils/trace.h) to avoid compile error. #include <atomic> #define ATRACE_TAG ATRACE_TAG_ADB #include <cutils/trace.h> #include <utils/Trace.h> Loading Loading
adb/adb.cpp +36 −27 Original line number Diff line number Diff line Loading @@ -253,6 +253,19 @@ void send_connect(atransport* t) { send_packet(cp, t); } #if ADB_HOST void SendConnectOnHost(atransport* t) { // Send an empty message before A_CNXN message. This is because the data toggle of the ep_out on // host and ep_in on device may not be the same. apacket* p = get_apacket(); CHECK(p); send_packet(p, t); send_connect(t); } #endif // qual_overwrite is used to overwrite a qualifier string. dst is a // pointer to a char pointer. It is assumed that if *dst is non-NULL, it // was malloc'ed and needs to freed. *dst will be set to a dup of src. Loading Loading @@ -299,29 +312,29 @@ void parse_banner(const std::string& banner, atransport* t) { const std::string& type = pieces[0]; if (type == "bootloader") { D("setting connection_state to kCsBootloader"); t->connection_state = kCsBootloader; t->SetConnectionState(kCsBootloader); update_transports(); } else if (type == "device") { D("setting connection_state to kCsDevice"); t->connection_state = kCsDevice; t->SetConnectionState(kCsDevice); update_transports(); } else if (type == "recovery") { D("setting connection_state to kCsRecovery"); t->connection_state = kCsRecovery; t->SetConnectionState(kCsRecovery); update_transports(); } else if (type == "sideload") { D("setting connection_state to kCsSideload"); t->connection_state = kCsSideload; t->SetConnectionState(kCsSideload); update_transports(); } else { D("setting connection_state to kCsHost"); t->connection_state = kCsHost; t->SetConnectionState(kCsHost); } } static void handle_new_connection(atransport* t, apacket* p) { if (t->connection_state != kCsOffline) { t->connection_state = kCsOffline; if (t->GetConnectionState() != kCsOffline) { t->SetConnectionState(kCsOffline); handle_offline(t); } Loading Loading @@ -355,10 +368,10 @@ void handle_packet(apacket *p, atransport *t) if (p->msg.arg0){ send_packet(p, t); #if ADB_HOST send_connect(t); SendConnectOnHost(t); #endif } else { t->connection_state = kCsOffline; t->SetConnectionState(kCsOffline); handle_offline(t); send_packet(p, t); } Loading @@ -372,7 +385,9 @@ void handle_packet(apacket *p, atransport *t) switch (p->msg.arg0) { #if ADB_HOST case ADB_AUTH_TOKEN: t->connection_state = kCsUnauthorized; if (t->GetConnectionState() == kCsOffline) { t->SetConnectionState(kCsUnauthorized); } send_auth_response(p->data, p->msg.data_length, t); break; #else Loading @@ -391,7 +406,7 @@ void handle_packet(apacket *p, atransport *t) break; #endif default: t->connection_state = kCsOffline; t->SetConnectionState(kCsOffline); handle_offline(t); break; } Loading Loading @@ -1032,7 +1047,6 @@ static int SendOkay(int fd, const std::string& s) { SendProtocolString(fd, s); return 0; } #endif int handle_host_request(const char* service, TransportType type, const char* serial, int reply_fd, asocket* s) { Loading @@ -1051,7 +1065,6 @@ int handle_host_request(const char* service, TransportType type, android::base::quick_exit(0); } #if ADB_HOST // "transport:" is used for switching transport with a specified serial number // "transport-usb:" is used for switching transport to the only USB transport // "transport-local:" is used for switching transport to the only local transport Loading Loading @@ -1096,16 +1109,10 @@ int handle_host_request(const char* service, TransportType type, if (!strcmp(service, "reconnect-offline")) { std::string response; close_usb_devices([&response](const atransport* transport) { switch (transport->connection_state) { switch (transport->GetConnectionState()) { case kCsOffline: case kCsUnauthorized: response += "reconnecting "; if (transport->serial) { response += transport->serial; } else { response += "<unknown>"; } response += "\n"; response += "reconnecting " + transport->serial_name() + "\n"; return true; default: return false; Loading @@ -1129,7 +1136,6 @@ int handle_host_request(const char* service, TransportType type, return 0; } #if ADB_HOST if (!strcmp(service, "host-features")) { FeatureSet features = supported_features(); // Abuse features to report libusb status. Loading @@ -1139,7 +1145,6 @@ int handle_host_request(const char* service, TransportType type, SendOkay(reply_fd, FeatureSetToString(features)); return 0; } #endif // remove TCP transport if (!strncmp(service, "disconnect:", 11)) { Loading Loading @@ -1209,15 +1214,19 @@ int handle_host_request(const char* service, TransportType type, } if (!strcmp(service, "reconnect")) { if (s->transport != nullptr) { kick_transport(s->transport); std::string response; atransport* t = acquire_one_transport(type, serial, nullptr, &response, true); if (t != nullptr) { kick_transport(t); response = "reconnecting " + t->serial_name() + " [" + t->connection_state_name() + "]\n"; } return SendOkay(reply_fd, "done"); return SendOkay(reply_fd, response); } #endif // ADB_HOST int ret = handle_forward_request(service, type, serial, reply_fd); if (ret >= 0) return ret - 1; return -1; } #endif // ADB_HOST
adb/adb.h +4 −1 Original line number Diff line number Diff line Loading @@ -139,7 +139,7 @@ int adb_server_main(int is_daemon, const std::string& socket_spec, int ack_reply int get_available_local_transport_index(); #endif int init_socket_transport(atransport *t, int s, int port, int local); void init_usb_transport(atransport *t, usb_handle *usb, ConnectionState state); void init_usb_transport(atransport* t, usb_handle* usb); std::string getEmulatorSerialString(int console_port); #if ADB_HOST Loading Loading @@ -222,6 +222,9 @@ void handle_online(atransport *t); void handle_offline(atransport *t); void send_connect(atransport *t); #if ADB_HOST void SendConnectOnHost(atransport* t); #endif void parse_banner(const std::string&, atransport* t); Loading
adb/adb_client.cpp +4 −7 Original line number Diff line number Diff line Loading @@ -136,8 +136,7 @@ int _adb_connect(const std::string& service, std::string* error) { return -2; } if ((memcmp(&service[0],"host",4) != 0 || service == "host:reconnect") && switch_socket_transport(fd, error)) { if (memcmp(&service[0], "host", 4) != 0 && switch_socket_transport(fd, error)) { return -1; } Loading @@ -147,12 +146,10 @@ int _adb_connect(const std::string& service, std::string* error) { return -1; } if (service != "reconnect") { if (!adb_status(fd, error)) { adb_close(fd); return -1; } } D("_adb_connect: return fd %d", fd); return fd; Loading
adb/adb_trace.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -155,7 +155,7 @@ void adb_trace_init(char** argv) { } #endif #if !defined(_WIN32) #if ADB_HOST && !defined(_WIN32) // adb historically ignored $ANDROID_LOG_TAGS but passed it through to logcat. // If set, move it out of the way so that libbase logging doesn't try to parse it. std::string log_tags; Loading @@ -168,7 +168,7 @@ void adb_trace_init(char** argv) { android::base::InitLogging(argv, &AdbLogger); #if !defined(_WIN32) #if ADB_HOST && !defined(_WIN32) // Put $ANDROID_LOG_TAGS back so we can pass it to logcat. if (!log_tags.empty()) setenv("ANDROID_LOG_TAGS", log_tags.c_str(), 1); #endif Loading
adb/adb_trace.h +3 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,9 @@ extern int adb_trace_mask; void adb_trace_init(char**); void adb_trace_enable(AdbTrace trace_tag); // Include <atomic> before stdatomic.h (introduced in cutils/trace.h) to avoid compile error. #include <atomic> #define ATRACE_TAG ATRACE_TAG_ADB #include <cutils/trace.h> #include <utils/Trace.h> Loading