From: Vianney le C. de Saint-M. <co...@qu...> - 2018-12-05 21:42:18
|
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 <co...@qu...> --- libusb/os/linux_usbfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 2e7add45..1689c4ec 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -341,8 +341,10 @@ static const char *find_usbfs_path(void) /* 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 -- 2.19.2 |