Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 833628c6 authored by Steve Kondik's avatar Steve Kondik Committed by Michael Bestas
Browse files

adb: Add wait-for-online command

 * Add the pseudo-state "online" which means either "device" or
   "recovery". This is used by our tooling.

Change-Id: I92034c477d28f847e24ec72bbb87b252fba875e1
parent 35847566
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ enum ConnectionState {
    kCsRecovery,
    kCsSideload,
    kCsRescue,
    kCsOnline,
};

inline bool ConnectionStateIsOnline(ConnectionState state) {
+4 −4
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ static void help() {
        "scripting:\n"
        " wait-for[-TRANSPORT]-STATE\n"
        "     wait for device to be in the given state\n"
        "     STATE: device, recovery, rescue, sideload, bootloader, or disconnect\n"
        "     STATE: device, recovery, rescue, sideload, bootloader, online, or disconnect\n"
        "     TRANSPORT: usb, local, or any [default=any]\n"
        " get-state                print offline | bootloader | device\n"
        " get-serialno             print <serial-number>\n"
@@ -1072,11 +1072,11 @@ static bool wait_for_device(const char* service,

    if (components[3] != "any" && components[3] != "bootloader" && components[3] != "device" &&
        components[3] != "recovery" && components[3] != "rescue" && components[3] != "sideload" &&
        components[3] != "disconnect") {
        components[3] != "online" && components[3] != "disconnect") {
        fprintf(stderr,
                "adb: unknown state %s; "
                "expected 'any', 'bootloader', 'device', 'recovery', 'rescue', 'sideload', or "
                "'disconnect'\n",
                "expected 'any', 'bootloader', 'device', 'recovery', 'rescue', 'sideload', "
                "'online', or 'disconnect'\n",
                components[3].c_str());
        return false;
    }
+5 −1
Original line number Diff line number Diff line
@@ -116,7 +116,9 @@ static void wait_for_state(int fd, state_info* sinfo) {
                break;
            }
        } else if (t != nullptr &&
                   (sinfo->state == kCsAny || sinfo->state == t->GetConnectionState())) {
                   (sinfo->state == kCsAny || sinfo->state == t->GetConnectionState() ||
                   (sinfo->state == kCsOnline && (t->GetConnectionState() == kCsRecovery ||
                                                  t->GetConnectionState() == kCsDevice)) )) {
            SendOkay(fd);
            break;
        }
@@ -237,6 +239,8 @@ asocket* host_service_to_socket(std::string_view name, std::string_view serial,
            sinfo->state = kCsAny;
        } else if (name == "-disconnect") {
            sinfo->state = kCsOffline;
        } else if (name == "-online") {
            sinfo->state = kCsOnline;
        } else {
            return nullptr;
        }