Write descriptors for Mtp in UsbService
The current model for setting up a functionfs function is: UsbDeviceManager#setCurrentFunctions() -> intent is sent to MtpReceiver to write the descriptors -> init/hal waits for descriptors to write, then pulls up gadget -> Gadget is configured, a USB_STATE intent starts MtpServer The main downside of this is a lack of reliability because the Mtp process could be killed at any point. Normally, a gadget is unbound if its control endpoint is closed. no_disconnect works around this, but is still a little janky. In addition, the extra intent delays the startup of the gadget. With the new model, UsbDeviceManager writes the descriptors on initialization. Since it is a system service, it won't be killed. UsbDeviceManager#setCurrentFunctions() -> init/hal pulls up gadget -> Gadget is configured, a USB_STATE intent starts MtpServer MtpServer calls UsbManager#getControlFd to get a dup of the control endpoint. Also modify permissions so system server can access mtp files. Bug: 72877174 Test: Change usb configurations to ptp/mtp Change-Id: Id17d2b5930f4e1f37ec1b4f00add9d594174ad49
Loading
Please register or sign in to comment