Fix race condition when evaluating screen timeout.
When deciding whether or not to honor a window's timeout override,
do not require that the window has already been drawn this frame.
BUG=70225679
Change-Id: I4070f465b5c57d4de08807bfe3d4e67034b56827
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index 2a77c92..c3b2c24 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -897,10 +897,26 @@
boolean handleNotObscuredLocked(WindowState w, boolean obscured, boolean syswin) {
final WindowManager.LayoutParams attrs = w.mAttrs;
final int attrFlags = attrs.flags;
+ final boolean onScreen = w.isOnScreen();
final boolean canBeSeen = w.isDisplayedLw();
final int privateflags = attrs.privateFlags;
boolean displayHasContent = false;
+ if (DEBUG_KEEP_SCREEN_ON) {
+ Slog.d(TAG_KEEP_SCREEN_ON, "handleNotObscuredLocked w: " + w
+ + ", w.mHasSurface: " + w.mHasSurface
+ + ", w.isOnScreen(): " + onScreen
+ + ", w.isDisplayedLw(): " + w.isDisplayedLw()
+ + ", w.mAttrs.userActivityTimeout: " + w.mAttrs.userActivityTimeout);
+ }
+ if (w.mHasSurface && onScreen) {
+ if (!syswin && w.mAttrs.userActivityTimeout >= 0 && mUserActivityTimeout < 0) {
+ mUserActivityTimeout = w.mAttrs.userActivityTimeout;
+ if (DEBUG_KEEP_SCREEN_ON) {
+ Slog.d(TAG, "mUserActivityTimeout set to " + mUserActivityTimeout);
+ }
+ }
+ }
if (w.mHasSurface && canBeSeen) {
if ((attrFlags & FLAG_KEEP_SCREEN_ON) != 0) {
mHoldScreen = w.mSession;
@@ -913,9 +929,6 @@
if (!syswin && w.mAttrs.screenBrightness >= 0 && mScreenBrightness < 0) {
mScreenBrightness = w.mAttrs.screenBrightness;
}
- if (!syswin && w.mAttrs.userActivityTimeout >= 0 && mUserActivityTimeout < 0) {
- mUserActivityTimeout = w.mAttrs.userActivityTimeout;
- }
final int type = attrs.type;
// This function assumes that the contents of the default display are processed first