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

Commit de6aed81 authored by David Pursell's avatar David Pursell Committed by Android Git Automerger
Browse files

am a3ef4fad: am 0af19a0e: Merge "adb: Fix missing shell protocol usage."

* commit 'a3ef4fad':
  adb: Fix missing shell protocol usage.
parents 4ba7715f a3ef4fad
Loading
Loading
Loading
Loading
+22 −19
Original line number Diff line number Diff line
@@ -532,6 +532,20 @@ static std::string format_host_command(const char* command, TransportType type,
    return android::base::StringPrintf("%s:%s", prefix, command);
}

// Checks whether the device indicated by |transport_type| and |serial| supports
// |feature|. Returns the response string, which will be empty if the device
// could not be found or the feature is not supported.
static std::string CheckFeature(const std::string& feature,
                                TransportType transport_type,
                                const char* serial) {
    std::string result, error, command("check-feature:" + feature);
    if (!adb_query(format_host_command(command.c_str(), transport_type, serial),
                   &result, &error)) {
        return "";
    }
    return result;
}

static int adb_download_buffer(const char *service, const char *fn, const void* data, unsigned sz,
                               bool show_progress)
{
@@ -791,12 +805,15 @@ static int send_shell_command(TransportType transport_type, const char* serial,
        wait_for_device("wait-for-device", transport_type, serial);
    }

    read_and_dump(fd);
    int rc = adb_close(fd);
    if (rc) {
        perror("close");
    bool use_shell_protocol = !CheckFeature(kFeatureShell2, transport_type,
                                            serial).empty();
    int exit_code = read_and_dump(fd, use_shell_protocol);

    if (adb_close(fd) < 0) {
        PLOG(ERROR) << "failure closing FD " << fd;
    }
    return rc;

    return exit_code;
}

static int logcat(TransportType transport, const char* serial, int argc, const char** argv) {
@@ -1021,20 +1038,6 @@ static bool _is_valid_ack_reply_fd(const int ack_reply_fd) {
#endif
}

// Checks whether the device indicated by |transport_type| and |serial| supports
// |feature|. Returns the response string, which will be empty if the device
// could not be found or the feature is not supported.
static std::string CheckFeature(const std::string& feature,
                                TransportType transport_type,
                                const char* serial) {
    std::string result, error, command("check-feature:" + feature);
    if (!adb_query(format_host_command(command.c_str(), transport_type, serial),
                   &result, &error)) {
        return "";
    }
    return result;
}

int adb_commandline(int argc, const char **argv) {
    int no_daemon = 0;
    int is_daemon = 0;