adb: add support for 'wait-for-any'.
Allow waiting for a device in any state.
Bug: http://b/28168212
Change-Id: I1876ecd70089ca88f2da5de4182e13724ec50501
diff --git a/services.cpp b/services.cpp
index d5e963b..67e8e41 100644
--- a/services.cpp
+++ b/services.cpp
@@ -370,7 +370,7 @@
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 @@
sinfo->state = kCsSideload;
} else if (!strcmp(name, "-bootloader")) {
sinfo->state = kCsBootloader;
+ } else if (!strcmp(name, "-any")) {
+ sinfo->state = kCsAny;
} else {
return nullptr;
}