Repository navigation
Conversation
|
Hello chrisju, I was able to sucessfuly test your commit on unrooted Android 8. Thanks for publishing. |
|
@mcuee Can you add the bug label to this MR.? Current master not work in android apk, and |
|
Instead of adding a new public initializer ( |
If so, when developing other than android apk, you will not get the error correctly. |
|
Please, no. There doesn't need to be a new function for this. Something like |
|
Good point. We should use libusb_set_option() if possible, I remember that was introduced for usbdk. |
|
@chrisju Would you please rework the patch based on the suggestion from Chris? |
|
|
I also have a fork of libusb that supports unrooted android. My approach was to add a new API called libusb_import_android_fd. This allows an android app to get a valid device FD from the java android.hardware.usb.UsbManager API, and pass this into libusb. The next call to libusb_get_device_list() will then return a valid libusb_device that wraps the FD. |
If you want to use as a general library, you need to consider rooted use on Android. |
There is nothing requiring |
dickens
left a comment
There was a problem hiding this comment.
Please fix the whitespace in your change. You need to use tabs.
|
I also think this should be guarded in linux_usbfs.c with |
…K_AUTHORITY not supported on Linux
| UNUSED(ctx); | ||
| UNUSED(ap); | ||
|
|
||
| switch ((int)option) { |
There was a problem hiding this comment.
Why is there a cast here? Is it to avoid a compiler warning, or is it copied from windows_common.c?
There was a problem hiding this comment.
Copied from windows_common.c to avoid a compiler warning, op_exit in linux_usbfs.c also has that.
There was a problem hiding this comment.
jni/../../libusb/os/linux_usbfs.c:427:49: warning: unused parameter 'ctx' [-Wunused-parameter]
static int op_set_option(struct libusb_context *ctx, enum libusb_option option, va_list ap)
^
jni/../../libusb/os/linux_usbfs.c:427:89: warning: unused parameter 'ap' [-Wunused-parameter]
static int op_set_option(struct libusb_context *ctx, enum libusb_option option, va_list ap)
There was a problem hiding this comment.
I think the question was about the cast in (int)option
There was a problem hiding this comment.
Exactly. Casting to an int for the switch is odd.
There was a problem hiding this comment.
Sorry i misunderstood. Thank LudovicRousseau. The cast (int)option is just copied from windows_common.c.
There was a problem hiding this comment.
I have removed the cast in commit 86997c8.
|
Hello. I am using Android 9. |
On unrooted Android, we can not operate usb directly and need use
libusb_wrap_sys_device, we also will failed onlinux_scan_devices. For 1.0.23, before commit211d791, libusb can not work with rooted android. After commit211d791, libusb can not work with unrooted android. Libusb can not know if it has authority to scan devices, so i addlibusb_init_exto specify it manually.