libimobiledevice/usbmuxd

libusb init error on android

hcropps opened this issue · 0 comments

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;
    		}`