Permalink
Browse files

Lock screen: Quick Unlock feature (2/2)

Port of QU feature. This one allows to unlock the device from lock screen without pressing the enter button (just enter the pin/password).
Option stored in lock screen settings.

Signed-off-by: Dirk Rettschlag <dirk.rettschlag@gmail.com>
  • Loading branch information...
carlosavignano committed May 31, 2013
1 parent 72ddce4 commit 21a02b86d45540e325b03c807c3a2e22ad984c9f
@@ -2636,6 +2636,12 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
*/
public static final String LOCKSCREEN_ALLOW_ROTATION = "lockscreen_allow_rotation";
+ /**
+ * Allows quick unlock
+ * @hide
+ */
+ public static final String LOCKSCREEN_QUICK_UNLOCK = "lockscreen_quick_unlock";
+
/**
* Allows lockscreen to show homescreen widgets
* The value is boolean (1 or 0).
@@ -47,6 +47,7 @@
protected View mEcaView;
private Drawable mBouncerFrame;
protected boolean mEnableHaptics;
+ private boolean mQuickUnlock;
// 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.
@@ -92,6 +93,7 @@ public void reset() {
protected abstract int getPasswordTextViewId();
protected abstract void resetState();
+ protected abstract boolean getQuickUnlockAllowed();
@Override
protected void onFinishInflate() {
@@ -111,6 +113,9 @@ public void onClick(View v) {
}
});
+ mQuickUnlock = Settings.System.getBoolean(mContext.getContentResolver(),
+ Settings.System.LOCKSCREEN_QUICK_UNLOCK, false);
+
mPasswordEntry.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@@ -122,6 +127,13 @@ public void afterTextChanged(Editable s) {
if (mCallback != null) {
mCallback.userActivity(0);
}
+ if (mQuickUnlock && getQuickUnlockAllowed()) {
+ if (s.length() > MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT &&
+ mLockPatternUtils.checkPassword(s.toString())) {
+ mCallback.dismiss(true);
+ mCallback.reportSuccessfulUnlockAttempt();
+ }
+ }
}
});
mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
@@ -55,6 +55,11 @@ protected int getPasswordTextViewId() {
return R.id.pinEntry;
}
+ @Override
+ protected boolean getQuickUnlockAllowed() {
+ return true;
+ }
+
@Override
protected void onFinishInflate() {
super.onFinishInflate();
@@ -68,6 +68,11 @@ protected int getPasswordTextViewId() {
return R.id.passwordEntry;
}
+ @Override
+ protected boolean getQuickUnlockAllowed() {
+ return true;
+ }
+
@Override
public boolean needsInput() {
return true;
@@ -62,6 +62,11 @@ protected int getPasswordTextViewId() {
return R.id.pinEntry;
}
+ @Override
+ protected boolean getQuickUnlockAllowed() {
+ return false;
+ }
+
@Override
protected void onFinishInflate() {
super.onFinishInflate();
@@ -113,6 +113,11 @@ protected int getPasswordTextViewId() {
return R.id.pinEntry;
}
+ @Override
+ protected boolean getQuickUnlockAllowed() {
+ return false;
+ }
+
@Override
protected void onFinishInflate() {
super.onFinishInflate();

0 comments on commit 21a02b8

Please sign in to comment.