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

Commit 450ebb58 authored by Clara Bayarri's avatar Clara Bayarri Committed by Android (Google) Code Review
Browse files

Merge "Fix bugs around unification when no password is set"

parents e32497c6 7402b251
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -316,10 +316,11 @@ public class ChooseLockGeneric extends SettingsActivity {
        }

        private String getKeyForCurrent() {
            if (mLockPatternUtils.isLockScreenDisabled(mUserId)) {
            final int credentialOwner = mUserManager.getCredentialOwnerProfile(mUserId);
            if (mLockPatternUtils.isLockScreenDisabled(credentialOwner)) {
                return KEY_UNLOCK_SET_OFF;
            }
            switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) {
            switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(credentialOwner)) {
                case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
                    return KEY_UNLOCK_SET_PATTERN;
                case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
@@ -521,6 +522,7 @@ public class ChooseLockGeneric extends SettingsActivity {
            }

            if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
                mLockPatternUtils.setSeparateProfileChallengeEnabled(mUserId, true);
                mChooseLockSettingsHelper.utils().clearLock(mUserId);
                mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId);
                mLockPatternUtils.setSeparateProfileChallengeEnabled(mUserId, false);
+15 −5
Original line number Diff line number Diff line
@@ -128,12 +128,16 @@ public class ProfileChallengePreferenceFragment extends SettingsPreferenceFragme
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == UNIFY_LOCK_METHOD_REQUEST && resultCode == Activity.RESULT_OK) {
            mLockPatternUtils.clearLock(mProfileUserId);
            mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileUserId, false);
            unifyLocks();
            return;
        }
    }

    private void unifyLocks() {
        mLockPatternUtils.clearLock(mProfileUserId);
        mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileUserId, false);
    }

    @Override
    public void onResume() {
        super.onResume();
@@ -260,6 +264,8 @@ public class ProfileChallengePreferenceFragment extends SettingsPreferenceFragme
        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            final Bundle args = getArguments();
            final ProfileChallengePreferenceFragment parentFragment =
                    ((ProfileChallengePreferenceFragment) getParentFragment());
            return new AlertDialog.Builder(getActivity())
                    .setTitle(R.string.lock_settings_profile_unification_dialog_title)
                    .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);
                                    ChooseLockSettingsHelper helper =
                                            new ChooseLockSettingsHelper(
                                                    getActivity(), getParentFragment());
                                    helper.launchConfirmationActivity(UNIFY_LOCK_METHOD_REQUEST,
                                            title, true, args.getInt(ARG_USER_ID));
                                                    getActivity(), parentFragment);
                                    if (!helper.launchConfirmationActivity(
                                            UNIFY_LOCK_METHOD_REQUEST,
                                            title, true, args.getInt(ARG_USER_ID))) {
                                        parentFragment.unifyLocks();
                                        parentFragment.createPreferenceHierarchy();
                                    }
                                }
                            }
                    )