Android app "Device or resource busy" when accessing a USB device via JNA

When using JNA in an Android app, I encounter a LastErrorException with the message Device or resource busy when I try to perform an ioctl operation on a USB device. I cannot guess why this is or what to do about it. Can anyone offer any recommendations at all?

I actually use a third-party fragment, the source of which is available for viewing here .

The error I am getting is as follows:

 E/AndroidRuntime: FATAL EXCEPTION: Thread-556 Process: edu.ucdavis.auditoryenhancer, PID: 31335 com.sun.jna.LastErrorException: [16] Device or resource busy at com.sun.jna.Native.invokeInt(Native Method) at com.sun.jna.Function.invoke(Function.java:390) at com.sun.jna.Function.invoke(Function.java:323) at com.sun.jna.Library$Handler.invoke(Library.java:236) at java.lang.reflect.Proxy.invoke(Proxy.java:393) at biz.source_code.usb.$Proxy0.ioctl(Unknown Source) at biz.source_code.usb.UsbIso.setInterface(UsbIso.java:414) 

My own code that leads to this error stack is as follows:

 // the variable "dev" is an instance of android.hardware.usb.UsbDevice UsbInterface interface = dev.getInterface(2); UsbEndpoint endpoint = dev.getEndpoint(0); UsbDeviceConnection connection = usbMgr.openDevice(dev); new UsbIso(connection.getFileDescriptor(), 1, endpoint.getMaxPacketSize()); try { usbIso.setInterface(getInterfaceNumber(), getAlternateSetting()); } catch (IOException e) { e.printStackTrace(); return false; } 
+1
source share

Source: https://habr.com/ru/post/906164/


All Articles