From 474093d69981e8d71e293cf0d64ce0709b84e3d6 Mon Sep 17 00:00:00 2001 From: chaviw Date: Wed, 7 Mar 2018 15:03:38 -0800 Subject: Set canTurnScreenOn to false for any window with flag. There are cases where the window has the flag TURN_SCREEN_ON but the other checks aren't satisfied. In those cases, canTurnScreenOn will still be true allowing another relayout to turn the screen on. Instead, set canTurnScreenOn flag to false if any window has the flag TURN_SCREEN_ON, regardless if the other conditions are met. The previous fix If8ff9ba1afb1f7f9632e8c911ed475aed531b880 broke the testTurnScreenOnActivity_withRelayout test so this is a more correct solution. Change-Id: I3fa6285cd5f246e96f9034a7af76b8828e16c15d Fixes: 74086704 Test: testTurnScreenOnActivity_withRelayout --- services/core/java/com/android/server/wm/WindowState.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 2398661668b1..d335077711dd 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -2284,13 +2284,14 @@ class WindowState extends WindowContainer implements WindowManagerP // interactive, the value may persist until the next animation, which could potentially // be occurring while turning off the screen. This would lead to the screen incorrectly // turning back on. - if (hasTurnScreenOnFlag && allowTheaterMode && canTurnScreenOn - && !mPowerManagerWrapper.isInteractive()) { - if (DEBUG_VISIBILITY || DEBUG_POWER) { - Slog.v(TAG, "Relayout window turning screen on: " + this); + if (hasTurnScreenOnFlag) { + if (allowTheaterMode && canTurnScreenOn && !mPowerManagerWrapper.isInteractive()) { + if (DEBUG_VISIBILITY || DEBUG_POWER) { + Slog.v(TAG, "Relayout window turning screen on: " + this); + } + mPowerManagerWrapper.wakeUp(SystemClock.uptimeMillis(), + "android.server.wm:TURN_ON"); } - mPowerManagerWrapper.wakeUp(SystemClock.uptimeMillis(), - "android.server.wm:TURN_ON"); if (mAppToken != null) { mAppToken.setCanTurnScreenOn(false); -- cgit v1.2.3-59-g8ed1b