mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Android: add more verbose logging when trying to open USB
The goal is to be able to tell what's actually going wrong. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2ca8b98091
commit
8b37e3f10e
1 changed files with 6 additions and 0 deletions
|
@ -112,6 +112,7 @@ int get_usb_fd(uint16_t idVendor, uint16_t idProduct)
|
||||||
jint num_devices = deviceMap.callMethod<jint>("size", "()I");
|
jint num_devices = deviceMap.callMethod<jint>("size", "()I");
|
||||||
if (num_devices == 0) {
|
if (num_devices == 0) {
|
||||||
// No USB device is attached.
|
// No USB device is attached.
|
||||||
|
LOG("usbManager says no devices attached");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,11 +125,13 @@ int get_usb_fd(uint16_t idVendor, uint16_t idProduct)
|
||||||
usbDevice = deviceMap.callObjectMethod ("get", "(Ljava/lang/Object;)Ljava/lang/Object;", usbName.object());
|
usbDevice = deviceMap.callObjectMethod ("get", "(Ljava/lang/Object;)Ljava/lang/Object;", usbName.object());
|
||||||
vendorid = usbDevice.callMethod<jint>("getVendorId", "()I");
|
vendorid = usbDevice.callMethod<jint>("getVendorId", "()I");
|
||||||
productid = usbDevice.callMethod<jint>("getProductId", "()I");
|
productid = usbDevice.callMethod<jint>("getProductId", "()I");
|
||||||
|
LOG(QString("Looking at device with VID/PID %1/%2").arg(vendorid).arg(productid));
|
||||||
if(vendorid == idVendor && productid == idProduct) // Found the requested device
|
if(vendorid == idVendor && productid == idProduct) // Found the requested device
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == num_devices) {
|
if (i == num_devices) {
|
||||||
// No device found.
|
// No device found.
|
||||||
|
LOG(QString("Didn't find device matching %1/%2").arg(idVendor).arg(idProduct))
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -138,6 +141,7 @@ int get_usb_fd(uint16_t idVendor, uint16_t idProduct)
|
||||||
// You do not have permission to use the usbDevice.
|
// You do not have permission to use the usbDevice.
|
||||||
// Please remove and reinsert the USB device.
|
// Please remove and reinsert the USB device.
|
||||||
// Could also give an dialogbox asking for permission.
|
// Could also give an dialogbox asking for permission.
|
||||||
|
LOG("usbManager tells us we don't have permission to access this device");
|
||||||
errno = EPERM;
|
errno = EPERM;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -147,6 +151,7 @@ int get_usb_fd(uint16_t idVendor, uint16_t idProduct)
|
||||||
QAndroidJniObject usbDeviceConnection = usbManager.callObjectMethod("openDevice", "(Landroid/hardware/usb/UsbDevice;)Landroid/hardware/usb/UsbDeviceConnection;", usbDevice.object());
|
QAndroidJniObject usbDeviceConnection = usbManager.callObjectMethod("openDevice", "(Landroid/hardware/usb/UsbDevice;)Landroid/hardware/usb/UsbDeviceConnection;", usbDevice.object());
|
||||||
if (usbDeviceConnection.object() == NULL) {
|
if (usbDeviceConnection.object() == NULL) {
|
||||||
// Some error occurred while opening the device. Exit.
|
// Some error occurred while opening the device. Exit.
|
||||||
|
LOG("usbManager said we had permission to access, but then opening the device failed");
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -155,6 +160,7 @@ int get_usb_fd(uint16_t idVendor, uint16_t idProduct)
|
||||||
fd = usbDeviceConnection.callMethod<jint>("getFileDescriptor", "()I");
|
fd = usbDeviceConnection.callMethod<jint>("getFileDescriptor", "()I");
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
// The device is not opened. Some error.
|
// The device is not opened. Some error.
|
||||||
|
LOG("usbManager said we successfully opened the device, but the fd was -1");
|
||||||
errno = ENODEV;
|
errno = ENODEV;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue