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

Commit 19b79a74 authored by Luis Hector Chavez's avatar Luis Hector Chavez Committed by android-build-merger
Browse files

Merge changes Iccfe3bd4,I6380245b,I20d9f2fe am: c23280a1 am: 0314aa7c am: 3c8a288b

am: 11bf3129

Change-Id: I213c72e25ee918bb4537517a31dbb90bbba86f8f
parents d504126c 11bf3129
Loading
Loading
Loading
Loading
+9 −18
Original line number Original line Diff line number Diff line
@@ -264,15 +264,6 @@ void send_connect(atransport* t) {
    send_packet(cp, t);
    send_packet(cp, t);
}
}


// qual_overwrite is used to overwrite a qualifier string.  dst is a
// pointer to a char pointer.  It is assumed that if *dst is non-NULL, it
// was malloc'ed and needs to freed.  *dst will be set to a dup of src.
// TODO: switch to std::string for these atransport fields instead.
static void qual_overwrite(char** dst, const std::string& src) {
    free(*dst);
    *dst = strdup(src.c_str());
}

void parse_banner(const std::string& banner, atransport* t) {
void parse_banner(const std::string& banner, atransport* t) {
    D("parse_banner: %s", banner.c_str());
    D("parse_banner: %s", banner.c_str());


@@ -296,11 +287,11 @@ void parse_banner(const std::string& banner, atransport* t) {
            const std::string& key = key_value[0];
            const std::string& key = key_value[0];
            const std::string& value = key_value[1];
            const std::string& value = key_value[1];
            if (key == "ro.product.name") {
            if (key == "ro.product.name") {
                qual_overwrite(&t->product, value);
                t->product = value;
            } else if (key == "ro.product.model") {
            } else if (key == "ro.product.model") {
                qual_overwrite(&t->model, value);
                t->model = value;
            } else if (key == "ro.product.device") {
            } else if (key == "ro.product.device") {
                qual_overwrite(&t->device, value);
                t->device = value;
            } else if (key == "features") {
            } else if (key == "features") {
                t->SetFeatures(value);
                t->SetFeatures(value);
            }
            }
@@ -424,8 +415,8 @@ void handle_packet(apacket *p, atransport *t)
                    /* Other READY messages must use the same local-id */
                    /* Other READY messages must use the same local-id */
                    s->ready(s);
                    s->ready(s);
                } else {
                } else {
                    D("Invalid A_OKAY(%d,%d), expected A_OKAY(%d,%d) on transport %s",
                    D("Invalid A_OKAY(%d,%d), expected A_OKAY(%d,%d) on transport %s", p->msg.arg0,
                      p->msg.arg0, p->msg.arg1, s->peer->id, p->msg.arg1, t->serial);
                      p->msg.arg1, s->peer->id, p->msg.arg1, t->serial.c_str());
                }
                }
            } else {
            } else {
                // When receiving A_OKAY from device for A_OPEN request, the host server may
                // When receiving A_OKAY from device for A_OPEN request, the host server may
@@ -451,8 +442,8 @@ void handle_packet(apacket *p, atransport *t)
                 * socket has a peer on the same transport.
                 * socket has a peer on the same transport.
                 */
                 */
                if (p->msg.arg0 == 0 && s->peer && s->peer->transport != t) {
                if (p->msg.arg0 == 0 && s->peer && s->peer->transport != t) {
                    D("Invalid A_CLSE(0, %u) from transport %s, expected transport %s",
                    D("Invalid A_CLSE(0, %u) from transport %s, expected transport %s", p->msg.arg1,
                      p->msg.arg1, t->serial, s->peer->transport->serial);
                      t->serial.c_str(), s->peer->transport->serial.c_str());
                } else {
                } else {
                    s->close(s);
                    s->close(s);
                }
                }
@@ -1171,7 +1162,7 @@ int handle_host_request(const char* service, TransportType type, const char* ser
        std::string error;
        std::string error;
        atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error);
        atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error);
        if (t) {
        if (t) {
            return SendOkay(reply_fd, t->serial ? t->serial : "unknown");
            return SendOkay(reply_fd, !t->serial.empty() ? t->serial : "unknown");
        } else {
        } else {
            return SendFail(reply_fd, error);
            return SendFail(reply_fd, error);
        }
        }
@@ -1180,7 +1171,7 @@ int handle_host_request(const char* service, TransportType type, const char* ser
        std::string error;
        std::string error;
        atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error);
        atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error);
        if (t) {
        if (t) {
            return SendOkay(reply_fd, t->devpath ? t->devpath : "unknown");
            return SendOkay(reply_fd, !t->devpath.empty() ? t->devpath : "unknown");
        } else {
        } else {
            return SendFail(reply_fd, error);
            return SendFail(reply_fd, error);
        }
        }
+0 −5
Original line number Original line Diff line number Diff line
@@ -156,11 +156,6 @@ int create_jdwp_connection_fd(int jdwp_pid);


int handle_forward_request(const char* service, atransport* transport, int reply_fd);
int handle_forward_request(const char* service, atransport* transport, int reply_fd);


#if !ADB_HOST
void framebuffer_service(int fd, void* cookie);
void set_verity_enabled_state_service(int fd, void* cookie);
#endif

