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

Commit cf85fdb5 authored by wilsonshih's avatar wilsonshih
Browse files

Do not play enter dim animation when starting window is on top of task.

There does not need to play the entering dim animation when starting
window is exist in the task, since the starting window should always
above the dim layer.
And allows to apply dim if the host is the task itself, because it
won't affect display anyway.

Bug: 295280282
Test: verify less flickering when opening a dimming task from recents.
Change-Id: I92ae7e15d483bbd29d17c9c1e14d27a2cc735c91
parent 0283bc86
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.server.wm.AlphaAnimationSpecProto.TO;
import static com.android.server.wm.AnimationSpecProto.ALPHA;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_DIMMER;

import android.annotation.NonNull;
import android.graphics.Rect;
import android.util.Log;
import android.util.proto.ProtoOutputStream;
@@ -178,6 +179,7 @@ class Dimmer {
        mSurfaceAnimatorStarter = surfaceAnimatorStarter;
    }

    @NonNull
    WindowContainer<?> getHost() {
        return mHost;
    }
@@ -199,13 +201,6 @@ class Dimmer {
            try {
                final SurfaceControl ctl = makeDimLayer();
                mDimState = new DimState(ctl);
                /**
                 * See documentation on {@link #dimAbove} to understand lifecycle management of
                 * Dim's via state resetting for Dim's with containers.
                 */
                if (container == null) {
                    mDimState.mDontReset = true;
                }
            } catch (Surface.OutOfResourcesException e) {
                Log.w(TAG, "OutOfResourcesException creating dim surface");
            }
@@ -241,7 +236,7 @@ class Dimmer {
     * @param container The container which to dim above. Should be a child of our host.
     * @param alpha     The alpha at which to Dim.
     */
    void dimAbove(WindowContainer container, float alpha) {
    void dimAbove(@NonNull WindowContainer container, float alpha) {
        dim(container, 1, alpha, 0);
    }

@@ -253,7 +248,7 @@ class Dimmer {
     * @param blurRadius The amount of blur added to the Dim.
     */

    void dimBelow(WindowContainer container, float alpha, int blurRadius) {
    void dimBelow(@NonNull WindowContainer container, float alpha, int blurRadius) {
        dim(container, -1, alpha, blurRadius);
    }

@@ -316,8 +311,13 @@ class Dimmer {
            if (!mDimState.isVisible) {
                mDimState.isVisible = true;
                t.show(mDimState.mDimLayer);
                // Skip enter animation while starting window is on top of its activity
                final WindowState ws = mLastRequestedDimContainer.asWindowState();
                if (ws == null || ws.mActivityRecord == null
                        || ws.mActivityRecord.mStartingData == null) {
                    startDimEnter(mLastRequestedDimContainer, mDimState.mSurfaceAnimator, t);
                }
            }
            return true;
        }
    }
+5 −4
Original line number Diff line number Diff line
@@ -440,10 +440,11 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
    boolean canApplyDim(@NonNull Task task) {
        if (mTransientLaunches == null) return true;
        final Dimmer dimmer = task.getDimmer();
        final WindowContainer<?> dimmerHost = dimmer != null ? dimmer.getHost() : null;
        if (dimmerHost == null) return false;
        if (isInTransientHide(dimmerHost)) {
            // The layer of dimmer is inside transient-hide task, then allow to dim.
        if (dimmer == null) {
            return false;
        }
        if (dimmer.getHost().asTask() != null) {
            // Always allow to dim if the host only affects its task.
            return true;
        }
        // The dimmer host of a translucent task can be a display, then it is not in transient-hide.