adb: add support for 'wait-for-any'.
Allow waiting for a device in any state.
Bug: http://b/28168212
Change-Id: I1876ecd70089ca88f2da5de4182e13724ec50501
(cherry picked from commit 86441c31fe)
This commit is contained in:
parent
3d8df3cb2a
commit
5863fb61e1
2 changed files with 6 additions and 4 deletions
|
|
@ -1057,11 +1057,11 @@ static bool wait_for_device(const char* service, TransportType t, const char* se
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (components[3] != "bootloader" && components[3] != "device" && components[3] != "recovery" &&
|
if (components[3] != "any" && components[3] != "bootloader" && components[3] != "device" &&
|
||||||
components[3] != "sideload") {
|
components[3] != "recovery" && components[3] != "sideload") {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"adb: unknown state %s; "
|
"adb: unknown state %s; "
|
||||||
"expected 'bootloader', 'device', 'recovery', or 'sideload'\n",
|
"expected 'any', 'bootloader', 'device', 'recovery', or 'sideload'\n",
|
||||||
components[3].c_str());
|
components[3].c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -370,7 +370,7 @@ static void wait_for_state(int fd, void* data) {
|
||||||
std::string error = "unknown error";
|
std::string error = "unknown error";
|
||||||
const char* serial = sinfo->serial.length() ? sinfo->serial.c_str() : NULL;
|
const char* serial = sinfo->serial.length() ? sinfo->serial.c_str() : NULL;
|
||||||
atransport* t = acquire_one_transport(sinfo->transport_type, serial, &is_ambiguous, &error);
|
atransport* t = acquire_one_transport(sinfo->transport_type, serial, &is_ambiguous, &error);
|
||||||
if (t != nullptr && t->connection_state == sinfo->state) {
|
if (t != nullptr && (sinfo->state == kCsAny || sinfo->state == t->connection_state)) {
|
||||||
SendOkay(fd);
|
SendOkay(fd);
|
||||||
break;
|
break;
|
||||||
} else if (!is_ambiguous) {
|
} else if (!is_ambiguous) {
|
||||||
|
|
@ -534,6 +534,8 @@ asocket* host_service_to_socket(const char* name, const char* serial) {
|
||||||
sinfo->state = kCsSideload;
|
sinfo->state = kCsSideload;
|
||||||
} else if (!strcmp(name, "-bootloader")) {
|
} else if (!strcmp(name, "-bootloader")) {
|
||||||
sinfo->state = kCsBootloader;
|
sinfo->state = kCsBootloader;
|
||||||
|
} else if (!strcmp(name, "-any")) {
|
||||||
|
sinfo->state = kCsAny;
|
||||||
} else {
|
} else {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue