Loading adb/adb.cpp +25 −0 Original line number Original line Diff line number Diff line Loading @@ -1089,6 +1089,31 @@ int handle_host_request(const char* service, TransportType type, return 1; return 1; } } if (!strcmp(service, "reconnect-offline")) { std::string response; close_usb_devices([&response](const atransport* transport) { switch (transport->connection_state) { case kCsOffline: case kCsUnauthorized: response += "reconnecting "; if (transport->serial) { response += transport->serial; } else { response += "<unknown>"; } response += "\n"; return true; default: return false; } }); if (!response.empty()) { response.resize(response.size() - 1); } SendOkay(reply_fd, response); return 0; } if (!strcmp(service, "features")) { if (!strcmp(service, "features")) { std::string error; std::string error; atransport* t = acquire_one_transport(type, serial, nullptr, &error); atransport* t = acquire_one_transport(type, serial, nullptr, &error); Loading adb/commandline.cpp +11 −4 Original line number Original line Diff line number Diff line Loading @@ -1950,10 +1950,17 @@ int adb_commandline(int argc, const char** argv) { } else if (!strcmp(argv[0], "reconnect")) { } else if (!strcmp(argv[0], "reconnect")) { if (argc == 1) { if (argc == 1) { return adb_query_command("host:reconnect"); return adb_query_command("host:reconnect"); } else if (argc == 2 && !strcmp(argv[1], "device")) { } else if (argc == 2) { if (!strcmp(argv[1], "device")) { std::string err; std::string err; adb_connect("reconnect", &err); adb_connect("reconnect", &err); return 0; return 0; } else if (!strcmp(argv[1], "offline")) { std::string err; return adb_query_command("host:reconnect-offline"); } else { return usage(); } } } } } Loading adb/sockets.cpp +5 −2 Original line number Original line Diff line number Diff line Loading @@ -791,11 +791,14 @@ static int smart_socket_enqueue(asocket* s, apacket* p) { } } #endif #endif if (!(s->transport) || (s->transport->connection_state == kCsOffline)) { if (!s->transport) { SendFail(s->peer->fd, "device offline (no transport)"); goto fail; } else if (s->transport->connection_state == kCsOffline) { /* if there's no remote we fail the connection /* if there's no remote we fail the connection ** right here and terminate it ** right here and terminate it */ */ SendFail(s->peer->fd, "device offline (x)"); SendFail(s->peer->fd, "device offline (transport offline)"); goto fail; goto fail; } } Loading adb/transport.cpp +10 −4 Original line number Original line Diff line number Diff line Loading @@ -908,13 +908,19 @@ std::string list_transports(bool long_listing) { return result; return result; } } /* hack for osx */ void close_usb_devices(std::function<bool(const atransport*)> predicate) { void close_usb_devices() { std::lock_guard<std::mutex> lock(transport_lock); std::lock_guard<std::mutex> lock(transport_lock); for (const auto& t : transport_list) { for (auto& t : transport_list) { if (predicate(t)) { t->Kick(); t->Kick(); } } } } } /* hack for osx */ void close_usb_devices() { close_usb_devices([](const atransport*) { return true; }); } #endif // ADB_HOST #endif // ADB_HOST int register_socket_transport(int s, const char *serial, int port, int local) { int register_socket_transport(int s, const char *serial, int port, int local) { Loading adb/transport.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <sys/types.h> #include <sys/types.h> #include <deque> #include <deque> #include <functional> #include <list> #include <list> #include <memory> #include <memory> #include <string> #include <string> Loading Loading @@ -199,8 +200,8 @@ void unregister_usb_transport(usb_handle* usb); int check_header(apacket* p, atransport* t); int check_header(apacket* p, atransport* t); int check_data(apacket* p); int check_data(apacket* p); /* for MacOS X cleanup */ void close_usb_devices(); void close_usb_devices(); void close_usb_devices(std::function<bool(const atransport*)> predicate); void send_packet(apacket* p, atransport* t); void send_packet(apacket* p, atransport* t); Loading Loading
adb/adb.cpp +25 −0 Original line number Original line Diff line number Diff line Loading @@ -1089,6 +1089,31 @@ int handle_host_request(const char* service, TransportType type, return 1; return 1; } } if (!strcmp(service, "reconnect-offline")) { std::string response; close_usb_devices([&response](const atransport* transport) { switch (transport->connection_state) { case kCsOffline: case kCsUnauthorized: response += "reconnecting "; if (transport->serial) { response += transport->serial; } else { response += "<unknown>"; } response += "\n"; return true; default: return false; } }); if (!response.empty()) { response.resize(response.size() - 1); } SendOkay(reply_fd, response); return 0; } if (!strcmp(service, "features")) { if (!strcmp(service, "features")) { std::string error; std::string error; atransport* t = acquire_one_transport(type, serial, nullptr, &error); atransport* t = acquire_one_transport(type, serial, nullptr, &error); Loading
adb/commandline.cpp +11 −4 Original line number Original line Diff line number Diff line Loading @@ -1950,10 +1950,17 @@ int adb_commandline(int argc, const char** argv) { } else if (!strcmp(argv[0], "reconnect")) { } else if (!strcmp(argv[0], "reconnect")) { if (argc == 1) { if (argc == 1) { return adb_query_command("host:reconnect"); return adb_query_command("host:reconnect"); } else if (argc == 2 && !strcmp(argv[1], "device")) { } else if (argc == 2) { if (!strcmp(argv[1], "device")) { std::string err; std::string err; adb_connect("reconnect", &err); adb_connect("reconnect", &err); return 0; return 0; } else if (!strcmp(argv[1], "offline")) { std::string err; return adb_query_command("host:reconnect-offline"); } else { return usage(); } } } } } Loading
adb/sockets.cpp +5 −2 Original line number Original line Diff line number Diff line Loading @@ -791,11 +791,14 @@ static int smart_socket_enqueue(asocket* s, apacket* p) { } } #endif #endif if (!(s->transport) || (s->transport->connection_state == kCsOffline)) { if (!s->transport) { SendFail(s->peer->fd, "device offline (no transport)"); goto fail; } else if (s->transport->connection_state == kCsOffline) { /* if there's no remote we fail the connection /* if there's no remote we fail the connection ** right here and terminate it ** right here and terminate it */ */ SendFail(s->peer->fd, "device offline (x)"); SendFail(s->peer->fd, "device offline (transport offline)"); goto fail; goto fail; } } Loading
adb/transport.cpp +10 −4 Original line number Original line Diff line number Diff line Loading @@ -908,13 +908,19 @@ std::string list_transports(bool long_listing) { return result; return result; } } /* hack for osx */ void close_usb_devices(std::function<bool(const atransport*)> predicate) { void close_usb_devices() { std::lock_guard<std::mutex> lock(transport_lock); std::lock_guard<std::mutex> lock(transport_lock); for (const auto& t : transport_list) { for (auto& t : transport_list) { if (predicate(t)) { t->Kick(); t->Kick(); } } } } } /* hack for osx */ void close_usb_devices() { close_usb_devices([](const atransport*) { return true; }); } #endif // ADB_HOST #endif // ADB_HOST int register_socket_transport(int s, const char *serial, int port, int local) { int register_socket_transport(int s, const char *serial, int port, int local) { Loading
adb/transport.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <sys/types.h> #include <sys/types.h> #include <deque> #include <deque> #include <functional> #include <list> #include <list> #include <memory> #include <memory> #include <string> #include <string> Loading Loading @@ -199,8 +200,8 @@ void unregister_usb_transport(usb_handle* usb); int check_header(apacket* p, atransport* t); int check_header(apacket* p, atransport* t); int check_data(apacket* p); int check_data(apacket* p); /* for MacOS X cleanup */ void close_usb_devices(); void close_usb_devices(); void close_usb_devices(std::function<bool(const atransport*)> predicate); void send_packet(apacket* p, atransport* t); void send_packet(apacket* p, atransport* t); Loading