Skip to content

Commit

Permalink
adb: allow wait-for-disconnect to match offline for TCP devices.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jmgao committed Apr 22, 2020
1 parent d231cda commit 843f191
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions services.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
SendOkay(fd);
return;
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;
}
}
}

Expand Down

0 comments on commit 843f191

Please sign in to comment.