Loading adb/adb.cpp +36 −25 Original line number Diff line number Diff line Loading @@ -1044,7 +1044,7 @@ static int SendOkay(int fd, const std::string& s) { return 0; } int handle_host_request(const char* service, TransportType type, const char* serial, bool handle_host_request(const char* service, TransportType type, const char* serial, TransportId transport_id, int reply_fd, asocket* s) { if (strcmp(service, "kill") == 0) { fprintf(stderr, "adb server killed by remote request\n"); Loading @@ -1070,7 +1070,7 @@ int handle_host_request(const char* service, TransportType type, const char* ser transport_id = strtoll(service, const_cast<char**>(&service), 10); if (*service != '\0') { SendFail(reply_fd, "invalid transport id"); return 1; return true; } } else if (!strncmp(service, "transport-usb", strlen("transport-usb"))) { type = kTransportUsb; Loading @@ -1088,10 +1088,13 @@ int handle_host_request(const char* service, TransportType type, const char* ser if (t != nullptr) { s->transport = t; SendOkay(reply_fd); // We succesfully handled the device selection, but there's another request coming. return false; } else { SendFail(reply_fd, error); return true; } return 1; } // return a list of all connected devices Loading @@ -1101,9 +1104,9 @@ int handle_host_request(const char* service, TransportType type, const char* ser D("Getting device list..."); std::string device_list = list_transports(long_listing); D("Sending device list..."); return SendOkay(reply_fd, device_list); SendOkay(reply_fd, device_list); } return 1; return true; } if (!strcmp(service, "reconnect-offline")) { Loading @@ -1119,7 +1122,7 @@ int handle_host_request(const char* service, TransportType type, const char* ser response.resize(response.size() - 1); } SendOkay(reply_fd, response); return 0; return true; } if (!strcmp(service, "features")) { Loading @@ -1130,7 +1133,7 @@ int handle_host_request(const char* service, TransportType type, const char* ser } else { SendFail(reply_fd, error); } return 0; return true; } if (!strcmp(service, "host-features")) { Loading @@ -1141,7 +1144,7 @@ int handle_host_request(const char* service, TransportType type, const char* ser } features.insert(kFeaturePushSync); SendOkay(reply_fd, FeatureSetToString(features)); return 0; return true; } // remove TCP transport Loading @@ -1149,7 +1152,8 @@ int handle_host_request(const char* service, TransportType type, const char* ser const std::string address(service + 11); if (address.empty()) { kick_all_tcp_devices(); return SendOkay(reply_fd, "disconnected everything"); SendOkay(reply_fd, "disconnected everything"); return true; } std::string serial; Loading @@ -1157,21 +1161,24 @@ int handle_host_request(const char* service, TransportType type, const char* ser int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT; std::string error; if (!android::base::ParseNetAddress(address, &host, &port, &serial, &error)) { return SendFail(reply_fd, android::base::StringPrintf("couldn't parse '%s': %s", SendFail(reply_fd, android::base::StringPrintf("couldn't parse '%s': %s", address.c_str(), error.c_str())); return true; } atransport* t = find_transport(serial.c_str()); if (t == nullptr) { return SendFail(reply_fd, android::base::StringPrintf("no such device '%s'", serial.c_str())); SendFail(reply_fd, android::base::StringPrintf("no such device '%s'", serial.c_str())); return true; } kick_transport(t); return SendOkay(reply_fd, android::base::StringPrintf("disconnected %s", address.c_str())); SendOkay(reply_fd, android::base::StringPrintf("disconnected %s", address.c_str())); return true; } // Returns our value for ADB_SERVER_VERSION. if (!strcmp(service, "version")) { return SendOkay(reply_fd, android::base::StringPrintf("%04x", ADB_SERVER_VERSION)); SendOkay(reply_fd, android::base::StringPrintf("%04x", ADB_SERVER_VERSION)); return true; } // These always report "unknown" rather than the actual error, for scripts. Loading @@ -1179,28 +1186,31 @@ int handle_host_request(const char* service, TransportType type, const char* ser std::string error; atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); if (t) { return SendOkay(reply_fd, !t->serial.empty() ? t->serial : "unknown"); SendOkay(reply_fd, !t->serial.empty() ? t->serial : "unknown"); } else { return SendFail(reply_fd, error); SendFail(reply_fd, error); } return true; } if (!strcmp(service, "get-devpath")) { std::string error; atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); if (t) { return SendOkay(reply_fd, !t->devpath.empty() ? t->devpath : "unknown"); SendOkay(reply_fd, !t->devpath.empty() ? t->devpath : "unknown"); } else { return SendFail(reply_fd, error); SendFail(reply_fd, error); } return true; } if (!strcmp(service, "get-state")) { std::string error; atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); if (t) { return SendOkay(reply_fd, t->connection_state_name()); SendOkay(reply_fd, t->connection_state_name()); } else { return SendFail(reply_fd, error); SendFail(reply_fd, error); } return true; } // Indicates a new emulator instance has started. Loading @@ -1208,7 +1218,7 @@ int handle_host_request(const char* service, TransportType type, const char* ser int port = atoi(service+9); local_connect(port); /* we don't even need to send a reply */ return 0; return true; } if (!strcmp(service, "reconnect")) { Loading @@ -1219,7 +1229,8 @@ int handle_host_request(const char* service, TransportType type, const char* ser response = "reconnecting " + t->serial_name() + " [" + t->connection_state_name() + "]\n"; } return SendOkay(reply_fd, response); SendOkay(reply_fd, response); return true; } if (handle_forward_request(service, Loading @@ -1228,10 +1239,10 @@ int handle_host_request(const char* service, TransportType type, const char* ser error); }, reply_fd)) { return 0; return true; } return -1; return false; } static auto& init_mutex = *new std::mutex(); Loading adb/adb.h +2 −2 Original line number Diff line number Diff line Loading @@ -210,7 +210,7 @@ extern const char* adb_device_banner; #define USB_FFS_ADB_IN USB_FFS_ADB_EP(ep2) #endif int handle_host_request(const char* service, TransportType type, const char* serial, bool handle_host_request(const char* service, TransportType type, const char* serial, TransportId transport_id, int reply_fd, asocket* s); void handle_online(atransport* t); Loading adb/sockets.cpp +3 −7 Original line number Diff line number Diff line Loading @@ -685,13 +685,9 @@ static int smart_socket_enqueue(asocket* s, apacket::payload_type data) { if (service) { asocket* s2; /* some requests are handled immediately -- in that ** case the handle_host_request() routine has sent ** the OKAY or FAIL message and all we have to do ** is clean up. */ if (handle_host_request(service, type, serial, transport_id, s->peer->fd, s) == 0) { /* XXX fail message? */ // Some requests are handled immediately -- in that case the handle_host_request() routine // has sent the OKAY or FAIL message and all we have to do is clean up. if (handle_host_request(service, type, serial, transport_id, s->peer->fd, s)) { D("SS(%d): handled host service '%s'", s->id, service); goto fail; } Loading Loading
adb/adb.cpp +36 −25 Original line number Diff line number Diff line Loading @@ -1044,7 +1044,7 @@ static int SendOkay(int fd, const std::string& s) { return 0; } int handle_host_request(const char* service, TransportType type, const char* serial, bool handle_host_request(const char* service, TransportType type, const char* serial, TransportId transport_id, int reply_fd, asocket* s) { if (strcmp(service, "kill") == 0) { fprintf(stderr, "adb server killed by remote request\n"); Loading @@ -1070,7 +1070,7 @@ int handle_host_request(const char* service, TransportType type, const char* ser transport_id = strtoll(service, const_cast<char**>(&service), 10); if (*service != '\0') { SendFail(reply_fd, "invalid transport id"); return 1; return true; } } else if (!strncmp(service, "transport-usb", strlen("transport-usb"))) { type = kTransportUsb; Loading @@ -1088,10 +1088,13 @@ int handle_host_request(const char* service, TransportType type, const char* ser if (t != nullptr) { s->transport = t; SendOkay(reply_fd); // We succesfully handled the device selection, but there's another request coming. return false; } else { SendFail(reply_fd, error); return true; } return 1; } // return a list of all connected devices Loading @@ -1101,9 +1104,9 @@ int handle_host_request(const char* service, TransportType type, const char* ser D("Getting device list..."); std::string device_list = list_transports(long_listing); D("Sending device list..."); return SendOkay(reply_fd, device_list); SendOkay(reply_fd, device_list); } return 1; return true; } if (!strcmp(service, "reconnect-offline")) { Loading @@ -1119,7 +1122,7 @@ int handle_host_request(const char* service, TransportType type, const char* ser response.resize(response.size() - 1); } SendOkay(reply_fd, response); return 0; return true; } if (!strcmp(service, "features")) { Loading @@ -1130,7 +1133,7 @@ int handle_host_request(const char* service, TransportType type, const char* ser } else { SendFail(reply_fd, error); } return 0; return true; } if (!strcmp(service, "host-features")) { Loading @@ -1141,7 +1144,7 @@ int handle_host_request(const char* service, TransportType type, const char* ser } features.insert(kFeaturePushSync); SendOkay(reply_fd, FeatureSetToString(features)); return 0; return true; } // remove TCP transport Loading @@ -1149,7 +1152,8 @@ int handle_host_request(const char* service, TransportType type, const char* ser const std::string address(service + 11); if (address.empty()) { kick_all_tcp_devices(); return SendOkay(reply_fd, "disconnected everything"); SendOkay(reply_fd, "disconnected everything"); return true; } std::string serial; Loading @@ -1157,21 +1161,24 @@ int handle_host_request(const char* service, TransportType type, const char* ser int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT; std::string error; if (!android::base::ParseNetAddress(address, &host, &port, &serial, &error)) { return SendFail(reply_fd, android::base::StringPrintf("couldn't parse '%s': %s", SendFail(reply_fd, android::base::StringPrintf("couldn't parse '%s': %s", address.c_str(), error.c_str())); return true; } atransport* t = find_transport(serial.c_str()); if (t == nullptr) { return SendFail(reply_fd, android::base::StringPrintf("no such device '%s'", serial.c_str())); SendFail(reply_fd, android::base::StringPrintf("no such device '%s'", serial.c_str())); return true; } kick_transport(t); return SendOkay(reply_fd, android::base::StringPrintf("disconnected %s", address.c_str())); SendOkay(reply_fd, android::base::StringPrintf("disconnected %s", address.c_str())); return true; } // Returns our value for ADB_SERVER_VERSION. if (!strcmp(service, "version")) { return SendOkay(reply_fd, android::base::StringPrintf("%04x", ADB_SERVER_VERSION)); SendOkay(reply_fd, android::base::StringPrintf("%04x", ADB_SERVER_VERSION)); return true; } // These always report "unknown" rather than the actual error, for scripts. Loading @@ -1179,28 +1186,31 @@ int handle_host_request(const char* service, TransportType type, const char* ser std::string error; atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); if (t) { return SendOkay(reply_fd, !t->serial.empty() ? t->serial : "unknown"); SendOkay(reply_fd, !t->serial.empty() ? t->serial : "unknown"); } else { return SendFail(reply_fd, error); SendFail(reply_fd, error); } return true; } if (!strcmp(service, "get-devpath")) { std::string error; atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); if (t) { return SendOkay(reply_fd, !t->devpath.empty() ? t->devpath : "unknown"); SendOkay(reply_fd, !t->devpath.empty() ? t->devpath : "unknown"); } else { return SendFail(reply_fd, error); SendFail(reply_fd, error); } return true; } if (!strcmp(service, "get-state")) { std::string error; atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error); if (t) { return SendOkay(reply_fd, t->connection_state_name()); SendOkay(reply_fd, t->connection_state_name()); } else { return SendFail(reply_fd, error); SendFail(reply_fd, error); } return true; } // Indicates a new emulator instance has started. Loading @@ -1208,7 +1218,7 @@ int handle_host_request(const char* service, TransportType type, const char* ser int port = atoi(service+9); local_connect(port); /* we don't even need to send a reply */ return 0; return true; } if (!strcmp(service, "reconnect")) { Loading @@ -1219,7 +1229,8 @@ int handle_host_request(const char* service, TransportType type, const char* ser response = "reconnecting " + t->serial_name() + " [" + t->connection_state_name() + "]\n"; } return SendOkay(reply_fd, response); SendOkay(reply_fd, response); return true; } if (handle_forward_request(service, Loading @@ -1228,10 +1239,10 @@ int handle_host_request(const char* service, TransportType type, const char* ser error); }, reply_fd)) { return 0; return true; } return -1; return false; } static auto& init_mutex = *new std::mutex(); Loading
adb/adb.h +2 −2 Original line number Diff line number Diff line Loading @@ -210,7 +210,7 @@ extern const char* adb_device_banner; #define USB_FFS_ADB_IN USB_FFS_ADB_EP(ep2) #endif int handle_host_request(const char* service, TransportType type, const char* serial, bool handle_host_request(const char* service, TransportType type, const char* serial, TransportId transport_id, int reply_fd, asocket* s); void handle_online(atransport* t); Loading
adb/sockets.cpp +3 −7 Original line number Diff line number Diff line Loading @@ -685,13 +685,9 @@ static int smart_socket_enqueue(asocket* s, apacket::payload_type data) { if (service) { asocket* s2; /* some requests are handled immediately -- in that ** case the handle_host_request() routine has sent ** the OKAY or FAIL message and all we have to do ** is clean up. */ if (handle_host_request(service, type, serial, transport_id, s->peer->fd, s) == 0) { /* XXX fail message? */ // Some requests are handled immediately -- in that case the handle_host_request() routine // has sent the OKAY or FAIL message and all we have to do is clean up. if (handle_host_request(service, type, serial, transport_id, s->peer->fd, s)) { D("SS(%d): handled host service '%s'", s->id, service); goto fail; } Loading