Merge "Rename drag to desktop transitions" into udc-qpr-dev am: c5cbf47072

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24059609

Change-Id: Ic2382c99726395c66c93fd10aa9d532cf6e38767
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Maryam Dehaini
2023-07-17 23:40:26 +00:00
committed by Automerger Merge Worker
5 changed files with 56 additions and 35 deletions

View File

@@ -202,17 +202,18 @@ class DesktopTasksController(
} }
/** /**
* Moves a single task to freeform and sets the taskBounds to the passed in bounds, * The first part of the animated move to desktop transition. Applies the changes to move task
* startBounds * to desktop mode and sets the taskBounds to the passed in bounds, startBounds. This is
* followed with a call to {@link finishMoveToDesktop} or {@link cancelMoveToDesktop}.
*/ */
fun moveToFreeform( fun startMoveToDesktop(
taskInfo: RunningTaskInfo, taskInfo: RunningTaskInfo,
startBounds: Rect, startBounds: Rect,
dragToDesktopValueAnimator: MoveToDesktopAnimator dragToDesktopValueAnimator: MoveToDesktopAnimator
) { ) {
KtProtoLog.v( KtProtoLog.v(
WM_SHELL_DESKTOP_MODE, WM_SHELL_DESKTOP_MODE,
"DesktopTasksController: moveToFreeform with bounds taskId=%d", "DesktopTasksController: startMoveToDesktop taskId=%d",
taskInfo.taskId taskInfo.taskId
) )
val wct = WindowContainerTransaction() val wct = WindowContainerTransaction()
@@ -221,18 +222,21 @@ class DesktopTasksController(
wct.setBounds(taskInfo.token, startBounds) wct.setBounds(taskInfo.token, startBounds)
if (Transitions.ENABLE_SHELL_TRANSITIONS) { if (Transitions.ENABLE_SHELL_TRANSITIONS) {
enterDesktopTaskTransitionHandler.startMoveToFreeformAnimation(wct, enterDesktopTaskTransitionHandler.startMoveToDesktop(wct, dragToDesktopValueAnimator,
dragToDesktopValueAnimator, mOnAnimationFinishedCallback) mOnAnimationFinishedCallback)
} else { } else {
shellTaskOrganizer.applyTransaction(wct) shellTaskOrganizer.applyTransaction(wct)
} }
} }
/** Brings apps to front and sets freeform task bounds */ /**
private fun moveToDesktopWithAnimation(taskInfo: RunningTaskInfo, freeformBounds: Rect) { * The second part of the animated move to desktop transition, called after
* {@link startMoveToDesktop}. Brings apps to front and sets freeform task bounds.
*/
private fun finalizeMoveToDesktop(taskInfo: RunningTaskInfo, freeformBounds: Rect) {
KtProtoLog.v( KtProtoLog.v(
WM_SHELL_DESKTOP_MODE, WM_SHELL_DESKTOP_MODE,
"DesktopTasksController: moveToDesktop with animation taskId=%d", "DesktopTasksController: finalizeMoveToDesktop taskId=%d",
taskInfo.taskId taskInfo.taskId
) )
val wct = WindowContainerTransaction() val wct = WindowContainerTransaction()
@@ -241,8 +245,8 @@ class DesktopTasksController(
wct.setBounds(taskInfo.token, freeformBounds) wct.setBounds(taskInfo.token, freeformBounds)
if (Transitions.ENABLE_SHELL_TRANSITIONS) { if (Transitions.ENABLE_SHELL_TRANSITIONS) {
enterDesktopTaskTransitionHandler.startTransition( enterDesktopTaskTransitionHandler.finalizeMoveToDesktop(wct,
Transitions.TRANSIT_ENTER_DESKTOP_MODE, wct, mOnAnimationFinishedCallback) mOnAnimationFinishedCallback)
} else { } else {
shellTaskOrganizer.applyTransaction(wct) shellTaskOrganizer.applyTransaction(wct)
releaseVisualIndicator() releaseVisualIndicator()
@@ -272,13 +276,14 @@ class DesktopTasksController(
} }
/** /**
* Move a task to fullscreen after being dragged from fullscreen and released back into * The second part of the animated move to desktop transition, called after
* status bar area * {@link startMoveToDesktop}. Move a task to fullscreen after being dragged from fullscreen
* and released back into status bar area.
*/ */
fun cancelMoveToFreeform(task: RunningTaskInfo, moveToDesktopAnimator: MoveToDesktopAnimator) { fun cancelMoveToDesktop(task: RunningTaskInfo, moveToDesktopAnimator: MoveToDesktopAnimator) {
KtProtoLog.v( KtProtoLog.v(
WM_SHELL_DESKTOP_MODE, WM_SHELL_DESKTOP_MODE,
"DesktopTasksController: cancelMoveToFreeform taskId=%d", "DesktopTasksController: cancelMoveToDesktop taskId=%d",
task.taskId task.taskId
) )
val wct = WindowContainerTransaction() val wct = WindowContainerTransaction()
@@ -784,7 +789,7 @@ class DesktopTasksController(
taskInfo: RunningTaskInfo, taskInfo: RunningTaskInfo,
freeformBounds: Rect freeformBounds: Rect
) { ) {
moveToDesktopWithAnimation(taskInfo, freeformBounds) finalizeMoveToDesktop(taskInfo, freeformBounds)
} }
private fun getStatusBarHeight(taskInfo: RunningTaskInfo): Int { private fun getStatusBarHeight(taskInfo: RunningTaskInfo): Int {

View File

@@ -79,7 +79,7 @@ public class EnterDesktopTaskTransitionHandler implements Transitions.Transition
* @param wct WindowContainerTransaction for transition * @param wct WindowContainerTransaction for transition
* @param onAnimationEndCallback to be called after animation * @param onAnimationEndCallback to be called after animation
*/ */
public void startTransition(@WindowManager.TransitionType int type, private void startTransition(@WindowManager.TransitionType int type,
@NonNull WindowContainerTransaction wct, @NonNull WindowContainerTransaction wct,
Consumer<SurfaceControl.Transaction> onAnimationEndCallback) { Consumer<SurfaceControl.Transaction> onAnimationEndCallback) {
mOnAnimationFinishedCallback = onAnimationEndCallback; mOnAnimationFinishedCallback = onAnimationEndCallback;
@@ -88,17 +88,29 @@ public class EnterDesktopTaskTransitionHandler implements Transitions.Transition
} }
/** /**
* Starts Transition of type TRANSIT_ENTER_FREEFORM * Starts Transition of type TRANSIT_START_MOVE_TO_DESKTOP_MODE
* @param wct WindowContainerTransaction for transition * @param wct WindowContainerTransaction for transition
* @param moveToDesktopAnimator Animator that shrinks and positions task during two part move * @param moveToDesktopAnimator Animator that shrinks and positions task during two part move
* to desktop animation * to desktop animation
* @param onAnimationEndCallback to be called after animation * @param onAnimationEndCallback to be called after animation
*/ */
public void startMoveToFreeformAnimation(@NonNull WindowContainerTransaction wct, public void startMoveToDesktop(@NonNull WindowContainerTransaction wct,
@NonNull MoveToDesktopAnimator moveToDesktopAnimator, @NonNull MoveToDesktopAnimator moveToDesktopAnimator,
Consumer<SurfaceControl.Transaction> onAnimationEndCallback) { Consumer<SurfaceControl.Transaction> onAnimationEndCallback) {
mMoveToDesktopAnimator = moveToDesktopAnimator; mMoveToDesktopAnimator = moveToDesktopAnimator;
startTransition(Transitions.TRANSIT_ENTER_FREEFORM, wct, onAnimationEndCallback); startTransition(Transitions.TRANSIT_START_MOVE_TO_DESKTOP_MODE, wct,
onAnimationEndCallback);
}
/**
* Starts Transition of type TRANSIT_FINALIZE_MOVE_TO_DESKTOP_MODE
* @param wct WindowContainerTransaction for transition
* @param onAnimationEndCallback to be called after animation
*/
public void finalizeMoveToDesktop(@NonNull WindowContainerTransaction wct,
Consumer<SurfaceControl.Transaction> onAnimationEndCallback) {
startTransition(Transitions.TRANSIT_FINALIZE_MOVE_TO_DESKTOP_MODE, wct,
onAnimationEndCallback);
} }
/** /**
@@ -155,7 +167,7 @@ public class EnterDesktopTaskTransitionHandler implements Transitions.Transition
} }
final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo(); final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo();
if (type == Transitions.TRANSIT_ENTER_FREEFORM if (type == Transitions.TRANSIT_START_MOVE_TO_DESKTOP_MODE
&& taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) { && taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) {
// Transitioning to freeform but keeping fullscreen bounds, so the crop is set // Transitioning to freeform but keeping fullscreen bounds, so the crop is set
// to null and we don't require an animation // to null and we don't require an animation
@@ -182,7 +194,7 @@ public class EnterDesktopTaskTransitionHandler implements Transitions.Transition
} }
Rect endBounds = change.getEndAbsBounds(); Rect endBounds = change.getEndAbsBounds();
if (type == Transitions.TRANSIT_ENTER_DESKTOP_MODE if (type == Transitions.TRANSIT_FINALIZE_MOVE_TO_DESKTOP_MODE
&& taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM && taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM
&& !endBounds.isEmpty()) { && !endBounds.isEmpty()) {
// This Transition animates a task to freeform bounds after being dragged into freeform // This Transition animates a task to freeform bounds after being dragged into freeform

View File

@@ -149,11 +149,13 @@ public class Transitions implements RemoteCallable<Transitions>,
/** Transition type for maximize to freeform transition. */ /** Transition type for maximize to freeform transition. */
public static final int TRANSIT_RESTORE_FROM_MAXIMIZE = WindowManager.TRANSIT_FIRST_CUSTOM + 9; public static final int TRANSIT_RESTORE_FROM_MAXIMIZE = WindowManager.TRANSIT_FIRST_CUSTOM + 9;
/** Transition type to freeform in desktop mode. */ /** Transition type for starting the move to desktop mode. */
public static final int TRANSIT_ENTER_FREEFORM = WindowManager.TRANSIT_FIRST_CUSTOM + 10; public static final int TRANSIT_START_MOVE_TO_DESKTOP_MODE =
WindowManager.TRANSIT_FIRST_CUSTOM + 10;
/** Transition type to freeform in desktop mode. */ /** Transition type for finalizing the move to desktop mode. */
public static final int TRANSIT_ENTER_DESKTOP_MODE = WindowManager.TRANSIT_FIRST_CUSTOM + 11; public static final int TRANSIT_FINALIZE_MOVE_TO_DESKTOP_MODE =
WindowManager.TRANSIT_FIRST_CUSTOM + 11;
/** Transition type to fullscreen from desktop mode. */ /** Transition type to fullscreen from desktop mode. */
public static final int TRANSIT_EXIT_DESKTOP_MODE = WindowManager.TRANSIT_FIRST_CUSTOM + 12; public static final int TRANSIT_EXIT_DESKTOP_MODE = WindowManager.TRANSIT_FIRST_CUSTOM + 12;

View File

@@ -197,7 +197,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
@NonNull TransitionInfo info, @NonNull TransitionInfo info,
@NonNull TransitionInfo.Change change) { @NonNull TransitionInfo.Change change) {
if (change.getMode() == WindowManager.TRANSIT_CHANGE if (change.getMode() == WindowManager.TRANSIT_CHANGE
&& (info.getType() == Transitions.TRANSIT_ENTER_DESKTOP_MODE && (info.getType() == Transitions.TRANSIT_FINALIZE_MOVE_TO_DESKTOP_MODE
|| info.getType() == Transitions.TRANSIT_CANCEL_ENTERING_DESKTOP_MODE || info.getType() == Transitions.TRANSIT_CANCEL_ENTERING_DESKTOP_MODE
|| info.getType() == Transitions.TRANSIT_EXIT_DESKTOP_MODE || info.getType() == Transitions.TRANSIT_EXIT_DESKTOP_MODE
|| info.getType() == Transitions.TRANSIT_DESKTOP_MODE_TOGGLE_RESIZE)) { || info.getType() == Transitions.TRANSIT_DESKTOP_MODE_TOGGLE_RESIZE)) {
@@ -616,7 +616,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
} else if (mMoveToDesktopAnimator != null) { } else if (mMoveToDesktopAnimator != null) {
relevantDecor.incrementRelayoutBlock(); relevantDecor.incrementRelayoutBlock();
mDesktopTasksController.ifPresent( mDesktopTasksController.ifPresent(
c -> c.cancelMoveToFreeform(relevantDecor.mTaskInfo, c -> c.cancelMoveToDesktop(relevantDecor.mTaskInfo,
mMoveToDesktopAnimator)); mMoveToDesktopAnimator));
mMoveToDesktopAnimator = null; mMoveToDesktopAnimator = null;
return; return;
@@ -643,7 +643,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
mDragToDesktopAnimationStartBounds, relevantDecor.mTaskInfo, mDragToDesktopAnimationStartBounds, relevantDecor.mTaskInfo,
relevantDecor.mTaskSurface); relevantDecor.mTaskSurface);
mDesktopTasksController.ifPresent( mDesktopTasksController.ifPresent(
c -> c.moveToFreeform(relevantDecor.mTaskInfo, c -> c.startMoveToDesktop(relevantDecor.mTaskInfo,
mDragToDesktopAnimationStartBounds, mDragToDesktopAnimationStartBounds,
mMoveToDesktopAnimator)); mMoveToDesktopAnimator));
mMoveToDesktopAnimator.startAnimation(); mMoveToDesktopAnimator.startAnimation();

View File

@@ -99,16 +99,17 @@ public class EnterDesktopTaskTransitionHandlerTest {
final int taskId = 1; final int taskId = 1;
WindowContainerTransaction wct = new WindowContainerTransaction(); WindowContainerTransaction wct = new WindowContainerTransaction();
doReturn(mToken).when(mTransitions) doReturn(mToken).when(mTransitions)
.startTransition(Transitions.TRANSIT_ENTER_FREEFORM, wct, .startTransition(Transitions.TRANSIT_START_MOVE_TO_DESKTOP_MODE, wct,
mEnterDesktopTaskTransitionHandler); mEnterDesktopTaskTransitionHandler);
doReturn(taskId).when(mMoveToDesktopAnimator).getTaskId(); doReturn(taskId).when(mMoveToDesktopAnimator).getTaskId();
mEnterDesktopTaskTransitionHandler.startMoveToFreeformAnimation(wct, mEnterDesktopTaskTransitionHandler.startMoveToDesktop(wct,
mMoveToDesktopAnimator, null); mMoveToDesktopAnimator, null);
TransitionInfo.Change change = TransitionInfo.Change change =
createChange(WindowManager.TRANSIT_CHANGE, taskId, WINDOWING_MODE_FREEFORM); createChange(WindowManager.TRANSIT_CHANGE, taskId, WINDOWING_MODE_FREEFORM);
TransitionInfo info = createTransitionInfo(Transitions.TRANSIT_ENTER_FREEFORM, change); TransitionInfo info = createTransitionInfo(Transitions.TRANSIT_START_MOVE_TO_DESKTOP_MODE,
change);
assertTrue(mEnterDesktopTaskTransitionHandler assertTrue(mEnterDesktopTaskTransitionHandler
@@ -120,17 +121,18 @@ public class EnterDesktopTaskTransitionHandlerTest {
@Test @Test
public void testTransitEnterDesktopModeAnimation() throws Throwable { public void testTransitEnterDesktopModeAnimation() throws Throwable {
final int transitionType = Transitions.TRANSIT_ENTER_DESKTOP_MODE; final int transitionType = Transitions.TRANSIT_FINALIZE_MOVE_TO_DESKTOP_MODE;
final int taskId = 1; final int taskId = 1;
WindowContainerTransaction wct = new WindowContainerTransaction(); WindowContainerTransaction wct = new WindowContainerTransaction();
doReturn(mToken).when(mTransitions) doReturn(mToken).when(mTransitions)
.startTransition(transitionType, wct, mEnterDesktopTaskTransitionHandler); .startTransition(transitionType, wct, mEnterDesktopTaskTransitionHandler);
mEnterDesktopTaskTransitionHandler.startTransition(transitionType, wct, null); mEnterDesktopTaskTransitionHandler.finalizeMoveToDesktop(wct, null);
TransitionInfo.Change change = TransitionInfo.Change change =
createChange(WindowManager.TRANSIT_CHANGE, taskId, WINDOWING_MODE_FREEFORM); createChange(WindowManager.TRANSIT_CHANGE, taskId, WINDOWING_MODE_FREEFORM);
change.setEndAbsBounds(new Rect(0, 0, 1, 1)); change.setEndAbsBounds(new Rect(0, 0, 1, 1));
TransitionInfo info = createTransitionInfo(Transitions.TRANSIT_ENTER_DESKTOP_MODE, change); TransitionInfo info = createTransitionInfo(
Transitions.TRANSIT_FINALIZE_MOVE_TO_DESKTOP_MODE, change);
runOnUiThread(() -> { runOnUiThread(() -> {
try { try {