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

Commit bfbe2b6a authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "fastbootd: Add more logging for when the USB transport fails." am: f9c36a2c

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1457444

Change-Id: If93c7e497ef6daac9a9168395254087d888d51be
parents c29cf50c f9c36a2c
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -139,7 +139,13 @@ bool FastbootDevice::WriteStatus(FastbootResult result, const std::string& messa
bool FastbootDevice::HandleData(bool read, std::vector<char>* data) {
    auto read_write_data_size = read ? this->get_transport()->Read(data->data(), data->size())
                                     : this->get_transport()->Write(data->data(), data->size());
    if (read_write_data_size == -1 || static_cast<size_t>(read_write_data_size) != data->size()) {
    if (read_write_data_size == -1) {
        LOG(ERROR) << (read ? "read from" : "write to") << " transport failed";
        return false;
    }
    if (static_cast<size_t>(read_write_data_size) != data->size()) {
        LOG(ERROR) << (read ? "read" : "write") << " expected " << data->size() << " bytes, got "
                   << read_write_data_size;
        return false;
    }
    return true;
+7 −1
Original line number Diff line number Diff line
@@ -248,7 +248,12 @@ ClientUsbTransport::ClientUsbTransport()
}

ssize_t ClientUsbTransport::Read(void* data, size_t len) {
    if (handle_ == nullptr || len > SSIZE_MAX) {
    if (handle_ == nullptr) {
        LOG(ERROR) << "ClientUsbTransport: no handle";
        return -1;
    }
    if (len > SSIZE_MAX) {
        LOG(ERROR) << "ClientUsbTransport: maximum length exceeds bounds";
        return -1;
    }
    char* char_data = static_cast<char*>(data);
@@ -258,6 +263,7 @@ ssize_t ClientUsbTransport::Read(void* data, size_t len) {
        auto bytes_read_now =
                handle_->read(handle_.get(), char_data, bytes_to_read, true /* allow_partial */);
        if (bytes_read_now < 0) {
            PLOG(ERROR) << "ClientUsbTransport: read failed";
            return bytes_read_total == 0 ? -1 : bytes_read_total;
        }
        bytes_read_total += bytes_read_now;