Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using libusb on Android without rooting

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?

like image 798
user2335095 Avatar asked Apr 30 '13 14:04

user2335095


1 Answers

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.

like image 97
Kuldeep Dhaka Avatar answered Oct 17 '22 13:10

Kuldeep Dhaka