Loading adb/client/commandline.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -190,8 +190,8 @@ static void help() { "scripting:\n" " wait-for[-TRANSPORT]-STATE\n" " wait for device to be in the given state\n" " State: device, recovery, sideload, or bootloader\n" " Transport: usb, local, or any [default=any]\n" " STATE: device, recovery, sideload, bootloader, or disconnect\n" " TRANSPORT: usb, local, or any [default=any]\n" " get-state print offline | bootloader | device\n" " get-serialno print <serial-number>\n" " get-devpath print <device-path>\n" Loading Loading @@ -1031,10 +1031,11 @@ static bool wait_for_device(const char* service) { } if (components[3] != "any" && components[3] != "bootloader" && components[3] != "device" && components[3] != "recovery" && components[3] != "sideload") { components[3] != "recovery" && components[3] != "sideload" && components[3] != "disconnect") { fprintf(stderr, "adb: unknown state %s; " "expected 'any', 'bootloader', 'device', 'recovery', or 'sideload'\n", "expected 'any', 'bootloader', 'device', 'recovery', 'sideload', or 'disconnect'\n", components[3].c_str()); return false; } Loading adb/services.cpp +14 −3 Original line number Diff line number Diff line Loading @@ -109,12 +109,21 @@ static void wait_for_state(int fd, state_info* sinfo) { const char* serial = sinfo->serial.length() ? sinfo->serial.c_str() : nullptr; atransport* t = acquire_one_transport(sinfo->transport_type, serial, sinfo->transport_id, &is_ambiguous, &error); if (t != nullptr && (sinfo->state == kCsAny || sinfo->state == t->GetConnectionState())) { if (sinfo->state == kCsOffline) { // wait-for-disconnect uses kCsOffline, we don't actually want to wait for 'offline'. if (t == nullptr) { SendOkay(fd); break; } else if (!is_ambiguous) { } } else if (t != nullptr && (sinfo->state == kCsAny || sinfo->state == t->GetConnectionState())) { SendOkay(fd); break; } if (!is_ambiguous) { adb_pollfd pfd = {.fd = fd, .events = POLLIN}; int rc = adb_poll(&pfd, 1, 1000); int rc = adb_poll(&pfd, 1, 100); if (rc < 0) { SendFail(fd, error); break; Loading Loading @@ -224,6 +233,8 @@ asocket* host_service_to_socket(std::string_view name, std::string_view serial, sinfo->state = kCsBootloader; } else if (name == "-any") { sinfo->state = kCsAny; } else if (name == "-disconnect") { sinfo->state = kCsOffline; } else { return nullptr; } Loading Loading
adb/client/commandline.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -190,8 +190,8 @@ static void help() { "scripting:\n" " wait-for[-TRANSPORT]-STATE\n" " wait for device to be in the given state\n" " State: device, recovery, sideload, or bootloader\n" " Transport: usb, local, or any [default=any]\n" " STATE: device, recovery, sideload, bootloader, or disconnect\n" " TRANSPORT: usb, local, or any [default=any]\n" " get-state print offline | bootloader | device\n" " get-serialno print <serial-number>\n" " get-devpath print <device-path>\n" Loading Loading @@ -1031,10 +1031,11 @@ static bool wait_for_device(const char* service) { } if (components[3] != "any" && components[3] != "bootloader" && components[3] != "device" && components[3] != "recovery" && components[3] != "sideload") { components[3] != "recovery" && components[3] != "sideload" && components[3] != "disconnect") { fprintf(stderr, "adb: unknown state %s; " "expected 'any', 'bootloader', 'device', 'recovery', or 'sideload'\n", "expected 'any', 'bootloader', 'device', 'recovery', 'sideload', or 'disconnect'\n", components[3].c_str()); return false; } Loading
adb/services.cpp +14 −3 Original line number Diff line number Diff line Loading @@ -109,12 +109,21 @@ static void wait_for_state(int fd, state_info* sinfo) { const char* serial = sinfo->serial.length() ? sinfo->serial.c_str() : nullptr; atransport* t = acquire_one_transport(sinfo->transport_type, serial, sinfo->transport_id, &is_ambiguous, &error); if (t != nullptr && (sinfo->state == kCsAny || sinfo->state == t->GetConnectionState())) { if (sinfo->state == kCsOffline) { // wait-for-disconnect uses kCsOffline, we don't actually want to wait for 'offline'. if (t == nullptr) { SendOkay(fd); break; } else if (!is_ambiguous) { } } else if (t != nullptr && (sinfo->state == kCsAny || sinfo->state == t->GetConnectionState())) { SendOkay(fd); break; } if (!is_ambiguous) { adb_pollfd pfd = {.fd = fd, .events = POLLIN}; int rc = adb_poll(&pfd, 1, 1000); int rc = adb_poll(&pfd, 1, 100); if (rc < 0) { SendFail(fd, error); break; Loading Loading @@ -224,6 +233,8 @@ asocket* host_service_to_socket(std::string_view name, std::string_view serial, sinfo->state = kCsBootloader; } else if (name == "-any") { sinfo->state = kCsAny; } else if (name == "-disconnect") { sinfo->state = kCsOffline; } else { return nullptr; } Loading