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

Commit 2ae2ee68 authored by Scott Mertz's avatar Scott Mertz Committed by Roman Birg
Browse files

LockPatternUtils: Use the actual user id to set pattern size

Ticket: CYNGNOS-2462
Change-Id: Ia68e26ec2dfc23317135d933bc25204c1380bb02
parent c694ab1c
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -263,7 +263,7 @@ public class LockPatternUtils {
            throws RequestThrottledException {
        try {
            VerifyCredentialResponse response =
                getLockSettings().verifyPattern(patternToString(pattern), challenge, userId);
                getLockSettings().verifyPattern(patternToString(pattern, userId), challenge, userId);
            if (response == null) {
                // Shouldn't happen
                return null;
@@ -291,7 +291,7 @@ public class LockPatternUtils {
            throws RequestThrottledException {
        try {
            VerifyCredentialResponse response =
                    getLockSettings().checkPattern(patternToString(pattern), userId);
                    getLockSettings().checkPattern(patternToString(pattern, userId), userId);

            if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {
                return true;
@@ -518,7 +518,7 @@ public class LockPatternUtils {
                        + MIN_LOCK_PATTERN_SIZE + " dots long.");
            }

            getLockSettings().setLockPattern(patternToString(pattern), savedPattern, userId);
            getLockSettings().setLockPattern(patternToString(pattern, userId), savedPattern, userId);
            DevicePolicyManager dpm = getDevicePolicyManager();

            // Update the device encryption password.
@@ -527,7 +527,7 @@ public class LockPatternUtils {
                if (!shouldEncryptWithCredentials(true)) {
                    clearEncryptionPassword();
                } else {
                    String stringPattern = patternToString(pattern);
                    String stringPattern = patternToString(pattern, userId);
                    updateEncryptionPassword(StorageManager.CRYPT_TYPE_PATTERN, stringPattern);
                }
            }
@@ -878,8 +878,8 @@ public class LockPatternUtils {
     * @param pattern The pattern.
     * @return The pattern in string form.
     */
    public String patternToString(List<LockPatternView.Cell> pattern) {
        return patternToString(pattern, getLockPatternSize());
    public String patternToString(List<LockPatternView.Cell> pattern, int userId) {
        return patternToString(pattern, getLockPatternSize(userId));
    }

    /**
@@ -1100,8 +1100,8 @@ public class LockPatternUtils {
    /**
     * @return the pattern lockscreen size
     */
    public byte getLockPatternSize() {
        long size = getLong(Settings.Secure.LOCK_PATTERN_SIZE, -1, UserHandle.USER_CURRENT);
    public byte getLockPatternSize(int userId) {
        long size = getLong(Settings.Secure.LOCK_PATTERN_SIZE, -1, userId);
        if (size > 0 && size < 128) {
            return (byte) size;
        }
@@ -1111,8 +1111,8 @@ public class LockPatternUtils {
    /**
     * Set the pattern lockscreen size
     */
    public void setLockPatternSize(long size) {
        setLong(Settings.Secure.LOCK_PATTERN_SIZE, size, UserHandle.USER_CURRENT);
    public void setLockPatternSize(long size, int userId) {
        setLong(Settings.Secure.LOCK_PATTERN_SIZE, size, userId);
    }

    public void setVisibleDotsEnabled(boolean enabled, int userId) {
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
        mLockPatternView.setSaveEnabled(false);
        mLockPatternView.setOnPatternListener(new UnlockPatternListener());
        mLockPatternView.setLockPatternUtils(mLockPatternUtils);
        mLockPatternView.setLockPatternSize(mLockPatternUtils.getLockPatternSize());
        mLockPatternView.setLockPatternSize(mLockPatternUtils.getLockPatternSize(KeyguardUpdateMonitor.getCurrentUser()));

        mLockPatternView.setVisibleDots(mLockPatternUtils.isVisibleDotsEnabled(
                KeyguardUpdateMonitor.getCurrentUser()));
+1 −1
Original line number Diff line number Diff line
@@ -2250,7 +2250,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
                try {
                    LockPatternUtils lpu = new LockPatternUtils(mContext);
                    List<LockPatternView.Cell> cellPattern =
                            LockPatternUtils.stringToPattern(lockPattern, lpu.getLockPatternSize());
                            LockPatternUtils.stringToPattern(lockPattern, lpu.getLockPatternSize(mUserHandle));
                    lpu.saveLockPattern(cellPattern, null, UserHandle.USER_OWNER);
                } catch (IllegalArgumentException e) {
                    // Don't want corrupted lock pattern to hang the reboot process