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

Commit 42756897 authored by Hongwei Wang's avatar Hongwei Wang Committed by Android (Google) Code Review
Browse files

Merge "Send isTransitioningToPip when pip anim starts" into main

parents b6eb5b62 0e99af53
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -496,7 +496,9 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                "startSwipePipToHome: %s, state=%s", componentName, mPipTransitionState);
        mPipTransitionState.setInSwipePipToHomeTransition(true);
        if (!ENABLE_SHELL_TRANSITIONS) {
        if (ENABLE_SHELL_TRANSITIONS) {
            mPipTransitionController.onStartSwipePipToHome();
        } else {
            sendOnPipTransitionStarted(TRANSITION_DIRECTION_TO_PIP);
        }
        setBoundsStateForEntry(componentName, pictureInPictureParams, activityInfo);
+5 −0
Original line number Diff line number Diff line
@@ -190,6 +190,11 @@ public class PipTransition extends PipTransitionController {
        }
    }

    @Override
    protected boolean isInSwipePipToHomeTransition() {
        return mPipTransitionState.getInSwipePipToHomeTransition();
    }

    @Override
    public void startExitTransition(int type, WindowContainerTransaction out,
            @Nullable Rect destinationBounds) {
+28 −1
Original line number Diff line number Diff line
@@ -189,6 +189,32 @@ public abstract class PipTransitionController implements Transitions.TransitionH
        mPipTransitionCallbacks.put(callback, executor);
    }

    protected void onStartSwipePipToHome() {
        if (Flags.enablePipUiStateCallbackOnEntering()) {
            try {
                ActivityTaskManager.getService().onPictureInPictureUiStateChanged(
                        new PictureInPictureUiState.Builder()
                                .setTransitioningToPip(true)
                                .build());
            } catch (RemoteException | IllegalStateException e) {
                ProtoLog.e(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                        "Failed to set alert PiP state change.");
            }
        }
    }

    /**
     * Used in {@link #sendOnPipTransitionStarted(int)} to decide whether we should send the
     * PictureInPictureUiState change callback on transition start.
     * For instance, in auto-enter-pip case, {@link #onStartSwipePipToHome()} should have signaled
     * the app, and we can return {@code true} here to avoid double callback.
     *
     * @return {@code true} if there is a ongoing swipe pip to home transition.
     */
    protected boolean isInSwipePipToHomeTransition() {
        return false;
    }

    protected void sendOnPipTransitionStarted(
            @PipAnimationController.TransitionDirection int direction) {
        final Rect pipBounds = mPipBoundsState.getBounds();
@@ -199,7 +225,8 @@ public abstract class PipTransitionController implements Transitions.TransitionH
            entry.getValue().execute(
                    () -> entry.getKey().onPipTransitionStarted(direction, pipBounds));
        }
        if (isInPipDirection(direction) && Flags.enablePipUiStateCallbackOnEntering()) {
        if (isInPipDirection(direction) && Flags.enablePipUiStateCallbackOnEntering()
                && !isInSwipePipToHomeTransition()) {
            try {
                ActivityTaskManager.getService().onPictureInPictureUiStateChanged(
                        new PictureInPictureUiState.Builder()
+5 −0
Original line number Diff line number Diff line
@@ -137,6 +137,11 @@ public class PipTransition extends PipTransitionController implements
        }
    }

    @Override
    protected boolean isInSwipePipToHomeTransition() {
        return mPipTransitionState.isInSwipePipToHomeTransition();
    }

    //
    // Transition collection stage lifecycle hooks
    //