mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
c19e3bd5ba
commit
b0eccec8ed
2 changed files with 13 additions and 8 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue