Add mandatory biometric prompt to platform surfaces (1/N)
1. Face settings 2. Fingerprint settings 3. Change device credential Flag: android.hardware.biometrics.Flags.MANDATORY_BIOMETRICS Bug: 339910718 Test: atest UtilsTest Change-Id: I69778d1733ea9fb312e7c26ae0fa23b6008dde5d
This commit is contained in:
@@ -16,8 +16,11 @@
|
||||
|
||||
package com.android.settings.password;
|
||||
|
||||
import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_ERROR_USER_CANCELED;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.hardware.biometrics.BiometricManager;
|
||||
import android.hardware.biometrics.BiometricPrompt;
|
||||
import android.hardware.biometrics.BiometricPrompt.AuthenticationCallback;
|
||||
import android.hardware.biometrics.BiometricPrompt.AuthenticationResult;
|
||||
@@ -137,7 +140,7 @@ public class BiometricFragment extends InstrumentedFragment {
|
||||
BiometricPrompt.Builder promptBuilder = new BiometricPrompt.Builder(getContext())
|
||||
.setTitle(promptInfo.getTitle())
|
||||
.setUseDefaultTitle() // use default title if title is null/empty
|
||||
.setDeviceCredentialAllowed(true)
|
||||
.setAllowedAuthenticators(promptInfo.getAuthenticators())
|
||||
.setSubtitle(promptInfo.getSubtitle())
|
||||
.setDescription(promptInfo.getDescription())
|
||||
.setTextForDeviceCredential(
|
||||
@@ -170,6 +173,15 @@ public class BiometricFragment extends InstrumentedFragment {
|
||||
if (promptInfo.isUseDefaultSubtitle()) {
|
||||
promptBuilder.setUseDefaultSubtitle();
|
||||
}
|
||||
|
||||
if ((promptInfo.getAuthenticators()
|
||||
& BiometricManager.Authenticators.DEVICE_CREDENTIAL) == 0) {
|
||||
promptBuilder.setNegativeButton(promptInfo.getNegativeButtonText(),
|
||||
getContext().getMainExecutor(),
|
||||
(dialog, which) -> mAuthenticationCallback.onAuthenticationError(
|
||||
BIOMETRIC_ERROR_USER_CANCELED,
|
||||
null /* errString */));
|
||||
}
|
||||
mBiometricPrompt = promptBuilder.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user