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

Commit 7c1c7f3e authored by Merissa Mitchell's avatar Merissa Mitchell Committed by Android (Google) Code Review
Browse files

Merge "[PiP2 on Desktop] Enter PiP with bounds change animation." into main

parents adecd0fe 51f099fa
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -77,6 +77,10 @@ class DesktopMixedTransitionHandler(
    override fun startMinimizedModeTransition(wct: WindowContainerTransaction?): IBinder =
        freeformTaskTransitionHandler.startMinimizedModeTransition(wct)

    /** Delegates starting PiP transition to [FreeformTaskTransitionHandler]. */
    override fun startPipTransition(wct: WindowContainerTransaction?): IBinder =
        freeformTaskTransitionHandler.startPipTransition(wct)

    /** Starts close transition and handles or delegates desktop task close animation. */
    override fun startRemoveTransition(wct: WindowContainerTransaction?): IBinder {
        if (
+37 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import android.view.WindowManager.TRANSIT_CHANGE
import android.view.WindowManager.TRANSIT_CLOSE
import android.view.WindowManager.TRANSIT_NONE
import android.view.WindowManager.TRANSIT_OPEN
import android.view.WindowManager.TRANSIT_PIP
import android.view.WindowManager.TRANSIT_TO_FRONT
import android.widget.Toast
import android.window.DesktopModeFlags
@@ -220,6 +221,7 @@ class DesktopTasksController(
    // Launch cookie used to identify a drag and drop transition to fullscreen after it has begun.
    // Used to prevent handleRequest from moving the new fullscreen task to freeform.
    private var dragAndDropFullscreenCookie: Binder? = null
    private var pendingPipTransitionAndTask: Pair<IBinder, Int>? = null

    init {
        desktopMode = DesktopModeImpl()
@@ -557,6 +559,26 @@ class DesktopTasksController(
    }

    fun minimizeTask(taskInfo: RunningTaskInfo) {
        val wct = WindowContainerTransaction()

        val isMinimizingToPip = taskInfo.pictureInPictureParams?.isAutoEnterEnabled() ?: false
        // If task is going to PiP, start a PiP transition instead of a minimize transition
        if (isMinimizingToPip) {
            val requestInfo = TransitionRequestInfo(
                TRANSIT_PIP, /* triggerTask= */ null, taskInfo, /* remoteTransition= */ null,
                /* displayChange= */ null, /* flags= */ 0
            )
            val requestRes = transitions.dispatchRequest(Binder(), requestInfo, /* skip= */ null)
            wct.merge(requestRes.second, true)
            pendingPipTransitionAndTask =
                freeformTaskTransitionStarter.startPipTransition(wct) to taskInfo.taskId
            return
        }

        minimizeTaskInner(taskInfo)
    }

    private fun minimizeTaskInner(taskInfo: RunningTaskInfo) {
        val taskId = taskInfo.taskId
        val displayId = taskInfo.displayId
        val wct = WindowContainerTransaction()
@@ -1335,6 +1357,21 @@ class DesktopTasksController(
        return false
    }

    override fun onTransitionConsumed(
        transition: IBinder,
        aborted: Boolean,
        finishT: Transaction?
    ) {
        pendingPipTransitionAndTask?.let { (pipTransition, taskId) ->
            if (transition == pipTransition) {
                if (aborted) {
                    shellTaskOrganizer.getRunningTaskInfo(taskId)?.let { minimizeTaskInner(it) }
                }
                pendingPipTransitionAndTask = null
            }
        }
    }

    override fun handleRequest(
        transition: IBinder,
        request: TransitionRequestInfo,
+7 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.freeform;

import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.view.WindowManager.TRANSIT_PIP;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -99,6 +100,12 @@ public class FreeformTaskTransitionHandler
        return token;
    }

    @Override
    public IBinder startPipTransition(WindowContainerTransaction wct) {
        final IBinder token = mTransitions.startTransition(TRANSIT_PIP, wct, null);
        mPendingTransitionTokens.add(token);
        return token;
    }

    @Override
    public IBinder startRemoveTransition(WindowContainerTransaction wct) {
+9 −0
Original line number Diff line number Diff line
@@ -51,4 +51,13 @@ public interface FreeformTaskTransitionStarter {
     * @return the started transition
     */
    IBinder startRemoveTransition(WindowContainerTransaction wct);

    /**
     * Starts PiP transition
     *
     * @param wct the {@link WindowContainerTransaction} that launches the PiP
     *
     * @return the started transition
     */
    IBinder startPipTransition(WindowContainerTransaction wct);
}
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import android.window.WindowContainerTransaction;
import androidx.annotation.Nullable;

import com.android.internal.util.Preconditions;
import com.android.window.flags.Flags;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.pip.PipBoundsAlgorithm;
import com.android.wm.shell.common.pip.PipBoundsState;
@@ -729,6 +730,10 @@ public class PipTransition extends PipTransitionController implements
                    && getFixedRotationDelta(info, pipTaskChange) == ROTATION_90) {
                adjustedSourceRectHint.offset(cutoutInsets.left, cutoutInsets.top);
            }
            if (Flags.enableDesktopWindowingPip()) {
                adjustedSourceRectHint.offset(-pipActivityChange.getStartAbsBounds().left,
                        -pipActivityChange.getStartAbsBounds().top);
            }
        } else {
            // For non-valid app provided src-rect-hint, calculate one to crop into during
            // app icon overlay animation.
Loading