From c4bcf041d20095fd55d3e39b3e2b2a07b848dab4 Mon Sep 17 00:00:00 2001 From: Curtis Belmonte Date: Tue, 11 Feb 2020 13:05:45 -0800 Subject: [PATCH] Pass CDC text as credential-only to BiometricPrompt Invokes the new hidden API to allow the work authentication prompt to supply specific text to BiometricPrompt for credential auth. This allows the prompt to use work-specific language when verifying work credentials, while retaining more generic language when authenticating with biometrics. Test: Work lock prompt shows "Enter your work ___" for credential Test: Work lock prompt now shows "Verify it's you" for face Bug: 149003660 Change-Id: Icab8e16702ca31d08fa8b0b00f0519c9a37f609f --- .../settings/password/BiometricFragment.java | 8 ++++++-- .../ConfirmDeviceCredentialActivity.java | 20 +++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/com/android/settings/password/BiometricFragment.java b/src/com/android/settings/password/BiometricFragment.java index fe0740b18dd..bc0e5c75231 100644 --- a/src/com/android/settings/password/BiometricFragment.java +++ b/src/com/android/settings/password/BiometricFragment.java @@ -130,8 +130,12 @@ public class BiometricFragment extends InstrumentedFragment { .setDeviceCredentialAllowed(true) .setSubtitle(mBundle.getString(BiometricPrompt.KEY_SUBTITLE)) .setDescription(mBundle.getString(BiometricPrompt.KEY_DESCRIPTION)) - .setConfirmationRequired( - mBundle.getBoolean(BiometricPrompt.KEY_REQUIRE_CONFIRMATION, true)) + .setTextForDeviceCredential( + mBundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_TITLE), + mBundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_SUBTITLE), + mBundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_DESCRIPTION)) + .setConfirmationRequired(mBundle.getBoolean( + BiometricPrompt.KEY_REQUIRE_CONFIRMATION, true)) .setDisallowBiometricsIfPolicyExists(mBundle.getBoolean( BiometricPrompt.EXTRA_DISALLOW_BIOMETRICS_IF_POLICY_EXISTS, false)); diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java index 6f505bd21c9..83368f95e0f 100644 --- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java +++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java @@ -182,14 +182,7 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity { if ((mTitle == null) && isManagedProfile) { mTitle = getTitleFromOrganizationName(mUserId); } - final @LockPatternUtils.CredentialType int credentialType = Utils.getCredentialType( - mContext, effectiveUserId); - if (mTitle == null) { - mTitle = getTitleFromCredentialType(credentialType, isManagedProfile); - } - if (mDetails == null) { - mDetails = getDetailsFromCredentialType(credentialType, isManagedProfile); - } + mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this); final LockPatternUtils lockPatternUtils = new LockPatternUtils(this); @@ -200,6 +193,17 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity { bpBundle.putBoolean(BiometricPrompt.EXTRA_DISALLOW_BIOMETRICS_IF_POLICY_EXISTS, mCheckDevicePolicyManager); + final @LockPatternUtils.CredentialType int credentialType = Utils.getCredentialType( + mContext, effectiveUserId); + if (mTitle == null) { + bpBundle.putString(BiometricPrompt.KEY_DEVICE_CREDENTIAL_TITLE, + getTitleFromCredentialType(credentialType, isManagedProfile)); + } + if (mDetails == null) { + bpBundle.putString(BiometricPrompt.KEY_DEVICE_CREDENTIAL_DESCRIPTION, + getDetailsFromCredentialType(credentialType, isManagedProfile)); + } + boolean launchedBiometric = false; boolean launchedCDC = false; // If the target is a managed user and user key not unlocked yet, we will force unlock