system/core
リビジョン | 59ec200272072a54e19fdb448a6e8f355f269bb6 (tree) |
---|---|
日時 | 2016-09-12 05:53:41 |
作者 | Steve Kondik <steve@cyng...> |
コミッター | Steve Kondik |
adb: Add wait-for-online command
Change-Id: I92034c477d28f847e24ec72bbb87b252fba875e1
@@ -114,6 +114,7 @@ enum ConnectionState { | ||
114 | 114 | kCsNoPerm, // Insufficient permissions to communicate with the device. |
115 | 115 | kCsSideload, |
116 | 116 | kCsUnauthorized, |
117 | + kCsOnline, | |
117 | 118 | }; |
118 | 119 | |
119 | 120 | /* A listener is an entity which binds to a local port |
@@ -209,7 +209,7 @@ static void help() { | ||
209 | 209 | "scripting:\n" |
210 | 210 | " adb wait-for[-<transport>]-<state>\n" |
211 | 211 | " - wait for device to be in the given state:\n" |
212 | - " device, recovery, sideload, or bootloader\n" | |
212 | + " device, recovery, sideload, online, or bootloader\n" | |
213 | 213 | " Transport is: usb, local or any [default=any]\n" |
214 | 214 | " adb start-server - ensure that there is a server running\n" |
215 | 215 | " adb kill-server - kill the server if it is running\n" |
@@ -1083,10 +1083,10 @@ static bool wait_for_device(const char* service, TransportType t, const char* se | ||
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | if (components[3] != "any" && components[3] != "bootloader" && components[3] != "device" && |
1086 | - components[3] != "recovery" && components[3] != "sideload") { | |
1086 | + components[3] != "recovery" && components[3] != "sideload" && components[3] != "online") { | |
1087 | 1087 | fprintf(stderr, |
1088 | 1088 | "adb: unknown state %s; " |
1089 | - "expected 'any', 'bootloader', 'device', 'recovery', or 'sideload'\n", | |
1089 | + "expected 'any', 'bootloader', 'device', 'recovery', 'online', or 'sideload'\n", | |
1090 | 1090 | components[3].c_str()); |
1091 | 1091 | return false; |
1092 | 1092 | } |
@@ -391,7 +391,9 @@ static void wait_for_state(int fd, void* data) { | ||
391 | 391 | std::string error = "unknown error"; |
392 | 392 | const char* serial = sinfo->serial.length() ? sinfo->serial.c_str() : NULL; |
393 | 393 | atransport* t = acquire_one_transport(sinfo->transport_type, serial, &is_ambiguous, &error); |
394 | - if (t != nullptr && (sinfo->state == kCsAny || sinfo->state == t->connection_state)) { | |
394 | + if (t != nullptr && (sinfo->state == kCsAny || sinfo->state == t->connection_state || | |
395 | + (sinfo->state == kCsOnline && (t->connection_state == kCsRecovery || | |
396 | + t->connection_state == kCsDevice)) )) { | |
395 | 397 | SendOkay(fd); |
396 | 398 | break; |
397 | 399 | } else if (!is_ambiguous) { |
@@ -557,6 +559,8 @@ asocket* host_service_to_socket(const char* name, const char* serial) { | ||
557 | 559 | sinfo->state = kCsBootloader; |
558 | 560 | } else if (!strcmp(name, "-any")) { |
559 | 561 | sinfo->state = kCsAny; |
562 | + } else if (!strcmp(name, "-online")) { | |
563 | + sinfo->state = kCsOnline; | |
560 | 564 | } else { |
561 | 565 | return nullptr; |
562 | 566 | } |