Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c665c082 authored by Curtis Belmonte's avatar Curtis Belmonte
Browse files

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
parent 7660d740
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1532,6 +1532,8 @@
    <string name="biometric_dialog_default_title">Verify it\u2019s you</string>
    <!-- Subtitle shown on the system-provided biometric dialog, asking the user to authenticate with a biometric (e.g. fingerprint or face). [CHAR LIMIT=70] -->
    <string name="biometric_dialog_default_subtitle">Use your biometric to continue</string>
    <!-- Subtitle shown on the system-provided biometric dialog, asking the user to authenticate with a biometric (e.g. fingerprint or face) or their screen lock credential (i.e. PIN, pattern, or password). [CHAR LIMIT=90] -->
    <string name="biometric_or_screen_lock_dialog_default_subtitle">Use your biometric or screen lock to continue</string>

    <!-- Message shown when biometric hardware is not available [CHAR LIMIT=50] -->
    <string name="biometric_error_hw_unavailable">Biometric hardware unavailable</string>
@@ -1604,6 +1606,8 @@
    <string name="fingerprint_or_screen_lock_app_setting_name">Use fingerprint or screen lock</string>
    <!-- Subtitle shown on the system-provided biometric dialog, asking the user to authenticate with their fingerprint. [CHAR LIMIT=70] -->
    <string name="fingerprint_dialog_default_subtitle">Use your fingerprint to continue</string>
    <!-- Subtitle shown on the system-provided biometric dialog, asking the user to authenticate with their fingerprint or screen lock credential (i.e. PIN, pattern, or password). [CHAR LIMIT=90] -->
    <string name="fingerprint_or_screen_lock_dialog_default_subtitle">Use your fingerprint or screen lock to continue</string>

    <!-- Array containing custom error messages from vendor.  Vendor is expected to add and translate these strings -->
    <string-array name="fingerprint_error_vendor">
@@ -1704,6 +1708,8 @@
    <string name="face_or_screen_lock_app_setting_name">Use face or screen lock</string>
    <!-- Subtitle shown on the system-provided biometric dialog, asking the user to authenticate with their face. [CHAR LIMIT=70] -->
    <string name="face_dialog_default_subtitle">Use face unlock to continue</string>
    <!-- Subtitle shown on the system-provided biometric dialog, asking the user to authenticate with their face or screen lock credential (i.e. PIN, pattern, or password). [CHAR LIMIT=90] -->
    <string name="face_or_screen_lock_dialog_default_subtitle">Use your face or screen lock to continue</string>

    <!-- Array containing custom error messages from vendor.  Vendor is expected to add and translate these strings -->
    <string-array name="face_error_vendor">
+3 −0
Original line number Diff line number Diff line
@@ -2476,6 +2476,7 @@
  <java-symbol type="string" name="biometric_or_screen_lock_app_setting_name" />
  <java-symbol type="string" name="biometric_dialog_default_title" />
  <java-symbol type="string" name="biometric_dialog_default_subtitle" />
  <java-symbol type="string" name="biometric_or_screen_lock_dialog_default_subtitle" />
  <java-symbol type="string" name="biometric_error_hw_unavailable" />
  <java-symbol type="string" name="biometric_error_user_canceled" />
  <java-symbol type="string" name="biometric_not_recognized" />
@@ -2507,6 +2508,7 @@
  <java-symbol type="string" name="fingerprint_app_setting_name" />
  <java-symbol type="string" name="fingerprint_or_screen_lock_app_setting_name" />
  <java-symbol type="string" name="fingerprint_dialog_default_subtitle" />
  <java-symbol type="string" name="fingerprint_or_screen_lock_dialog_default_subtitle" />
  <java-symbol type="string" name="fingerprint_authenticated" />
  <java-symbol type="string" name="fingerprint_error_no_fingerprints" />
  <java-symbol type="string" name="fingerprint_error_hw_not_present" />
@@ -2556,6 +2558,7 @@
  <java-symbol type="string" name="face_app_setting_name" />
  <java-symbol type="string" name="face_or_screen_lock_app_setting_name" />
  <java-symbol type="string" name="face_dialog_default_subtitle" />
  <java-symbol type="string" name="face_or_screen_lock_dialog_default_subtitle" />
  <java-symbol type="string" name="face_authenticated_no_confirmation_required" />
  <java-symbol type="string" name="face_authenticated_confirmation_required" />
  <java-symbol type="string" name="face_error_security_update_required" />
+27 −4
Original line number Diff line number Diff line
@@ -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:
                        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:
                        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);