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

Commit 5bd11afa authored by lumark's avatar lumark
Browse files

Make WC#applyAnimation can apply on Task / TaskStack layer (2/N)

- Introduce WC#getAnimatingContainer to get the current animating container:
  When Task / TaskStack level animation enabled, some checks  in WallpaperController,
  like to check wallpaper.mActivityRecord.getAnimation.getShowWallpaper if the animation
  should show wallpaper, would need to use this method to get the value from
  the upper layer of animating container.

- Fix some places that calls isAnimating() needs to add PARENTS flag in
  WallpaperController / WindowState

Bug: 142617871
Bug: 131661052
Test: atest WindowContainerTests, WallpaperControllerTests

Change-Id: I842f377d643d43104facaba4f401a76ef9dd2ce0
parent 5341d1c7
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -3089,7 +3089,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                "Removing app %s delayed=%b animation=%s animating=%b", this, delayed,
                getAnimation(), isAnimating(PARENTS | TRANSITION));
                getAnimation(), isAnimating(TRANSITION | PARENTS));

        ProtoLog.v(WM_DEBUG_ADD_REMOVE, "removeAppToken: %s"
                + " delayed=%b Callers=%s", this, delayed, Debug.getCallers(4));
@@ -3101,7 +3101,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // If this window was animating, then we need to ensure that the app transition notifies
        // that animations have completed in DisplayContent.handleAnimatingStoppedAndTransition(),
        // so add to that list now
        if (isAnimating(PARENTS | TRANSITION)) {
        if (isAnimating(TRANSITION | PARENTS)) {
            getDisplayContent().mNoAnimationNotifyOnTransitionFinished.add(token);
        }

@@ -5345,13 +5345,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (!allDrawn && w.mightAffectAllDrawn()) {
            if (DEBUG_VISIBILITY || WM_DEBUG_ORIENTATION.isLogToLogcat()) {
                Slog.v(TAG, "Eval win " + w + ": isDrawn=" + w.isDrawnLw()
                        + ", isAnimationSet=" + isAnimating(PARENTS | TRANSITION));
                        + ", isAnimationSet=" + isAnimating(TRANSITION | PARENTS));
                if (!w.isDrawnLw()) {
                    Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurfaceController
                            + " pv=" + w.isVisibleByPolicy()
                            + " mDrawState=" + winAnimator.drawStateToString()
                            + " ph=" + w.isParentWindowHidden() + " th=" + mVisibleRequested
                            + " a=" + isAnimating(PARENTS | TRANSITION));
                            + " a=" + isAnimating(TRANSITION | PARENTS));
                }
            }

