summaryrefslogtreecommitdiffstats
path: root/packages/Keyguard
diff options
context:
space:
mode:
authorXiyuan Xia <xiyuan@google.com>2015-05-05 15:16:08 -0700
committerXiyuan Xia <xiyuan@google.com>2015-05-12 12:42:38 -0700
commit6e38058908d6e49a241e384cd7023d9ac0927afb (patch)
treeb0d27ce3939b0c7c36645ddd13fac37393fcb987 /packages/Keyguard
parenta2e26b49539af04ea9d13eb3178f710b496e88bc (diff)
downloadframeworks_base-6e38058908d6e49a241e384cd7023d9ac0927afb.zip
frameworks_base-6e38058908d6e49a241e384cd7023d9ac0927afb.tar.gz
frameworks_base-6e38058908d6e49a241e384cd7023d9ac0927afb.tar.bz2
Make PIN/Password/Pattern check async
- Add LockPatternChecker to support async security check; - Migrate Keyguard UI to use the async check; Bug: 20697812 Change-Id: I77002a12931feb17cc20923d7c917b3e37f2cd31
Diffstat (limited to 'packages/Keyguard')
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java31
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java31
2 files changed, 57 insertions, 5 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
index c4f4b9a..db56161 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
@@ -17,6 +17,7 @@
package com.android.keyguard;
import android.content.Context;
+import android.os.AsyncTask;
import android.os.CountDownTimer;
import android.os.SystemClock;
import android.util.AttributeSet;
@@ -25,6 +26,7 @@ import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;
+import com.android.internal.widget.LockPatternChecker;
import com.android.internal.widget.LockPatternUtils;
/**
@@ -34,6 +36,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
implements KeyguardSecurityView, EmergencyButton.EmergencyButtonCallback {
protected KeyguardSecurityCallback mCallback;
protected LockPatternUtils mLockPatternUtils;
+ protected AsyncTask<?, ?, ?> mPendingLockCheck;
protected SecurityMessageDisplay mSecurityMessageDisplay;
protected View mEcaView;
protected boolean mEnableHaptics;
@@ -106,8 +109,27 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
}
protected void verifyPasswordAndUnlock() {
- String entry = getPasswordText();
- if (mLockPatternUtils.checkPassword(entry, KeyguardUpdateMonitor.getCurrentUser())) {
+ final String entry = getPasswordText();
+ setPasswordEntryEnabled(false);
+ if (mPendingLockCheck != null) {
+ mPendingLockCheck.cancel(false);
+ }
+ mPendingLockCheck = LockPatternChecker.checkPassword(
+ mLockPatternUtils,
+ entry,
+ KeyguardUpdateMonitor.getCurrentUser(),
+ new LockPatternChecker.OnCheckCallback() {
+ @Override
+ public void onChecked(boolean matched) {
+ setPasswordEntryEnabled(true);
+ mPendingLockCheck = null;
+ onPasswordChecked(entry, matched);
+ }
+ });
+ }
+
+ private void onPasswordChecked(String entry, boolean matched) {
+ if (matched) {
mCallback.reportUnlockAttempt(true);
mCallback.dismiss(true);
} else {
@@ -165,7 +187,10 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
@Override
public void onPause() {
-
+ if (mPendingLockCheck != null) {
+ mPendingLockCheck.cancel(false);
+ mPendingLockCheck = null;
+ }
}
@Override
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
index 557cd13..f67b2e7 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
@@ -20,6 +20,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Rect;
+import android.os.AsyncTask;
import android.os.CountDownTimer;
import android.os.SystemClock;
import android.text.TextUtils;
@@ -32,6 +33,7 @@ import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.widget.LinearLayout;
+import com.android.internal.widget.LockPatternChecker;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView;
@@ -59,6 +61,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
private CountDownTimer mCountdownTimer = null;
private LockPatternUtils mLockPatternUtils;
+ private AsyncTask<?, ?, ?> mPendingLockCheck;
private LockPatternView mLockPatternView;
private KeyguardSecurityCallback mCallback;
@@ -214,8 +217,28 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
mCallback.userActivity();
}
- public void onPatternDetected(List<LockPatternView.Cell> pattern) {
- if (mLockPatternUtils.checkPattern(pattern, KeyguardUpdateMonitor.getCurrentUser())) {
+ public void onPatternDetected(final List<LockPatternView.Cell> pattern) {
+ mLockPatternView.disableInput();
+ if (mPendingLockCheck != null) {
+ mPendingLockCheck.cancel(false);
+ }
+
+ mPendingLockCheck = LockPatternChecker.checkPattern(
+ mLockPatternUtils,
+ pattern,
+ KeyguardUpdateMonitor.getCurrentUser(),
+ new LockPatternChecker.OnCheckCallback() {
+ @Override
+ public void onChecked(boolean matched) {
+ mLockPatternView.enableInput();
+ mPendingLockCheck = null;
+ onPatternChecked(pattern, matched);
+ }
+ });
+ }
+
+ private void onPatternChecked(List<LockPatternView.Cell> pattern, boolean matched) {
+ if (matched) {
mCallback.reportUnlockAttempt(true);
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
mCallback.dismiss(true);
@@ -277,6 +300,10 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
mCountdownTimer.cancel();
mCountdownTimer = null;
}
+ if (mPendingLockCheck != null) {
+ mPendingLockCheck.cancel(false);
+ mPendingLockCheck = null;
+ }
}
@Override