summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Miller <jaggies@google.com>2010-02-25 19:56:06 -0800
committerJim Miller <jaggies@google.com>2010-02-25 21:33:48 -0800
commit50bb8c4fc251552bd7ad3e8d7b7e99afafd94097 (patch)
tree7287fa2a40fb57c6d093ac96cd65602cb65b5d7b
parent571b97d08b1d9327ed6a28251d97e203d5cdcdc5 (diff)
downloadbase-50bb8c4fc251552bd7ad3e8d7b7e99afafd94097.tar.gz
Fix 2468960: Make sure unlock screen gets updated when SIM state changes.
Added code to let us lazily re-create the unlock screen when the SIM status changes. This fixes a bug where we sometimes show the Pattern/Password unlock instead of the SIM PIN unlock due to an ordering issue with recent changes to the telephony layer SIM update logic. It now correctly re-evaluates the SIM state and updates the UI accordingly.
-rw-r--r--phone/com/android/internal/policy/impl/LockPatternKeyguardView.java63
1 files changed, 55 insertions, 8 deletions
diff --git a/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java b/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 48abe63..e4f28e9 100644
--- a/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -122,7 +122,12 @@ public class LockPatternKeyguardView extends KeyguardViewBase
/**
* Unlock by entering a password or PIN
*/
- Password
+ Password,
+
+ /**
+ * Unknown (uninitialized) value
+ */
+ Unknown
}
/**
@@ -153,6 +158,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase
private int mNumAccounts;
private boolean mIsPortrait;
+ private UnlockMode mCurrentUnlockMode = UnlockMode.Unknown;
+
/**
* @return Whether we are stuck on the lock screen because the sim is
* missing.
@@ -421,7 +428,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase
}
}
- private void recreateScreens() {
+ private void recreateLockScreen() {
if (mLockScreen.getVisibility() == View.VISIBLE) {
((KeyguardScreen) mLockScreen).onPause();
}
@@ -431,7 +438,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase
mLockScreen = createLockScreen();
mLockScreen.setVisibility(View.INVISIBLE);
addView(mLockScreen);
+ }
+ private void recreateUnlockScreen() {
if (mUnlockScreen.getVisibility() == View.VISIBLE) {
((KeyguardScreen) mUnlockScreen).onPause();
}
@@ -443,11 +452,14 @@ public class LockPatternKeyguardView extends KeyguardViewBase
mUnlockScreen.setVisibility(View.INVISIBLE);
mUnlockScreenMode = unlockMode;
addView(mUnlockScreen);
+ }
+ private void recreateScreens() {
+ recreateLockScreen();
+ recreateUnlockScreen();
updateScreen(mMode);
}
-
@Override
public void wakeWhenReadyTq(int keyCode) {
if (DEBUG) Log.d(TAG, "onWakeKey");
@@ -512,6 +524,12 @@ public class LockPatternKeyguardView extends KeyguardViewBase
mMode = mode;
+ // Re-create the unlock screen if necessary. This is primarily required to properly handle
+ // SIM state changes. This typically happens when this method is called by reset()
+ if (mode == Mode.UnlockScreen && mCurrentUnlockMode != getUnlockMode()) {
+ recreateUnlockScreen();
+ }
+
final View goneScreen = (mode == Mode.LockScreen) ? mUnlockScreen : mLockScreen;
final View visibleScreen = (mode == Mode.LockScreen) ? mLockScreen : mUnlockScreen;
@@ -551,6 +569,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase
// Capture the orientation this layout was created in.
mIsPortrait = getResources().getBoolean(R.bool.lockscreen_isPortrait);
+ View unlockView = null;
if (unlockMode == UnlockMode.Pattern) {
PatternUnlockScreen view = new PatternUnlockScreen(
mContext,
@@ -561,16 +580,16 @@ public class LockPatternKeyguardView extends KeyguardViewBase
if (DEBUG) Log.d(TAG,
"createUnlockScreenFor(" + unlockMode + "): mEnableFallback=" + mEnableFallback);
view.setEnableFallback(mEnableFallback);
- return view;
+ unlockView = view;
} else if (unlockMode == UnlockMode.SimPin) {
- return new SimUnlockScreen(
+ unlockView = new SimUnlockScreen(
mContext,
mUpdateMonitor,
mKeyguardScreenCallback,
mLockPatternUtils);
} else if (unlockMode == UnlockMode.Account) {
try {
- return new AccountUnlockScreen(
+ unlockView = new AccountUnlockScreen(
mContext,
mKeyguardScreenCallback,
mLockPatternUtils);
@@ -587,10 +606,10 @@ public class LockPatternKeyguardView extends KeyguardViewBase
// regular pattern unlock UI, regardless of the value of
// mUnlockScreenMode or whether or not we're in the
// "permanently locked" state.)
- return createUnlockScreenFor(UnlockMode.Pattern);
+ unlockView = createUnlockScreenFor(UnlockMode.Pattern);
}
} else if (unlockMode == UnlockMode.Password) {
- return new PasswordUnlockScreen(
+ unlockView = new PasswordUnlockScreen(
mContext,
mLockPatternUtils,
mUpdateMonitor,
@@ -598,6 +617,34 @@ public class LockPatternKeyguardView extends KeyguardViewBase
} else {
throw new IllegalArgumentException("unknown unlock mode " + unlockMode);
}
+ mCurrentUnlockMode = unlockMode;
+ return unlockView;
+ }
+
+ private View getUnlockScreenForCurrentUnlockMode() {
+ final UnlockMode unlockMode = getUnlockMode();
+
+ // if a screen exists for the correct mode, we're done
+ if (unlockMode == mUnlockScreenMode) {
+ return mUnlockScreen;
+ }
+
+ // remember the mode
+ mUnlockScreenMode = unlockMode;
+
+ // unlock mode has changed and we have an existing old unlock screen
+ // to clean up
+ if (mScreenOn && (mUnlockScreen.getVisibility() == View.VISIBLE)) {
+ ((KeyguardScreen) mUnlockScreen).onPause();
+ }
+ ((KeyguardScreen) mUnlockScreen).cleanUp();
+ removeViewInLayout(mUnlockScreen);
+
+ // create the new one
+ mUnlockScreen = createUnlockScreenFor(unlockMode);
+ mUnlockScreen.setVisibility(View.INVISIBLE);
+ addView(mUnlockScreen);
+ return mUnlockScreen;
}
/**