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

Commit b8a22e42 authored by Clara Bayarri's avatar Clara Bayarri
Browse files

Update Work Challenge check to take userId

Change-Id: I239bca2dc55066c717d74487105646df22768d93
parent 8c9521f2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -486,6 +486,7 @@ public class ChooseLockGeneric extends SettingsActivity {
            if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
                mChooseLockSettingsHelper.utils().clearLock(mUserId);
                mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId);
                mLockPatternUtils.setSeparateProfileChallengeEnabled(mUserId, false);
                removeAllFingerprintTemplatesAndFinish();
                getActivity().setResult(Activity.RESULT_OK);
            } else {
+1 −2
Original line number Diff line number Diff line
@@ -670,12 +670,11 @@ public class ChooseLockPassword extends SettingsActivity {
        private String mChosenPassword;
        private String mCurrentPassword;
        private int mRequestedQuality;
        private int mUserId;

        public void start(LockPatternUtils utils, boolean required,
                boolean hasChallenge, long challenge,
                String chosenPassword, String currentPassword, int requestedQuality, int userId) {
            prepare(utils, required, hasChallenge, challenge);
            prepare(utils, required, hasChallenge, challenge, userId);

            mChosenPassword = chosenPassword;
            mCurrentPassword = currentPassword;
+1 −2
Original line number Diff line number Diff line
@@ -671,12 +671,11 @@ public class ChooseLockPattern extends SettingsActivity {
        private List<LockPatternView.Cell> mChosenPattern;
        private String mCurrentPattern;
        private boolean mLockVirgin;
        private int mUserId;

        public void start(LockPatternUtils utils, boolean credentialRequired,
                boolean hasChallenge, long challenge,
                List<LockPatternView.Cell> chosenPattern, String currentPattern, int userId) {
            prepare(utils, credentialRequired, hasChallenge, challenge);
            prepare(utils, credentialRequired, hasChallenge, challenge, userId);

            mCurrentPattern = currentPattern;
            mChosenPattern = chosenPattern;
+6 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.app.Fragment;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.UserHandle;

import com.android.internal.widget.LockPatternUtils;

@@ -38,6 +37,7 @@ abstract class SaveChosenLockWorkerBase extends Fragment {
    protected boolean mHasChallenge;
    protected long mChallenge;
    protected boolean mWasSecureBefore;
    protected int mUserId;

    @Override
    public void onCreate(Bundle savedInstanceState) {
@@ -57,12 +57,15 @@ abstract class SaveChosenLockWorkerBase extends Fragment {
    }

    protected void prepare(LockPatternUtils utils, boolean credentialRequired,
            boolean hasChallenge, long challenge) {
            boolean hasChallenge, long challenge, int userId) {
        mUtils = utils;
        mUserId = userId;

        mHasChallenge = hasChallenge;
        mChallenge = challenge;
        mWasSecureBefore = mUtils.isSecure(UserHandle.myUserId());
        // This will be a no-op for non managed profiles.
        mUtils.setSeparateProfileChallengeEnabled(mUserId, true);
        mWasSecureBefore = mUtils.isSecure(mUserId);

        mUtils.setCredentialRequiredToDecrypt(credentialRequired);

+16 −6
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
                    mProfileChallengeUserId = profile.id;
                }
            }
            if (LockPatternUtils.isSeparateWorkChallengeEnabled()) {
            if (mLockPatternUtils.isSeparateProfileChallengeAllowed(mProfileChallengeUserId)) {
                addPreferencesFromResource(R.xml.security_settings_profile);
            }
        }
@@ -776,12 +776,22 @@ public class SecuritySettings extends SettingsPreferenceFragment
            result.add(sir);

            final UserManager um = UserManager.get(context);
            boolean hasChildProfile = um.getProfiles(UserHandle.myUserId()).size() > 1;
            if (hasChildProfile && LockPatternUtils.isSeparateWorkChallengeEnabled()) {
            List<UserInfo> profiles = um.getProfiles(UserHandle.myUserId());
            int numProfiles = profiles.size();
            if (numProfiles > 1) {
                int profileUserId = -1;
                for (int i = 0; i < numProfiles; ++i) {
                    UserInfo profile = profiles.get(i);
                    if (profile.id != UserHandle.myUserId()) {
                        profileUserId = profile.id;
                    }
                }
                if (lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)) {
                    sir = new SearchIndexableResource(context);
                    sir.xmlResId = R.xml.security_settings_profile;
                    result.add(sir);
                }
            }

            if (um.isAdminUser()) {
                DevicePolicyManager dpm = (DevicePolicyManager)