Report keyguard as initially showing and secure until we know

This fixes a bug where an app calls KeyguardManager.isLocked()
before keyguard has had a chance to show.  The fix is to assume
keyguard is showing and secure until we know otherwise.

Fixes bug 11670159

Change-Id: Ifbe4cdf40e3b76d2069ecace940f85fa58f31187
This commit is contained in:
Jim Miller
2013-11-13 15:40:48 -08:00
parent c641de017a
commit e5f17ab5a6
2 changed files with 12 additions and 1 deletions

View File

@@ -200,7 +200,7 @@ public class KeyguardViewMediator {
// cached value of whether we are showing (need to know this to quickly
// answer whether the input should be restricted)
private boolean mShowing = false;
private boolean mShowing;
// true if the keyguard is hidden by another window
private boolean mHidden = false;
@@ -508,6 +508,9 @@ public class KeyguardViewMediator {
? lockPatternUtils : new LockPatternUtils(mContext);
mLockPatternUtils.setCurrentUser(UserHandle.USER_OWNER);
// Assume keyguard is showing (unless it's disabled) until we know for sure...
mShowing = !mLockPatternUtils.isLockScreenDisabled();
WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
mKeyguardViewManager = new KeyguardViewManager(context, wm, mViewMediatorCallback,

View File

@@ -40,6 +40,14 @@ public class KeyguardServiceDelegate {
private KeyguardState mKeyguardState = new KeyguardState();
/* package */ static final class KeyguardState {
KeyguardState() {
// Assume keyguard is showing and secure until we know for sure. This is here in
// the event something checks before the service is actually started.
// KeyguardService itself should default to this state until the real state is known.
showing = true;
showingAndNotHidden = true;
secure = true;
}
boolean showing;
boolean showingAndNotHidden;
boolean inputRestricted;