Merge changes I2d005e17,If2eec162,Icfd642e6

am: 2683d0a2ca

Change-Id: Ib087d841618d328969ca2fa13990265b2d849d5d
This commit is contained in:
Josh Gao 2019-06-04 18:08:32 -07:00 committed by android-build-merger
commit 961b03661a
2 changed files with 33 additions and 1 deletions

View file

@ -370,6 +370,38 @@ 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(INFO) << "acking device-to-host control transfer";
ssize_t rc = adb_write(control_fd_.get(), "", 0);
if (rc != 0) {
PLOG(ERROR) << "failed to write empty packet to host";
break;
}
} 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;
}
}
}
}

View file

@ -299,6 +299,7 @@ bool open_functionfs(android::base::unique_fd* out_control, android::base::uniqu
}
// Signal only when writing the descriptors to ffs
android::base::SetProperty("sys.usb.ffs.ready", "1");
*out_control = std::move(control);
}
bulk_out.reset(adb_open(USB_FFS_ADB_OUT, O_RDONLY));
@ -313,7 +314,6 @@ bool open_functionfs(android::base::unique_fd* out_control, android::base::uniqu
return false;
}
*out_control = std::move(control);
*out_bulk_in = std::move(bulk_in);
*out_bulk_out = std::move(bulk_out);
return true;