From 674d3e40212d077c06f46589992f6e16c6c1b22d Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Tue, 6 Oct 2009 09:28:54 -0400 Subject: [PATCH] Hold a partial wakelock while showing the keyguard This ensures that the keyguard is fully displayed before the processor suspends, which avoids a race condition when the device is powered back up. Fixes one instance of bug b/2164183 Change-Id: Ifd7f928068cf779ec725937db82af69306c02107 Signed-off-by: Mike Lockwood --- .../internal/policy/impl/KeyguardViewMediator.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/policy/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/com/android/internal/policy/impl/KeyguardViewMediator.java index 680f942177526..34b5e3a3850e3 100644 --- a/policy/com/android/internal/policy/impl/KeyguardViewMediator.java +++ b/policy/com/android/internal/policy/impl/KeyguardViewMediator.java @@ -149,6 +149,12 @@ public class KeyguardViewMediator implements KeyguardViewCallback, */ private PowerManager.WakeLock mWakeLock; + /** + * Used to keep the device awake while to ensure the keyguard finishes opening before + * we sleep. + */ + private PowerManager.WakeLock mShowKeyguardWakeLock; + /** * Does not turn on screen, held while a call to {@link KeyguardViewManager#wakeWhenReadyTq(int)} * is called to make sure the device doesn't sleep before it has a chance to poke @@ -224,6 +230,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback, PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "keyguard"); mWakeLock.setReferenceCounted(false); + mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard"); + mShowKeyguardWakeLock.setReferenceCounted(false); mWakeAndHandOff = mPM.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, @@ -542,6 +550,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback, */ private void showLocked() { if (DEBUG) Log.d(TAG, "showLocked"); + // ensure we stay awake until we are finished displaying the keyguard + mShowKeyguardWakeLock.acquire(); Message msg = mHandler.obtainMessage(SHOW); mHandler.sendMessage(msg); } @@ -855,6 +865,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, ActivityManagerNative.getDefault().closeSystemDialogs("lock"); } catch (RemoteException e) { } + mShowKeyguardWakeLock.release(); } }