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

Commit 4c22055e authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Skip running window animation for invisible activity

Unlike legacy transition can keep activity surface visible
even if it is committed invisible, shell transition always
make activity surface invisible for a CLOSE target.
So the legacy exit animation of activity window can be skipped.

Bug: 365884835
Flag: EXEMPT remove outdated code
Test: atest ActivityRecordTests
Change-Id: Ie3226e3df80a841821e131c336c8cc76a25b905c
parent 310f7b88
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -246,7 +246,6 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WIND
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES;
import static com.android.server.wm.WindowManagerService.sEnableShellTransitions;
import static com.android.server.wm.WindowState.LEGACY_POLICY_VISIBILITY;

import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
@@ -5770,19 +5769,16 @@ final class ActivityRecord extends WindowToken {
            return;
        }

        final int windowsCount = mChildren.size();
        // With Shell-Transition, the activity will running a transition when it is visible.
        // It won't be included when fromTransition is true means the call from finishTransition.
        final boolean runningAnimation = sEnableShellTransitions ? visible
                : isAnimating(PARENTS, ANIMATION_TYPE_APP_TRANSITION);
        for (int i = 0; i < windowsCount; i++) {
            mChildren.get(i).onAppVisibilityChanged(visible, runningAnimation);
        if (!visible) {
            for (int i = mChildren.size() - 1; i >= 0; --i) {
                mChildren.get(i).onAppCommitInvisible();
            }
        }
        setVisible(visible);
        setVisibleRequested(visible);
        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS, "commitVisibility: %s: visible=%b"
                        + " visibleRequested=%b, isInTransition=%b, runningAnimation=%b, caller=%s",
                this, isVisible(), mVisibleRequested, isInTransition(), runningAnimation,
                        + " visibleRequested=%b, inTransition=%b, caller=%s",
                this, visible, mVisibleRequested, inTransition(),
                Debug.getCallers(5));
        if (visible) {
            // If we are being set visible, and the starting window is not yet displayed,
+7 −30
Original line number Diff line number Diff line
@@ -2068,38 +2068,15 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        super.onMovedByResize();
    }

    void onAppVisibilityChanged(boolean visible, boolean runningAppAnimation) {
    void onAppCommitInvisible() {
        for (int i = mChildren.size() - 1; i >= 0; --i) {
            mChildren.get(i).onAppVisibilityChanged(visible, runningAppAnimation);
            mChildren.get(i).onAppCommitInvisible();
        }

        final boolean isVisibleNow = isVisibleNow();
        if (mAttrs.type == TYPE_APPLICATION_STARTING) {
            // Starting window that's exiting will be removed when the animation finishes.
            // Mark all relevant flags for that onExitAnimationDone will proceed all the way
            // to actually remove it.
            if (!visible && isVisibleNow && mActivityRecord.isAnimating(PARENTS | TRANSITION)) {
                ProtoLog.d(WM_DEBUG_ANIM,
                        "Set animatingExit: reason=onAppVisibilityChanged win=%s", this);
                mAnimatingExit = true;
                mRemoveOnExit = true;
                mWindowRemovalAllowed = true;
            }
        } else if (visible != isVisibleNow) {
            // Run exit animation if:
            // 1. App visibility and WS visibility are different
            // 2. App is not running an animation
            // 3. WS is currently visible
            if (!runningAppAnimation && isVisibleNow) {
                final AccessibilityController accessibilityController =
                        mWmService.mAccessibilityController;
                final int winTransit = TRANSIT_EXIT;
                mWinAnimator.applyAnimationLocked(winTransit, false /* isEntrance */);
                if (accessibilityController.hasCallbacks()) {
                    accessibilityController.onWindowTransition(this, winTransit);
                }
            }
            setDisplayLayoutNeeded();
        if (mAttrs.type != TYPE_APPLICATION_STARTING
                && mWmService.mAccessibilityController.hasCallbacks()
                // It is a change only if App visibility and WS visibility are different.
                && isVisible()) {
            mWmService.mAccessibilityController.onWindowTransition(this, TRANSIT_EXIT);
        }
    }