diff options
-rw-r--r-- | android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java | 4 | ||||
-rw-r--r-- | core/android.cpp | 17 |
2 files changed, 13 insertions, 8 deletions
diff --git a/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java b/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java index 52f401b71..c50dfb237 100644 --- a/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java +++ b/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java @@ -27,7 +27,7 @@ public class SubsurfaceMobileActivity extends QtActivity public static boolean isIntentPending; public static boolean isInitialized; private static final String TAG = "subsurfacedivelog.mobile"; - public static native void setDeviceString(String deviceString); + public static native void setUsbDevice(UsbDevice usbDevice); private static Context appContext; // we need to provide two endpoints: @@ -105,7 +105,7 @@ public class SubsurfaceMobileActivity extends QtActivity return; } Log.i(TAG + " processIntent device name", device.getDeviceName()); - setDeviceString(device.toString()); + setUsbDevice(device); } // processIntent 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; } |