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

Commit 4fbf06ab authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

Jumpcut animation to exit PiP while entering PiP

If onActivityRestartAttempt() request comes into
PiP to PipTaskOrganizer#exitPip() and if we are still
entering PiP, jump-cut the enter-PiP animation to its end
submitting finishWCT as usual via animator callback
and allow for a runnable to be run right after to
exitPip() for instance.

Bug: 322419955
Test: manually reproduce the steps in the bug
Change-Id: Ib703ee8095c48df60db2cd211831c7e648b4d374
parent 41b21255
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -578,6 +578,17 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
            return;
        }

        if (mPipTransitionState.isEnteringPip()
                && !mPipTransitionState.getInSwipePipToHomeTransition()) {
            // If we are still entering PiP with Shell playing enter animation, jump-cut to
            // the end of the enter animation and reschedule exitPip to run after enter-PiP
            // has finished its transition and allowed the client to draw in PiP mode.
            mPipTransitionController.end(() -> {
                exitPip(animationDurationMs, requestEnterSplit);
            });
            return;
        }

        ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                "exitPip: %s, state=%s", mTaskInfo.topActivity, mPipTransitionState);
        final WindowContainerTransaction wct = new WindowContainerTransaction();
+10 −4
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ import static com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_PIP;
import static com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_PIP_TO_SPLIT;
import static com.android.wm.shell.transition.Transitions.TRANSIT_REMOVE_PIP;

import android.animation.Animator;
import android.annotation.IntDef;
import android.app.ActivityManager;
import android.app.TaskInfo;
@@ -348,9 +347,16 @@ public class PipTransition extends PipTransitionController {

    @Override
    public void end() {
        Animator animator = mPipAnimationController.getCurrentAnimator();
        if (animator != null && animator.isRunning()) {
            animator.end();
        end(null);
    }

    @Override
    public void end(@Nullable Runnable onTransitionEnd) {
        if (mPipAnimationController.isAnimating()) {
            mPipAnimationController.getCurrentAnimator().end();
        }
        if (onTransitionEnd != null) {
            onTransitionEnd.run();
        }
    }

+8 −0
Original line number Diff line number Diff line
@@ -305,6 +305,14 @@ public abstract class PipTransitionController implements Transitions.TransitionH
    public void end() {
    }

    /**
     * End the currently-playing PiP animation.
     *
     * @param onTransitionEnd callback to run upon finishing the playing transition.
     */
    public void end(@Nullable Runnable onTransitionEnd) {
    }

    /** Starts the {@link android.window.SystemPerformanceHinter.HighPerfSession}. */
    public void startHighPerfSession() {}