From: Vianney le C. de Saint-M. <co...@qu...> - 2018-12-05 21:42:10
|
On Android, the platform API should be used to scan for and open devices and pass file descriptors to libusb. Newer devices (Android 5+) even prohibit listening for hotplug events, resulting in libusb failing to initialize without this patch. Note that this patch effectively renders libusb useless on older devices that do not have USB support in the platform API (anything before Android 5). Signed-off-by: Vianney le Clément de Saint-Marcq <co...@qu...> --- libusb/os/linux_usbfs.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 1689c4ec..a6b7963f 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -534,8 +534,10 @@ static int linux_start_event_monitor(void) { #if defined(USE_UDEV) return linux_udev_start_event_monitor(); -#else +#elif !defined(__ANDROID__) return linux_netlink_start_event_monitor(); +#else + return LIBUSB_SUCCESS; #endif } @@ -543,20 +545,22 @@ static int linux_stop_event_monitor(void) { #if defined(USE_UDEV) return linux_udev_stop_event_monitor(); -#else +#elif !defined(__ANDROID__) return linux_netlink_stop_event_monitor(); +#else + return LIBUSB_SUCCESS; #endif } static int linux_scan_devices(struct libusb_context *ctx) { - int ret; + int ret = 0; usbi_mutex_static_lock(&linux_hotplug_lock); #if defined(USE_UDEV) ret = linux_udev_scan_devices(ctx); -#else +#elif !defined(__ANDROID__) ret = linux_default_scan_devices(ctx); #endif @@ -569,7 +573,7 @@ static void op_hotplug_poll(void) { #if defined(USE_UDEV) linux_udev_hotplug_poll(); -#else +#elif !defined(__ANDROID__) linux_netlink_hotplug_poll(); #endif } -- 2.19.2 |