mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-28 10:47:46 +00:00
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
This commit is contained in:
parent
a370f086c0
commit
9a671783c9
@ -497,5 +497,13 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".service.PanicResponderListener"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="info.guardianproject.panic.action.TRIGGER" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user