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

Commit d41f71d2 authored by Winson Chung's avatar Winson Chung
Browse files

Reparent recents animation task leash to app animation layer

- When swiping up in split screen, the task is clipped by the unminimized
  stack bounds, instead reparent to app animation layer to allow it to be
  unconstrained. Currently, this will bump it up to the top, but we need
  a mechanism later to bump it only to under the primary splitscreen stack.

Bug: 73118672
Test: Swipe up from split screen, ensure app window is not clipped
Change-Id: Iacc6d6b82274b8b26b2dab85628479b5ff490817
parent f557c3b5
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -3566,7 +3566,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                    if (s.inSplitScreenWindowingMode() && mSplitScreenDividerAnchor != null) {
                    if (s.inSplitScreenWindowingMode() && mSplitScreenDividerAnchor != null) {
                        t.setLayer(mSplitScreenDividerAnchor, layer++);
                        t.setLayer(mSplitScreenDividerAnchor, layer++);
                    }
                    }
                    if (s.isAppAnimating() && state != ALWAYS_ON_TOP_STATE) {
                    if ((s.isTaskAnimating() || s.isAppAnimating())
                            && state != ALWAYS_ON_TOP_STATE) {
                        // Ensure the animation layer ends up above the
                        // Ensure the animation layer ends up above the
                        // highest animating stack and no higher.
                        // highest animating stack and no higher.
                        layerForAnimationLayer = layer++;
                        layerForAnimationLayer = layer++;
+16 −6
Original line number Original line Diff line number Diff line
@@ -432,6 +432,15 @@ public class RecentsAnimationController implements DeathRecipient {
        return mHomeAppToken.windowsCanBeWallpaperTarget();
        return mHomeAppToken.windowsCanBeWallpaperTarget();
    }
    }


    boolean isAnimatingTask(Task task) {
        for (int i = mPendingAnimations.size() - 1; i >= 0; i--) {
            if (task == mPendingAnimations.get(i).mTask) {
                return true;
            }
        }
        return false;
    }

    private boolean isAnimatingApp(AppWindowToken appToken) {
    private boolean isAnimatingApp(AppWindowToken appToken) {
        for (int i = mPendingAnimations.size() - 1; i >= 0; i--) {
        for (int i = mPendingAnimations.size() - 1; i >= 0; i--) {
            final Task task = mPendingAnimations.get(i).mTask;
            final Task task = mPendingAnimations.get(i).mTask;
@@ -452,18 +461,18 @@ public class RecentsAnimationController implements DeathRecipient {
        private OnAnimationFinishedCallback mCapturedFinishCallback;
        private OnAnimationFinishedCallback mCapturedFinishCallback;
        private final boolean mIsRecentTaskInvisible;
        private final boolean mIsRecentTaskInvisible;
        private RemoteAnimationTarget mTarget;
        private RemoteAnimationTarget mTarget;
        private final Point mPosition = new Point();
        private final Rect mBounds = new Rect();


        TaskAnimationAdapter(Task task, boolean isRecentTaskInvisible) {
        TaskAnimationAdapter(Task task, boolean isRecentTaskInvisible) {
            mTask = task;
            mTask = task;
            mIsRecentTaskInvisible = isRecentTaskInvisible;
            mIsRecentTaskInvisible = isRecentTaskInvisible;
            final WindowContainer container = mTask.getParent();
            container.getRelativePosition(mPosition);
            container.getBounds(mBounds);
        }
        }


        RemoteAnimationTarget createRemoteAnimationApp() {
        RemoteAnimationTarget createRemoteAnimationApp() {
            final Point position = new Point();
            final Rect bounds = new Rect();
            final WindowContainer container = mTask.getParent();
            container.getRelativePosition(position);
            container.getBounds(bounds);
            final WindowState mainWindow = mTask.getTopVisibleAppMainWindow();
            final WindowState mainWindow = mTask.getTopVisibleAppMainWindow();
            if (mainWindow == null) {
            if (mainWindow == null) {
                return null;
                return null;
@@ -472,7 +481,7 @@ public class RecentsAnimationController implements DeathRecipient {
            InsetUtils.addInsets(insets, mainWindow.mAppToken.getLetterboxInsets());
            InsetUtils.addInsets(insets, mainWindow.mAppToken.getLetterboxInsets());
            mTarget = new RemoteAnimationTarget(mTask.mTaskId, MODE_CLOSING, mCapturedLeash,
            mTarget = new RemoteAnimationTarget(mTask.mTaskId, MODE_CLOSING, mCapturedLeash,
                    !mTask.fillsParent(), mainWindow.mWinAnimator.mLastClipRect,
                    !mTask.fillsParent(), mainWindow.mWinAnimator.mLastClipRect,
                    insets, mTask.getPrefixOrderIndex(), position, bounds,
                    insets, mTask.getPrefixOrderIndex(), mPosition, mBounds,
                    mTask.getWindowConfiguration(), mIsRecentTaskInvisible);
                    mTask.getWindowConfiguration(), mIsRecentTaskInvisible);
            return mTarget;
            return mTarget;
        }
        }
@@ -495,6 +504,7 @@ public class RecentsAnimationController implements DeathRecipient {
        @Override
        @Override
        public void startAnimation(SurfaceControl animationLeash, Transaction t,
        public void startAnimation(SurfaceControl animationLeash, Transaction t,
                OnAnimationFinishedCallback finishCallback) {
                OnAnimationFinishedCallback finishCallback) {
            t.setPosition(animationLeash, mPosition.x, mPosition.y);
            mCapturedLeash = animationLeash;
            mCapturedLeash = animationLeash;
            mCapturedFinishCallback = finishCallback;
            mCapturedFinishCallback = finishCallback;
        }
        }
+18 −0
Original line number Original line Diff line number Diff line
@@ -44,6 +44,7 @@ import android.util.Slog;
import android.util.proto.ProtoOutputStream;
import android.util.proto.ProtoOutputStream;
import android.view.Surface;
import android.view.Surface;


import android.view.SurfaceControl;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;


import java.io.PrintWriter;
import java.io.PrintWriter;
@@ -559,6 +560,23 @@ class Task extends WindowContainer<AppWindowToken> {
                && !mStack.isAnimatingBoundsToFullscreen() && !mPreserveNonFloatingState;
                && !mStack.isAnimatingBoundsToFullscreen() && !mPreserveNonFloatingState;
    }
    }


    @Override
    public SurfaceControl getAnimationLeashParent() {
        // Reparent to the animation layer so that we aren't clipped by the non-minimized
        // stack bounds, currently we only animate the task for the recents animation
        return getAppAnimationLayer(false /* boosted */);
    }

    boolean isTaskAnimating() {
        final RecentsAnimationController recentsAnim = mService.getRecentsAnimationController();
        if (recentsAnim != null) {
            if (recentsAnim.isAnimatingTask(this)) {
                return true;
            }
        }
        return false;
    }

    WindowState getTopVisibleAppMainWindow() {
    WindowState getTopVisibleAppMainWindow() {
        final AppWindowToken token = getTopVisibleAppToken();
        final AppWindowToken token = getTopVisibleAppToken();
        return token != null ? token.findMainWindow() : null;
        return token != null ? token.findMainWindow() : null;
+14 −0
Original line number Original line Diff line number Diff line
@@ -1331,6 +1331,20 @@ public class TaskStack extends WindowContainer<Task> implements
        return mMinimizeAmount != 0f;
        return mMinimizeAmount != 0f;
    }
    }


    /**
     * @return {@code true} if we have a {@link Task} that is animating (currently only used for the
     *         recents animation); {@code false} otherwise.
     */
    boolean isTaskAnimating() {
        for (int j = mChildren.size() - 1; j >= 0; j--) {
            final Task task = mChildren.get(j);
            if (task.isTaskAnimating()) {
                return true;
            }
        }
        return false;
    }

    @CallSuper
    @CallSuper
    @Override
    @Override
    public void writeToProto(ProtoOutputStream proto, long fieldId, boolean trim) {
    public void writeToProto(ProtoOutputStream proto, long fieldId, boolean trim) {