mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +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 isIntentPending;
|
||||||
public static boolean isInitialized;
|
public static boolean isInitialized;
|
||||||
private static final String TAG = "subsurfacedivelog.mobile";
|
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;
|
private static Context appContext;
|
||||||
|
|
||||||
// we need to provide two endpoints:
|
// we need to provide two endpoints:
|
||||||
|
@ -105,7 +105,7 @@ public class SubsurfaceMobileActivity extends QtActivity
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.i(TAG + " processIntent device name", device.getDeviceName());
|
Log.i(TAG + " processIntent device name", device.getDeviceName());
|
||||||
setDeviceString(device.toString());
|
setUsbDevice(device);
|
||||||
} // processIntent
|
} // processIntent
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <QtAndroidExtras/QAndroidJniObject>
|
#include <QtAndroidExtras/QAndroidJniObject>
|
||||||
#include <QtAndroid>
|
#include <QtAndroid>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <core/serial_usb_android.h>
|
||||||
|
|
||||||
#if defined(SUBSURFACE_MOBILE)
|
#if defined(SUBSURFACE_MOBILE)
|
||||||
#include "mobile-widgets/qmlmanager.h"
|
#include "mobile-widgets/qmlmanager.h"
|
||||||
|
@ -170,17 +171,21 @@ int get_usb_fd(uint16_t idVendor, uint16_t idProduct)
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_subsurfacedivelog_mobile_SubsurfaceMobileActivity_setDeviceString(JNIEnv *env,
|
Java_org_subsurfacedivelog_mobile_SubsurfaceMobileActivity_setUsbDevice(JNIEnv *env,
|
||||||
jobject obj,
|
jobject obj,
|
||||||
jstring javaDeviceString)
|
jobject javaUsbDevice)
|
||||||
{
|
{
|
||||||
const char *deviceString = env->GetStringUTFChars(javaDeviceString, NULL);
|
|
||||||
Q_UNUSED (obj)
|
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)
|
#if defined(SUBSURFACE_MOBILE)
|
||||||
QMLManager::instance()->showDownloadPage(deviceString);
|
QMLManager::instance()->showDownloadPage(usbDevice);
|
||||||
#endif
|
#endif
|
||||||
env->ReleaseStringUTFChars(javaDeviceString, deviceString);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue