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>
This commit is contained in:
Dirk Hohndel 2020-03-15 12:27:10 -07:00
parent 4619b4932e
commit 0b72495413
5 changed files with 70 additions and 12 deletions

View file

@ -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)
{