mirror of https://github.com/M66B/FairEmail.git
Cancel biometric prompt on pause
This commit is contained in:
parent
51ce845828
commit
5bc040a3f3
|
@ -206,7 +206,7 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
|
|||
};
|
||||
|
||||
if (Helper.shouldAuthenticate(this))
|
||||
Helper.authenticate(ActivityMain.this, null,
|
||||
Helper.authenticate(ActivityMain.this, ActivityMain.this, null,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -159,7 +159,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
|||
public void onClick(View v) {
|
||||
final boolean biometrics = prefs.getBoolean("biometrics", false);
|
||||
|
||||
Helper.authenticate(getActivity(), biometrics, new Runnable() {
|
||||
Helper.authenticate(getActivity(), getViewLifecycleOwner(), biometrics, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
|
|
@ -44,7 +44,6 @@ import android.os.LocaleList;
|
|||
import android.os.Parcel;
|
||||
import android.os.PowerManager;
|
||||
import android.os.StatFs;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.security.KeyChain;
|
||||
import android.security.KeyChainAliasCallback;
|
||||
import android.security.KeyChainException;
|
||||
|
@ -1079,7 +1078,7 @@ public class Helper {
|
|||
return false;
|
||||
}
|
||||
|
||||
static void authenticate(final FragmentActivity activity,
|
||||
static void authenticate(final FragmentActivity activity, final LifecycleOwner owner,
|
||||
Boolean enabled, final
|
||||
Runnable authenticated, final Runnable cancelled) {
|
||||
final Handler handler = new Handler();
|
||||
|
@ -1104,7 +1103,7 @@ public class Helper {
|
|||
? R.string.title_setup_biometrics_disable
|
||||
: R.string.title_setup_biometrics_enable));
|
||||
|
||||
BiometricPrompt prompt = new BiometricPrompt(activity, executor,
|
||||
final BiometricPrompt prompt = new BiometricPrompt(activity, executor,
|
||||
new BiometricPrompt.AuthenticationCallback() {
|
||||
@Override
|
||||
public void onAuthenticationError(final int errorCode, @NonNull final CharSequence errString) {
|
||||
|
@ -1140,6 +1139,16 @@ public class Helper {
|
|||
});
|
||||
|
||||
prompt.authenticate(info.build());
|
||||
|
||||
owner.getLifecycle().addObserver(new LifecycleObserver() {
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
||||
public void onPause() {
|
||||
prompt.cancelAuthentication();
|
||||
handler.post(cancelled);
|
||||
owner.getLifecycle().removeObserver(this);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
final View dview = LayoutInflater.from(activity).inflate(R.layout.dialog_pin_ask, null);
|
||||
final EditText etPin = dview.findViewById(R.id.etPin);
|
||||
|
|
Loading…
Reference in New Issue