Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3c62cc5 authored by Josh Gao's avatar Josh Gao
Browse files

adb: allow wait-for-disconnect to match offline for TCP devices.

This fixes a bug in adb root/unroot where we always fail because we're
waiting for a TCP device to disappear.

Test: test_device.py over TCP
Change-Id: I7e4b6fdaa1070cee1f9b471de46ae00bf89b3089
parent 03bee486
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -202,11 +202,22 @@ static void wait_service(unique_fd fd, std::string serial, TransportId transport
                                      transport_id, &is_ambiguous, &error);

        for (const auto& state : states) {
            // wait-for-disconnect uses kCsOffline, we don't actually want to wait for 'offline'.
            if ((t == nullptr && state == kCsOffline) || (t != nullptr && state == kCsAny) ||
                (t != nullptr && state == t->GetConnectionState())) {
            if (state == kCsOffline) {
                // Special case for wait-for-disconnect:
                // We want to wait for USB devices to completely disappear, but TCP devices can
                // go into the offline state, since we automatically reconnect.
                if (!t) {
                    SendOkay(fd);
                    return;
                } else if (!t->GetUsbHandle()) {
                    SendOkay(fd);
                    return;
                }
            } else {
                if (t && (state == kCsAny || state == t->GetConnectionState())) {
                    SendOkay(fd);
                    return;
                }
            }
        }