Remove crypto pattern after two seconds
Currently pattern is left on after a failed attempt. This change removes it after a timeout. Change-Id: I77830510b17396f6e64a482816f6041af0fdc166
This commit is contained in:
@@ -65,6 +65,8 @@ import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.internal.widget.LockPatternView;
|
||||
import com.android.internal.widget.LockPatternView.Cell;
|
||||
|
||||
import static com.android.internal.widget.LockPatternView.DisplayMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -123,6 +125,15 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
|
||||
/** Number of calls to {@link #notifyUser()} before we release the wakelock */
|
||||
private int mReleaseWakeLockCountdown = 0;
|
||||
|
||||
// how long we wait to clear a wrong pattern
|
||||
private static final int WRONG_PATTERN_CLEAR_TIMEOUT_MS = 1500;
|
||||
|
||||
private Runnable mClearPatternRunnable = new Runnable() {
|
||||
public void run() {
|
||||
mLockPatternView.clearPattern();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to propagate state through configuration changes (e.g. screen rotation)
|
||||
*/
|
||||
@@ -175,15 +186,22 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
|
||||
} else if (failedAttempts == MAX_FAILED_ATTEMPTS) {
|
||||
// Factory reset the device.
|
||||
sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
|
||||
} else if ((failedAttempts % COOL_DOWN_ATTEMPTS) == 0) {
|
||||
} else {
|
||||
// Wrong entry. Handle pattern case.
|
||||
if (mLockPatternView != null) {
|
||||
mLockPatternView.clearPattern();
|
||||
mLockPatternView.setDisplayMode(DisplayMode.Wrong);
|
||||
mLockPatternView.removeCallbacks(mClearPatternRunnable);
|
||||
mLockPatternView.postDelayed(mClearPatternRunnable, WRONG_PATTERN_CLEAR_TIMEOUT_MS);
|
||||
}
|
||||
if ((failedAttempts % COOL_DOWN_ATTEMPTS) == 0) {
|
||||
mCooldown = COOL_DOWN_INTERVAL;
|
||||
cooldown();
|
||||
} else {
|
||||
final TextView status = (TextView) findViewById(R.id.status);
|
||||
status.setText(R.string.try_again);
|
||||
if (mLockPatternView != null) {
|
||||
mLockPatternView.setDisplayMode(DisplayMode.Wrong);
|
||||
}
|
||||
// Reenable the password entry
|
||||
if (mPasswordEntry != null) {
|
||||
mPasswordEntry.setEnabled(true);
|
||||
@@ -194,6 +212,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ValidationTask extends AsyncTask<Void, Void, Boolean> {
|
||||
@Override
|
||||
@@ -587,6 +606,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
|
||||
|
||||
@Override
|
||||
public void onPatternStart() {
|
||||
mLockPatternView.removeCallbacks(mClearPatternRunnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user