adb: add `adb reconnect offline` to reconnect offline devices.
Add a command to reconnect offline/unauthorized devices, mainly for use
with the inotify-monitoring of vendor key directories added by 2e671202.
Bug: http://b/29273531
Test: manually tested with a sailfish + copying vendor keys
Change-Id: If34cccee4ae553ada65d128b57d03cba8c0d7c46
diff --git a/adb/adb.cpp b/adb/adb.cpp
index 29d6e65..8b6b2b5 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -1089,6 +1089,31 @@
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")) {
std::string error;
atransport* t = acquire_one_transport(type, serial, nullptr, &error);