From a027c95e798d75de1165feebefb2df4d1c7c0927 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Fri, 12 Mar 2010 17:32:01 -0800 Subject: [PATCH] Fix 2428368: Fix most of the lockscreen orientation refresh bugs This change removes the legacy notification of orientation and configuration changed events from KeyguardUpdateMonitor and moves them into the individual activities. This was necessary to guarantee order of events. In addition, to minimize discrepencies due to notification lag, Keyguard screens (LockScreen, PatternUnlock, etc.) are now responsible for handling onConfigurationChanged() notification and forwarding them to LockPatternKeyguardView by a call to recreateMe() with the new configuration. Change-Id: I703daf3e91bc6588e87c844a3ed3d259a6b8ecdf --- .../internal/widget/LockPatternUtils.java | 2 +- .../impl/LockPatternKeyguardViewTest.java | 31 +++---------------- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index efd025af2c55c..9b7f4872c1547 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -47,6 +47,7 @@ import java.util.List; public class LockPatternUtils { private static final String TAG = "LockPatternUtils"; + private static final boolean LDEBUG = false; private static final String LOCK_PATTERN_FILE = "/system/gesture.key"; private static final String LOCK_PASSWORD_FILE = "/system/password.key"; @@ -126,7 +127,6 @@ public class LockPatternUtils { public LockPatternUtils(Context context) { mContext = context; mContentResolver = context.getContentResolver(); - mDevicePolicyManager = getDevicePolicyManager(); // Initialize the location of gesture lock file if (sLockPatternFilename == null) { sLockPatternFilename = android.os.Environment.getDataDirectory() diff --git a/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java b/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java index fd05fed2e07ff..1e57bd2ca1220 100644 --- a/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java +++ b/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java @@ -18,6 +18,7 @@ package com.android.internal.policy.impl; import android.content.Context; import com.android.internal.telephony.IccCard; +import android.content.res.Configuration; import android.test.AndroidTestCase; import android.view.View; import android.view.KeyEvent; @@ -39,8 +40,6 @@ public class LockPatternKeyguardViewTest extends AndroidTestCase { private static class MockUpdateMonitor extends KeyguardUpdateMonitor { public IccCard.State simState = IccCard.State.READY; - public boolean inPortrait = false; - public boolean keyboardOpen = false; private MockUpdateMonitor(Context context) { super(context); @@ -50,26 +49,6 @@ public class LockPatternKeyguardViewTest extends AndroidTestCase { public IccCard.State getSimState() { return simState; } - - @Override - public boolean isInPortrait() { - return inPortrait; - } - - @Override - public boolean isKeyboardOpen() { - return keyboardOpen; - } - - @Override - boolean queryInPortrait() { - return inPortrait; - } - - @Override - boolean queryKeyboardOpen() { - return keyboardOpen; - } } private static class MockLockPatternUtils extends LockPatternUtils { @@ -115,7 +94,7 @@ public class LockPatternKeyguardViewTest extends AndroidTestCase { public boolean needsInput() { return false; } - + /** {@inheritDoc} */ public void onPause() { mOnPauseCount++; @@ -202,7 +181,7 @@ public class LockPatternKeyguardViewTest extends AndroidTestCase { } public void keyguardDoneDrawing() { - + } public int getPokeWakelockCount() { @@ -293,7 +272,7 @@ public class LockPatternKeyguardViewTest extends AndroidTestCase { // should have poked the wakelock to turn on the screen assertEquals(1, mKeyguardViewCallback.getPokeWakelockCount()); - + // shouldn't be any additional views created assertEquals(1, mLPKV.getInjectedLockScreens().size()); assertEquals(1, mLPKV.getInjectedUnlockScreens().size()); @@ -317,7 +296,7 @@ public class LockPatternKeyguardViewTest extends AndroidTestCase { assertEquals(1, lockScreen.getOnResumeCount()); // simulate screen asking to be recreated - mLPKV.mKeyguardScreenCallback.recreateMe(); + mLPKV.mKeyguardScreenCallback.recreateMe(new Configuration()); // should have been recreated assertEquals(2, mLPKV.getInjectedLockScreens().size());