summaryrefslogtreecommitdiffstats
path: root/core/android.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-15 12:27:10 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-16 07:58:20 -0700
commit0b72495413e8b060b58b96aa6d6a0ce96baa168c (patch)
tree6517fa914d2ffd9ba1317e100e8f92f419990430 /core/android.cpp
parent4619b4932eb2f75f8026b79e8a810ddf5f5fd7e9 (diff)
downloadsubsurface-0b72495413e8b060b58b96aa6d6a0ce96baa168c.tar.gz
android/usb: simply restart the download after receiving permission
If the user tries to download from a device that he hasn't given the app permission to read from, Android will pop up a dialogue asking for that permission. With this after giving the permission we continue (well, technically, restart) the download which is likely the expected behavior. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/android.cpp')
-rw-r--r--core/android.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/core/android.cpp b/core/android.cpp
index 0c4520ae4..b86f2e557 100644
--- a/core/android.cpp
+++ b/core/android.cpp
@@ -181,7 +181,7 @@ Java_org_subsurfacedivelog_mobile_SubsurfaceMobileActivity_setUsbDevice(JNIEnv *
if (usbDevice.isValid()) {
android_usb_serial_device_descriptor descriptor = getDescriptor(usbDevice);
- LOG(QString("called by intent for device %1").arg(QString::fromStdString(descriptor.uiRepresentation)));
+ LOG(QString("called by connect intent for device %1").arg(QString::fromStdString(descriptor.uiRepresentation)));
}
#if defined(SUBSURFACE_MOBILE)
QMLManager::instance()->showDownloadPage(usbDevice);
@@ -189,6 +189,25 @@ Java_org_subsurfacedivelog_mobile_SubsurfaceMobileActivity_setUsbDevice(JNIEnv *
return;
}
+JNIEXPORT void JNICALL
+Java_org_subsurfacedivelog_mobile_SubsurfaceMobileActivity_restartDownload(JNIEnv *env,
+ jobject obj,
+ jobject javaUsbDevice)
+{
+ Q_UNUSED (obj)
+ Q_UNUSED (env)
+ QAndroidJniObject usbDevice(javaUsbDevice);
+ if (usbDevice.isValid()) {
+ android_usb_serial_device_descriptor descriptor = getDescriptor(usbDevice);
+
+ LOG(QString("called by permission granted intent for device %1").arg(QString::fromStdString(descriptor.uiRepresentation)));
+ }
+#if defined(SUBSURFACE_MOBILE)
+ QMLManager::instance()->restartDownload(usbDevice);
+#endif
+ return;
+}
+
/* NOP wrappers to comform with windows.c */
int subsurface_rename(const char *path, const char *newpath)
{