From c72b15f2ee751e7cb747e0b53ddecc9da69c9e0c Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Sat, 28 Nov 2009 20:58:22 -0500 Subject: [PATCH] Fix bug 2290852: Screen wakes up in my pocket while listening to music When the screen is off keyguard is open but hidden by another activity make sure that non-waking events like volume key or track ball press do not turn the screen back on. Change-Id: Ie6b191360b903b54388a6f65680ccc3264a51dd8 Signed-off-by: Mike Lockwood --- .../internal/policy/impl/PhoneWindowManager.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/policy/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/com/android/internal/policy/impl/PhoneWindowManager.java index 2143f52dfd1d5..2f9faae85b2c1 100755 --- a/policy/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/com/android/internal/policy/impl/PhoneWindowManager.java @@ -1620,14 +1620,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { public int interceptKeyTq(RawInputEvent event, boolean screenIsOn) { int result = ACTION_PASS_TO_USER; final boolean isWakeKey = isWakeKeyTq(event); - final boolean keyguardShowing = keyguardIsShowingTq(); + // If screen is off then we treat the case where the keyguard is open but hidden + // the same as if it were open and in front. + // This will prevent any keys other than the power button from waking the screen + // when the keyguard is hidden by another activity. + final boolean keyguardActive = (screenIsOn ? + mKeyguardMediator.isShowingAndNotHidden() : + mKeyguardMediator.isShowing()); if (false) { Log.d(TAG, "interceptKeyTq event=" + event + " keycode=" + event.keycode - + " screenIsOn=" + screenIsOn + " keyguardShowing=" + keyguardShowing); + + " screenIsOn=" + screenIsOn + " keyguardActive=" + keyguardActive); } - if (keyguardShowing) { + if (keyguardActive) { if (screenIsOn) { // when the screen is on, always give the event to the keyguard result |= ACTION_PASS_TO_USER; @@ -1721,7 +1727,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mShouldTurnOffOnKeyUp = false; boolean gohome = (mEndcallBehavior & ENDCALL_HOME) != 0; boolean sleeps = (mEndcallBehavior & ENDCALL_SLEEPS) != 0; - if (keyguardShowing + if (keyguardActive || (sleeps && !gohome) || (gohome && !goHome() && sleeps)) { // they must already be on the keyguad or home screen,