I am trying to communicate with USB device from Android-based smartphone via OTG. I was able to communicate with my device using Android USB Host API. The problem of USB Host API solution is performance (single bulk transfer bounded by 16384 bytes).
The libusb can perform larger requests and now I am trying to integrate it using Android NDK. I succeeded to compile libusb sources for Android and even initUSB()
, but libusb_open(dev, &dev_handle)
returns -3 (Access denied).
How can I pass the file descriptor
int fd = connection.getFileDescriptor()
to libusb after getting USB_PERMISSION under Android USB Host API and get USB device access under libusb?
This is what you are looking for.
https://github.com/kuldeepdhaka/libusb/tree/android-open2
just compile it and drop it in. :)
see the "How To for Android" section for full usage.
i made all the required modification to libusb (and im also using it).
It has SELinux fix for "Android 5.0"+ too.