Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e85a267 authored by Josh Gao's avatar Josh Gao Committed by android-build-merger
Browse files

Merge "adbd: read, print, and ignore USB control transfers." into qt-dev am: 60312869

am: 26a6faf0

Change-Id: I8ba21f777ef74625bc53cab5be549ef59337b6aa
parents c1cb371e 26a6faf0
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -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;
                        }
                    }
                }
            }