mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
ce7d4d1ca6
commit
d953c645e9
1 changed files with 22 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue