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

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

Merge "[PiP2] Implement Content-PiP2" into main

parents 766af1f7 9a17f933
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -1342,6 +1342,7 @@ public class ActivityOptions extends ComponentOptions {
        final ActivityOptions opts = new ActivityOptions();
        final ActivityOptions opts = new ActivityOptions();
        opts.mLaunchIntoPipParams = new PictureInPictureParams.Builder(pictureInPictureParams)
        opts.mLaunchIntoPipParams = new PictureInPictureParams.Builder(pictureInPictureParams)
                .setIsLaunchIntoPip(true)
                .setIsLaunchIntoPip(true)
                .setAutoEnterEnabled(true)
                .build();
                .build();
        return opts;
        return opts;
    }
    }
+2 −2
Original line number Original line Diff line number Diff line
@@ -144,14 +144,14 @@ public abstract class PipTransitionController implements Transitions.TransitionH
    /**
    /**
     * Called when the Shell wants to start an exit-via-expand from Pip transition/animation.
     * Called when the Shell wants to start an exit-via-expand from Pip transition/animation.
     */
     */
    public void startExpandTransition(WindowContainerTransaction out, boolean toSplit) {
    public void startExpandTransition(WindowContainerTransaction wct, boolean toSplit) {
        // Default implementation does nothing.
        // Default implementation does nothing.
    }
    }


    /**
    /**
     * Called when the Shell wants to start a remove Pip transition/animation.
     * Called when the Shell wants to start a remove Pip transition/animation.
     */
     */
    public void startRemoveTransition(boolean withFadeout) {
    public void startRemoveTransition(WindowContainerTransaction wct, boolean withFadeout) {
        // Default implementation does nothing.
        // Default implementation does nothing.
    }
    }


+3 −0
Original line number Original line Diff line number Diff line
@@ -616,6 +616,9 @@ public class PipController implements ConfigurationChangeListener,
                    mPipUiEventLogger.log(
                    mPipUiEventLogger.log(
                            PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_AUTO_ENTER);
                            PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_AUTO_ENTER);
                    mPipTransitionState.resetSwipePipToHomeState();
                    mPipTransitionState.resetSwipePipToHomeState();
                } else if (taskInfo != null && taskInfo.launchIntoPipHostTaskId != -1) {
                    mPipUiEventLogger.log(
                            PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_ENTER_CONTENT_PIP);
                } else {
                } else {
                    mPipUiEventLogger.log(PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_ENTER);
                    mPipUiEventLogger.log(PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_ENTER);
                }
                }
+8 −1
Original line number Original line Diff line number Diff line
@@ -360,8 +360,15 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
        }
        }
        cancelPhysicsAnimation();
        cancelPhysicsAnimation();
        mMenuController.hideMenu(ANIM_TYPE_NONE, false /* resize */);
        mMenuController.hideMenu(ANIM_TYPE_NONE, false /* resize */);

        boolean isContentPip = mPipTransitionState.getPipTaskInfo() != null
                && mPipTransitionState.getPipTaskInfo().launchIntoPipHostTaskId != -1;
        if (isContentPip) {
            mPipScheduler.scheduleRemovePip(true /* withFadeout */);
        } else {
            mPipScheduler.scheduleExitPipViaExpand();
            mPipScheduler.scheduleExitPipViaExpand();
        }
        }
    }


    /**
    /**
     * Dismisses the pinned stack.
     * Dismisses the pinned stack.
+27 −4
Original line number Original line Diff line number Diff line
@@ -16,7 +16,10 @@


package com.android.wm.shell.pip2.phone;
package com.android.wm.shell.pip2.phone;


import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;

import android.app.PictureInPictureParams;
import android.app.PictureInPictureParams;
import android.app.TaskInfo;
import android.content.Context;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Bundle;
@@ -128,18 +131,39 @@ public class PipScheduler implements PipTransitionState.PipTransitionStateChange
        wct.setBounds(pipTaskToken, null);
        wct.setBounds(pipTaskToken, null);
        wct.setWindowingMode(pipTaskToken, mPipDesktopState.getOutPipWindowingMode());
        wct.setWindowingMode(pipTaskToken, mPipDesktopState.getOutPipWindowingMode());


        final TaskInfo pipTaskInfo = mPipTransitionState.getPipTaskInfo();
        mDesktopPipTransitionController.ifPresent(c -> {
        mDesktopPipTransitionController.ifPresent(c -> {
            // In multi-activity case, windowing mode change will reparent to original host task, so
            // In multi-activity case, windowing mode change will reparent to original host task, so
            // we have to update the parent windowing mode to what is expected.
            // we have to update the parent windowing mode to what is expected.
            c.maybeUpdateParentInWct(wct,
            c.maybeUpdateParentInWct(wct,
                    mPipTransitionState.getPipTaskInfo().lastParentTaskIdBeforePip);
                    pipTaskInfo.lastParentTaskIdBeforePip);
            // In multi-desks case, we have to reparent the task to the root desk.
            // In multi-desks case, we have to reparent the task to the root desk.
            c.maybeReparentTaskToDesk(wct, mPipTransitionState.getPipTaskInfo().taskId);
            c.maybeReparentTaskToDesk(wct, pipTaskInfo.taskId);
        });
        });


        return wct;
        return wct;
    }
    }


    @Nullable
    private WindowContainerTransaction getRemovePipTransaction() {
        WindowContainerToken pipTaskToken = mPipTransitionState.getPipTaskToken();
        if (pipTaskToken == null) {
            return null;
        }
        WindowContainerTransaction wct = new WindowContainerTransaction();
        wct.setBounds(pipTaskToken, null);
        wct.setWindowingMode(pipTaskToken, WINDOWING_MODE_UNDEFINED);
        wct.reorder(pipTaskToken, false);

        final TaskInfo pipTaskInfo = mPipTransitionState.getPipTaskInfo();
        if (pipTaskInfo.launchIntoPipHostTaskId != -1) {
            // If the current PiP session was entered through content-PiP,
            // then relaunch the original host task too.
            wct.startTask(pipTaskInfo.launchIntoPipHostTaskId, null /* ActivityOptions */);
        }
        return wct;
    }

    /**
    /**
     * Schedules exit PiP via expand transition.
     * Schedules exit PiP via expand transition.
     */
     */
@@ -159,7 +183,6 @@ public class PipScheduler implements PipTransitionState.PipTransitionStateChange
                            null /* taskInfo */, SplitScreenConstants.SPLIT_POSITION_UNDEFINED);
                            null /* taskInfo */, SplitScreenConstants.SPLIT_POSITION_UNDEFINED);
                }
                }
            });
            });

            boolean toSplit = !wct.isEmpty();
            boolean toSplit = !wct.isEmpty();
            wct.merge(expandWct, true /* transfer */);
            wct.merge(expandWct, true /* transfer */);
            mPipTransitionController.startExpandTransition(wct, toSplit);
            mPipTransitionController.startExpandTransition(wct, toSplit);
@@ -170,7 +193,7 @@ public class PipScheduler implements PipTransitionState.PipTransitionStateChange
    public void scheduleRemovePip(boolean withFadeout) {
    public void scheduleRemovePip(boolean withFadeout) {
        mMainExecutor.execute(() -> {
        mMainExecutor.execute(() -> {
            if (!mPipTransitionState.isInPip()) return;
            if (!mPipTransitionState.isInPip()) return;
            mPipTransitionController.startRemoveTransition(withFadeout);
            mPipTransitionController.startRemoveTransition(getRemovePipTransaction(), withFadeout);
        });
        });
    }
    }


Loading