Policy part of fixing issue #2519590: Lock screen stuck in landscape mode

Change-Id: Id7f3a7102a86f4fecb7f7ef40b1275b75e27dac4
This commit is contained in:
Dianne Hackborn
2010-03-18 01:04:37 -07:00
parent e78fab5a2e
commit 75787398fa
5 changed files with 86 additions and 18 deletions

View File

@@ -60,6 +60,8 @@ import java.io.IOException;
public class LockPatternKeyguardView extends KeyguardViewBase
implements AccountManagerCallback<Account[]> {
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 "

View File

@@ -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() {

View File

@@ -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) {

View File

@@ -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);
}

View File

@@ -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();
}
/**