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

Commit 1ac8e3db authored by Ikram Gabiyev's avatar Ikram Gabiyev Committed by Android (Google) Code Review
Browse files

Merge "[PiP2] Fix Btn-nav and direct enter PiP from Split" into main

parents 75ea3ea1 44547892
Loading
Loading
Loading
Loading
+20 −24
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@ import static android.view.Surface.ROTATION_0;
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;

import static com.android.wm.shell.pip.PipTransitionController.ANIM_TYPE_ALPHA;
import static com.android.wm.shell.pip.PipTransitionController.ANIM_TYPE_BOUNDS;

import android.animation.AnimationHandler;
import android.animation.Animator;
import android.animation.RectEvaluator;
@@ -59,16 +62,6 @@ public class PipAnimationController {
    static final float FRACTION_START = 0f;
    static final float FRACTION_END = 1f;

    public static final int ANIM_TYPE_BOUNDS = 0;
    public static final int ANIM_TYPE_ALPHA = 1;

    @IntDef(prefix = { "ANIM_TYPE_" }, value = {
            ANIM_TYPE_BOUNDS,
            ANIM_TYPE_ALPHA
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface AnimationType {}

    /**
     * The alpha type is set for swiping to home. But the swiped task may not enter PiP. And if
     * another task enters PiP by non-swipe ways, e.g. call API in foreground or switch to 3-button
@@ -125,7 +118,7 @@ public class PipAnimationController {
            });

    private PipTransitionAnimator mCurrentAnimator;
    @AnimationType
    @PipTransitionController.AnimationType
    private int mOneShotAnimationType = ANIM_TYPE_BOUNDS;
    private long mLastOneShotAlphaAnimationTime;

@@ -157,9 +150,9 @@ public class PipAnimationController {
    /**
     * Construct and return an animator that animates from the {@param startBounds} to the
     * {@param endBounds} with the given {@param direction}. If {@param direction} is type
     * {@link ANIM_TYPE_BOUNDS}, then {@param sourceHintRect} will be used to animate
     * in a better, more smooth manner. If the original bound was rotated and a reset needs to
     * happen, pass in {@param startingAngle}.
     * {@link PipTransitionController#ANIM_TYPE_BOUNDS}, then {@param sourceHintRect} will be used
     * to animate in a better, more smooth manner. If the original bound was rotated and a reset
     * needs to happen, pass in {@param startingAngle}.
     *
     * In the case where one wants to start animation during an intermediate animation (for example,
     * if the user is currently doing a pinch-resize, and upon letting go now PiP needs to animate
@@ -244,12 +237,13 @@ public class PipAnimationController {

    /**
     * Sets the preferred enter animation type for one time. This is typically used to set the
     * animation type to {@link PipAnimationController#ANIM_TYPE_ALPHA}.
     * animation type to {@link PipTransitionController#ANIM_TYPE_ALPHA}.
     * <p>
     * For example, gesture navigation would first fade out the PiP activity, and the transition
     * should be responsible to animate in (such as fade in) the PiP.
     */
    public void setOneShotEnterAnimationType(@AnimationType int animationType) {
    public void setOneShotEnterAnimationType(
            @PipTransitionController.AnimationType int animationType) {
        mOneShotAnimationType = animationType;
        if (animationType == ANIM_TYPE_ALPHA) {
            mLastOneShotAlphaAnimationTime = SystemClock.uptimeMillis();
@@ -257,7 +251,7 @@ public class PipAnimationController {
    }

    /** Returns the preferred animation type and consumes the one-shot type if needed. */
    @AnimationType
    @PipTransitionController.AnimationType
    public int takeOneShotEnterAnimationType() {
        final int type = mOneShotAnimationType;
        if (type == ANIM_TYPE_ALPHA) {
@@ -321,7 +315,7 @@ public class PipAnimationController {
            ValueAnimator.AnimatorListener {
        private final TaskInfo mTaskInfo;
        private final SurfaceControl mLeash;
        private final @AnimationType int mAnimationType;
        private final @PipTransitionController.AnimationType int mAnimationType;
        private final Rect mDestinationBounds = new Rect();

        private final Point mLeashOffset = new Point();
@@ -341,16 +335,17 @@ public class PipAnimationController {
        private boolean mHasRequestedEnd;

        private PipTransitionAnimator(@NonNull TaskInfo taskInfo, @NonNull SurfaceControl leash,
                @AnimationType int animationType, @NonNull Rect destinationBounds,
                @NonNull T baseValue, @NonNull T startValue, @NonNull T endValue) {
                @PipTransitionController.AnimationType int animationType,
                @NonNull Rect destinationBounds, @NonNull T baseValue, @NonNull T startValue,
                @NonNull T endValue) {
            this(taskInfo, leash, animationType, destinationBounds, new Point(), baseValue,
                    startValue, endValue);
        }

        private PipTransitionAnimator(@NonNull TaskInfo taskInfo, @NonNull SurfaceControl leash,
                @AnimationType int animationType, @NonNull Rect destinationBounds,
                @NonNull Point leashOffset, @NonNull T baseValue, @NonNull T startValue,
                @NonNull T endValue) {
                @PipTransitionController.AnimationType int animationType,
                @NonNull Rect destinationBounds, @NonNull Point leashOffset,
                @NonNull T baseValue, @NonNull T startValue, @NonNull T endValue) {
            mTaskInfo = taskInfo;
            mLeash = leash;
            mAnimationType = animationType;
@@ -408,7 +403,8 @@ public class PipAnimationController {
        @Override public void onAnimationRepeat(Animator animation) {}

        @VisibleForTesting
        @AnimationType public int getAnimationType() {
        @PipTransitionController.AnimationType
        public int getAnimationType() {
            return mAnimationType;
        }

+3 −3
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@ import static com.android.wm.shell.ShellTaskOrganizer.TASK_LISTENER_TYPE_PIP;
import static com.android.wm.shell.ShellTaskOrganizer.taskListenerTypeToString;
import static com.android.wm.shell.desktopmode.DesktopModeUtils.calculateInitialBounds;
import static com.android.wm.shell.desktopmode.DesktopTasksController.DESKTOP_MODE_INITIAL_BOUNDS_SCALE;
import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_ALPHA;
import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
import static com.android.wm.shell.pip.PipAnimationController.FRACTION_START;
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_EXPAND_OR_UNEXPAND;
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP;
@@ -43,6 +41,8 @@ import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTI
import static com.android.wm.shell.pip.PipAnimationController.isInPipDirection;
import static com.android.wm.shell.pip.PipAnimationController.isOutPipDirection;
import static com.android.wm.shell.pip.PipAnimationController.isRemovePipDirection;
import static com.android.wm.shell.pip.PipTransitionController.ANIM_TYPE_ALPHA;
import static com.android.wm.shell.pip.PipTransitionController.ANIM_TYPE_BOUNDS;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
import static com.android.wm.shell.transition.Transitions.ENABLE_SHELL_TRANSITIONS;
@@ -1716,7 +1716,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,

    private void finishResize(SurfaceControl.Transaction tx, Rect destinationBounds,
            @PipAnimationController.TransitionDirection int direction,
            @PipAnimationController.AnimationType int type) {
            @PipTransitionController.AnimationType int type) {
        final Rect preResizeBounds = new Rect(mPipBoundsState.getBounds());
        mPipBoundsState.setBounds(destinationBounds);
        if (direction == TRANSITION_DIRECTION_REMOVE_STACK) {
+2 −4
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.window.TransitionInfo.FLAG_IS_DISPLAY;

import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_ALPHA;
import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP;
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_SAME;
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
@@ -116,7 +114,7 @@ public class PipTransition extends PipTransitionController {
    private final HomeTransitionObserver mHomeTransitionObserver;
    private final Optional<SplitScreenController> mSplitScreenOptional;
    private final PipAnimationController mPipAnimationController;
    private @PipAnimationController.AnimationType int mEnterAnimationType = ANIM_TYPE_BOUNDS;
    private @AnimationType int mEnterAnimationType = ANIM_TYPE_BOUNDS;
    private Transitions.TransitionFinishCallback mFinishCallback;
    private SurfaceControl.Transaction mFinishTransaction;
    private final Rect mExitDestinationBounds = new Rect();
@@ -992,7 +990,7 @@ public class PipTransition extends PipTransitionController {
    }

    @Override
    public void setEnterAnimationType(@PipAnimationController.AnimationType int type) {
    public void setEnterAnimationType(@AnimationType int type) {
        mEnterAnimationType = type;
    }

+15 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.view.WindowManager.TRANSIT_PIP;
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_REMOVE_STACK;
import static com.android.wm.shell.pip.PipAnimationController.isInPipDirection;

import android.annotation.IntDef;
import android.annotation.Nullable;
import android.app.ActivityTaskManager;
import android.app.Flags;
@@ -55,6 +56,8 @@ import com.android.wm.shell.transition.DefaultMixedHandler;
import com.android.wm.shell.transition.Transitions;

import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executor;
@@ -73,6 +76,17 @@ public abstract class PipTransitionController implements Transitions.TransitionH
    protected PipTaskOrganizer mPipOrganizer;
    protected DefaultMixedHandler mMixedHandler;

    public static final int ANIM_TYPE_BOUNDS = 0;
    public static final int ANIM_TYPE_ALPHA = 1;

    @IntDef(prefix = { "ANIM_TYPE_" }, value = {
            ANIM_TYPE_BOUNDS,
            ANIM_TYPE_ALPHA
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface AnimationType {}


    protected final PipAnimationController.PipAnimationCallback mPipAnimationCallback =
            new PipAnimationController.PipAnimationCallback() {
                @Override
@@ -357,7 +371,7 @@ public abstract class PipTransitionController implements Transitions.TransitionH
    }

    /** Sets the type of animation when a PiP task appears. */
    public void setEnterAnimationType(@PipAnimationController.AnimationType int type) {
    public void setEnterAnimationType(@AnimationType int type) {
    }

    /** Play a transition animation for entering PiP on a specific PiP change. */
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE;
import static android.view.WindowManager.INPUT_CONSUMER_PIP;

import static com.android.internal.jank.InteractionJankMonitor.CUJ_PIP_TRANSITION;
import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_ALPHA;
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_EXPAND_OR_UNEXPAND;
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP;
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN;
@@ -32,6 +31,7 @@ import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTI
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_USER_RESIZE;
import static com.android.wm.shell.pip.PipAnimationController.isOutPipDirection;
import static com.android.wm.shell.pip.PipTransitionController.ANIM_TYPE_ALPHA;

import android.app.ActivityManager;
import android.app.ActivityTaskManager;
Loading