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

Commit 2683d0a2 authored by Josh Gao's avatar Josh Gao Committed by Gerrit Code Review
Browse files

Merge changes I2d005e17,If2eec162,Icfd642e6

* changes:
  adb: daemon: Assign valid fd to usb_handle ep0 file descriptor
  adbd: respond to device-to-host control transfers.
  adbd: read, print, and ignore USB control transfers.
parents a891ffdd 1cbe5edb
Loading
Loading
Loading
Loading
+32 −0
Original line number Original line Diff line number Diff line
@@ -370,6 +370,38 @@ struct UsbFfsConnection : public Connection {
                        bound = false;
                        bound = false;
                        running = false;
                        running = false;
                        break;
                        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;
                        }
                    }
                }
                }
            }
            }


+1 −1
Original line number Original line Diff line number Diff line
@@ -299,6 +299,7 @@ bool open_functionfs(android::base::unique_fd* out_control, android::base::uniqu
        }
        }
        // Signal only when writing the descriptors to ffs
        // Signal only when writing the descriptors to ffs
        android::base::SetProperty("sys.usb.ffs.ready", "1");
        android::base::SetProperty("sys.usb.ffs.ready", "1");
        *out_control = std::move(control);
    }
    }


    bulk_out.reset(adb_open(USB_FFS_ADB_OUT, O_RDONLY));
    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;
        return false;
    }
    }


    *out_control = std::move(control);
    *out_bulk_in = std::move(bulk_in);
    *out_bulk_in = std::move(bulk_in);
    *out_bulk_out = std::move(bulk_out);
    *out_bulk_out = std::move(bulk_out);
    return true;
    return true;