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
This commit is contained in:
Alex Johnston
2021-04-26 16:46:38 +01:00
parent 8c895001b8
commit a942f3fdd1

View File

@@ -192,15 +192,14 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
} }
} }
final int effectiveUserId = mUserManager.getCredentialOwnerProfile(mUserId); 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, // 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 // 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); mTitle = getTitleFromOrganizationName(mUserId);
} }
final LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
final PromptInfo promptInfo = new PromptInfo(); final PromptInfo promptInfo = new PromptInfo();
promptInfo.setTitle(mTitle); promptInfo.setTitle(mTitle);
promptInfo.setDescription(mDetails); promptInfo.setDescription(mDetails);
@@ -210,11 +209,11 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
mContext, effectiveUserId); mContext, effectiveUserId);
if (mTitle == null) { if (mTitle == null) {
promptInfo.setDeviceCredentialTitle( promptInfo.setDeviceCredentialTitle(
getTitleFromCredentialType(credentialType, isManagedProfile)); getTitleFromCredentialType(credentialType, isEffectiveUserManagedProfile));
} }
if (mDetails == null) { if (mDetails == null) {
promptInfo.setSubtitle( promptInfo.setSubtitle(
getDetailsFromCredentialType(credentialType, isManagedProfile)); getDetailsFromCredentialType(credentialType, isEffectiveUserManagedProfile));
} }
boolean launchedBiometric = false; boolean launchedBiometric = false;
@@ -231,8 +230,7 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
.setExternal(true) .setExternal(true)
.setUserId(LockPatternUtils.USER_FRP) .setUserId(LockPatternUtils.USER_FRP)
.show(); .show();
} else if (isManagedProfile && isInternalActivity() } else if (isEffectiveUserManagedProfile && isInternalActivity()) {
&& !lockPatternUtils.isSeparateProfileChallengeEnabled(mUserId)) {
mCredentialMode = CREDENTIAL_MANAGED; mCredentialMode = CREDENTIAL_MANAGED;
if (isBiometricAllowed(effectiveUserId, mUserId)) { if (isBiometricAllowed(effectiveUserId, mUserId)) {
showBiometricPrompt(promptInfo); showBiometricPrompt(promptInfo);
@@ -267,18 +265,18 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
} }
private String getTitleFromCredentialType(@LockPatternUtils.CredentialType int credentialType, private String getTitleFromCredentialType(@LockPatternUtils.CredentialType int credentialType,
boolean isManagedProfile) { boolean isEffectiveUserManagedProfile) {
switch (credentialType) { switch (credentialType) {
case LockPatternUtils.CREDENTIAL_TYPE_PIN: case LockPatternUtils.CREDENTIAL_TYPE_PIN:
return isManagedProfile return isEffectiveUserManagedProfile
? getString(R.string.lockpassword_confirm_your_work_pin_header) ? getString(R.string.lockpassword_confirm_your_work_pin_header)
: getString(R.string.lockpassword_confirm_your_pin_header); : getString(R.string.lockpassword_confirm_your_pin_header);
case LockPatternUtils.CREDENTIAL_TYPE_PATTERN: case LockPatternUtils.CREDENTIAL_TYPE_PATTERN:
return isManagedProfile return isEffectiveUserManagedProfile
? getString(R.string.lockpassword_confirm_your_work_pattern_header) ? getString(R.string.lockpassword_confirm_your_work_pattern_header)
: getString(R.string.lockpassword_confirm_your_pattern_header); : getString(R.string.lockpassword_confirm_your_pattern_header);
case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD: case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD:
return isManagedProfile return isEffectiveUserManagedProfile
? getString(R.string.lockpassword_confirm_your_work_password_header) ? getString(R.string.lockpassword_confirm_your_work_password_header)
: getString(R.string.lockpassword_confirm_your_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, private String getDetailsFromCredentialType(@LockPatternUtils.CredentialType int credentialType,
boolean isManagedProfile) { boolean isEffectiveUserManagedProfile) {
switch (credentialType) { switch (credentialType) {
case LockPatternUtils.CREDENTIAL_TYPE_PIN: 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_profile)
: getString(R.string.lockpassword_confirm_your_pin_generic); : getString(R.string.lockpassword_confirm_your_pin_generic);
case LockPatternUtils.CREDENTIAL_TYPE_PATTERN: 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_profile)
: getString(R.string.lockpassword_confirm_your_pattern_generic); : getString(R.string.lockpassword_confirm_your_pattern_generic);
case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD: 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_profile)
: getString(R.string.lockpassword_confirm_your_password_generic); : getString(R.string.lockpassword_confirm_your_password_generic);
} }