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

Commit bdc28b50 authored by Roman Birg's avatar Roman Birg Committed by Gerrit Code Review
Browse files

Settings: fix potential crash when setting new pattern



When setting a pattern that has a different size length than default, or
the currently set pattern, an exception can occur when rotating the
device because the lock pattern utils method assumes a length, which may
not be correct.

Update to use the static version of stringToPattern() which accepts a
length.

Also fix the pattern comparison check. It was comparing two array list
objects to decide whether the pattern was the same, and after a
rotation, the objects would have been reconstructed, and it never would
have accepted the correct pattern.

Ref: CYNGNOS-661

Change-Id: I07aea58638195e9c8b7689b1e8db80694cb1c1db
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent cfc0b279
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -174,7 +174,8 @@ public class ChooseLockPattern extends SettingsActivity {
                    if (mUiStage == Stage.NeedToConfirm || mUiStage == Stage.ConfirmWrong) {
                        if (mChosenPattern == null) throw new IllegalStateException(
                                "null chosen pattern in stage 'need to confirm");
                        if (mChosenPattern.equals(pattern)) {

                        if (LockPatternUtils.patternMatches(mChosenPattern, pattern)) {
                            updateStage(Stage.ChoiceConfirmed);
                        } else {
                            updateStage(Stage.ConfirmWrong);
@@ -396,8 +397,7 @@ public class ChooseLockPattern extends SettingsActivity {
                // restore from previous state
                final String patternString = savedInstanceState.getString(KEY_PATTERN_CHOICE);
                if (patternString != null) {
                    LockPatternUtils utils = mChooseLockSettingsHelper.utils();
                    mChosenPattern = utils.stringToPattern(patternString);
                    mChosenPattern = LockPatternUtils.stringToPattern(patternString, mPatternSize);
                }
                updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
            }
@@ -474,11 +474,8 @@ public class ChooseLockPattern extends SettingsActivity {
            super.onSaveInstanceState(outState);

            outState.putInt(KEY_UI_STAGE, mUiStage.ordinal());
            if (mChosenPattern != null) {
                LockPatternUtils utils = mChooseLockSettingsHelper.utils();
            outState.putString(KEY_PATTERN_CHOICE,
                        utils.patternToString(mChosenPattern));
            }
                    LockPatternUtils.patternToString(mChosenPattern, mPatternSize));
        }

        /**