From 9a671783c9405e34a54413392d9e53a8fcde1e6a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 23 Jun 2016 14:40:00 +0200 Subject: [PATCH] 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. As previously discussed in #5341 Closes #5550 //FREEBIE --- AndroidManifest.xml | 8 ++++++ .../service/PanicResponderListener.java | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/org/thoughtcrime/securesms/service/PanicResponderListener.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 1c727a9b98..2858a2ef9a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -497,5 +497,13 @@ + + + + + + diff --git a/src/org/thoughtcrime/securesms/service/PanicResponderListener.java b/src/org/thoughtcrime/securesms/service/PanicResponderListener.java new file mode 100644 index 0000000000..a3b9aee45f --- /dev/null +++ b/src/org/thoughtcrime/securesms/service/PanicResponderListener.java @@ -0,0 +1,28 @@ +package org.thoughtcrime.securesms.service; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +import org.thoughtcrime.securesms.util.TextSecurePreferences; + +/** + * Respond to a PanicKit trigger Intent by locking the app. 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 via the Signal lock preference. If the + * user has not set a passphrase, then the panic trigger intent does nothing. + */ +public class PanicResponderListener extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + if (intent != null && !TextSecurePreferences.isPasswordDisabled(context) && + "info.guardianproject.panic.action.TRIGGER".equals(intent.getAction())) + { + Intent lockIntent = new Intent(context, KeyCachingService.class); + lockIntent.setAction(KeyCachingService.CLEAR_KEY_ACTION); + context.startService(lockIntent); + } + } +} \ No newline at end of file