From 25c3f8fb131adbee92c9c510c6fcbd8b0a8ceea7 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 30 Dec 2015 22:14:34 +0100 Subject: [PATCH 1/2] respond to generic panic trigger Intent by locking PanicKit provides a common framework for creating "panic button" apps that can trigger actions in "panic responder" apps. In this case, the response is to lock the app, if it has been configured to do so https://dev.guardianproject.info/projects/panic/wiki --- app/src/main/AndroidManifest.xml | 8 +++++ .../keepassdroid/PanicResponderActivity.java | 34 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 app/src/main/java/com/keepassdroid/PanicResponderActivity.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 639d195c3..09d08ce1b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -100,6 +100,14 @@ + + + + + + = 21) { + finishAndRemoveTask(); + } else { + finish(); + } + } +} From 54549e7eb8523e6d39f503890246daacf381eff1 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 30 Dec 2015 22:15:12 +0100 Subject: [PATCH 2/2] after receiving panic trigger and locking app, remove from history This makes the app fully exit, and removes it from the Recent Apps listing. --- app/src/main/AndroidManifest.xml | 1 + .../java/com/keepassdroid/ExitActivity.java | 36 +++++++++++++++++++ .../keepassdroid/PanicResponderActivity.java | 1 + 3 files changed, 38 insertions(+) create mode 100644 app/src/main/java/com/keepassdroid/ExitActivity.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 09d08ce1b..0c7717f59 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -108,6 +108,7 @@ + = 21) { + finishAndRemoveTask(); + } else { + finish(); + } + + System.exit(0); + } + + public static void exitAndRemoveFromRecentApps(Activity activity) { + Intent intent = new Intent(activity, ExitActivity.class); + + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS + | Intent.FLAG_ACTIVITY_CLEAR_TASK + | Intent.FLAG_ACTIVITY_NO_ANIMATION); + + activity.startActivity(intent); + } +} diff --git a/app/src/main/java/com/keepassdroid/PanicResponderActivity.java b/app/src/main/java/com/keepassdroid/PanicResponderActivity.java index 5f6a0b3d4..d18ea0eec 100644 --- a/app/src/main/java/com/keepassdroid/PanicResponderActivity.java +++ b/app/src/main/java/com/keepassdroid/PanicResponderActivity.java @@ -23,6 +23,7 @@ protected void onCreate(Bundle savedInstanceState) { if (intent != null && PANIC_TRIGGER_ACTION.equals(intent.getAction())) { App.setShutdown(); setResult(KeePass.EXIT_LOCK); + ExitActivity.exitAndRemoveFromRecentApps(this); } if (Build.VERSION.SDK_INT >= 21) {