/* packet allocator */
/* packet allocator */
apacket* get_apacket(void);
apacket* get_apacket(void);
void put_apacket(apacket* p);
void put_apacket(apacket* p);
+4 −3
Original line number Original line Diff line number Diff line
@@ -136,8 +136,9 @@ std::string format_listeners() EXCLUDES(listener_list_mutex) {
        }
        }
        //  <device-serial> " " <local-name> " " <remote-name> "\n"
        //  <device-serial> " " <local-name> " " <remote-name> "\n"
        // Entries from "adb reverse" have no serial.
        // Entries from "adb reverse" have no serial.
        android::base::StringAppendF(&result, "%s %s %s\n",
        android::base::StringAppendF(
                                     l->transport->serial ? l->transport->serial : "(reverse)",
                &result, "%s %s %s\n",
                !l->transport->serial.empty() ? l->transport->serial.c_str() : "(reverse)",
                l->local_name.c_str(), l->connect_to.c_str());
                l->local_name.c_str(), l->connect_to.c_str());
    }
    }
    return result;
    return result;
+9 −13
Original line number Original line Diff line number Diff line
@@ -362,9 +362,8 @@ static void stdinout_raw_epilogue(int inFd, int outFd, int old_stdin_mode, int o
}
}


static void copy_to_file(int inFd, int outFd) {
static void copy_to_file(int inFd, int outFd) {
    const size_t BUFSIZE = 32 * 1024;
    constexpr size_t BUFSIZE = 32 * 1024;
    char* buf = (char*) malloc(BUFSIZE);
    std::vector<char> buf(BUFSIZE);
    if (buf == nullptr) fatal("couldn't allocate buffer for copy_to_file");
    int len;
    int len;
    long total = 0;
    long total = 0;
    int old_stdin_mode = -1;
    int old_stdin_mode = -1;
@@ -376,9 +375,9 @@ static void copy_to_file(int inFd, int outFd) {


    while (true) {
    while (true) {
        if (inFd == STDIN_FILENO) {
        if (inFd == STDIN_FILENO) {
            len = unix_read(inFd, buf, BUFSIZE);
            len = unix_read(inFd, buf.data(), BUFSIZE);
        } else {
        } else {
            len = adb_read(inFd, buf, BUFSIZE);
            len = adb_read(inFd, buf.data(), BUFSIZE);
        }
        }
        if (len == 0) {
        if (len == 0) {
            D("copy_to_file() : read 0 bytes; exiting");
            D("copy_to_file() : read 0 bytes; exiting");
@@ -389,10 +388,10 @@ static void copy_to_file(int inFd, int outFd) {
            break;
            break;
        }
        }
        if (outFd == STDOUT_FILENO) {
        if (outFd == STDOUT_FILENO) {
            fwrite(buf, 1, len, stdout);
            fwrite(buf.data(), 1, len, stdout);
            fflush(stdout);
            fflush(stdout);
        } else {
        } else {
            adb_write(outFd, buf, len);
            adb_write(outFd, buf.data(), len);
        }
        }
        total += len;
        total += len;
    }
    }
@@ -400,7 +399,6 @@ static void copy_to_file(int inFd, int outFd) {
    stdinout_raw_epilogue(inFd, outFd, old_stdin_mode, old_stdout_mode);
    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 after %lu bytes", total);
    free(buf);
}
}


static void send_window_size_change(int fd, std::unique_ptr<ShellProtocol>& shell) {
static void send_window_size_change(int fd, std::unique_ptr<ShellProtocol>& shell) {
@@ -1142,24 +1140,22 @@ static int logcat(int argc, const char** argv) {
static void write_zeros(int bytes, int fd) {
static void write_zeros(int bytes, int fd) {
    int old_stdin_mode = -1;
    int old_stdin_mode = -1;
    int old_stdout_mode = -1;
    int old_stdout_mode = -1;
    char* buf = (char*) calloc(1, bytes);
    std::vector<char> buf(bytes);
    if (buf == nullptr) fatal("couldn't allocate buffer for write_zeros");


    D("write_zeros(%d) -> %d", bytes, fd);
    D("write_zeros(%d) -> %d", bytes, fd);


    stdinout_raw_prologue(-1, fd, old_stdin_mode, old_stdout_mode);
    stdinout_raw_prologue(-1, fd, old_stdin_mode, old_stdout_mode);


    if (fd == STDOUT_FILENO) {
    if (fd == STDOUT_FILENO) {
        fwrite(buf, 1, bytes, stdout);
        fwrite(buf.data(), 1, bytes, stdout);
        fflush(stdout);
        fflush(stdout);
    } else {
    } else {
        adb_write(fd, buf, bytes);
        adb_write(fd, buf.data(), bytes);
    }
    }


    stdinout_raw_prologue(-1, fd, old_stdin_mode, old_stdout_mode);
    stdinout_raw_prologue(-1, fd, old_stdin_mode, old_stdout_mode);


    D("write_zeros() finished");
    D("write_zeros() finished");
    free(buf);
}
}


static int backup(int argc, const char** argv) {
static int backup(int argc, const char** argv) {
+2 −3
Original line number Original line Diff line number Diff line
@@ -525,12 +525,11 @@ static bool handle_sync_command(int fd, std::vector<char>& buffer) {
    return true;
    return true;
}
}


void file_sync_service(int fd, void*) {
void file_sync_service(android::base::unique_fd fd) {
    std::vector<char> buffer(SYNC_DATA_MAX);
    std::vector<char> buffer(SYNC_DATA_MAX);


    while (handle_sync_command(fd, buffer)) {
    while (handle_sync_command(fd.get(), buffer)) {
    }
    }


    D("sync: done");
    D("sync: done");
    adb_close(fd);
}
}
Loading