From bee63000ede8ddd9ebd2fcd098569aca87a3596c Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Tue, 7 Jul 2015 14:55:50 -0700 Subject: [PATCH] Fix bug that prevented waking from dream If a device was securely locked, FLAG_TURN_SCREEN_ON failed to wake the device from dreaming even if FLAG_SHOW_WHEN_LOCKED was set. The fix allows SHOW_WHEN_LOCKED activities that are about to turn the screen on to show even if they're not currently the top most window with SHOW_WHEN_LOCKED set (which in this case would always be the dream) Bug: 21719374 Change-Id: I8d7bce05d95ed9de50b5a52b0973562b070aca5a --- .../com/android/server/wm/WindowAnimator.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowAnimator.java b/services/core/java/com/android/server/wm/WindowAnimator.java index 76baaa74dd8fb..026b4e011836d 100644 --- a/services/core/java/com/android/server/wm/WindowAnimator.java +++ b/services/core/java/com/android/server/wm/WindowAnimator.java @@ -197,18 +197,25 @@ public class WindowAnimator { final WindowState winShowWhenLocked = (WindowState) mPolicy.getWinShowWhenLockedLw(); final AppWindowToken appShowWhenLocked = winShowWhenLocked == null ? null : winShowWhenLocked.mAppToken; - final boolean hideWhenLocked = - !(((win.mIsImWindow || imeTarget == win) && showImeOverKeyguard) - || (appShowWhenLocked != null && (appShowWhenLocked == win.mAppToken - // Show all SHOW_WHEN_LOCKED windows while they're animating - || (win.mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0 && win.isAnimatingLw() - // Show error dialogs over apps that dismiss keyguard. - || (win.mAttrs.privateFlags & PRIVATE_FLAG_SYSTEM_ERROR) != 0))); + + boolean allowWhenLocked = false; + // Show IME over the keyguard if the target allows it + allowWhenLocked |= (win.mIsImWindow || imeTarget == win) && showImeOverKeyguard; + // Show SHOW_WHEN_LOCKED windows that turn on the screen + allowWhenLocked |= (win.mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0 && win.mTurnOnScreen; + + if (appShowWhenLocked != null) { + allowWhenLocked |= appShowWhenLocked == win.mAppToken + // Show all SHOW_WHEN_LOCKED windows while they're animating + || (win.mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0 && win.isAnimatingLw() + // Show error dialogs over apps that dismiss keyguard. + || (win.mAttrs.privateFlags & PRIVATE_FLAG_SYSTEM_ERROR) != 0; + } // Only hide windows if the keyguard is active and not animating away. boolean keyguardOn = mPolicy.isKeyguardShowingOrOccluded() && mForceHiding != KEYGUARD_ANIMATING_OUT; - return keyguardOn && hideWhenLocked && (win.getDisplayId() == Display.DEFAULT_DISPLAY); + return keyguardOn && !allowWhenLocked && (win.getDisplayId() == Display.DEFAULT_DISPLAY); } private void updateWindowsLocked(final int displayId) {