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

Commit 2b4e94bd authored by gsarrica's avatar gsarrica Committed by Steve Kondik
Browse files

Added Quick unlock key Listener

Change-Id: I1d27e92bf7fbd8c6785ec1645320982cd49b886f
parent 718d8e7f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2051,6 +2051,13 @@ public final class Settings {
         */
        public static final String TRACKBALL_UNLOCK_SCREEN = "trackball_unlock_screen";

        /**
         * Whether to use the custom quick unlock screen control
         * @hide
         */
        public static final String LOCKSCREEN_QUICK_UNLOCK_CONTROL =
            "lockscreen_quick_unlock_control";

        /**
         * Pulse the Trackball with Screen On.  The value is boolean (1 or 0).
         * @hide
+28 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.internal.widget.PasswordEntryKeyboardView;

import android.os.CountDownTimer;
import android.os.SystemClock;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.method.DigitsKeyListener;
import android.text.method.TextKeyListener;
@@ -63,6 +64,7 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
    private int mCreationHardKeyboardHidden;
    private CountDownTimer mCountdownTimer;
    private TextView mTitle;
    private boolean mQuickUnlockScreen;

    // To avoid accidental lockout due to events while the device in in the pocket, ignore
    // any passwords with length less than or equal to this length.
@@ -79,6 +81,9 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
        mCallback = callback;
        mLockPatternUtils = lockPatternUtils;

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

        LayoutInflater layoutInflater = LayoutInflater.from(context);
        if (mCreationOrientation != Configuration.ORIENTATION_LANDSCAPE) {
            layoutInflater.inflate(R.layout.keyguard_screen_password_portrait, this, true);
@@ -116,6 +121,29 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen

        mKeyboardHelper.setVibratePattern(mLockPatternUtils.isTactileFeedbackEnabled() ?
                com.android.internal.R.array.config_virtualKeyVibePattern : 0);

        if (mQuickUnlockScreen) {
            mPasswordEntry.setOnKeyListener(new View.OnKeyListener() {
                @Override
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    mCallback.pokeWakelock();
                    String entry = mPasswordEntry.getText().toString();
                    if (keyCode != KeyEvent.KEYCODE_DEL) {
                        if (mLockPatternUtils.checkPassword(entry)) {
                            mCallback.keyguardDone(true);
                            mCallback.reportSuccessfulUnlockAttempt();
                        }
                    } else if (entry.length() > MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT) {
                        mCallback.reportFailedUnlockAttempt();
                        if (0 == (mUpdateMonitor.getFailedAttempts() % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
                            long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
                            handleAttemptLockout(deadline);
                        }
                    }
                    return false;
                }
            });
        }
    }

    @Override