Merge "Fix 5636798: clear PIN/PUK fields when device sleeps or user cancels" into ics-mr1
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
index dd3b75d..6eff4b6 100644
--- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -558,9 +558,12 @@
         mScreenOn = false;
         mForgotPattern = false;
         mHasOverlay = mUpdateMonitor.getPhoneState() != TelephonyManager.CALL_STATE_IDLE;
-        if (mMode == Mode.LockScreen) {
+
+        // Emulate activity life-cycle for both lock and unlock screen.
+        if (mLockScreen != null) {
             ((KeyguardScreen) mLockScreen).onPause();
-        } else {
+        }
+        if (mUnlockScreen != null) {
             ((KeyguardScreen) mUnlockScreen).onPause();
         }
 
@@ -651,9 +654,11 @@
 
     @Override
     public void show() {
-        if (mMode == Mode.LockScreen) {
+        // Emulate activity life-cycle for both lock and unlock screen.
+        if (mLockScreen != null) {
             ((KeyguardScreen) mLockScreen).onResume();
-        } else {
+        }
+        if (mUnlockScreen != null) {
             ((KeyguardScreen) mUnlockScreen).onResume();
         }
 
diff --git a/policy/src/com/android/internal/policy/impl/SimPukUnlockScreen.java b/policy/src/com/android/internal/policy/impl/SimPukUnlockScreen.java
index 0d1f436..ba06996 100644
--- a/policy/src/com/android/internal/policy/impl/SimPukUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/SimPukUnlockScreen.java
@@ -383,6 +383,9 @@
 
         public void onClick(View v) {
             if (v == mCancelButton) {
+                // clear the PIN/PUK entry fields if the user cancels
+                mPinText.setText("");
+                mPukText.setText("");
                 mCallback.goToLockScreen();
                 return;
             }
diff --git a/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java b/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
index f80637a..9604cdc 100644
--- a/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
@@ -359,6 +359,7 @@
 
         public void onClick(View v) {
             if (v == mCancelButton) {
+                mPinText.setText(""); // clear the PIN entry field if the user cancels
                 mCallback.goToLockScreen();
                 return;
             }