diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-03-14 18:11:46 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-03-16 07:58:20 -0700 |
commit | ec3a968df9d8fc706fedb788959631e2ed84e04b (patch) | |
tree | aaa56de98ae2a861aef1d9bc2ab78fe05f06f745 /core/serial_usb_android.cpp | |
parent | 1495aa2dbf5366cc135c1ceb959c6a12abbb3e0b (diff) | |
download | subsurface-ec3a968df9d8fc706fedb788959631e2ed84e04b.tar.gz |
android/usb: pass in the UsbDevice when downloading
This finally allows us to download from not just the first device, but specifically
the device that the user picks.
Passing the object through a void pointer is not nice - but since this traverses
C code other solutions (like passing an index into the list) seemed even worse.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/serial_usb_android.cpp')
-rw-r--r-- | core/serial_usb_android.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/core/serial_usb_android.cpp b/core/serial_usb_android.cpp index 8da56b510..7583f5011 100644 --- a/core/serial_usb_android.cpp +++ b/core/serial_usb_android.cpp @@ -348,13 +348,12 @@ std::vector<android_usb_serial_device_descriptor> serial_usb_android_get_devices * For testing and compatibility only, can be removed after the UI changes. Behaves exactly like the "old" * implementation if only one device is attached. */ -dc_status_t serial_usb_android_open(dc_iostream_t **iostream, dc_context_t *context) +dc_status_t serial_usb_android_open(dc_iostream_t **iostream, dc_context_t *context, void *androidUsbDevice) { - std::vector<android_usb_serial_device_descriptor> devices = serial_usb_android_get_devices(); - - if(devices.empty()) + if (!androidUsbDevice) return DC_STATUS_NODEVICE; + android_usb_serial_device_descriptor *usbDeviceDescriptor = (android_usb_serial_device_descriptor *)androidUsbDevice; - return serial_usb_android_open(iostream, context, devices[0].usbDevice, devices[0].className); - + // danger, danger, we need to pick the correct device here - passing the index around assumes that the table didn't change + return serial_usb_android_open(iostream, context, usbDeviceDescriptor->usbDevice, usbDeviceDescriptor->className); } |