Loading libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java +23 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_LOCKED; import static android.view.WindowManager.TRANSIT_OPEN; import static android.view.WindowManager.TRANSIT_PIP; import static android.view.WindowManager.TRANSIT_SLEEP; import static android.view.WindowManager.TRANSIT_TO_BACK; import static android.view.WindowManager.TRANSIT_TO_FRONT; import static android.window.DesktopModeFlags.ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX; import static android.window.TransitionInfo.FLAG_MOVED_TO_TOP; Loading Loading @@ -427,6 +428,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler, private WindowContainerToken mRecentsTask = null; private int mRecentsTaskId = -1; private TransitionInfo mInfo = null; private TransitionInfo mMergingInfo; private boolean mOpeningSeparateHome = false; private boolean mPausingSeparateHome = false; private ArrayMap<SurfaceControl, SurfaceControl> mLeashMap = null; Loading Loading @@ -508,6 +510,25 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler, sendCancel(null, null); } } if (toHome && mMergingInfo != null && mPausingTasks != null && mMergingInfo.getType() == TRANSIT_CHANGE && TransitionUtil.hasDisplayChange(mMergingInfo)) { // Update the mode of pausing tasks from CHANGE to TO_BACK, so the next transition // handler (if any) can animate it correctly. final var changes = mMergingInfo.getChanges(); for (int i = changes.size() - 1; i >= 0; --i) { final TransitionInfo.Change change = changes.get(i); final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo(); if (taskInfo == null || change.getMode() != TRANSIT_CHANGE || TaskState.indexOf(mPausingTasks, change) < 0) { continue; } change.setMode(TRANSIT_TO_BACK); ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION, "[%d] RecentsController.cancel: set TO_BACK for taskId=%d", mInstanceId, taskInfo.taskId); } } if (mFinishCB != null) { finishInner(toHome, false /* userLeave */, null /* finishCb */, "cancel"); } else { Loading Loading @@ -597,6 +618,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler, mClosingTasks = null; mOpeningTasks = null; mInfo = null; mMergingInfo = null; mTransition = null; mPendingPauseSnapshotsForCancel = null; mPipTaskId = -1; Loading Loading @@ -1042,6 +1064,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler, cancel("keyguard_locked"); return; } mMergingInfo = info; ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION, "[%d] RecentsController.merge", mInstanceId); // Keep all tasks in one list because order matters. Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/recents/RecentsTransitionHandlerTest.java +38 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.wm.shell.recents; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.view.WindowManager.TRANSIT_CHANGE; import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_OPEN; import static android.view.WindowManager.TRANSIT_SLEEP; Loading Loading @@ -514,6 +515,43 @@ public class RecentsTransitionHandlerTest extends ShellTestCase { verify(finishT).setCornerRadius(leash, FREEFORM_TASK_CORNER_RADIUS_ON_CD); } @Test public void testMerge_cancelToHome_onDisplayChange() throws Exception { final IRecentsAnimationRunner animationRunner = mock(IRecentsAnimationRunner.class); final IBinder transition = startRecentsTransition(/* synthetic= */ false, animationRunner); final ActivityManager.RunningTaskInfo appTask = new TestRunningTaskInfoBuilder() .setTopActivityType(ACTIVITY_TYPE_STANDARD).build(); final TransitionInfo.Change appChange = new TransitionInfo.Change( appTask.token, new SurfaceControl()); appChange.setMode(TRANSIT_TO_BACK); appChange.setTaskInfo(appTask); final TransitionInfo startTransitionInfo = new TransitionInfoBuilder( TRANSIT_START_RECENTS_TRANSITION).addChange(appChange).build(); mRecentsTransitionHandler.startAnimation(transition, startTransitionInfo, new StubTransaction(), new StubTransaction(), mock(Transitions.TransitionFinishCallback.class)); final TransitionInfo.Change displayChange = new TransitionInfo.Change( /* container= */ null, new SurfaceControl()); displayChange.setMode(TRANSIT_CHANGE); displayChange.setFlags(TransitionInfo.FLAG_IS_DISPLAY); final TransitionInfo.Change newAppChange = new TransitionInfo.Change( appTask.token, appChange.getLeash()); newAppChange.setMode(TRANSIT_CHANGE); newAppChange.setTaskInfo(appTask); final TransitionInfo mergeTransitionInfo = new TransitionInfoBuilder(TRANSIT_CHANGE) .addChange(displayChange).addChange(newAppChange).build(); mRecentsTransitionHandler.findController(transition).merge(mergeTransitionInfo, new StubTransaction(), new StubTransaction(), mock(Transitions.TransitionFinishCallback.class)); mMainExecutor.flushAll(); verify(animationRunner).onAnimationCanceled(any(), any()); // The CHANGE should be updated to TO_BACK because pausing tasks will be occluded by home. assertThat(newAppChange.getMode()).isEqualTo(TRANSIT_TO_BACK); assertThat(mRecentsTransitionHandler.findController(transition)).isNull(); } @Test @EnableFlags(FLAG_ENABLE_RECENTS_BOOKEND_TRANSITION) public void testMerge_cancelToHome_onTransitSleep() throws Exception { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java +23 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_LOCKED; import static android.view.WindowManager.TRANSIT_OPEN; import static android.view.WindowManager.TRANSIT_PIP; import static android.view.WindowManager.TRANSIT_SLEEP; import static android.view.WindowManager.TRANSIT_TO_BACK; import static android.view.WindowManager.TRANSIT_TO_FRONT; import static android.window.DesktopModeFlags.ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX; import static android.window.TransitionInfo.FLAG_MOVED_TO_TOP; Loading Loading @@ -427,6 +428,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler, private WindowContainerToken mRecentsTask = null; private int mRecentsTaskId = -1; private TransitionInfo mInfo = null; private TransitionInfo mMergingInfo; private boolean mOpeningSeparateHome = false; private boolean mPausingSeparateHome = false; private ArrayMap<SurfaceControl, SurfaceControl> mLeashMap = null; Loading Loading @@ -508,6 +510,25 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler, sendCancel(null, null); } } if (toHome && mMergingInfo != null && mPausingTasks != null && mMergingInfo.getType() == TRANSIT_CHANGE && TransitionUtil.hasDisplayChange(mMergingInfo)) { // Update the mode of pausing tasks from CHANGE to TO_BACK, so the next transition // handler (if any) can animate it correctly. final var changes = mMergingInfo.getChanges(); for (int i = changes.size() - 1; i >= 0; --i) { final TransitionInfo.Change change = changes.get(i); final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo(); if (taskInfo == null || change.getMode() != TRANSIT_CHANGE || TaskState.indexOf(mPausingTasks, change) < 0) { continue; } change.setMode(TRANSIT_TO_BACK); ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION, "[%d] RecentsController.cancel: set TO_BACK for taskId=%d", mInstanceId, taskInfo.taskId); } } if (mFinishCB != null) { finishInner(toHome, false /* userLeave */, null /* finishCb */, "cancel"); } else { Loading Loading @@ -597,6 +618,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler, mClosingTasks = null; mOpeningTasks = null; mInfo = null; mMergingInfo = null; mTransition = null; mPendingPauseSnapshotsForCancel = null; mPipTaskId = -1; Loading Loading @@ -1042,6 +1064,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler, cancel("keyguard_locked"); return; } mMergingInfo = info; ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION, "[%d] RecentsController.merge", mInstanceId); // Keep all tasks in one list because order matters. Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/recents/RecentsTransitionHandlerTest.java +38 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.wm.shell.recents; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.view.WindowManager.TRANSIT_CHANGE; import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_OPEN; import static android.view.WindowManager.TRANSIT_SLEEP; Loading Loading @@ -514,6 +515,43 @@ public class RecentsTransitionHandlerTest extends ShellTestCase { verify(finishT).setCornerRadius(leash, FREEFORM_TASK_CORNER_RADIUS_ON_CD); } @Test public void testMerge_cancelToHome_onDisplayChange() throws Exception { final IRecentsAnimationRunner animationRunner = mock(IRecentsAnimationRunner.class); final IBinder transition = startRecentsTransition(/* synthetic= */ false, animationRunner); final ActivityManager.RunningTaskInfo appTask = new TestRunningTaskInfoBuilder() .setTopActivityType(ACTIVITY_TYPE_STANDARD).build(); final TransitionInfo.Change appChange = new TransitionInfo.Change( appTask.token, new SurfaceControl()); appChange.setMode(TRANSIT_TO_BACK); appChange.setTaskInfo(appTask); final TransitionInfo startTransitionInfo = new TransitionInfoBuilder( TRANSIT_START_RECENTS_TRANSITION).addChange(appChange).build(); mRecentsTransitionHandler.startAnimation(transition, startTransitionInfo, new StubTransaction(), new StubTransaction(), mock(Transitions.TransitionFinishCallback.class)); final TransitionInfo.Change displayChange = new TransitionInfo.Change( /* container= */ null, new SurfaceControl()); displayChange.setMode(TRANSIT_CHANGE); displayChange.setFlags(TransitionInfo.FLAG_IS_DISPLAY); final TransitionInfo.Change newAppChange = new TransitionInfo.Change( appTask.token, appChange.getLeash()); newAppChange.setMode(TRANSIT_CHANGE); newAppChange.setTaskInfo(appTask); final TransitionInfo mergeTransitionInfo = new TransitionInfoBuilder(TRANSIT_CHANGE) .addChange(displayChange).addChange(newAppChange).build(); mRecentsTransitionHandler.findController(transition).merge(mergeTransitionInfo, new StubTransaction(), new StubTransaction(), mock(Transitions.TransitionFinishCallback.class)); mMainExecutor.flushAll(); verify(animationRunner).onAnimationCanceled(any(), any()); // The CHANGE should be updated to TO_BACK because pausing tasks will be occluded by home. assertThat(newAppChange.getMode()).isEqualTo(TRANSIT_TO_BACK); assertThat(mRecentsTransitionHandler.findController(transition)).isNull(); } @Test @EnableFlags(FLAG_ENABLE_RECENTS_BOOKEND_TRANSITION) public void testMerge_cancelToHome_onTransitSleep() throws Exception { Loading