From 9a3caf39e4c628c6dfcac92f7e2b7e4538a73009 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 17 Nov 2011 17:58:40 -0800 Subject: [PATCH] Fix 5636798: clear PIN/PUK fields when device sleeps or user cancels This bug is the result of onPause()/onResume() not being called properly when we have both lock and unlock screens present, which is true for the SIM and PUK unlock cases. The fix is to invoke onPause() and onResume() on both of them if they exist. Verified the rest of the code correctly handles having both. Also, when the user cancels, we now clear the fields. Change-Id: If7fbd31df7eab9e3d60656d50d2392607a4bf471 --- .../policy/impl/LockPatternKeyguardView.java | 13 +++++++++---- .../internal/policy/impl/SimPukUnlockScreen.java | 3 +++ .../internal/policy/impl/SimUnlockScreen.java | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java index dd3b75d2c7a4e..6eff4b6e1c2f0 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 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler 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 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler @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 47a715767c4e2..a11308482b8b6 100644 --- a/policy/src/com/android/internal/policy/impl/SimPukUnlockScreen.java +++ b/policy/src/com/android/internal/policy/impl/SimPukUnlockScreen.java @@ -379,6 +379,9 @@ public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen, 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 99e1ce10cfb6c..bf61fbc357338 100644 --- a/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java +++ b/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java @@ -355,6 +355,7 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie public void onClick(View v) { if (v == mCancelButton) { + mPinText.setText(""); // clear the PIN entry field if the user cancels mCallback.goToLockScreen(); return; }