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

Commit 78e4429c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Desks: Use a single transition for desktop->split flows" into main

parents 12612bf2 410b818a
Loading
Loading
Loading
Loading
+9 −26
Original line number Diff line number Diff line
@@ -3226,11 +3226,7 @@ class DesktopTasksController(
     * Adds split screen changes to a transaction. Note that bounds are not reset here due to
     * animation; see {@link onDesktopSplitSelectAnimComplete}
     */
    private fun addMoveToSplitChanges(
        wct: WindowContainerTransaction,
        taskInfo: RunningTaskInfo,
        deskId: Int?,
    ): RunOnTransitStart? {
    private fun addMoveToSplitChanges(wct: WindowContainerTransaction, taskInfo: RunningTaskInfo) {
        if (!DesktopModeFlags.ENABLE_INPUT_LAYER_TRANSITION_FIX.isTrue) {
            // This windowing mode is to get the transition animation started; once we complete
            // split select, we will change windowing mode to undefined and inherit from split
@@ -3242,15 +3238,6 @@ class DesktopTasksController(
        // The task's density may have been overridden in freeform; revert it here as we don't
        // want it overridden in multi-window.
        wct.setDensityDpi(taskInfo.token, getDefaultDensityDpi())

        return performDesktopExitCleanupIfNeeded(
            taskId = taskInfo.taskId,
            displayId = taskInfo.displayId,
            deskId = deskId,
            wct = wct,
            forceToFullscreen = true,
            shouldEndUpAtHome = false,
        )
    }

    /** Returns the ID of the Task that will be minimized, or null if no task will be minimized. */
@@ -3692,18 +3679,14 @@ class DesktopTasksController(
                val deskId = taskRepository.getDeskIdForTask(taskInfo.taskId)
                logV("Split requested for task=%d in desk=%d", taskInfo.taskId, deskId)
                val wct = WindowContainerTransaction()
                val runOnTransitStart = addMoveToSplitChanges(wct, taskInfo, deskId)
                val transition =
                addMoveToSplitChanges(wct, taskInfo)
                splitScreenController.requestEnterSplitSelect(
                    taskInfo,
                        wct,
                        if (leftOrTop) SPLIT_POSITION_TOP_OR_LEFT
                        else SPLIT_POSITION_BOTTOM_OR_RIGHT,
                    if (leftOrTop) SPLIT_POSITION_TOP_OR_LEFT else SPLIT_POSITION_BOTTOM_OR_RIGHT,
                    taskInfo.configuration.windowConfiguration.bounds,
                    /* startRecents = */ true,
                    /* withRecentsWct = */ wct,
                )
                if (transition != null) {
                    runOnTransitStart?.invoke(transition)
                }
            }
        }
    }
+28 −19
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.UserHandle
import android.view.Choreographer
import android.view.SurfaceControl
import android.view.SurfaceControl.Transaction
import android.view.WindowManager.TRANSIT_CHANGE
import android.view.WindowManager.TRANSIT_CLOSE
import android.window.DesktopExperienceFlags
import android.window.DesktopModeFlags
@@ -234,6 +235,7 @@ sealed class DragToDesktopTransitionHandler(
     * means the user wants to remain in their current windowing mode.
     */
    fun cancelDragToDesktopTransition(cancelState: CancelState) {
        logV("cancelDragToDesktop cancel=%s", cancelState)
        if (!inProgress) {
            logV("cancelDragToDesktop: not in progress, returning")
            // Don't attempt to cancel a drag to desktop transition since there is no transition in
@@ -278,14 +280,18 @@ sealed class DragToDesktopTransitionHandler(
                } else {
                    SPLIT_POSITION_BOTTOM_OR_RIGHT
                }
            val wct = WindowContainerTransaction()
            restoreWindowOrder(wct, state)
            logV(
                "cancelDragToDesktop finishing start-transition and starting split-select " +
                    "request to position=%s with state=%s",
                splitPosition,
                state,
            )
            state.startTransitionFinishTransaction?.apply()
            val finishWCT = WindowContainerTransaction()
            val taskInfo = state.draggedTaskChange?.taskInfo ?: error("Expected non-null taskInfo")
            finishWCT.setDoNotPip(taskInfo.token)
            state.startTransitionFinishCb?.onTransitionFinished(finishWCT)
            requestSplitFromScaledTask(splitPosition, wct)
            requestSplitFromScaledTask(splitPosition, homeRunning = true)
            clearState()
        } else if (
            state.draggedTaskChange != null &&
@@ -313,13 +319,13 @@ sealed class DragToDesktopTransitionHandler(
    /** Calculate the bounds of a scaled task, then use those bounds to request split select. */
    private fun requestSplitFromScaledTask(
        @SplitPosition splitPosition: Int,
        wct: WindowContainerTransaction,
        homeRunning: Boolean,
    ) {
        val state = requireTransitionState()
        val taskInfo = state.draggedTaskChange?.taskInfo ?: error("Expected non-null taskInfo")
        val animatedTaskBounds = getAnimatedTaskBounds()
        state.dragAnimator.cancelAnimator()
        requestSplitSelect(wct, taskInfo, splitPosition, animatedTaskBounds)
        requestSplitSelect(taskInfo, splitPosition, animatedTaskBounds, homeRunning)
    }

    private fun getAnimatedTaskBounds(): Rect {
@@ -339,25 +345,30 @@ sealed class DragToDesktopTransitionHandler(
    }

    private fun requestSplitSelect(
        wct: WindowContainerTransaction,
        taskInfo: RunningTaskInfo,
        @SplitPosition splitPosition: Int,
        taskBounds: Rect = Rect(taskInfo.configuration.windowConfiguration.bounds),
        homeRunning: Boolean,
    ) {
        // Prepare to exit split in order to enter split select.
        if (taskInfo.windowingMode == WINDOWING_MODE_MULTI_WINDOW) {
            splitScreenController.prepareExitSplitScreen(
                wct,
                splitScreenController.getStageOfTask(taskInfo.taskId),
                SplitScreenController.EXIT_REASON_DESKTOP_MODE,
            )
            splitScreenController.transitionHandler.onSplitToDesktop()
        }
        val wct = WindowContainerTransaction()
        if (!DesktopModeFlags.ENABLE_INPUT_LAYER_TRANSITION_FIX.isTrue) {
            wct.setWindowingMode(taskInfo.token, WINDOWING_MODE_MULTI_WINDOW)
        }
        wct.setDensityDpi(taskInfo.token, context.resources.displayMetrics.densityDpi)
        splitScreenController.requestEnterSplitSelect(taskInfo, wct, splitPosition, taskBounds)

        val startRecents = !homeRunning
        val delegateWctToRecents = startRecents && !wct.isEmpty
        if (!startRecents && !wct.isEmpty) {
            // Split-select won't start a transition, so apply |wct| here.
            transitions.startTransition(TRANSIT_CHANGE, wct, /* handler= */ null)
        }
        splitScreenController.requestEnterSplitSelect(
            taskInfo,
            splitPosition,
            taskBounds,
            startRecents,
            /* withRecentsWct= */ if (delegateWctToRecents) wct else null,
        )
    }

    private fun requestBubbleFromScaledTask(onLeft: Boolean) {
@@ -557,11 +568,9 @@ sealed class DragToDesktopTransitionHandler(
                } else {
                    SPLIT_POSITION_BOTTOM_OR_RIGHT
                }
            val wct = WindowContainerTransaction()
            restoreWindowOrder(wct)
            state.startTransitionFinishTransaction?.apply()
            state.startTransitionFinishCb?.onTransitionFinished(/* wct= */ null)
            requestSplitSelect(wct, taskInfo, splitPosition)
            requestSplitSelect(taskInfo, splitPosition, homeRunning = true)
        } else if (
            state.cancelState == CancelState.CANCEL_BUBBLE_LEFT ||
                state.cancelState == CancelState.CANCEL_BUBBLE_RIGHT
+3 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.app.IApplicationThread;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.window.WindowContainerTransaction;

import com.android.wm.shell.recents.IRecentsAnimationRunner;
import com.android.wm.shell.recents.IRecentTasksListener;
@@ -55,5 +56,6 @@ interface IRecentTasks {
     * Starts a recents transition.
     */
    oneway void startRecentsTransition(in PendingIntent intent, in Intent fillIn, in Bundle options,
                    IApplicationThread appThread, IRecentsAnimationRunner listener) = 5;
                    in @nullable WindowContainerTransaction wct, IApplicationThread appThread,
                    IRecentsAnimationRunner listener) = 5;
}
+3 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.util.SparseIntArray;
import android.window.DesktopExperienceFlags;
import android.window.DesktopModeFlags;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;

import androidx.annotation.BinderThread;
import androidx.annotation.NonNull;
@@ -1085,6 +1086,7 @@ public class RecentTasksController implements TaskStackListenerCallback,

        @Override
        public void startRecentsTransition(PendingIntent intent, Intent fillIn, Bundle options,
                @Nullable WindowContainerTransaction wct,
                IApplicationThread appThread, IRecentsAnimationRunner listener) {
            if (mController.mTransitionHandler == null) {
                Slog.e(TAG, "Used shell-transitions startRecentsTransition without"
@@ -1093,7 +1095,7 @@ public class RecentTasksController implements TaskStackListenerCallback,
            }
            executeRemoteCallWithTaskPermission(mController, "startRecentsTransition",
                    (controller) -> controller.mTransitionHandler.startRecentsTransition(
                            intent, fillIn, options, appThread, listener));
                            intent, fillIn, options, wct, appThread, listener));
        }
    }
}
+5 −4
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.IApplicationThread;
import android.app.PendingIntent;
import android.app.WindowConfiguration;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
@@ -180,6 +179,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
     */
    @VisibleForTesting
    public IBinder startRecentsTransition(PendingIntent intent, Intent fillIn, Bundle options,
            @Nullable WindowContainerTransaction wct,
            IApplicationThread appThread, IRecentsAnimationRunner listener) {
        // only care about latest one.
        mAnimApp = appThread;
@@ -194,7 +194,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
        if (isSyntheticRequest) {
            transition = startSyntheticRecentsTransition(listener);
        } else {
            transition = startRealRecentsTransition(intent, fillIn, options, listener);
            transition = startRealRecentsTransition(intent, fillIn, options, wct, listener);
        }
        return transition;
    }
@@ -224,11 +224,12 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
     * Starts a real WM-backed recents transition.
     */
    private IBinder startRealRecentsTransition(PendingIntent intent, Intent fillIn, Bundle options,
            IRecentsAnimationRunner listener) {
            @Nullable WindowContainerTransaction requestWct, IRecentsAnimationRunner listener) {
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                "RecentsTransitionHandler.startRecentsTransition");

        final WindowContainerTransaction wct = new WindowContainerTransaction();
        final WindowContainerTransaction wct = requestWct != null
                ? requestWct : new WindowContainerTransaction();
        wct.sendPendingIntent(intent, fillIn, options);

        // Find the mixed handler which should handle this request (if we are in a state where a
Loading