adbd: read, print, and ignore USB control transfers.
It seems like we're blowing up when receiving a control transfer that's
intended for Android Auto, because we're not expecting to get the data
for the control transfer in a subsequent read.
Bug: http://b/131867920
Test: none
Change-Id: Icfd642e6dfc02d2ccbdd60c39f89e534298c944d
Merged-In: Icfd642e6dfc02d2ccbdd60c39f89e534298c944d
(cherry-picked from internal commit 12807c7012
)
This commit is contained in:
parent
3c94eaad5f
commit
fc2e2003dd
|
@ -370,6 +370,33 @@ struct UsbFfsConnection : public Connection {
|
|||
bound = false;
|
||||
running = false;
|
||||
break;
|
||||
|
||||
case FUNCTIONFS_SETUP: {
|
||||
LOG(INFO) << "received FUNCTIONFS_SETUP control transfer: bRequestType = "
|
||||
<< static_cast<int>(event.u.setup.bRequestType)
|
||||
<< ", bRequest = " << static_cast<int>(event.u.setup.bRequest)
|
||||
<< ", wValue = " << static_cast<int>(event.u.setup.wValue)
|
||||
<< ", wIndex = " << static_cast<int>(event.u.setup.wIndex)
|
||||
<< ", wLength = " << static_cast<int>(event.u.setup.wLength);
|
||||
|
||||
if ((event.u.setup.bRequestType & USB_DIR_IN)) {
|
||||
LOG(WARNING) << "received a device-to-host control transfer, ignoring";
|
||||
} else {
|
||||
std::string buf;
|
||||
buf.resize(event.u.setup.wLength + 1);
|
||||
|
||||
ssize_t rc = adb_read(control_fd_.get(), buf.data(), buf.size());
|
||||
if (rc != event.u.setup.wLength) {
|
||||
LOG(ERROR)
|
||||
<< "read " << rc
|
||||
<< " bytes when trying to read control request, expected "
|
||||
<< event.u.setup.wLength;
|
||||
}
|
||||
|
||||
LOG(INFO) << "control request contents: " << buf;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue