aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2018-06-30 17:50:15 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-11 11:14:22 -0700
commit8b37e3f10e072fc92814a65ccd2c6c5c653a7557 (patch)
tree3ec3235cc7267dc3ace19e88dc4a36cd216f5c69
parent2ca8b9809130ea6822a37f73835abbdc93faf3c3 (diff)
downloadsubsurface-8b37e3f10e072fc92814a65ccd2c6c5c653a7557.tar.gz
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>
-rw-r--r--core/android.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/android.cpp b/core/android.cpp
index d9dbf27e2..865a0ad7e 100644
--- a/core/android.cpp
+++ b/core/android.cpp
@@ -112,6 +112,7 @@ int get_usb_fd(uint16_t idVendor, uint16_t idProduct)
jint num_devices = deviceMap.callMethod<jint>("size", "()I");
if (num_devices == 0) {
// No USB device is attached.
+ LOG("usbManager says no devices attached");
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());
vendorid = usbDevice.callMethod<jint>("getVendorId", "()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
break;
}
if (i == num_devices) {
// No device found.
+ LOG(QString("Didn't find device matching %1/%2").arg(idVendor).arg(idProduct))
errno = ENOENT;
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.
// Please remove and reinsert the USB device.
// Could also give an dialogbox asking for permission.
+ LOG("usbManager tells us we don't have permission to access this device");
errno = EPERM;
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());
if (usbDeviceConnection.object() == NULL) {
// Some error occurred while opening the device. Exit.
+ LOG("usbManager said we had permission to access, but then opening the device failed");
errno = EINVAL;
return -1;
}
@@ -155,6 +160,7 @@ int get_usb_fd(uint16_t idVendor, uint16_t idProduct)
fd = usbDeviceConnection.callMethod<jint>("getFileDescriptor", "()I");
if (fd == -1) {
// The device is not opened. Some error.
+ LOG("usbManager said we successfully opened the device, but the fd was -1");
errno = ENODEV;
return -1;
}