summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Miller <jaggies@google.com>2010-03-15 15:33:44 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-03-15 15:33:44 -0700
commit95da65e172b846515b9245e4a01c3dc260177d68 (patch)
tree24c9351dc372dd34f35a01274f1409028d4d7252
parent4c938f402663bcdbadc08af91afdd9e96eac7e42 (diff)
parentba945c0183e84018a8c2a678fa3d50876e1a5ee4 (diff)
downloadbase-95da65e172b846515b9245e4a01c3dc260177d68.tar.gz
Merge "Fix 2428368: Fix most of the lockscreen orientation refresh bugs"
-rw-r--r--phone/com/android/internal/policy/impl/AccountUnlockScreen.java7
-rw-r--r--phone/com/android/internal/policy/impl/KeyguardScreenCallback.java4
-rw-r--r--phone/com/android/internal/policy/impl/KeyguardUpdateMonitor.java88
-rw-r--r--phone/com/android/internal/policy/impl/LockPatternKeyguardView.java66
-rw-r--r--phone/com/android/internal/policy/impl/LockScreen.java67
-rw-r--r--phone/com/android/internal/policy/impl/PasswordUnlockScreen.java38
-rw-r--r--phone/com/android/internal/policy/impl/PatternUnlockScreen.java36
-rw-r--r--phone/com/android/internal/policy/impl/SimUnlockScreen.java44
8 files changed, 129 insertions, 221 deletions
diff --git a/phone/com/android/internal/policy/impl/AccountUnlockScreen.java b/phone/com/android/internal/policy/impl/AccountUnlockScreen.java
index 1aaef83..53793de 100644
--- a/phone/com/android/internal/policy/impl/AccountUnlockScreen.java
+++ b/phone/com/android/internal/policy/impl/AccountUnlockScreen.java
@@ -27,6 +27,7 @@ import android.accounts.AuthenticatorException;
import android.accounts.AccountManagerCallback;
import android.content.Context;
import android.content.Intent;
+import android.content.res.Configuration;
import android.graphics.Rect;
import android.telephony.TelephonyManager;
import android.text.Editable;
@@ -79,10 +80,10 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
/**
* AccountUnlockScreen constructor.
+ * @param configuration
*/
- public AccountUnlockScreen(Context context,
- KeyguardScreenCallback callback,
- LockPatternUtils lockPatternUtils) {
+ public AccountUnlockScreen(Context context,Configuration configuration,
+ KeyguardScreenCallback callback, LockPatternUtils lockPatternUtils) {
super(context);
mCallback = callback;
mLockPatternUtils = lockPatternUtils;
diff --git a/phone/com/android/internal/policy/impl/KeyguardScreenCallback.java b/phone/com/android/internal/policy/impl/KeyguardScreenCallback.java
index 06a5f19..a843603 100644
--- a/phone/com/android/internal/policy/impl/KeyguardScreenCallback.java
+++ b/phone/com/android/internal/policy/impl/KeyguardScreenCallback.java
@@ -16,6 +16,8 @@
package com.android.internal.policy.impl;
+import android.content.res.Configuration;
+
/**
* Within a keyguard, there may be several screens that need a callback
* to the host keyguard view.
@@ -55,7 +57,7 @@ public interface KeyguardScreenCallback extends KeyguardViewCallback {
/**
* Stay on me, but recreate me (so I can use a different layout).
*/
- void recreateMe();
+ void recreateMe(Configuration config);
/**
* Take action to send an emergency call.
diff --git a/phone/com/android/internal/policy/impl/KeyguardUpdateMonitor.java b/phone/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
index b7bb184..b225e56 100644
--- a/phone/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
+++ b/phone/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
@@ -28,6 +28,7 @@ import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN;
import android.media.AudioManager;
import android.os.Handler;
import android.os.Message;
+import android.os.SystemClock;
import android.provider.Settings;
import android.provider.Telephony;
import static android.provider.Telephony.Intents.EXTRA_PLMN;
@@ -66,8 +67,6 @@ public class KeyguardUpdateMonitor {
private final Context mContext;
private IccCard.State mSimState = IccCard.State.READY;
- private boolean mInPortrait;
- private boolean mKeyboardOpen;
private boolean mKeyguardBypassEnabled;
@@ -84,15 +83,11 @@ public class KeyguardUpdateMonitor {
private Handler mHandler;
- private ArrayList<ConfigurationChangeCallback> mConfigurationChangeCallbacks
- = Lists.newArrayList();
private ArrayList<InfoCallback> mInfoCallbacks = Lists.newArrayList();
private ArrayList<SimStateCallback> mSimStateCallbacks = Lists.newArrayList();
private ContentObserver mContentObserver;
-
// messages for the handler
- private static final int MSG_CONFIGURATION_CHANGED = 300;
private static final int MSG_TIME_UPDATE = 301;
private static final int MSG_BATTERY_UPDATE = 302;
private static final int MSG_CARRIER_INFO_UPDATE = 303;
@@ -150,9 +145,6 @@ public class KeyguardUpdateMonitor {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
- case MSG_CONFIGURATION_CHANGED:
- handleConfigurationChange();
- break;
case MSG_TIME_UPDATE:
handleTimeUpdate();
break;
@@ -209,9 +201,6 @@ public class KeyguardUpdateMonitor {
Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
}
- mInPortrait = queryInPortrait();
- mKeyboardOpen = queryKeyboardOpen();
-
// take a guess to start
mSimState = IccCard.State.READY;
mDevicePluggedIn = true;
@@ -221,7 +210,6 @@ public class KeyguardUpdateMonitor {
// setup receiver
final IntentFilter filter = new IntentFilter();
- filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
filter.addAction(Intent.ACTION_TIME_TICK);
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
@@ -236,9 +224,7 @@ public class KeyguardUpdateMonitor {
final String action = intent.getAction();
if (DEBUG) Log.d(TAG, "received broadcast " + action);
- if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
- mHandler.sendMessage(mHandler.obtainMessage(MSG_CONFIGURATION_CHANGED));
- } else if (Intent.ACTION_TIME_TICK.equals(action)
+ if (Intent.ACTION_TIME_TICK.equals(action)
|| Intent.ACTION_TIME_CHANGED.equals(action)
|| Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_TIME_UPDATE));
@@ -285,29 +271,6 @@ public class KeyguardUpdateMonitor {
}
/**
- * Handle {@link #MSG_CONFIGURATION_CHANGED}
- */
- private void handleConfigurationChange() {
- if (DEBUG) Log.d(TAG, "handleConfigurationChange");
-
- final boolean inPortrait = queryInPortrait();
- if (mInPortrait != inPortrait) {
- mInPortrait = inPortrait;
- for (int i = 0; i < mConfigurationChangeCallbacks.size(); i++) {
- mConfigurationChangeCallbacks.get(i).onOrientationChange(inPortrait);
- }
- }
-
- final boolean keyboardOpen = queryKeyboardOpen();
- if (mKeyboardOpen != keyboardOpen) {
- mKeyboardOpen = keyboardOpen;
- for (int i = 0; i < mConfigurationChangeCallbacks.size(); i++) {
- mConfigurationChangeCallbacks.get(i).onKeyboardChange(keyboardOpen);
- }
- }
- }
-
- /**
* Handle {@link #MSG_TIME_UPDATE}
*/
private void handleTimeUpdate() {
@@ -394,23 +357,6 @@ public class KeyguardUpdateMonitor {
}
/**
- * What is the current orientation?
- */
- boolean queryInPortrait() {
- final Configuration configuration = mContext.getResources().getConfiguration();
- return configuration.orientation == Configuration.ORIENTATION_PORTRAIT;
- }
-
- /**
- * Is the (hard) keyboard currently open?
- */
- boolean queryKeyboardOpen() {
- final Configuration configuration = mContext.getResources().getConfiguration();
-
- return configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
- }
-
- /**
* @param intent The intent with action {@link Telephony.Intents#SPN_STRINGS_UPDATED_ACTION}
* @return The string to use for the plmn, or null if it should not be shown.
*/
@@ -455,21 +401,11 @@ public class KeyguardUpdateMonitor {
* {@link InfoCallback} or {@link SimStateCallback}
*/
public void removeCallback(Object observer) {
- mConfigurationChangeCallbacks.remove(observer);
mInfoCallbacks.remove(observer);
mSimStateCallbacks.remove(observer);
}
/**
- * Callback for configuration changes.
- */
- interface ConfigurationChangeCallback {
- void onOrientationChange(boolean inPortrait);
-
- void onKeyboardChange(boolean isKeyboardOpen);
- }
-
- /**
* Callback for general information relevant to lock screen.
*/
interface InfoCallback {
@@ -507,18 +443,6 @@ public class KeyguardUpdateMonitor {
}
/**
- * Register to receive notifications about configuration changes.
- * @param callback The callback.
- */
- public void registerConfigurationChangeCallback(ConfigurationChangeCallback callback) {
- if (!mConfigurationChangeCallbacks.contains(callback)) {
- mConfigurationChangeCallbacks.add(callback);
- } else {
- Log.e(TAG, "Object tried to add another CONFIG callback", new Exception("Whoops"));
- }
- }
-
- /**
* Register to receive notifications about general keyguard information
* (see {@link InfoCallback}.
* @param callback The callback.
@@ -556,14 +480,6 @@ public class KeyguardUpdateMonitor {
mSimState = IccCard.State.READY;
}
- public boolean isInPortrait() {
- return mInPortrait;
- }
-
- public boolean isKeyboardOpen() {
- return mKeyboardOpen;
- }
-
public boolean isKeyguardBypassEnabled() {
return mKeyguardBypassEnabled;
}
diff --git a/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java b/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 8bda760..8ec1e74 100644
--- a/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -34,15 +34,14 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
-import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
+import android.os.SystemClock;
import android.os.SystemProperties;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
-import android.view.ViewGroup;
import android.view.WindowManager;
import java.io.IOException;
@@ -79,7 +78,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase
private boolean mScreenOn = false;
private boolean mEnableFallback = false; // assume no fallback UI until we know better
-
/**
* The current {@link KeyguardScreen} will use this to communicate back to us.
*/
@@ -156,11 +154,15 @@ public class LockPatternKeyguardView extends KeyguardViewBase
private final LockPatternUtils mLockPatternUtils;
private int mNumAccounts;
- private boolean mIsPortrait;
private UnlockMode mCurrentUnlockMode = UnlockMode.Unknown;
/**
+ * The current configuration.
+ */
+ private Configuration mConfiguration;
+
+ /**
* @return Whether we are stuck on the lock screen because the sim is
* missing.
*/
@@ -203,6 +205,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase
KeyguardWindowController controller) {
super(context);
+ mConfiguration = context.getResources().getConfiguration();
mEnableFallback = false;
mRequiresSim =
@@ -257,7 +260,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase
return mIsVerifyUnlockOnly;
}
- public void recreateMe() {
+ public void recreateMe(Configuration config) {
+ mConfiguration = config;
recreateScreens();
}
@@ -370,23 +374,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase
// be removed once the race condition is fixed. See bugs 2262578 and 2292713.
@Override
protected void dispatchDraw(Canvas canvas) {
- final int orientation = getResources().getConfiguration().orientation;
- if (mIsPortrait && Configuration.ORIENTATION_PORTRAIT != orientation
- || getResources().getBoolean(R.bool.lockscreen_isPortrait) != mIsPortrait) {
- // Make sure we redraw once things settle down.
- // Log.v(TAG, "dispatchDraw(): not drawing because state is inconsistent");
- postInvalidate();
-
- // In order to minimize flashing, draw the first child's background for now.
- ViewGroup view = (ViewGroup) (mMode == Mode.LockScreen ? mLockScreen : mUnlockScreen);
- if (view != null && view.getChildAt(0) != null) {
- Drawable background = view.getChildAt(0).getBackground();
- if (background != null) {
- background.draw(canvas);
- }
- }
- return;
- }
+ if (DEBUG) Log.v(TAG, "*** dispatchDraw() time: " + SystemClock.elapsedRealtime());
super.dispatchDraw(canvas);
}
@@ -550,19 +538,18 @@ public class LockPatternKeyguardView extends KeyguardViewBase
View createLockScreen() {
return new LockScreen(
mContext,
+ mConfiguration,
mLockPatternUtils,
mUpdateMonitor,
mKeyguardScreenCallback);
}
View createUnlockScreenFor(UnlockMode unlockMode) {
- // 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,
+ mConfiguration,
mLockPatternUtils,
mUpdateMonitor,
mKeyguardScreenCallback,
@@ -574,6 +561,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase
} else if (unlockMode == UnlockMode.SimPin) {
unlockView = new SimUnlockScreen(
mContext,
+ mConfiguration,
mUpdateMonitor,
mKeyguardScreenCallback,
mLockPatternUtils);
@@ -581,6 +569,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase
try {
unlockView = new AccountUnlockScreen(
mContext,
+ mConfiguration,
mKeyguardScreenCallback,
mLockPatternUtils);
} catch (IllegalStateException e) {
@@ -601,6 +590,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase
} else if (unlockMode == UnlockMode.Password) {
unlockView = new PasswordUnlockScreen(
mContext,
+ mConfiguration,
mLockPatternUtils,
mUpdateMonitor,
mKeyguardScreenCallback);
@@ -611,32 +601,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase
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;
- }
-
/**
* Given the current state of things, what should be the initial mode of
* the lock screen (lock or unlock).
diff --git a/phone/com/android/internal/policy/impl/LockScreen.java b/phone/com/android/internal/policy/impl/LockScreen.java
index 22a4336..ae1367a 100644
--- a/phone/com/android/internal/policy/impl/LockScreen.java
+++ b/phone/com/android/internal/policy/impl/LockScreen.java
@@ -18,15 +18,13 @@ package com.android.internal.policy.impl;
import com.android.internal.R;
import com.android.internal.telephony.IccCard;
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.Phone.State;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.SlidingTab;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.ColorStateList;
-import android.telephony.TelephonyManager;
import android.text.format.DateFormat;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -36,6 +34,7 @@ import android.widget.*;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.media.AudioManager;
+import android.os.SystemClock;
import android.os.SystemProperties;
import android.provider.Settings;
@@ -48,8 +47,7 @@ import java.io.File;
* past it, as applicable.
*/
class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateMonitor.InfoCallback,
- KeyguardUpdateMonitor.SimStateCallback, KeyguardUpdateMonitor.ConfigurationChangeCallback,
- SlidingTab.OnTriggerListener {
+ KeyguardUpdateMonitor.SimStateCallback, SlidingTab.OnTriggerListener {
private static final boolean DBG = false;
private static final String TAG = "LockScreen";
@@ -70,6 +68,10 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
private TextView mScreenLocked;
private Button mEmergencyCallButton;
+ // current configuration state of keyboard and display
+ private int mKeyboardHidden;
+ private int mCreationOrientation;
+
// are we showing battery information?
private boolean mShowingBatteryInfo = false;
@@ -88,7 +90,6 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
private AudioManager mAudioManager;
private String mDateFormatString;
private java.text.DateFormat mTimeFormat;
- private boolean mCreatedInPortrait;
private boolean mEnableMenuKeyInLockScreen;
/**
@@ -159,12 +160,13 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
/**
* @param context Used to setup the view.
+ * @param configuration The current configuration. Used to use when selecting layout, etc.
* @param lockPatternUtils Used to know the state of the lock pattern settings.
* @param updateMonitor Used to register for updates on various keyguard related
* state, and query the initial state at setup.
* @param callback Used to communicate back to the host keyguard view.
*/
- LockScreen(Context context, LockPatternUtils lockPatternUtils,
+ LockScreen(Context context, Configuration configuration, LockPatternUtils lockPatternUtils,
KeyguardUpdateMonitor updateMonitor,
KeyguardScreenCallback callback) {
super(context);
@@ -174,10 +176,13 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
mEnableMenuKeyInLockScreen = shouldEnableMenuKey();
- mCreatedInPortrait = updateMonitor.isInPortrait();
+ mCreationOrientation = configuration.orientation;
+
+ mKeyboardHidden = configuration.hardKeyboardHidden;
final LayoutInflater inflater = LayoutInflater.from(context);
- if (mCreatedInPortrait) {
+ if (DBG) Log.v(TAG, "Creation orientation = " + mCreationOrientation);
+ if (mCreationOrientation != Configuration.ORIENTATION_LANDSCAPE) {
inflater.inflate(R.layout.keyguard_screen_tab_unlock, this, true);
} else {
inflater.inflate(R.layout.keyguard_screen_tab_unlock_land, this, true);
@@ -211,7 +216,6 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
updateMonitor.registerInfoCallback(this);
updateMonitor.registerSimStateCallback(this);
- updateMonitor.registerConfigurationChangeCallback(this);
mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
mSilentMode = isSilentMode();
@@ -234,14 +238,14 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
}
private void updateRightTabResources() {
- boolean vibe = mSilentMode
+ boolean vibe = mSilentMode
&& (mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE);
mSelector.setRightTabResources(
mSilentMode ? ( vibe ? R.drawable.ic_jog_dial_vibrate_on
- : R.drawable.ic_jog_dial_sound_off )
+ : R.drawable.ic_jog_dial_sound_off )
: R.drawable.ic_jog_dial_sound_on,
- mSilentMode ? R.drawable.jog_tab_target_yellow
+ mSilentMode ? R.drawable.jog_tab_target_yellow
: R.drawable.jog_tab_target_gray,
mSilentMode ? R.drawable.jog_tab_bar_right_sound_on
: R.drawable.jog_tab_bar_right_sound_off,
@@ -288,7 +292,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
Settings.System.VIBRATE_IN_SILENT, 1) == 1);
mAudioManager.setRingerMode(vibe
- ? AudioManager.RINGER_MODE_VIBRATE
+ ? AudioManager.RINGER_MODE_VIBRATE
: AudioManager.RINGER_MODE_SILENT);
} else {
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
@@ -368,7 +372,6 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
private Runnable mPendingR1;
private Runnable mPendingR2;
-
private void refreshAlarmDisplay() {
mNextAlarm = mLockPatternUtils.getNextAlarm();
if (mNextAlarm != null) {
@@ -457,13 +460,6 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
updateLayout(mStatus);
}
- private void addRelativeLayoutRule(View view, int rule, int viewId) {
- final RelativeLayout.LayoutParams layoutParams =
- (RelativeLayout.LayoutParams) view.getLayoutParams();
- layoutParams.addRule(rule, viewId);
- view.setLayoutParams(layoutParams);
- }
-
/**
* Determine the current status of the lock screen given the sim state and other stuff.
*/
@@ -604,20 +600,27 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
updateStatusLines();
}
-
- public void onOrientationChange(boolean inPortrait) {
- if (inPortrait != mCreatedInPortrait) {
- mCallback.recreateMe();
+ /** {@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:"));
+ }
}
- }
-
- public void onKeyboardChange(boolean isKeyboardOpen) {
- if (mUpdateMonitor.isKeyguardBypassEnabled() && isKeyboardOpen) {
- mCallback.goToUnlockScreen();
+ if (newConfig.orientation != mCreationOrientation) {
+ mCallback.recreateMe(newConfig);
+ } else if (newConfig.hardKeyboardHidden != mKeyboardHidden) {
+ mKeyboardHidden = newConfig.hardKeyboardHidden;
+ final boolean isKeyboardOpen = mKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
+ if (mUpdateMonitor.isKeyguardBypassEnabled() && isKeyboardOpen) {
+ mCallback.goToUnlockScreen();
+ }
}
}
-
/** {@inheritDoc} */
public boolean needsInput() {
return false;
diff --git a/phone/com/android/internal/policy/impl/PasswordUnlockScreen.java b/phone/com/android/internal/policy/impl/PasswordUnlockScreen.java
index c52ef53..0bbab3e 100644
--- a/phone/com/android/internal/policy/impl/PasswordUnlockScreen.java
+++ b/phone/com/android/internal/policy/impl/PasswordUnlockScreen.java
@@ -17,6 +17,7 @@
package com.android.internal.policy.impl;
import android.content.Context;
+import android.content.res.Configuration;
import android.graphics.Rect;
import com.android.internal.widget.LockPatternUtils;
@@ -42,37 +43,38 @@ import com.android.internal.widget.PasswordEntryKeyboardHelper;
* Displays a dialer-like interface or alphanumeric (latin-1) key entry for the user to enter
* an unlock password
*/
-public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen, View.OnClickListener,
- KeyguardUpdateMonitor.ConfigurationChangeCallback, KeyguardUpdateMonitor.InfoCallback,
- OnEditorActionListener {
-
- private static final int DIGIT_PRESS_WAKE_MILLIS = 5000;
+public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen,
+ View.OnClickListener, KeyguardUpdateMonitor.InfoCallback, OnEditorActionListener {
private final KeyguardUpdateMonitor mUpdateMonitor;
private final KeyguardScreenCallback mCallback;
- private final boolean mCreatedWithKeyboardOpen;
-
private EditText mPasswordEntry;
private Button mEmergencyCallButton;
private LockPatternUtils mLockPatternUtils;
private PasswordEntryKeyboardView mKeyboardView;
private PasswordEntryKeyboardHelper mKeyboardHelper;
+ private int mCreationOrientation;
+ private int mKeyboardHidden;
+
// To avoid accidental lockout due to events while the device in in the pocket, ignore
// any passwords with length less than or equal to this length.
private static final int MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT = 3;
- public PasswordUnlockScreen(Context context, LockPatternUtils lockPatternUtils,
- KeyguardUpdateMonitor updateMonitor, KeyguardScreenCallback callback) {
+ public PasswordUnlockScreen(Context context, Configuration configuration,
+ LockPatternUtils lockPatternUtils, KeyguardUpdateMonitor updateMonitor,
+ KeyguardScreenCallback callback) {
super(context);
+
+ mKeyboardHidden = configuration.hardKeyboardHidden;
+ mCreationOrientation = configuration.orientation;
mUpdateMonitor = updateMonitor;
mCallback = callback;
- mCreatedWithKeyboardOpen = mUpdateMonitor.isKeyboardOpen();
mLockPatternUtils = lockPatternUtils;
LayoutInflater layoutInflater = LayoutInflater.from(context);
- if (mUpdateMonitor.isInPortrait()) {
+ if (mCreationOrientation != Configuration.ORIENTATION_LANDSCAPE) {
layoutInflater.inflate(R.layout.keyguard_screen_password_portrait, this, true);
} else {
layoutInflater.inflate(R.layout.keyguard_screen_password_landscape, this, true);
@@ -85,13 +87,13 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
mEmergencyCallButton = (Button) findViewById(R.id.emergencyCall);
mEmergencyCallButton.setOnClickListener(this);
mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
- mUpdateMonitor.registerConfigurationChangeCallback(this);
mKeyboardHelper = new PasswordEntryKeyboardHelper(context, mKeyboardView, this);
mKeyboardHelper.setKeyboardMode(isAlpha ? PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
: PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
- mKeyboardView.setVisibility(mCreatedWithKeyboardOpen ? View.INVISIBLE : View.VISIBLE);
+ mKeyboardView.setVisibility(mKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO
+ ? View.INVISIBLE : View.VISIBLE);
mPasswordEntry.requestFocus();
// This allows keyboards with overlapping qwerty/numeric keys to choose just the
@@ -104,7 +106,6 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
mKeyboardHelper.setVibratePattern(mLockPatternUtils.isTactileFeedbackEnabled() ?
com.android.internal.R.array.config_virtualKeyVibePattern : 0);
-
}
@Override
@@ -162,8 +163,13 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
return false;
}
- public void onOrientationChange(boolean inPortrait) {
- mCallback.recreateMe();
+ /** {@inheritDoc} */
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ if (newConfig.orientation != mCreationOrientation) {
+ mCallback.recreateMe(newConfig);
+ }
}
public void onKeyboardChange(boolean isKeyboardOpen) {
diff --git a/phone/com/android/internal/policy/impl/PatternUnlockScreen.java b/phone/com/android/internal/policy/impl/PatternUnlockScreen.java
index d09b358..a93b462 100644
--- a/phone/com/android/internal/policy/impl/PatternUnlockScreen.java
+++ b/phone/com/android/internal/policy/impl/PatternUnlockScreen.java
@@ -17,6 +17,7 @@
package com.android.internal.policy.impl;
import android.content.Context;
+import android.content.res.Configuration;
import android.os.CountDownTimer;
import android.os.SystemClock;
import android.view.LayoutInflater;
@@ -25,7 +26,6 @@ import android.view.ViewGroup;
import android.view.MotionEvent;
import android.widget.Button;
import android.widget.TextView;
-import android.telephony.TelephonyManager;
import android.text.format.DateFormat;
import android.text.TextUtils;
import android.util.Log;
@@ -44,8 +44,8 @@ import java.util.Date;
* the user how to unlock their device, or make an emergency call.
*/
class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
- implements KeyguardScreen, KeyguardUpdateMonitor.ConfigurationChangeCallback,
- KeyguardUpdateMonitor.InfoCallback, KeyguardUpdateMonitor.SimStateCallback {
+ implements KeyguardScreen, KeyguardUpdateMonitor.InfoCallback,
+ KeyguardUpdateMonitor.SimStateCallback {
private static final boolean DEBUG = false;
private static final String TAG = "UnlockScreen";
@@ -75,8 +75,6 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
*/
private boolean mEnableFallback;
- private boolean mCreatedInPortrait;
-
private String mDateFormatString;
private TextView mCarrier;
@@ -124,6 +122,7 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
private Button mForgotPatternButton;
private Button mEmergencyAlone;
private Button mEmergencyTogether;
+ private int mCreationOrientation;
enum FooterMode {
Normal,
@@ -150,6 +149,7 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
/**
* @param context The context.
+ * @param configuration
* @param lockPatternUtils Used to lookup lock pattern settings.
* @param updateMonitor Used to lookup state affecting keyguard.
* @param callback Used to notify the manager when we're done, etc.
@@ -159,7 +159,7 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
* backup option).
*/
PatternUnlockScreen(Context context,
- LockPatternUtils lockPatternUtils,
+ Configuration configuration, LockPatternUtils lockPatternUtils,
KeyguardUpdateMonitor updateMonitor,
KeyguardScreenCallback callback,
int totalFailedAttempts) {
@@ -168,7 +168,8 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
mUpdateMonitor = updateMonitor;
mCallback = callback;
mTotalFailedPatternAttempts = totalFailedAttempts;
- mFailedPatternAttemptsSinceLastTimeout = totalFailedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT;
+ mFailedPatternAttemptsSinceLastTimeout =
+ totalFailedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT;
if (DEBUG) Log.d(TAG,
"UnlockScreen() ctor: totalFailedAttempts="
@@ -176,10 +177,13 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
+ mFailedPatternAttemptsSinceLastTimeout
);
- if (mUpdateMonitor.isInPortrait()) {
- LayoutInflater.from(context).inflate(R.layout.keyguard_screen_unlock_portrait, this, true);
+ mCreationOrientation = configuration.orientation;
+
+ LayoutInflater inflater = LayoutInflater.from(context);
+ if (mCreationOrientation != Configuration.ORIENTATION_LANDSCAPE) {
+ inflater.inflate(R.layout.keyguard_screen_unlock_portrait, this, true);
} else {
- LayoutInflater.from(context).inflate(R.layout.keyguard_screen_unlock_landscape, this, true);
+ inflater.inflate(R.layout.keyguard_screen_unlock_landscape, this, true);
}
mCarrier = (TextView) findViewById(R.id.carrier);
@@ -241,10 +245,8 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
// assume normal footer mode for now
updateFooter(FooterMode.Normal);
- mCreatedInPortrait = updateMonitor.isInPortrait();
updateMonitor.registerInfoCallback(this);
updateMonitor.registerSimStateCallback(this);
- updateMonitor.registerConfigurationChangeCallback(this);
setFocusableInTouchMode(true);
// Required to get Marquee to work.
@@ -397,12 +399,12 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
}
-
-
/** {@inheritDoc} */
- public void onOrientationChange(boolean inPortrait) {
- if (inPortrait != mCreatedInPortrait) {
- mCallback.recreateMe();
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ if (newConfig.orientation != mCreationOrientation) {
+ mCallback.recreateMe(newConfig);
}
}
diff --git a/phone/com/android/internal/policy/impl/SimUnlockScreen.java b/phone/com/android/internal/policy/impl/SimUnlockScreen.java
index d5da274..d92b961 100644
--- a/phone/com/android/internal/policy/impl/SimUnlockScreen.java
+++ b/phone/com/android/internal/policy/impl/SimUnlockScreen.java
@@ -19,8 +19,10 @@ package com.android.internal.policy.impl;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
+import android.content.res.Configuration;
import android.os.RemoteException;
import android.os.ServiceManager;
+
import com.android.internal.telephony.ITelephony;
import com.android.internal.widget.LockPatternUtils;
@@ -38,15 +40,13 @@ import com.android.internal.R;
* Displays a dialer like interface to unlock the SIM PIN.
*/
public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, View.OnClickListener,
- KeyguardUpdateMonitor.ConfigurationChangeCallback, KeyguardUpdateMonitor.InfoCallback {
+ KeyguardUpdateMonitor.InfoCallback {
private static final int DIGIT_PRESS_WAKE_MILLIS = 5000;
private final KeyguardUpdateMonitor mUpdateMonitor;
private final KeyguardScreenCallback mCallback;
- private final boolean mCreatedWithKeyboardOpen;
-
private TextView mHeaderText;
private TextView mPinText;
@@ -62,20 +62,28 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
private LockPatternUtils mLockPatternUtils;
+ private int mCreationOrientation;
+
+ private int mKeyboardHidden;
+
private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
- public SimUnlockScreen(Context context, KeyguardUpdateMonitor updateMonitor,
- KeyguardScreenCallback callback, LockPatternUtils lockpatternutils) {
+ public SimUnlockScreen(Context context, Configuration configuration,
+ KeyguardUpdateMonitor updateMonitor, KeyguardScreenCallback callback,
+ LockPatternUtils lockpatternutils) {
super(context);
mUpdateMonitor = updateMonitor;
mCallback = callback;
- mCreatedWithKeyboardOpen = mUpdateMonitor.isKeyboardOpen();
+
+ mCreationOrientation = configuration.orientation;
+ mKeyboardHidden = configuration.hardKeyboardHidden;
mLockPatternUtils = lockpatternutils;
- if (mCreatedWithKeyboardOpen) {
- LayoutInflater.from(context).inflate(R.layout.keyguard_screen_sim_pin_landscape, this, true);
+ LayoutInflater inflater = LayoutInflater.from(context);
+ if (mKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
+ inflater.inflate(R.layout.keyguard_screen_sim_pin_landscape, this, true);
} else {
- LayoutInflater.from(context).inflate(R.layout.keyguard_screen_sim_pin_portrait, this, true);
+ inflater.inflate(R.layout.keyguard_screen_sim_pin_portrait, this, true);
new TouchInput();
}
@@ -94,7 +102,6 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
mEmergencyCallButton.setOnClickListener(this);
mOkButton.setOnClickListener(this);
- mUpdateMonitor.registerConfigurationChangeCallback(this);
setFocusableInTouchMode(true);
}
@@ -272,11 +279,18 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
mEnteredPin[mEnteredDigits++] = digit;
}
- public void onOrientationChange(boolean inPortrait) {}
-
- public void onKeyboardChange(boolean isKeyboardOpen) {
- if (isKeyboardOpen != mCreatedWithKeyboardOpen) {
- mCallback.recreateMe();
+ /** {@inheritDoc} */
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ if (newConfig.orientation != mCreationOrientation) {
+ mCallback.recreateMe(newConfig);
+ } else if (newConfig.hardKeyboardHidden != mKeyboardHidden) {
+ mKeyboardHidden = newConfig.hardKeyboardHidden;
+ final boolean isKeyboardOpen = mKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
+ if (mUpdateMonitor.isKeyguardBypassEnabled() && isKeyboardOpen) {
+ mCallback.goToUnlockScreen();
+ }
}
}