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

Commit b81413f3 authored by Danesh M's avatar Danesh M Committed by Robert Burns
Browse files

Lockscreen : Quick / menu unlock

Unlock password/pin lockscreen without pressing enter button

Patchset 2 : Remove unecessary intialization

Change-Id: Iecb5ed52ef28234f6adad813906dc885296a157c

Quick unlock : Fix bug

There is an issue where users whose passwords are greater than 8 chars and
have quick unlock enabled will be unable to unlock their lockscreen.
This is due to the logic evaluating anything beyond 3chars as a password attempt.

This change modifies the quick unlock behavior so that when typing the password,
each character is considered an attempt, however if incorrect, is not reported as a failed attempt.
Only when the user presses enter is it considered an "explicit" attempt and a failed attempt is reported.

Patchset 2 : Rename runnable to better reflect its purpose
Patchset 3 : Switch to new behavior
Patchset 4 : Fix padding

Change-Id: Ida6289c77f6724cb42e8d3b82593f29afe3d6d1b

Menu unlock (frameworks part)

    	The option in Settings/Security/Lockscreen was
    	added before in some CM commit, but not working
    	and was missing a proper frameworks part

Patchet 3: Done like master Danesh M wanted

Change-Id: I589c77cd58d7beb4093e334f074c7f7643d90858

Change-Id: Ida6289c77f6724cb42e8d3b82593f29afe3d6d1b
parent f6f2e58a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.util.Slog;
import android.media.AudioManager;
import android.os.RemoteException;
import android.provider.MediaStore;
import android.provider.Settings;

import java.io.File;

@@ -427,7 +428,8 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
        final boolean configDisabled = res.getBoolean(R.bool.config_disableMenuKeyInLockScreen);
        final boolean isTestHarness = ActivityManager.isRunningInTestHarness();
        final boolean fileOverride = (new File(ENABLE_MENU_KEY_FILE)).exists();
        return !configDisabled || isTestHarness || fileOverride;
        final boolean menuOverride = Settings.System.getInt(getContext().getContentResolver(), Settings.System.MENU_UNLOCK_SCREEN, 0) == 1;
        return !configDisabled || isTestHarness || fileOverride || menuOverride;
    }

    /**
+13 −3
Original line number Diff line number Diff line
@@ -35,18 +35,15 @@ import android.text.InputType;
import android.text.TextWatcher;
import android.text.method.DigitsKeyListener;
import android.text.method.TextKeyListener;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Space;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

@@ -76,6 +73,7 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen

    private final KeyguardStatusViewManager mStatusViewManager;
    private final boolean mUseSystemIME = true; // TODO: Make configurable
    private boolean mQuickUnlock;
    private boolean mResuming; // used to prevent poking the wakelock during onResume()

    // To avoid accidental lockout due to events while the device in in the pocket, ignore
@@ -163,6 +161,10 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
                mCallback.pokeWakelock();
            }
        });

        mQuickUnlock = (Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.LOCKSCREEN_QUICK_UNLOCK_CONTROL, 0) == 1);

        mPasswordEntry.addTextChangedListener(new TextWatcher() {
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }
@@ -174,6 +176,14 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
                if (!mResuming) {
                    mCallback.pokeWakelock();
                }
                if (mQuickUnlock) {
                    String entry = mPasswordEntry.getText().toString();
                    if (entry.length() > MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT &&
                            mLockPatternUtils.checkPassword(entry)) {
                            mCallback.keyguardDone(true);
                            mCallback.reportSuccessfulUnlockAttempt();
                    }
                }
            }
        });