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

@ -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");
}