Skip to content

Unable to open HID device in android (SELinux prevents it) #461

Answered by Youw
tpkarras asked this question in Q&A
Discussion options

You must be logged in to vote

That's what I was trying to say in my first answer: hid_open will not work on Android.

What you need to do:

  1. Get Android permission to open your USB device of interest:
    usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
    HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList();
    for (UsbDevice usbDevice : deviceList.values()) {
        usbManager.requestPermission(usbDevice, mPermissionIntent);
    }
  1. Open that device (if user has granted the permission):
    UsbDeviceConnection usbDeviceConnection = usbManager.openDevice(camDevice);
    int fileDescriptor = usbDeviceConnection.getFileDescriptor();
  1. Open the device using hid_libusb_wrap_sys_device:
    P…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
3 replies
@tpkarras
Comment options

@Youw
Comment options

@tpkarras
Comment options

Comment options

You must be logged in to vote
4 replies
@Youw
Comment options

@tpkarras
Comment options

@Youw
Comment options

Answer selected by mcuee
@Youw
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants