Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +5 −0 Original line number Diff line number Diff line Loading @@ -1070,6 +1070,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) Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +25 −2 Original line number Diff line number Diff line Loading @@ -1349,13 +1349,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 Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +5 −0 Original line number Diff line number Diff line Loading @@ -1070,6 +1070,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) Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +25 −2 Original line number Diff line number Diff line Loading @@ -1349,13 +1349,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 Loading