Android USB HID requires and frees up an interface around bulktranfer?
Now I am talking to the HID Android USB host with the device. I have one read point and one write in one interface. On android host i am doing
UsbInterface Intf = _usbDevice.getInterface(0);
UsbEndpoint Ep = Intf.getEndpoint(1);
UsbDeviceConnection Connection = _usbManager.openDevice(_usbDevice);
Connection.claimInterface(Intf, true);
Connection.bulkTransfer(Ep, data, data.length, 0);
Connection.releaseInterface(Intf);
Connection.close();
So, for writing, I require: interface interface -> transfer -> release -> close
For reading purposes, I am doing the same on a different thread.
Do I need to open, request, release and close an interface every time I read or write on one of the two endpoints (both endpoints in the same interface)? Or can I open, request, release, and close at the beginning and end of my program, and during the program lifecycle, read and write to endpoints without asking and releasing every time around bulktransfer?
source to share
In my case (LG G4, Android 5. *), I have defined the private statics of all the objects needed (UsbDeviceConnection, UsbEndpoint, UsbInterface, etc.).
I am doing all the progress that Android has written on the usb host page .
After initialization is done, I use queue () and requestWait () on the endpoints to communicate with the initialized device until the user releases the device.
So I don't think you need to always do your chain: declare interface interface -> transfer -> release -> close ...
source to share