• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/core


Commit MetaInfo

Revisão6c78e3ba1b7f8b5d54c36d240efb89418a964957 (tree)
Hora2019-05-30 08:35:22
Autorchihhao.chen <chihhao.chen@medi...>
Commiterandroid-build-merger

Mensagem de Log

Merge "Fix non-aio USB read issue for fastbootd" into qt-dev
am: 9122289a97

Change-Id: Id416f267f477d04ed5d71f2158ebc35183befa22

Mudança Sumário

Diff

--- a/adb/daemon/include/adbd/usb.h
+++ b/adb/daemon/include/adbd/usb.h
@@ -43,7 +43,7 @@ struct usb_handle {
4343 bool open_new_connection = true;
4444
4545 int (*write)(usb_handle* h, const void* data, int len);
46- int (*read)(usb_handle* h, void* data, int len);
46+ int (*read)(usb_handle* h, void* data, int len, bool allow_partial);
4747 void (*kick)(usb_handle* h);
4848 void (*close)(usb_handle* h);
4949
--- a/adb/daemon/usb_legacy.cpp
+++ b/adb/daemon/usb_legacy.cpp
@@ -142,11 +142,12 @@ static int usb_ffs_write(usb_handle* h, const void* data, int len) {
142142 return orig_len;
143143 }
144144
145-static int usb_ffs_read(usb_handle* h, void* data, int len) {
145+static int usb_ffs_read(usb_handle* h, void* data, int len, bool allow_partial) {
146146 D("about to read (fd=%d, len=%d)", h->bulk_out.get(), len);
147147
148148 char* buf = static_cast<char*>(data);
149149 int orig_len = len;
150+ unsigned count = 0;
150151 while (len > 0) {
151152 int read_len = std::min(USB_FFS_BULK_SIZE, len);
152153 int n = adb_read(h->bulk_out, buf, read_len);
@@ -156,6 +157,16 @@ static int usb_ffs_read(usb_handle* h, void* data, int len) {
156157 }
157158 buf += n;
158159 len -= n;
160+ count += n;
161+
162+ // For fastbootd command such as "getvar all", len parameter is always set 64.
163+ // But what we read is actually less than 64.
164+ // For example, length 10 for "getvar all" command.
165+ // If we get less data than expected, this means there should be no more data.
166+ if (allow_partial && n < read_len) {
167+ orig_len = count;
168+ break;
169+ }
159170 }
160171
161172 D("[ done fd=%d ]", h->bulk_out.get());
@@ -221,7 +232,7 @@ static int usb_ffs_do_aio(usb_handle* h, const void* data, int len, bool read) {
221232 }
222233 }
223234
224-static int usb_ffs_aio_read(usb_handle* h, void* data, int len) {
235+static int usb_ffs_aio_read(usb_handle* h, void* data, int len, bool allow_partial) {
225236 return usb_ffs_do_aio(h, data, len, true);
226237 }
227238
@@ -299,7 +310,7 @@ int usb_write(usb_handle* h, const void* data, int len) {
299310 }
300311
301312 int usb_read(usb_handle* h, void* data, int len) {
302- return h->read(h, data, len);
313+ return h->read(h, data, len, false /* allow_partial */);
303314 }
304315
305316 int usb_close(usb_handle* h) {
--- a/fastboot/device/usb_client.cpp
+++ b/fastboot/device/usb_client.cpp
@@ -255,7 +255,8 @@ ssize_t ClientUsbTransport::Read(void* data, size_t len) {
255255 size_t bytes_read_total = 0;
256256 while (bytes_read_total < len) {
257257 auto bytes_to_read = std::min(len - bytes_read_total, kFbFfsNumBufs * kFbFfsBufSize);
258- auto bytes_read_now = handle_->read(handle_.get(), char_data, bytes_to_read);
258+ auto bytes_read_now =
259+ handle_->read(handle_.get(), char_data, bytes_to_read, true /* allow_partial */);
259260 if (bytes_read_now < 0) {
260261 return bytes_read_total;
261262 }