adb: kick the transport after sending the "adb root" command
This is needed because the USB driver on the device no longer resets the bus
when exits and restarts.
Since the host side adb no longer detects that adbd has restarted we need
to reset the connection on the host side now.
Change-Id: I1a8eabd292e8b45c34fa07a8a8b8c609cc15648d
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/adb/sockets.c b/adb/sockets.c
index 3d62f1e..6bfc7c8 100644
--- a/adb/sockets.c
+++ b/adb/sockets.c
@@ -190,6 +190,14 @@
static void local_socket_close(asocket *s)
{
+#if ADB_HOST
+ /* to special case commands that cause the remote daemon to terminate */
+ if (s->kick_on_close && s->transport) {
+ kick_transport(s->transport);
+ /* delay to work around a race condition */
+ sleep(1);
+ }
+#endif
adb_mutex_lock(&socket_list_lock);
local_socket_close_locked(s);
adb_mutex_unlock(&socket_list_lock);
@@ -524,6 +532,14 @@
apacket *p = get_apacket();
int len = strlen(destination) + 1;
+#if ADB_HOST
+ /* special case commands that cause the remote daemon to terminate */
+ if (!strcmp(destination, "root:")) {
+ D("connect_to_remote setting kick_on_close for %s\n", destination);
+ s->kick_on_close = 1;
+ }
+#endif
+
if(len > (MAX_PAYLOAD-1)) {
fatal("destination oversized");
}