From cf5a9530f7ded49e830a064526f4290f3a81062c Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Wed, 17 Sep 2014 16:22:19 -0400 Subject: Fix crash from USER_PRESENT broadcast in sysui Since sending the USER_PRESENT broadcast too early in the boot process can result in a SecurityException, don't do auto-unlock until after the boot has completed. Bug: 17464800 Change-Id: Iee3d0b9723ed38abddf0bdde009f95331881008b --- .../systemui/keyguard/KeyguardViewMediator.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'packages/SystemUI/src/com/android/systemui/keyguard') diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 50ba68e..2628b3e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -170,6 +170,8 @@ public class KeyguardViewMediator extends SystemUI { private boolean mSwitchingUser; private boolean mSystemReady; + private boolean mBootCompleted; + private boolean mBootSendUserPresent; // Whether the next call to playSounds() should be skipped. Defaults to // true because the first lock (on boot) should be silent. @@ -1146,8 +1148,14 @@ public class KeyguardViewMediator extends SystemUI { } private void sendUserPresentBroadcast() { - final UserHandle currentUser = new UserHandle(mLockPatternUtils.getCurrentUser()); - mContext.sendBroadcastAsUser(USER_PRESENT_INTENT, currentUser); + synchronized (this) { + if (mBootCompleted) { + final UserHandle currentUser = new UserHandle(mLockPatternUtils.getCurrentUser()); + mContext.sendBroadcastAsUser(USER_PRESENT_INTENT, currentUser); + } else { + mBootSendUserPresent = true; + } + } } /** @@ -1407,6 +1415,12 @@ public class KeyguardViewMediator extends SystemUI { public void onBootCompleted() { mUpdateMonitor.dispatchBootCompleted(); + synchronized (this) { + mBootCompleted = true; + if (mBootSendUserPresent) { + sendUserPresentBroadcast(); + } + } } public StatusBarKeyguardViewManager registerStatusBar(PhoneStatusBar phoneStatusBar, -- cgit v1.1