linux_usbfs: Disable hotplug events and scanning on Android

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).

Closes #242

Signed-off-by: Vianney le Clément de Saint-Marcq <code@quartic.eu>
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
This commit is contained in:
Vianney le Clément de Saint-Marcq 2016-12-13 15:04:11 +01:00 committed by Nathan Hjelm
parent ad075f6ecf
commit 2f3bc98b0d
2 changed files with 10 additions and 6 deletions

View file

@ -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
}

View file

@ -1 +1 @@
#define LIBUSB_NANO 11338
#define LIBUSB_NANO 11339