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

Commit 715f406c authored by Matt Mower's avatar Matt Mower Committed by Steve Kondik
Browse files

Keyguard: Forward port lockscreen quick unlock (1/2)

* PasswordTextView QuickUnlock listener functions and method thanks to
  ParanoidAndroid project:
    Keyguard: Implement quick unlock feature [1/2]
    BigBrother1984 <carlosavignano@aospa.co>
    I0b3d92b91f72020d327a7f2f184c2fbc5519a5df

Change-Id: I3b92cd7d45462f4b9e4d745e891a33a90bce58bc
parent 0f5d3fe3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1969,6 +1969,13 @@ public final class Settings {
        public static final String LOCKSCREEN_PIN_SCRAMBLE_LAYOUT =
                "lockscreen_scramble_pin_layout";

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

        /**
         * A formatted string of the next alarm that is set, or the empty string
         * if there is no alarm set.
+26 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.android.keyguard.PasswordTextView.QuickUnlockListener;

/**
 * Displays a PIN pad for unlocking.
 */
@@ -127,6 +129,9 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
                        null, mEcaView, null
                }};

        boolean quickUnlock = (Settings.System.getInt(getContext().getContentResolver(),
                Settings.System.LOCKSCREEN_QUICK_UNLOCK_CONTROL, 0) == 1);

        boolean scramblePin = (Settings.System.getInt(getContext().getContentResolver(),
                Settings.System.LOCKSCREEN_PIN_SCRAMBLE_LAYOUT, 0) == 1);

@@ -152,6 +157,16 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
                mViews[(i / 3) + 1][i % 3].setDigit(sNumbers.get(i));
            }
        }

        if (quickUnlock) {
            mPasswordEntry.setQuickUnlockListener(new QuickUnlockListener() {
                public void onValidateQuickUnlock(String password) {
                    validateQuickUnlock(password);
                }
            });
        } else {
            mPasswordEntry.setQuickUnlockListener(null);
        }
    }

    @Override
@@ -215,4 +230,15 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
    public boolean hasOverlappingRendering() {
        return false;
    }

    private void validateQuickUnlock(String password) {
        if (password != null) {
            if (password.length() > MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT
                    && mLockPatternUtils.checkPassword(password)) {
                mCallback.reportUnlockAttempt(true);
                mCallback.dismiss(true);
                resetPasswordText(true);
            }
        }
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ package com.android.keyguard;

import android.content.Context;
import android.graphics.Rect;
import android.provider.Settings;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
@@ -139,6 +140,9 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView

        boolean imeOrDeleteButtonVisible = false;

        final boolean quickUnlock = (Settings.System.getInt(getContext().getContentResolver(),
                Settings.System.LOCKSCREEN_QUICK_UNLOCK_CONTROL, 0) == 1);

        mImm = (InputMethodManager) getContext().getSystemService(
                Context.INPUT_METHOD_SERVICE);

@@ -170,6 +174,15 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
                if (mCallback != null) {
                    mCallback.userActivity();
                }
                if (quickUnlock) {
                    String entry = getPasswordText();
                    if (entry.length() > MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT
                            && mLockPatternUtils.checkPassword(entry)) {
                        mCallback.reportUnlockAttempt(true);
                        mCallback.dismiss(true);
                        resetPasswordText(true);
                    }
                }
            }
        });

+2 −0
Original line number Diff line number Diff line
@@ -163,6 +163,8 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
        if (mEcaView instanceof EmergencyCarrierArea) {
            ((EmergencyCarrierArea) mEcaView).setCarrierTextVisible(true);
        }

        mPasswordEntry.setQuickUnlockListener(null);
    }

    @Override
+2 −0
Original line number Diff line number Diff line
@@ -218,6 +218,8 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
        if (mEcaView instanceof EmergencyCarrierArea) {
            ((EmergencyCarrierArea) mEcaView).setCarrierTextVisible(true);
        }

        mPasswordEntry.setQuickUnlockListener(null);
    }

    @Override
Loading