Allow to keep screen on only if window can be seen

If user has static wallpaper on lock screen and live wallpaper
on home screen, when screen is locked, wallpaper will not be an
obscuring window. In this case, if there is a non-obscured app
window behind the lock screen which has FLAG_KEEP_SCREEN_ON set,
it will not allow to turn screen off automatically, although it
is not really visible behind lock screen.

This CL restricts holding screen windows to only ones that can be
seen. Same applies for screen and button brightness and user
activity timeout settings.

Bug: 30359386
Change-Id: I46de831211c943d8077282e3274b2df180739239
This commit is contained in:
Andrii Kulian
2016-08-09 18:52:01 -07:00
parent 002dd29764
commit b20addbdfb

View File

@@ -1468,7 +1468,7 @@ class WindowSurfacePlacer {
mObscured = true; mObscured = true;
} }
if (w.mHasSurface) { if (w.mHasSurface && canBeSeen) {
if ((attrFlags&FLAG_KEEP_SCREEN_ON) != 0) { if ((attrFlags&FLAG_KEEP_SCREEN_ON) != 0) {
mHoldScreen = w.mSession; mHoldScreen = w.mSession;
mHoldScreenWindow = w; mHoldScreenWindow = w;
@@ -1491,14 +1491,11 @@ class WindowSurfacePlacer {
} }
final int type = attrs.type; final int type = attrs.type;
if (canBeSeen if (type == TYPE_SYSTEM_DIALOG || type == TYPE_SYSTEM_ERROR
&& (type == TYPE_SYSTEM_DIALOG || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
|| type == TYPE_SYSTEM_ERROR
|| (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0)) {
mSyswin = true; mSyswin = true;
} }
if (canBeSeen) {
// This function assumes that the contents of the default display are // This function assumes that the contents of the default display are
// processed first before secondary displays. // processed first before secondary displays.
final DisplayContent displayContent = w.getDisplayContent(); final DisplayContent displayContent = w.getDisplayContent();
@@ -1530,7 +1527,6 @@ class WindowSurfacePlacer {
} }
} }
} }
}
private void updateAllDrawnLocked(DisplayContent displayContent) { private void updateAllDrawnLocked(DisplayContent displayContent) {
// See if any windows have been drawn, so they (and others // See if any windows have been drawn, so they (and others