Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libusb init error on android #201

Open
hcropps opened this issue Oct 10, 2022 · 0 comments
Open

libusb init error on android #201

hcropps opened this issue Oct 10, 2022 · 0 comments

Comments

@hcropps
Copy link

hcropps commented Oct 10, 2022

I want to run usbmuxd on android. But usbmuxd cannot run libusb. When I run libusby via jni in c file it works and sees the device. But when I init via usbmuxd it doesn't work. I added the following code to init.

`
int usb_init_android(int fileDescriptor)
{
int res;
const struct libusb_version* libusb_version_info = libusb_get_version();

devlist_failures = 0;
device_polling = 1;

libusb_context *ctx = NULL;
    libusb_device_handle *devh = NULL;
    int r = 0;
    //r = libusb_set_option(NULL, LIBUSB_OPTION_NO_DEVICE_DISCOVERY, NULL);
 r = libusb_set_option(&ctx, LIBUSB_OPTION_NO_DEVICE_DISCOVERY, NULL);
    if (r != LIBUSB_SUCCESS) {
	usbmuxd_log(LL_NOTICE, "libusb_set_option failed: %d\n", r);
	return -1;
    }
    r = libusb_init(&ctx);
    if (r < 0) {
	usbmuxd_log(LL_NOTICE, "libusb_init failed: %d\n", r);
	return r;
    }
    r = libusb_wrap_sys_device(ctx, (intptr_t)fileDescriptor, &devh);
    if (r < 0) {
	    usbmuxd_log(LL_NOTICE, "libusb_wrap_sys_device failed 111: %d\n", r);
	  r = libusb_wrap_sys_device(NULL, (intptr_t)fileDescriptor, &devh);
	    if (r < 0) {		    
		usbmuxd_log(LL_NOTICE, "libusb_wrap_sys_device failed 222: %d\n", r);
		return r;
    		}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant