On newer Android devices (5+), SELinux policies block normal processes
from reading /dev. The consequence is that the usbfs path cannot be
found. Rather than failing to initialize libusb in such case, fall back
to /dev/bus/usb. This path will actually not be used, as USB devices
should be opened through the Android API, passing the file descriptor to
libusb_wrap_sys_device.
Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
/* On udev based systems without any usb-devices /dev/bus/usb will not
* exist. So if we've not found anything and we're using udev for hotplug
- * simply assume /dev/bus/usb rather then making libusb_init fail. */
-#if defined(USE_UDEV)
+ * simply assume /dev/bus/usb rather then making libusb_init fail.
+ * Make the same assumption for Android where SELinux policies might block us
+ * from reading /dev on newer devices. */
+#if defined(USE_UDEV) || defined(__ANDROID__)
if (ret == NULL)
ret = "/dev/bus/usb";
#endif
-#define LIBUSB_NANO 11337
+#define LIBUSB_NANO 11338