mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
4619b4932e
commit
0b72495413
5 changed files with 70 additions and 12 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue