fastbootd: Add more logging for when the USB transport fails.
Bug: 161542676 Test: fastboot flashall Change-Id: Ief4e7452b72504c51c807dd38a07765ad65c96a4
This commit is contained in:
parent
8582aa21df
commit
f74c1a9556
2 changed files with 14 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue