Fix bugs around unification when no password is set

- When in a unified state, selecting the work lock to be "none" caused
a security exception
- When the work lock was set to "none", unifying didn't work
- When in a unified state, the work lock type selection screen showed
"none" as the current type instead of the device lock type

Bug: 26577247
Change-Id: I853d77186e23b6a458eaa6c1047942a7eefddc9c
This commit is contained in:
Clara Bayarri
2016-01-20 15:39:59 +00:00
parent ad1a279ac1
commit 7402b25143
2 changed files with 19 additions and 7 deletions

View File

@@ -316,10 +316,11 @@ public class ChooseLockGeneric extends SettingsActivity {
} }
private String getKeyForCurrent() { private String getKeyForCurrent() {
if (mLockPatternUtils.isLockScreenDisabled(mUserId)) { final int credentialOwner = mUserManager.getCredentialOwnerProfile(mUserId);
if (mLockPatternUtils.isLockScreenDisabled(credentialOwner)) {
return KEY_UNLOCK_SET_OFF; return KEY_UNLOCK_SET_OFF;
} }
switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) { switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(credentialOwner)) {
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
return KEY_UNLOCK_SET_PATTERN; return KEY_UNLOCK_SET_PATTERN;
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
@@ -521,6 +522,7 @@ public class ChooseLockGeneric extends SettingsActivity {
} }
if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) { if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
mLockPatternUtils.setSeparateProfileChallengeEnabled(mUserId, true);
mChooseLockSettingsHelper.utils().clearLock(mUserId); mChooseLockSettingsHelper.utils().clearLock(mUserId);
mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId); mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId);
mLockPatternUtils.setSeparateProfileChallengeEnabled(mUserId, false); mLockPatternUtils.setSeparateProfileChallengeEnabled(mUserId, false);

View File

@@ -128,12 +128,16 @@ public class ProfileChallengePreferenceFragment extends SettingsPreferenceFragme
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == UNIFY_LOCK_METHOD_REQUEST && resultCode == Activity.RESULT_OK) { if (requestCode == UNIFY_LOCK_METHOD_REQUEST && resultCode == Activity.RESULT_OK) {
mLockPatternUtils.clearLock(mProfileUserId); unifyLocks();
mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileUserId, false);
return; return;
} }
} }
private void unifyLocks() {
mLockPatternUtils.clearLock(mProfileUserId);
mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileUserId, false);
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
@@ -260,6 +264,8 @@ public class ProfileChallengePreferenceFragment extends SettingsPreferenceFragme
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
final Bundle args = getArguments(); final Bundle args = getArguments();
final ProfileChallengePreferenceFragment parentFragment =
((ProfileChallengePreferenceFragment) getParentFragment());
return new AlertDialog.Builder(getActivity()) return new AlertDialog.Builder(getActivity())
.setTitle(R.string.lock_settings_profile_unification_dialog_title) .setTitle(R.string.lock_settings_profile_unification_dialog_title)
.setMessage(R.string.lock_settings_profile_unification_dialog_body) .setMessage(R.string.lock_settings_profile_unification_dialog_body)
@@ -271,9 +277,13 @@ public class ProfileChallengePreferenceFragment extends SettingsPreferenceFragme
R.string.lock_settings_profile_screen_lock_title); R.string.lock_settings_profile_screen_lock_title);
ChooseLockSettingsHelper helper = ChooseLockSettingsHelper helper =
new ChooseLockSettingsHelper( new ChooseLockSettingsHelper(
getActivity(), getParentFragment()); getActivity(), parentFragment);
helper.launchConfirmationActivity(UNIFY_LOCK_METHOD_REQUEST, if (!helper.launchConfirmationActivity(
title, true, args.getInt(ARG_USER_ID)); UNIFY_LOCK_METHOD_REQUEST,
title, true, args.getInt(ARG_USER_ID))) {
parentFragment.unifyLocks();
parentFragment.createPreferenceHierarchy();
}
} }
} }
) )