Loading adb/daemon/include/adbd/usb.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -43,7 +43,7 @@ struct usb_handle { bool open_new_connection = true; bool open_new_connection = true; int (*write)(usb_handle* h, const void* data, int len); int (*write)(usb_handle* h, const void* data, int len); int (*read)(usb_handle* h, void* data, int len); int (*read)(usb_handle* h, void* data, int len, bool allow_partial); void (*kick)(usb_handle* h); void (*kick)(usb_handle* h); void (*close)(usb_handle* h); void (*close)(usb_handle* h); Loading adb/daemon/usb_legacy.cpp +14 −3 Original line number Original line Diff line number Diff line Loading @@ -142,11 +142,12 @@ static int usb_ffs_write(usb_handle* h, const void* data, int len) { return orig_len; return orig_len; } } static int usb_ffs_read(usb_handle* h, void* data, int len) { static int usb_ffs_read(usb_handle* h, void* data, int len, bool allow_partial) { D("about to read (fd=%d, len=%d)", h->bulk_out.get(), len); D("about to read (fd=%d, len=%d)", h->bulk_out.get(), len); char* buf = static_cast<char*>(data); char* buf = static_cast<char*>(data); int orig_len = len; int orig_len = len; unsigned count = 0; while (len > 0) { while (len > 0) { int read_len = std::min(USB_FFS_BULK_SIZE, len); int read_len = std::min(USB_FFS_BULK_SIZE, len); int n = adb_read(h->bulk_out, buf, read_len); int n = adb_read(h->bulk_out, buf, read_len); Loading @@ -156,6 +157,16 @@ static int usb_ffs_read(usb_handle* h, void* data, int len) { } } buf += n; buf += n; len -= n; len -= n; count += n; // For fastbootd command such as "getvar all", len parameter is always set 64. // But what we read is actually less than 64. // For example, length 10 for "getvar all" command. // If we get less data than expected, this means there should be no more data. if (allow_partial && n < read_len) { orig_len = count; break; } } } D("[ done fd=%d ]", h->bulk_out.get()); D("[ done fd=%d ]", h->bulk_out.get()); Loading Loading @@ -221,7 +232,7 @@ static int usb_ffs_do_aio(usb_handle* h, const void* data, int len, bool read) { } } } } static int usb_ffs_aio_read(usb_handle* h, void* data, int len) { static int usb_ffs_aio_read(usb_handle* h, void* data, int len, bool allow_partial) { return usb_ffs_do_aio(h, data, len, true); return usb_ffs_do_aio(h, data, len, true); } } Loading Loading @@ -299,7 +310,7 @@ int usb_write(usb_handle* h, const void* data, int len) { } } int usb_read(usb_handle* h, void* data, int len) { int usb_read(usb_handle* h, void* data, int len) { return h->read(h, data, len); return h->read(h, data, len, false /* allow_partial */); } } int usb_close(usb_handle* h) { int usb_close(usb_handle* h) { Loading base/mapped_file.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -76,7 +76,7 @@ MappedFile::~MappedFile() { if (base_ != nullptr) UnmapViewOfFile(base_); if (base_ != nullptr) UnmapViewOfFile(base_); if (handle_ != nullptr) CloseHandle(handle_); if (handle_ != nullptr) CloseHandle(handle_); #else #else if (base_ != nullptr) munmap(base_, size_); if (base_ != nullptr) munmap(base_, size_ + offset_); #endif #endif base_ = nullptr; base_ = nullptr; Loading fastboot/device/usb_client.cpp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -255,7 +255,8 @@ ssize_t ClientUsbTransport::Read(void* data, size_t len) { size_t bytes_read_total = 0; size_t bytes_read_total = 0; while (bytes_read_total < len) { while (bytes_read_total < len) { auto bytes_to_read = std::min(len - bytes_read_total, kFbFfsNumBufs * kFbFfsBufSize); auto bytes_to_read = std::min(len - bytes_read_total, kFbFfsNumBufs * kFbFfsBufSize); auto bytes_read_now = handle_->read(handle_.get(), char_data, bytes_to_read); auto bytes_read_now = handle_->read(handle_.get(), char_data, bytes_to_read, true /* allow_partial */); if (bytes_read_now < 0) { if (bytes_read_now < 0) { return bytes_read_total; return bytes_read_total; } } Loading Loading
adb/daemon/include/adbd/usb.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -43,7 +43,7 @@ struct usb_handle { bool open_new_connection = true; bool open_new_connection = true; int (*write)(usb_handle* h, const void* data, int len); int (*write)(usb_handle* h, const void* data, int len); int (*read)(usb_handle* h, void* data, int len); int (*read)(usb_handle* h, void* data, int len, bool allow_partial); void (*kick)(usb_handle* h); void (*kick)(usb_handle* h); void (*close)(usb_handle* h); void (*close)(usb_handle* h); Loading
adb/daemon/usb_legacy.cpp +14 −3 Original line number Original line Diff line number Diff line Loading @@ -142,11 +142,12 @@ static int usb_ffs_write(usb_handle* h, const void* data, int len) { return orig_len; return orig_len; } } static int usb_ffs_read(usb_handle* h, void* data, int len) { static int usb_ffs_read(usb_handle* h, void* data, int len, bool allow_partial) { D("about to read (fd=%d, len=%d)", h->bulk_out.get(), len); D("about to read (fd=%d, len=%d)", h->bulk_out.get(), len); char* buf = static_cast<char*>(data); char* buf = static_cast<char*>(data); int orig_len = len; int orig_len = len; unsigned count = 0; while (len > 0) { while (len > 0) { int read_len = std::min(USB_FFS_BULK_SIZE, len); int read_len = std::min(USB_FFS_BULK_SIZE, len); int n = adb_read(h->bulk_out, buf, read_len); int n = adb_read(h->bulk_out, buf, read_len); Loading @@ -156,6 +157,16 @@ static int usb_ffs_read(usb_handle* h, void* data, int len) { } } buf += n; buf += n; len -= n; len -= n; count += n; // For fastbootd command such as "getvar all", len parameter is always set 64. // But what we read is actually less than 64. // For example, length 10 for "getvar all" command. // If we get less data than expected, this means there should be no more data. if (allow_partial && n < read_len) { orig_len = count; break; } } } D("[ done fd=%d ]", h->bulk_out.get()); D("[ done fd=%d ]", h->bulk_out.get()); Loading Loading @@ -221,7 +232,7 @@ static int usb_ffs_do_aio(usb_handle* h, const void* data, int len, bool read) { } } } } static int usb_ffs_aio_read(usb_handle* h, void* data, int len) { static int usb_ffs_aio_read(usb_handle* h, void* data, int len, bool allow_partial) { return usb_ffs_do_aio(h, data, len, true); return usb_ffs_do_aio(h, data, len, true); } } Loading Loading @@ -299,7 +310,7 @@ int usb_write(usb_handle* h, const void* data, int len) { } } int usb_read(usb_handle* h, void* data, int len) { int usb_read(usb_handle* h, void* data, int len) { return h->read(h, data, len); return h->read(h, data, len, false /* allow_partial */); } } int usb_close(usb_handle* h) { int usb_close(usb_handle* h) { Loading
base/mapped_file.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -76,7 +76,7 @@ MappedFile::~MappedFile() { if (base_ != nullptr) UnmapViewOfFile(base_); if (base_ != nullptr) UnmapViewOfFile(base_); if (handle_ != nullptr) CloseHandle(handle_); if (handle_ != nullptr) CloseHandle(handle_); #else #else if (base_ != nullptr) munmap(base_, size_); if (base_ != nullptr) munmap(base_, size_ + offset_); #endif #endif base_ = nullptr; base_ = nullptr; Loading
fastboot/device/usb_client.cpp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -255,7 +255,8 @@ ssize_t ClientUsbTransport::Read(void* data, size_t len) { size_t bytes_read_total = 0; size_t bytes_read_total = 0; while (bytes_read_total < len) { while (bytes_read_total < len) { auto bytes_to_read = std::min(len - bytes_read_total, kFbFfsNumBufs * kFbFfsBufSize); auto bytes_to_read = std::min(len - bytes_read_total, kFbFfsNumBufs * kFbFfsBufSize); auto bytes_read_now = handle_->read(handle_.get(), char_data, bytes_to_read); auto bytes_read_now = handle_->read(handle_.get(), char_data, bytes_to_read, true /* allow_partial */); if (bytes_read_now < 0) { if (bytes_read_now < 0) { return bytes_read_total; return bytes_read_total; } } Loading