system/core
Révision | cea1c6248b6993565b90eb8ea3020ad851ba4e29 (tree) |
---|---|
l'heure | 2019-05-21 09:29:18 |
Auteur | Josh Gao <jmgao@goog...> |
Commiter | android-build-merger |
Merge "adbd: read, print, and ignore USB control transfers." into qt-dev
am: 6031286936
Change-Id: Iff482249f9442a851e2681869babc2bcb081385b
@@ -364,6 +364,33 @@ struct UsbFfsConnection : public Connection { | ||
364 | 364 | bound = false; |
365 | 365 | running = false; |
366 | 366 | break; |
367 | + | |
368 | + case FUNCTIONFS_SETUP: { | |
369 | + LOG(INFO) << "received FUNCTIONFS_SETUP control transfer: bRequestType = " | |
370 | + << static_cast<int>(event.u.setup.bRequestType) | |
371 | + << ", bRequest = " << static_cast<int>(event.u.setup.bRequest) | |
372 | + << ", wValue = " << static_cast<int>(event.u.setup.wValue) | |
373 | + << ", wIndex = " << static_cast<int>(event.u.setup.wIndex) | |
374 | + << ", wLength = " << static_cast<int>(event.u.setup.wLength); | |
375 | + | |
376 | + if ((event.u.setup.bRequestType & USB_DIR_IN)) { | |
377 | + LOG(WARNING) << "received a device-to-host control transfer, ignoring"; | |
378 | + } else { | |
379 | + std::string buf; | |
380 | + buf.resize(event.u.setup.wLength + 1); | |
381 | + | |
382 | + ssize_t rc = adb_read(control_fd_.get(), buf.data(), buf.size()); | |
383 | + if (rc != event.u.setup.wLength) { | |
384 | + LOG(ERROR) | |
385 | + << "read " << rc | |
386 | + << " bytes when trying to read control request, expected " | |
387 | + << event.u.setup.wLength; | |
388 | + } | |
389 | + | |
390 | + LOG(INFO) << "control request contents: " << buf; | |
391 | + break; | |
392 | + } | |
393 | + } | |
367 | 394 | } |
368 | 395 | } |
369 | 396 |