From 0b72495413e8b060b58b96aa6d6a0ce96baa168c Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 15 Mar 2020 12:27:10 -0700 Subject: 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 --- core/android.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'core') 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) { -- cgit v1.2.3-70-g09d2