diff --git a/src/com/android/settings/ConfirmLockPassword.java b/src/com/android/settings/ConfirmLockPassword.java
index 72da156..7fc48cd 100644
--- a/src/com/android/settings/ConfirmLockPassword.java
+++ b/src/com/android/settings/ConfirmLockPassword.java
@@ -25,7 +25,9 @@
 import android.app.admin.DevicePolicyManager;
 import android.content.Intent;
 import android.os.Bundle;
+import android.os.CountDownTimer;
 import android.os.Handler;
+import android.os.SystemClock;
 import android.text.Editable;
 import android.text.InputType;
 import android.text.TextWatcher;
@@ -75,7 +77,9 @@
         private PasswordEntryKeyboardHelper mKeyboardHelper;
         private PasswordEntryKeyboardView mKeyboardView;
         private Button mContinueButton;
-
+        private int mNumWrongConfirmAttempts;
+        private CountDownTimer mCountdownTimer;
+        private boolean mIsAlpha;
 
         // required constructor for fragments
         public ConfirmLockPasswordFragment() {
@@ -106,28 +110,26 @@
 
             mKeyboardView = (PasswordEntryKeyboardView) view.findViewById(R.id.keyboard);
             mHeaderText = (TextView) view.findViewById(R.id.headerText);
-            final boolean isAlpha = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC == storedQuality
+            mIsAlpha = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC == storedQuality
                     || DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC == storedQuality
                     || DevicePolicyManager.PASSWORD_QUALITY_COMPLEX == storedQuality;
-            mHeaderText.setText(isAlpha ? R.string.lockpassword_confirm_your_password_header
-                    : R.string.lockpassword_confirm_your_pin_header);
+            mHeaderText.setText(getDefaultHeader());
 
             final Activity activity = getActivity();
             mKeyboardHelper = new PasswordEntryKeyboardHelper(activity,
                     mKeyboardView, mPasswordEntry);
-            mKeyboardHelper.setKeyboardMode(isAlpha ?
+            mKeyboardHelper.setKeyboardMode(mIsAlpha ?
                     PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
                     : PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
             mKeyboardView.requestFocus();
 
             int currentType = mPasswordEntry.getInputType();
-            mPasswordEntry.setInputType(isAlpha ? currentType
+            mPasswordEntry.setInputType(mIsAlpha ? currentType
                     : (InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD));
 
             if (activity instanceof SettingsActivity) {
                 final SettingsActivity sa = (SettingsActivity) activity;
-                int id = isAlpha ? R.string.lockpassword_confirm_your_password_header
-                        : R.string.lockpassword_confirm_your_pin_header;
+                int id = getDefaultHeader();
                 CharSequence title = getText(id);
                 sa.setTitle(title);
             }
@@ -135,10 +137,19 @@
             return view;
         }
 
+        private int getDefaultHeader() {
+            return mIsAlpha ? R.string.lockpassword_confirm_your_password_header
+                    : R.string.lockpassword_confirm_your_pin_header;
+        }
+
         @Override
         public void onPause() {
             super.onPause();
             mKeyboardView.requestFocus();
+            if (mCountdownTimer != null) {
+                mCountdownTimer.cancel();
+                mCountdownTimer = null;
+            }
         }
 
         @Override
@@ -146,6 +157,10 @@
             // TODO Auto-generated method stub
             super.onResume();
             mKeyboardView.requestFocus();
+            long deadline = mLockPatternUtils.getLockoutAttemptDeadline();
+            if (deadline != 0) {
+                handleAttemptLockout(deadline);
+            }
         }
 
         private void handleNext() {
@@ -158,10 +173,40 @@
                 getActivity().setResult(RESULT_OK, intent);
                 getActivity().finish();
             } else {
-                showError(R.string.lockpattern_need_to_unlock_wrong);
+                if (++mNumWrongConfirmAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
+                    long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
+                    handleAttemptLockout(deadline);
+                } else {
+                    showError(R.string.lockpattern_need_to_unlock_wrong);
+                }
             }
         }
 
+        private void handleAttemptLockout(long elapsedRealtimeDeadline) {
+            long elapsedRealtime = SystemClock.elapsedRealtime();
+            showError(R.string.lockpattern_too_many_failed_confirmation_attempts_header, 0);
+            mPasswordEntry.setEnabled(false);
+            mCountdownTimer = new CountDownTimer(
+                    elapsedRealtimeDeadline - elapsedRealtime,
+                    LockPatternUtils.FAILED_ATTEMPT_COUNTDOWN_INTERVAL_MS) {
+
+                @Override
+                public void onTick(long millisUntilFinished) {
+                    final int secondsCountdown = (int) (millisUntilFinished / 1000);
+                    mHeaderText.setText(getString(
+                            R.string.lockpattern_too_many_failed_confirmation_attempts_footer,
+                            secondsCountdown));
+                }
+
+                @Override
+                public void onFinish() {
+                    mPasswordEntry.setEnabled(true);
+                    mHeaderText.setText(getDefaultHeader());
+                    mNumWrongConfirmAttempts = 0;
+                }
+            }.start();
+        }
+
         public void onClick(View v) {
             switch (v.getId()) {
                 case R.id.next_button:
@@ -176,14 +221,23 @@
         }
 
         private void showError(int msg) {
+            showError(msg, ERROR_MESSAGE_TIMEOUT);
+        }
+
+        private final Runnable mResetErrorRunnable = new Runnable() {
+            public void run() {
+                mHeaderText.setText(getDefaultHeader());
+            }
+        };
+
+        private void showError(int msg, long timeout) {
             mHeaderText.setText(msg);
             mHeaderText.announceForAccessibility(mHeaderText.getText());
             mPasswordEntry.setText(null);
-            mHandler.postDelayed(new Runnable() {
-                public void run() {
-                    mHeaderText.setText(R.string.lockpassword_confirm_your_password_header);
-                }
-            }, ERROR_MESSAGE_TIMEOUT);
+            mHandler.removeCallbacks(mResetErrorRunnable);
+            if (timeout != 0) {
+                mHandler.postDelayed(mResetErrorRunnable, timeout);
+            }
         }
 
         // {@link OnEditorActionListener} methods.
