aboutsummaryrefslogtreecommitdiffstats
path: root/android-mobile/src
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 /android-mobile/src
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 'android-mobile/src')
-rw-r--r--android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java b/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
index 0d6e5bbe1..b9bc216d2 100644
--- a/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
+++ b/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
@@ -28,6 +28,7 @@ public class SubsurfaceMobileActivity extends QtActivity
public static boolean isInitialized;
private static final String TAG = "subsurfacedivelog.mobile";
public static native void setUsbDevice(UsbDevice usbDevice);
+ public static native void restartDownload(UsbDevice usbDevice);
private static Context appContext;
// we need to provide two endpoints:
@@ -116,8 +117,13 @@ public class SubsurfaceMobileActivity extends QtActivity
if ("org.subsurfacedivelog.mobile.USB_PERMISSION".equals(action)) {
synchronized (this) {
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
- Log.d(TAG, "USB device permission granted");
- setUsbDevice(null);
+ UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
+ if (device == null) {
+ Log.i(TAG, " permission granted but null device");
+ return;
+ }
+ Log.d(TAG, "USB device permission granted for " + device.getDeviceName());
+ restartDownload(device);
} else {
Log.d(TAG, "USB device permission denied");
}