diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-03-14 17:57:36 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-03-16 07:58:20 -0700 |
commit | b0eccec8ed330d000e88b01404a30cc610d93ee2 (patch) | |
tree | cb28b26e4f8af3c35692239790daabfe3c3299c3 /core | |
parent | c19e3bd5ba1fa18d90c14643bf4321029f7b01fe (diff) | |
download | subsurface-b0eccec8ed330d000e88b01404a30cc610d93ee2.tar.gz |
android/usb: pass the usbDevice for intent handling
Instead of creating a string with all the object information, simply pass
the actual object to the C++ code.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/android.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/core/android.cpp b/core/android.cpp index a58da2ead..0c4520ae4 100644 --- a/core/android.cpp +++ b/core/android.cpp @@ -17,6 +17,7 @@ #include <QtAndroidExtras/QAndroidJniObject> #include <QtAndroid> #include <QDebug> +#include <core/serial_usb_android.h> #if defined(SUBSURFACE_MOBILE) #include "mobile-widgets/qmlmanager.h" @@ -170,17 +171,21 @@ int get_usb_fd(uint16_t idVendor, uint16_t idProduct) } JNIEXPORT void JNICALL -Java_org_subsurfacedivelog_mobile_SubsurfaceMobileActivity_setDeviceString(JNIEnv *env, +Java_org_subsurfacedivelog_mobile_SubsurfaceMobileActivity_setUsbDevice(JNIEnv *env, jobject obj, - jstring javaDeviceString) + jobject javaUsbDevice) { - const char *deviceString = env->GetStringUTFChars(javaDeviceString, NULL); Q_UNUSED (obj) - LOG(deviceString); + Q_UNUSED (env) + QAndroidJniObject usbDevice(javaUsbDevice); + if (usbDevice.isValid()) { + android_usb_serial_device_descriptor descriptor = getDescriptor(usbDevice); + + LOG(QString("called by intent for device %1").arg(QString::fromStdString(descriptor.uiRepresentation))); + } #if defined(SUBSURFACE_MOBILE) - QMLManager::instance()->showDownloadPage(deviceString); + QMLManager::instance()->showDownloadPage(usbDevice); #endif - env->ReleaseStringUTFChars(javaDeviceString, deviceString); return; } |