Android app “Device or resource busy” when accessing USB device via JNA

ぃ、小莉子 提交于 2020-01-03 02:47:12

问题


In making use of JNA in an Android app, I encounter a LastErrorException with the message Device or resource busy when I attempt 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 guidance at all?

I am in fact using a 3rd-party snippet, whose source is viewable here.

The error I get reads 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 up 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;
}

来源:https://stackoverflow.com/questions/37356148/android-app-device-or-resource-busy-when-accessing-usb-device-via-jna

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!