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

Commit 71f5743c 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 95e30ee9
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
@@ -29,6 +29,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.
 */
@@ -80,6 +82,9 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
        mRow3 = (ViewGroup) findViewById(R.id.row3);
        mDivider = findViewById(R.id.divider);

        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);

@@ -106,6 +111,16 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
                view.setDigit(sNumbers.get(i));
            }
        }

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

    @Override
@@ -178,4 +193,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
@@ -18,6 +18,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;
@@ -116,6 +117,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);

@@ -147,6 +151,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
@@ -158,6 +158,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
@@ -213,6 +213,8 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
        if (mEcaView instanceof EmergencyCarrierArea) {
            ((EmergencyCarrierArea) mEcaView).setCarrierTextVisible(true);
        }

        mPasswordEntry.setQuickUnlockListener(null);
    }

    @Override
Loading