Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 312eac40 authored by Craig Mautner's avatar Craig Mautner
Browse files

Retain dimming while animating and obscured.

Fixes for two dimming problems.

- Dimming was turning off at the start of animation because it was
dependent on hiddenRequested which becomes true while the view is
still visible.

- Looking for windows with FLAG_DIM_BEHIND set stopped at the first
obscured window. But Z-order shuffling due to Animation.setZAdjustment
causes the window list order to be different than the display order.
Consequently windows that are being shown are declared obscured by
handleNotObscuredLocked().

Bug 7396404 fixed.

Change-Id: Ic59150964d3950e29b115da5f6c0f07a64190d44
parent e3c4001c
Loading
Loading
Loading
Loading
+32 −22
Original line number Diff line number Diff line
@@ -4425,6 +4425,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    @Override
    public void setAppWillBeHidden(IBinder token) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
                "setAppWillBeHidden()")) {
@@ -4548,6 +4549,7 @@ public class WindowManagerService extends IWindowManager.Stub
        return delayed;
    }

    @Override
    public void setAppVisibility(IBinder token, boolean visible) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
                "setAppVisibility()")) {
@@ -4700,6 +4702,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    @Override
    public void startAppFreezingScreen(IBinder token, int configChanges) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
                "setAppFreezingScreen()")) {
@@ -4723,6 +4726,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    @Override
    public void stopAppFreezingScreen(IBinder token, boolean force) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
                "setAppFreezingScreen()")) {
@@ -8953,12 +8957,14 @@ public class WindowManagerService extends IWindowManager.Stub
            // so we want to leave all of them as undimmed (for
            // performance reasons).
            mInnerFields.mObscured = true;
        } else if (canBeSeen && (attrFlags & FLAG_DIM_BEHIND) != 0
                && !(w.mAppToken != null && w.mAppToken.hiddenRequested)
        }
    }

    private void handleFlagDimBehind(WindowState w, int innerDw, int innerDh) {
        final WindowManager.LayoutParams attrs = w.mAttrs;
        if ((attrs.flags & FLAG_DIM_BEHIND) != 0
                && w.isDisplayedLw()
                && !w.mExiting) {
            if (localLOGV) Slog.v(TAG, "Win " + w + " obscured=" + mInnerFields.mObscured);
            if (!mInnerFields.mDimming) {
                //Slog.i(TAG, "DIM BEHIND: " + w);
            mInnerFields.mDimming = true;
            final WindowStateAnimator winAnimator = w.mWinAnimator;
            if (!mAnimator.isDimmingLocked(winAnimator)) {
@@ -8971,12 +8977,12 @@ public class WindowManagerService extends IWindowManager.Stub
                    width = innerDw;
                    height = innerDh;
                }
                if (localLOGV) Slog.v(TAG, "Win " + w + " start dimming.");
                startDimmingLocked(
                        winAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount, width, height);
            }
        }
    }
    }

    private void updateAllDrawnLocked() {
        // See if any windows have been drawn, so they (and others
@@ -9152,6 +9158,10 @@ public class WindowManagerService extends IWindowManager.Stub
                        handleNotObscuredLocked(w, currentTime, innerDw, innerDh);
                    }

                    if (!mInnerFields.mDimming) {
                        handleFlagDimBehind(w, innerDw, innerDh);
                    }

                    if (isDefaultDisplay && obscuredChanged && (mWallpaperTarget == w)
                            && w.isVisibleLw()) {
                        // This is the wallpaper target and its obscured state