mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
committed by
Greyson Parrelli
parent
2256c8591a
commit
cedf512726
@@ -1,28 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package org.thoughtcrime.securesms.service
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import org.thoughtcrime.securesms.util.ServiceUtil
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
class PanicResponderListener : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
val passwordEnabled = !TextSecurePreferences.isPasswordDisabled(context)
|
||||||
|
val keyguardSecure = ServiceUtil.getKeyguardManager(context).isKeyguardSecure
|
||||||
|
val intentAction = intent.action
|
||||||
|
if ((passwordEnabled || keyguardSecure) && "info.guardianproject.panic.action.TRIGGER" == intentAction) {
|
||||||
|
val lockIntent = Intent(context, KeyCachingService::class.java)
|
||||||
|
lockIntent.action = KeyCachingService.CLEAR_KEY_ACTION
|
||||||
|
context.startService(lockIntent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user