From b0eccec8ed330d000e88b01404a30cc610d93ee2 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 14 Mar 2020 17:57:36 -0700 Subject: 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 --- core/android.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'core/android.cpp') 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 #include #include +#include #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; } -- cgit v1.2.3-70-g09d2