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:
Josh Gao 2016-04-13 12:18:58 -07:00
parent 3d8df3cb2a
commit 5863fb61e1
2 changed files with 6 additions and 4 deletions

View File

@ -1057,11 +1057,11 @@ static bool wait_for_device(const char* service, TransportType t, const char* se
return false;
}
if (components[3] != "bootloader" && components[3] != "device" && components[3] != "recovery" &&
components[3] != "sideload") {
if (components[3] != "any" && components[3] != "bootloader" && components[3] != "device" &&
components[3] != "recovery" && components[3] != "sideload") {
fprintf(stderr,
"adb: unknown state %s; "
"expected 'bootloader', 'device', 'recovery', or 'sideload'\n",
"expected 'any', 'bootloader', 'device', 'recovery', or 'sideload'\n",
components[3].c_str());
return false;
}

View File

@ -370,7 +370,7 @@ static void wait_for_state(int fd, void* data) {
std::string error = "unknown error";
const char* serial = sinfo->serial.length() ? sinfo->serial.c_str() : NULL;
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);
break;
} else if (!is_ambiguous) {
@ -534,6 +534,8 @@ asocket* host_service_to_socket(const char* name, const char* serial) {
sinfo->state = kCsSideload;
} else if (!strcmp(name, "-bootloader")) {
sinfo->state = kCsBootloader;
} else if (!strcmp(name, "-any")) {
sinfo->state = kCsAny;
} else {
return nullptr;
}