summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Gustav Sennton <gsennton@google.com> 2024-08-07 12:27:03 +0000
committer Gustav Sennton <gsennton@google.com> 2024-08-07 12:57:22 +0000
commit10ab4fde867092d135d100b59a8093ad4bad8411 (patch)
treec671f6cbec261b7ca5024cfec4b69a6463d310a4
parent1bb06ef3c3630ff7e7c5c346ed9f225598fdd93a (diff)
Move existing minimized tasks behind Home on fullscreen task launch
Recently we started moving the Home task behind other Desktop tasks on fullscreen task launch, with this CL we also move existing minimized tasks behind Home. Fixes: 357638060 Flag: com.android.window.flags.enable_desktop_windowing_task_limit Test: DesktopTasksControllerTest Change-Id: I4660d6fe965fb1720b812315f43fcd72594bd35f
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt5
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt27
2 files changed, 30 insertions, 2 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
index e154da58028a..c37a81ab288e 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
@@ -1068,6 +1068,11 @@ class DesktopTasksController(
// In some launches home task is moved behind new task being launched. Make sure
// that's not the case for launches in desktop.
moveHomeTask(wct, toTop = false)
+ // Move existing minimized tasks behind Home
+ taskRepository.getFreeformTasksInZOrder(task.displayId)
+ .filter { taskId -> taskRepository.isMinimizedTask(taskId) }
+ .mapNotNull { taskId -> shellTaskOrganizer.getRunningTaskInfo(taskId) }
+ .forEach { taskInfo -> wct.reorder(taskInfo.token, /* onTop= */ false) }
// Desktop Mode is already showing and we're launching a new Task - we might need to
// minimize another Task.
val taskToMinimize = addAndGetMinimizeChangesIfNeeded(task.displayId, wct, task)
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
index 92f705097c33..0449ee9f96a7 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
@@ -1305,13 +1305,36 @@ class DesktopTasksControllerTest : ShellTestCase() {
val freeformTasks = (1..MAX_TASK_LIMIT).map { _ -> setUpFreeformTask() }
freeformTasks.forEach { markTaskVisible(it) }
val fullscreenTask = createFullscreenTask()
+ val homeTask = setUpHomeTask(DEFAULT_DISPLAY)
val wct = controller.handleRequest(Binder(), createTransition(fullscreenTask))
// Make sure we reorder the new task to top, and the back task to the bottom
- assertThat(wct!!.hierarchyOps.size).isEqualTo(2)
+ assertThat(wct!!.hierarchyOps.size).isEqualTo(3)
wct.assertReorderAt(0, fullscreenTask, toTop = true)
- wct.assertReorderAt(1, freeformTasks[0], toTop = false)
+ wct.assertReorderAt(1, homeTask, toTop = false)
+ wct.assertReorderAt(2, freeformTasks[0], toTop = false)
+ }
+
+ @Test
+ fun handleRequest_fullscreenTaskToFreeform_alreadyBeyondLimit_existingAndNewTasksAreMinimized() {
+ assumeTrue(ENABLE_SHELL_TRANSITIONS)
+
+ val minimizedTask = setUpFreeformTask()
+ taskRepository.minimizeTask(displayId = DEFAULT_DISPLAY, taskId = minimizedTask.taskId)
+ val freeformTasks = (1..MAX_TASK_LIMIT).map { _ -> setUpFreeformTask() }
+ freeformTasks.forEach { markTaskVisible(it) }
+ val homeTask = setUpHomeTask()
+ val fullscreenTask = createFullscreenTask()
+
+ val wct = controller.handleRequest(Binder(), createTransition(fullscreenTask))
+
+ assertThat(wct!!.hierarchyOps.size).isEqualTo(4)
+ wct.assertReorderAt(0, fullscreenTask, toTop = true)
+ // Make sure we reorder the home task to the bottom, and minimized tasks below the home task.
+ wct.assertReorderAt(1, homeTask, toTop = false)
+ wct.assertReorderAt(2, minimizedTask, toTop = false)
+ wct.assertReorderAt(3, freeformTasks[0], toTop = false)
}
@Test