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

Commit c71a1e7a authored by Josh Gao's avatar Josh Gao Committed by Gerrit Code Review
Browse files

Merge "adb: report error in copy_to_file."

parents e8cd50a7 3828ebcd
Loading
Loading
Loading
Loading
+21 −8
Original line number Diff line number Diff line
@@ -227,18 +227,22 @@ static int install_app_streamed(int argc, const char** argv, bool use_fastdeploy
        return 1;
    }

    copy_to_file(local_fd.get(), remote_fd.get());
    if (!copy_to_file(local_fd.get(), remote_fd.get())) {
        fprintf(stderr, "adb: failed to install: copy_to_file: %s: %s", file, strerror(errno));
        return 1;
    }

    char buf[BUFSIZ];
    read_status_line(remote_fd.get(), buf, sizeof(buf));
    if (!strncmp("Success", buf, 7)) {
        fputs(buf, stdout);
        return 0;
    }
    if (strncmp("Success", buf, 7) != 0) {
        fprintf(stderr, "adb: failed to install %s: %s", file, buf);
        return 1;
    }

    fputs(buf, stdout);
    return 0;
}

static int install_app_legacy(int argc, const char** argv, bool use_fastdeploy) {
    printf("Performing Push Install\n");

@@ -455,7 +459,12 @@ int install_multiple_app(int argc, const char** argv) {
            goto finalize_session;
        }

        copy_to_file(local_fd.get(), remote_fd.get());
        if (!copy_to_file(local_fd.get(), remote_fd.get())) {
            fprintf(stderr, "adb: failed to write \"%s\": %s\n", file, strerror(errno));
            success = false;
            goto finalize_session;
        }

        read_status_line(remote_fd.get(), buf, sizeof(buf));

        if (strncmp("Success", buf, 7)) {
@@ -634,7 +643,11 @@ int install_multi_package(int argc, const char** argv) {
                goto finalize_multi_package_session;
            }

            copy_to_file(local_fd.get(), remote_fd.get());
            if (!copy_to_file(local_fd.get(), remote_fd.get())) {
                fprintf(stderr, "adb: failed to write %s: %s\n", split.c_str(), strerror(errno));
                goto finalize_multi_package_session;
            }

            read_status_line(remote_fd.get(), buf, sizeof(buf));

            if (strncmp("Success", buf, 7)) {
+5 −2
Original line number Diff line number Diff line
@@ -352,7 +352,8 @@ static void stdinout_raw_epilogue(int inFd, int outFd, int old_stdin_mode, int o
#endif
}

void copy_to_file(int inFd, int outFd) {
bool copy_to_file(int inFd, int outFd) {
    bool result = true;
    std::vector<char> buf(64 * 1024);
    int len;
    long total = 0;
@@ -375,6 +376,7 @@ void copy_to_file(int inFd, int outFd) {
        }
        if (len < 0) {
            D("copy_to_file(): read failed: %s", strerror(errno));
            result = false;
            break;
        }
        if (outFd == STDOUT_FILENO) {
@@ -388,7 +390,8 @@ void copy_to_file(int inFd, int outFd) {

    stdinout_raw_epilogue(inFd, outFd, old_stdin_mode, old_stdout_mode);

    D("copy_to_file() finished after %lu bytes", total);
    D("copy_to_file() finished with %s after %lu bytes", result ? "success" : "failure", total);
    return result;
}

static void send_window_size_change(int fd, std::unique_ptr<ShellProtocol>& shell) {
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ extern DefaultStandardStreamsCallback DEFAULT_STANDARD_STREAMS_CALLBACK;

int adb_commandline(int argc, const char** argv);

void copy_to_file(int inFd, int outFd);
bool copy_to_file(int inFd, int outFd);

// Connects to the device "shell" service with |command| and prints the
// resulting output.