Fix PanicKit for PIN lock.

Fixes #12816.
This commit is contained in:
Nicholas
2023-03-20 16:55:44 -04:00
committed by Greyson Parrelli
parent 2256c8591a
commit cedf512726
2 changed files with 26 additions and 28 deletions

View File

@@ -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);
}
}
}

View File

@@ -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)
}
}
}