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 --- .../org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'android-mobile/src') 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"); } -- cgit v1.2.3-70-g09d2