From c665c082530e80528d806984e5755749b716ae4a Mon Sep 17 00:00:00 2001 From: Curtis Belmonte Date: Tue, 9 Mar 2021 15:55:35 -0800 Subject: [PATCH] Use different prompt messages for biometric|credential Because the subtitle/description string is shared between the biometric and credential versions of BiometricPrompt, the corresponding prompt message string should indicate that either auth type may be used. Otherwise, the string "Use your fingerprint to continue" may be shown on a screen prompting the user for their PIN, or vice versa. This commit addresses the issue by having the getPromptMessage(int) method of BiometricManager return a different string when both biometric and credential authentication are allowed and available, as opposed to when only biometric authentication is allowed. Test: atest BiometricManagerTest Test: Manually tested strings using biometric integration test app Bug: 180732913 Change-Id: I39d22c756b71de533f228b6a765ef81b82c2f4da --- core/res/res/values/strings.xml | 6 ++++ core/res/res/values/symbols.xml | 3 ++ .../server/biometrics/AuthService.java | 31 ++++++++++++++++--- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 2b1168f14f210..f52aa9438cfa5 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1532,6 +1532,8 @@ Verify it\u2019s you Use your biometric to continue + + Use your biometric or screen lock to continue Biometric hardware unavailable @@ -1604,6 +1606,8 @@ Use fingerprint or screen lock Use your fingerprint to continue + + Use your fingerprint or screen lock to continue @@ -1704,6 +1708,8 @@ Use face or screen lock Use face unlock to continue + + Use your face or screen lock to continue diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index ff9d26fb2363a..a5c3c4162b53e 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2476,6 +2476,7 @@ + @@ -2507,6 +2508,7 @@ + @@ -2556,6 +2558,7 @@ + diff --git a/services/core/java/com/android/server/biometrics/AuthService.java b/services/core/java/com/android/server/biometrics/AuthService.java index 050b28b363d21..285f3185abc2d 100644 --- a/services/core/java/com/android/server/biometrics/AuthService.java +++ b/services/core/java/com/android/server/biometrics/AuthService.java @@ -406,26 +406,49 @@ public class AuthService extends SystemService { mBiometricService.getCurrentModality( opPackageName, userId, callingUserId, authenticators); + final boolean isCredentialAllowed = Utils.isCredentialRequested(authenticators); + final String result; switch (getCredentialBackupModality(modality)) { case BiometricAuthenticator.TYPE_NONE: result = null; break; + case BiometricAuthenticator.TYPE_CREDENTIAL: result = getContext().getString( R.string.screen_lock_dialog_default_subtitle); break; + case BiometricAuthenticator.TYPE_FINGERPRINT: - result = getContext().getString( - R.string.fingerprint_dialog_default_subtitle); + if (isCredentialAllowed) { + result = getContext().getString( + R.string.fingerprint_or_screen_lock_dialog_default_subtitle); + } else { + result = getContext().getString( + R.string.fingerprint_dialog_default_subtitle); + } break; + case BiometricAuthenticator.TYPE_FACE: - result = getContext().getString(R.string.face_dialog_default_subtitle); + if (isCredentialAllowed) { + result = getContext().getString( + R.string.face_or_screen_lock_dialog_default_subtitle); + } else { + result = getContext().getString(R.string.face_dialog_default_subtitle); + } break; + default: - result = getContext().getString(R.string.biometric_dialog_default_subtitle); + if (isCredentialAllowed) { + result = getContext().getString( + R.string.biometric_or_screen_lock_dialog_default_subtitle); + } else { + result = getContext().getString( + R.string.biometric_dialog_default_subtitle); + } break; } + return result; } finally { Binder.restoreCallingIdentity(identity);