Fix 2420689: Fix bug that prevents pattern unlock from showing lockout dialog.

This fixes the problem where the lockout dialog wasn't showing.  It also fixes a problem
where the "forgot pattern" button would stop working.
diff --git a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java
index e4f28e9..8bda760 100644
--- a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -290,7 +290,7 @@
                 // irrelevant to keyguard screen, they shouldn't be calling this
             }
 
-            public void reportFailedPatternAttempt() {
+            public void reportFailedUnlockAttempt() {
                 mUpdateMonitor.reportFailedAttempt();
                 final int failedAttempts = mUpdateMonitor.getFailedAttempts();
                 if (DEBUG) Log.d(TAG,
@@ -308,16 +308,13 @@
                         == 0) {
                     showTimeoutDialog();
                 }
+                mLockPatternUtils.reportFailedPasswordAttempt();
             }
 
             public boolean doesFallbackUnlockScreenExist() {
                 return mEnableFallback;
             }
 
-            public void reportFailedUnlockAttempt() {
-                mLockPatternUtils.reportFailedPasswordAttempt();
-            }
-
             public void reportSuccessfulUnlockAttempt() {
                 mLockPatternUtils.reportSuccessfulPasswordAttempt();
             }
@@ -330,13 +327,6 @@
         setFocusableInTouchMode(true);
         setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
 
-        // wall paper background
-        if (false) {
-            final BitmapDrawable drawable = (BitmapDrawable) context.getWallpaper();
-            setBackgroundDrawable(
-                    new FastBitmapDrawable(drawable.getBitmap()));
-        }
-
         // create both the lock and unlock screen so they are quickly available
         // when the screen turns on
         mLockScreen = createLockScreen();
@@ -680,7 +670,7 @@
                     break;
                 case LockPatternUtils.MODE_PATTERN:
                     // "forgot pattern" button is only available in the pattern mode...
-                    if (mForgotPattern && mLockPatternUtils.isPermanentlyLocked()) {
+                    if (mForgotPattern || mLockPatternUtils.isPermanentlyLocked()) {
                         currentMode = UnlockMode.Account;
                     } else {
                         currentMode = UnlockMode.Pattern;
diff --git a/policy/com/android/internal/policy/impl/PatternUnlockScreen.java b/policy/com/android/internal/policy/impl/PatternUnlockScreen.java
index 30fb8b8..d09b358 100644
--- a/policy/com/android/internal/policy/impl/PatternUnlockScreen.java
+++ b/policy/com/android/internal/policy/impl/PatternUnlockScreen.java
@@ -62,11 +62,6 @@
     // how many cells the user has to cross before we poke the wakelock
     private static final int MIN_PATTERN_BEFORE_POKE_WAKELOCK = 2;
 
-    // This dictates how long a pattern should be before we count it as an attempt.
-    // This should be long enough to avoid false triggers while the device is in a pocket,
-    // as this can lead to a wiped device if a {@link DeviceAdmin} is active and has it enabled.
-    private static final int MIN_PATTERN_BEFORE_REPORT = 3;
-
     private int mFailedPatternAttemptsSinceLastTimeout = 0;
     private int mTotalFailedPatternAttempts = 0;
     private CountDownTimer mCountdownTimer = null;
@@ -511,6 +506,7 @@
                 if (pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
                     mTotalFailedPatternAttempts++;
                     mFailedPatternAttemptsSinceLastTimeout++;
+                    mCallback.reportFailedUnlockAttempt();
                 }
                 if (mFailedPatternAttemptsSinceLastTimeout >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
                     long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
@@ -523,9 +519,6 @@
                             mCancelPatternRunnable,
                             PATTERN_CLEAR_TIMEOUT_MS);
                 }
-                if (pattern.size() > MIN_PATTERN_BEFORE_REPORT) {
-                    mCallback.reportFailedUnlockAttempt();
-                }
             }
         }
     }