diff --git a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java index 3deee6f795600..da51ad052f7ee 100644 --- a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java +++ b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java @@ -60,6 +60,8 @@ import java.io.IOException; public class LockPatternKeyguardView extends KeyguardViewBase implements AccountManagerCallback { + static final boolean DEBUG_CONFIGURATION = false; + // time after launching EmergencyDialer before the screen goes blank. private static final int EMERGENCY_CALL_TIMEOUT = 10000; @@ -413,7 +415,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase ((KeyguardScreen) mLockScreen).onPause(); } ((KeyguardScreen) mLockScreen).cleanUp(); - removeViewInLayout(mLockScreen); + removeView(mLockScreen); mLockScreen = createLockScreen(); mLockScreen.setVisibility(View.INVISIBLE); @@ -425,7 +427,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase ((KeyguardScreen) mUnlockScreen).onPause(); } ((KeyguardScreen) mUnlockScreen).cleanUp(); - removeViewInLayout(mUnlockScreen); + removeView(mUnlockScreen); final UnlockMode unlockMode = getUnlockMode(); mUnlockScreen = createUnlockScreenFor(unlockMode); @@ -502,6 +504,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase private void updateScreen(final Mode mode) { + if (DEBUG_CONFIGURATION) Log.v(TAG, "**** UPDATE SCREEN: mode=" + mode + + " last mode=" + mMode, new RuntimeException()); + mMode = mode; // Re-create the unlock screen if necessary. This is primarily required to properly handle @@ -517,7 +522,11 @@ public class LockPatternKeyguardView extends KeyguardViewBase // flag is set mWindowController.setNeedsInput(((KeyguardScreen)visibleScreen).needsInput()); - + if (DEBUG_CONFIGURATION) { + Log.v(TAG, "Gone=" + goneScreen); + Log.v(TAG, "Visible=" + visibleScreen); + } + if (mScreenOn) { if (goneScreen.getVisibility() == View.VISIBLE) { ((KeyguardScreen) goneScreen).onPause(); @@ -529,7 +538,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase goneScreen.setVisibility(View.GONE); visibleScreen.setVisibility(View.VISIBLE); - + requestLayout(); if (!visibleScreen.requestFocus()) { throw new IllegalStateException("keyguard screen must be able to take " diff --git a/policy/com/android/internal/policy/impl/LockScreen.java b/policy/com/android/internal/policy/impl/LockScreen.java index ae1367a075a60..baed9ebcea326 100644 --- a/policy/com/android/internal/policy/impl/LockScreen.java +++ b/policy/com/android/internal/policy/impl/LockScreen.java @@ -180,6 +180,12 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM mKeyboardHidden = configuration.hardKeyboardHidden; + if (LockPatternKeyguardView.DEBUG_CONFIGURATION) { + Log.v(TAG, "***** CREATING LOCK SCREEN", new RuntimeException()); + Log.v(TAG, "Cur orient=" + mCreationOrientation + + " res orient=" + context.getResources().getConfiguration().orientation); + } + final LayoutInflater inflater = LayoutInflater.from(context); if (DBG) Log.v(TAG, "Creation orientation = " + mCreationOrientation); if (mCreationOrientation != Configuration.ORIENTATION_LANDSCAPE) { @@ -600,16 +606,8 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM updateStatusLines(); } - /** {@inheritDoc} */ - @Override - protected void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - if (DBG) { - Log.v(TAG, "onConfigurationChanged() time " + SystemClock.elapsedRealtime()); - if (getResources().getConfiguration().orientation != newConfig.orientation) { - Log.e(TAG, "mismatchConfig: ", new Exception("stack trace:")); - } - } + void updateConfiguration() { + Configuration newConfig = getResources().getConfiguration(); if (newConfig.orientation != mCreationOrientation) { mCallback.recreateMe(newConfig); } else if (newConfig.hardKeyboardHidden != mKeyboardHidden) { @@ -620,6 +618,29 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM } } } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (LockPatternKeyguardView.DEBUG_CONFIGURATION) { + Log.v(TAG, "***** LOCK ATTACHED TO WINDOW"); + Log.v(TAG, "Cur orient=" + mCreationOrientation + + ", new config=" + getResources().getConfiguration()); + } + updateConfiguration(); + } + + /** {@inheritDoc} */ + @Override + protected void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + if (LockPatternKeyguardView.DEBUG_CONFIGURATION) { + Log.w(TAG, "***** LOCK CONFIG CHANGING", new RuntimeException()); + Log.v(TAG, "Cur orient=" + mCreationOrientation + + ", new config=" + newConfig); + } + updateConfiguration(); + } /** {@inheritDoc} */ public boolean needsInput() { diff --git a/policy/com/android/internal/policy/impl/PasswordUnlockScreen.java b/policy/com/android/internal/policy/impl/PasswordUnlockScreen.java index e08fe4f18e186..07eaf9369f92b 100644 --- a/policy/com/android/internal/policy/impl/PasswordUnlockScreen.java +++ b/policy/com/android/internal/policy/impl/PasswordUnlockScreen.java @@ -206,6 +206,14 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen return false; } + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (getResources().getConfiguration().orientation != mCreationOrientation) { + mCallback.recreateMe(getResources().getConfiguration()); + } + } + /** {@inheritDoc} */ @Override protected void onConfigurationChanged(Configuration newConfig) { diff --git a/policy/com/android/internal/policy/impl/PatternUnlockScreen.java b/policy/com/android/internal/policy/impl/PatternUnlockScreen.java index a93b4629d7845..418e243922795 100644 --- a/policy/com/android/internal/policy/impl/PatternUnlockScreen.java +++ b/policy/com/android/internal/policy/impl/PatternUnlockScreen.java @@ -398,11 +398,29 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient public void onSimStateChanged(IccCard.State simState) { } + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (LockPatternKeyguardView.DEBUG_CONFIGURATION) { + Log.v(TAG, "***** PATTERN ATTACHED TO WINDOW"); + Log.v(TAG, "Cur orient=" + mCreationOrientation + + ", new config=" + getResources().getConfiguration()); + } + if (getResources().getConfiguration().orientation != mCreationOrientation) { + mCallback.recreateMe(getResources().getConfiguration()); + } + } + /** {@inheritDoc} */ @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); + if (LockPatternKeyguardView.DEBUG_CONFIGURATION) { + Log.v(TAG, "***** PATTERN CONFIGURATION CHANGED"); + Log.v(TAG, "Cur orient=" + mCreationOrientation + + ", new config=" + getResources().getConfiguration()); + } if (newConfig.orientation != mCreationOrientation) { mCallback.recreateMe(newConfig); } diff --git a/policy/com/android/internal/policy/impl/SimUnlockScreen.java b/policy/com/android/internal/policy/impl/SimUnlockScreen.java index d92b961da22a9..5518e11ab6392 100644 --- a/policy/com/android/internal/policy/impl/SimUnlockScreen.java +++ b/policy/com/android/internal/policy/impl/SimUnlockScreen.java @@ -279,10 +279,8 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie mEnteredPin[mEnteredDigits++] = digit; } - /** {@inheritDoc} */ - @Override - protected void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); + void updateConfiguration() { + Configuration newConfig = getResources().getConfiguration(); if (newConfig.orientation != mCreationOrientation) { mCallback.recreateMe(newConfig); } else if (newConfig.hardKeyboardHidden != mKeyboardHidden) { @@ -292,6 +290,20 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie mCallback.goToUnlockScreen(); } } + + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + updateConfiguration(); + } + + /** {@inheritDoc} */ + @Override + protected void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + updateConfiguration(); } /**