+5 −3
Original line number Diff line number Diff line
@@ -436,9 +436,11 @@ public class AppTransition implements Dump {
        mNextAppTransition = TRANSIT_UNSET;
        mNextAppTransitionFlags = 0;
        setAppTransitionState(APP_STATE_RUNNING);
        final AnimationAdapter topOpeningAnim = topOpeningApp != null
                ? topOpeningApp.getAnimation()
        final AnimationAdapter topOpeningAnim =
                (topOpeningApp != null && topOpeningApp.getAnimatingContainer() != null)
                        ? topOpeningApp.getAnimatingContainer().getAnimation()
                        : null;

        int redoLayout = notifyAppTransitionStartingLocked(transit,
                topOpeningAnim != null ? topOpeningAnim.getDurationHint() : 0,
                topOpeningAnim != null
+9 −7
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ class WallpaperController {

        mFindResults.resetTopWallpaper = true;
        if (w.mActivityRecord != null && !w.mActivityRecord.isVisible()
                && !w.mActivityRecord.isAnimating(TRANSITION)) {
                && !w.mActivityRecord.isAnimating(TRANSITION | PARENTS)) {

            // If this window's app token is hidden and not animating, it is of no interest to us.
            if (DEBUG_WALLPAPER) Slog.v(TAG, "Skipping hidden and not animating token: " + w);
@@ -139,7 +139,7 @@ class WallpaperController {
        }

        final boolean keyguardGoingAwayWithWallpaper = (w.mActivityRecord != null
                && w.mActivityRecord.isAnimating(TRANSITION)
                && w.mActivityRecord.isAnimating(TRANSITION | PARENTS)
                && AppTransition.isKeyguardGoingAwayTransit(w.mActivityRecord.getTransit())
                && (w.mActivityRecord.getTransitFlags()
                        & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER) != 0);
@@ -162,9 +162,11 @@ class WallpaperController {

        final RecentsAnimationController recentsAnimationController =
                mService.getRecentsAnimationController();
        final boolean animationWallpaper = w.mActivityRecord != null
                && w.mActivityRecord.getAnimation() != null
                && w.mActivityRecord.getAnimation().getShowWallpaper();
        final WindowContainer animatingContainer =
                w.mActivityRecord != null ? w.mActivityRecord.getAnimatingContainer() : null;
        final boolean animationWallpaper = animatingContainer != null
                && animatingContainer.getAnimation() != null
                && animatingContainer.getAnimation().getShowWallpaper();
        final boolean hasWallpaper = (w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0
                || animationWallpaper;
        final boolean isRecentsTransitionTarget = (recentsAnimationController != null
@@ -228,14 +230,14 @@ class WallpaperController {
        if (DEBUG_WALLPAPER) Slog.v(TAG, "Wallpaper vis: target " + wallpaperTarget + ", obscured="
                + (wallpaperTarget != null ? Boolean.toString(wallpaperTarget.mObscured) : "??")
                + " animating=" + ((wallpaperTarget != null && wallpaperTarget.mActivityRecord != null)
                ? wallpaperTarget.mActivityRecord.isAnimating(TRANSITION) : null)
                ? wallpaperTarget.mActivityRecord.isAnimating(TRANSITION | PARENTS) : null)
                + " prev=" + mPrevWallpaperTarget
                + " recentsAnimationWallpaperVisible=" + isAnimatingWithRecentsComponent);
        return (wallpaperTarget != null
                && (!wallpaperTarget.mObscured
                        || isAnimatingWithRecentsComponent
                        || (wallpaperTarget.mActivityRecord != null
                        && wallpaperTarget.mActivityRecord.isAnimating(TRANSITION))))
                        && wallpaperTarget.mActivityRecord.isAnimating(TRANSITION | PARENTS))))
                || mPrevWallpaperTarget != null;
    }

+15 −0
Original line number Diff line number Diff line
@@ -2091,6 +2091,21 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        return mSurfaceAnimator.getAnimation();
    }

    /**
     * @return The {@link WindowContainer} which is running an animation.
     *
     * It traverses from the current container to its parents recursively. If nothing is animating,
     * it will return {@code null}.
     */
    @Nullable
    WindowContainer getAnimatingContainer() {
        if (isAnimating()) {
            return this;
        }
        final WindowContainer parent = getParent();
        return (parent != null) ? parent.getAnimatingContainer() : null;
    }

    /**
     * @see SurfaceAnimator#startDelayingAnimationStart
     */
+4 −4
Original line number Diff line number Diff line
@@ -1573,7 +1573,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    // TODO: Can we consolidate this with #isVisible() or have a more appropriate name for this?
    boolean isWinVisibleLw() {
        return (mActivityRecord == null || mActivityRecord.mVisibleRequested
                || mActivityRecord.isAnimating(TRANSITION)) && isVisible();
                || mActivityRecord.isAnimating(TRANSITION | PARENTS)) && isVisible();
    }

    /**
@@ -1799,7 +1799,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            // 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(TRANSITION)) {
            if (!visible && isVisibleNow && mActivityRecord.isAnimating(PARENTS | TRANSITION)) {
                mAnimatingExit = true;
                mRemoveOnExit = true;
                mWindowRemovalAllowed = true;
@@ -2068,7 +2068,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                    this, mWinAnimator.mSurfaceController, mAnimatingExit, mRemoveOnExit,
                    mHasSurface, mWinAnimator.getShown(),
                    isAnimating(TRANSITION | PARENTS),
                    mActivityRecord != null && mActivityRecord.isAnimating(TRANSITION),
                    mActivityRecord != null && mActivityRecord.isAnimating(PARENTS | TRANSITION),
                    mWillReplaceWindow,
                    mWmService.mDisplayFrozen, Debug.getCallers(6));

@@ -4287,7 +4287,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                    + " tok.visible=" + (mActivityRecord != null && mActivityRecord.isVisible())
                    + " animating=" + isAnimating(TRANSITION | PARENTS)
                    + " tok animating="
                    + (mActivityRecord != null && mActivityRecord.isAnimating(TRANSITION))
                    + (mActivityRecord != null && mActivityRecord.isAnimating(TRANSITION | PARENTS))
                    + " Callers=" + Debug.getCallers(4));
        }
    }