adb: add reconnect command.
Add reconnect command for debugging. `reconnect` kicks a transport
from the host side, `reconnect device` kicks a transport from
the device side. They can be used to produce transport errors.
Bug: 25935458
Change-Id: I47daa338796b561941e7aba44a51a6dd117d1e98
diff --git a/adb/services.cpp b/adb/services.cpp
index d5e963b..3c1aab8 100644
--- a/adb/services.cpp
+++ b/adb/services.cpp
@@ -184,6 +184,13 @@
adb_close(fd);
}
+static void reconnect_service(int fd, void* arg) {
+ WriteFdExactly(fd, "done");
+ adb_close(fd);
+ atransport* t = static_cast<atransport*>(arg);
+ kick_transport(t);
+}
+
int reverse_service(const char* command) {
int s[2];
if (adb_socketpair(s)) {
@@ -345,6 +352,8 @@
ret = create_service_thread(set_verity_enabled_state_service, (void*)0);
} else if(!strncmp(name, "enable-verity:", 15)) {
ret = create_service_thread(set_verity_enabled_state_service, (void*)1);
+ } else if (!strcmp(name, "reconnect")) {
+ ret = create_service_thread(reconnect_service, const_cast<atransport*>(transport));
#endif
}
if (ret >= 0) {