aboutsummaryrefslogtreecommitdiffstats
path: root/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
diff options
context:
space:
mode:
authorGravatar Christof Arnosti <charno@charno.ch>2020-03-14 18:17:05 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-16 07:58:20 -0700
commitd953c645e96aea092952653adb92280fe4c225f8 (patch)
tree0f1046977e246a773d4b4420e7877edfe426ae35 /android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
parentce7d4d1ca6faf644377f48e3f50e887ab28af1c5 (diff)
downloadsubsurface-d953c645e96aea092952653adb92280fe4c225f8.tar.gz
usb-serial-for-android: React to usb "permit granted" intent (stub)
When a user is downloading from a DC for the first time (without using the "usb device connected" popup), the user is requested to grant permission to use the USB device. This is done asynchronously, thus the download is aborted. To be more user-friendly, we now react to the intent with the "usb granted" result. The plan here is to start the download again. Signed-off-by: Christof Arnosti <charno@charno.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java')
-rw-r--r--android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java b/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
index c909210f2..52f401b71 100644
--- a/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
+++ b/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java
@@ -50,6 +50,11 @@ public class SubsurfaceMobileActivity extends QtActivity
isIntentPending = true;
}
}
+
+ // Register the usb permission intent filter.
+ IntentFilter filter = new IntentFilter("org.subsurfacedivelog.mobile.USB_PERMISSION");
+ registerReceiver(usbReceiver, filter);
+
} // onCreate
// if we are opened from other apps:
@@ -104,6 +109,23 @@ public class SubsurfaceMobileActivity extends QtActivity
} // processIntent
+ private final BroadcastReceiver usbReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ 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");
+ // Stub: press the download button here :)
+ }
+ else {
+ Log.d(TAG, "USB device permission granted");
+ }
+ }
+ }
+ }
+ };
+
public static Context getAppContext()
{
return appContext;