From a942f3fdd11b534b85bddef5a90969ba5c3cbd3c Mon Sep 17 00:00:00 2001 From: Alex Johnston Date: Mon, 26 Apr 2021 16:46:38 +0100 Subject: [PATCH] Correct string ConfirmDeviceCredentialActivity * If there is a managed profile but a separate profile challenge is not enabled, use the device title and subtitle in ConfirmDeviceCredentialActivity. Manual testing * Set device PIN * Create a work profile using TestDPC * adb shell am start --user 10 -a android.app.action.CONFIRM_DEVICE_CREDENTIAL * Verify title says 'Enter your device...' * Add a work profile PIN * adb shell am start --user 10 -a android.app.action.CONFIRM_DEVICE_CREDENTIAL * Verify title says 'Enter your work...' * Do the same for pattern and password Bug: 163108636 Test: manual testing Change-Id: I8b61e7d2df5792cbdb2e12b19e5a5582ea2290b7 --- .../ConfirmDeviceCredentialActivity.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java index 6a97dcd1b45..6241cc91cf8 100644 --- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java +++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java @@ -192,15 +192,14 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity { } } final int effectiveUserId = mUserManager.getCredentialOwnerProfile(mUserId); - final boolean isManagedProfile = UserManager.get(this).isManagedProfile(mUserId); + final boolean isEffectiveUserManagedProfile = + UserManager.get(this).isManagedProfile(effectiveUserId); // if the client app did not hand in a title and we are about to show the work challenge, // check whether there is a policy setting the organization name and use that as title - if ((mTitle == null) && isManagedProfile) { + if ((mTitle == null) && isEffectiveUserManagedProfile) { mTitle = getTitleFromOrganizationName(mUserId); } - final LockPatternUtils lockPatternUtils = new LockPatternUtils(this); - final PromptInfo promptInfo = new PromptInfo(); promptInfo.setTitle(mTitle); promptInfo.setDescription(mDetails); @@ -210,11 +209,11 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity { mContext, effectiveUserId); if (mTitle == null) { promptInfo.setDeviceCredentialTitle( - getTitleFromCredentialType(credentialType, isManagedProfile)); + getTitleFromCredentialType(credentialType, isEffectiveUserManagedProfile)); } if (mDetails == null) { promptInfo.setSubtitle( - getDetailsFromCredentialType(credentialType, isManagedProfile)); + getDetailsFromCredentialType(credentialType, isEffectiveUserManagedProfile)); } boolean launchedBiometric = false; @@ -231,8 +230,7 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity { .setExternal(true) .setUserId(LockPatternUtils.USER_FRP) .show(); - } else if (isManagedProfile && isInternalActivity() - && !lockPatternUtils.isSeparateProfileChallengeEnabled(mUserId)) { + } else if (isEffectiveUserManagedProfile && isInternalActivity()) { mCredentialMode = CREDENTIAL_MANAGED; if (isBiometricAllowed(effectiveUserId, mUserId)) { showBiometricPrompt(promptInfo); @@ -267,18 +265,18 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity { } private String getTitleFromCredentialType(@LockPatternUtils.CredentialType int credentialType, - boolean isManagedProfile) { + boolean isEffectiveUserManagedProfile) { switch (credentialType) { case LockPatternUtils.CREDENTIAL_TYPE_PIN: - return isManagedProfile + return isEffectiveUserManagedProfile ? getString(R.string.lockpassword_confirm_your_work_pin_header) : getString(R.string.lockpassword_confirm_your_pin_header); case LockPatternUtils.CREDENTIAL_TYPE_PATTERN: - return isManagedProfile + return isEffectiveUserManagedProfile ? getString(R.string.lockpassword_confirm_your_work_pattern_header) : getString(R.string.lockpassword_confirm_your_pattern_header); case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD: - return isManagedProfile + return isEffectiveUserManagedProfile ? getString(R.string.lockpassword_confirm_your_work_password_header) : getString(R.string.lockpassword_confirm_your_password_header); } @@ -286,18 +284,18 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity { } private String getDetailsFromCredentialType(@LockPatternUtils.CredentialType int credentialType, - boolean isManagedProfile) { + boolean isEffectiveUserManagedProfile) { switch (credentialType) { case LockPatternUtils.CREDENTIAL_TYPE_PIN: - return isManagedProfile + return isEffectiveUserManagedProfile ? getString(R.string.lockpassword_confirm_your_pin_generic_profile) : getString(R.string.lockpassword_confirm_your_pin_generic); case LockPatternUtils.CREDENTIAL_TYPE_PATTERN: - return isManagedProfile + return isEffectiveUserManagedProfile ? getString(R.string.lockpassword_confirm_your_pattern_generic_profile) : getString(R.string.lockpassword_confirm_your_pattern_generic); case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD: - return isManagedProfile + return isEffectiveUserManagedProfile ? getString(R.string.lockpassword_confirm_your_password_generic_profile) : getString(R.string.lockpassword_confirm_your_password_generic); }