Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +52 −22 Original line number Diff line number Diff line Loading @@ -2469,7 +2469,15 @@ class DesktopTasksController( task: RunningTaskInfo, transition: IBinder, ): WindowContainerTransaction? { logV("handleFreeformTaskLaunch") val anyDeskActive = taskRepository.isAnyDeskActive(task.displayId) val forceEnterDesktop = forceEnterDesktop(task.displayId) logV( "handleFreeformTaskLaunch taskId=%d displayId=%d anyDeskActive=%b forceEnterDesktop=%b", task.taskId, task.displayId, anyDeskActive, forceEnterDesktop, ) if (keyguardManager.isKeyguardLocked) { // Do NOT handle freeform task launch when locked. // It will be launched in fullscreen windowing mode (Details: b/160925539) Loading @@ -2477,10 +2485,23 @@ class DesktopTasksController( return null } val deskId = getDefaultDeskId(task.displayId) val isKnownDesktopTask = taskRepository.isActiveTask(task.taskId) val shouldEnterDesktop = forceEnterDesktop // New tasks should be forced into desktop, while known desktop tasks should // be moved outside of desktop. || !isKnownDesktopTask logV( "handleFreeformTaskLaunch taskId=%d displayId=%d anyDeskActive=%b" + " isKnownDesktopTask=%b shouldEnterDesktop=%b", task.taskId, task.displayId, anyDeskActive, isKnownDesktopTask, shouldEnterDesktop, ) val wct = WindowContainerTransaction() if (shouldFreeformTaskLaunchSwitchToFullscreen(task)) { logD("Bring desktop tasks to front on transition=taskId=%d", task.taskId) if (taskRepository.isActiveTask(task.taskId) && !forceEnterDesktop(task.displayId)) { if (!anyDeskActive && !shouldEnterDesktop) { // We are outside of desktop mode and already existing desktop task is being // launched. We should make this task go to fullscreen instead of freeform. Note // that this means any re-launch of a freeform window outside of desktop will be in Loading @@ -2499,11 +2520,20 @@ class DesktopTasksController( runOnTransitStart?.invoke(transition) return wct } // At this point we're either already in desktop and this task is moving to it, or we're // about to enter desktop with this task in it. if (DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) { // Make sure the launching task is moved into the desk. desksOrganizer.moveTaskToDesk(wct, deskId, task) } if (!anyDeskActive) { // We are outside of desktop and should enter desktop. val runOnTransitStart = addDeskActivationChanges(deskId, wct, task) runOnTransitStart?.invoke(transition) wct.reorder(task.token, true) return wct } // We were already in desktop. val inheritedTaskBounds = getInheritedExistingTaskBounds(taskRepository, shellTaskOrganizer, task, deskId) if (!taskRepository.isActiveTask(task.taskId) && inheritedTaskBounds != null) { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +28 −0 Original line number Diff line number Diff line Loading @@ -4665,6 +4665,34 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() assertNull(result, "Should NOT handle request") } @Test @EnableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) fun handleRequest_freeformTask_notInDesktop_noForceEnterDesktop_movesTaskToDesk() { whenever(DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context)) .thenReturn(false) taskRepository.setDeskInactive(deskId = 0) val freeformTask = createFreeformTask(displayId = DEFAULT_DISPLAY) val result = controller.handleRequest(Binder(), createTransition(freeformTask)) assertNotNull(result) verify(desksOrganizer).moveTaskToDesk(result, deskId = 0, freeformTask) } @Test @EnableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) fun handleRequest_freeformTask_alreadyInDesktop_noForceEnterDesktop_movesTaskToDesk() { whenever(DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context)) .thenReturn(false) taskRepository.setActiveDesk(displayId = DEFAULT_DISPLAY, deskId = 0) val freeformTask = createFreeformTask(displayId = DEFAULT_DISPLAY) val result = controller.handleRequest(Binder(), createTransition(freeformTask)) assertNotNull(result) verify(desksOrganizer).moveTaskToDesk(result, deskId = 0, freeformTask) } @Test fun handleRequest_notOpenOrToFrontTransition_returnNull() { val task = Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +52 −22 Original line number Diff line number Diff line Loading @@ -2469,7 +2469,15 @@ class DesktopTasksController( task: RunningTaskInfo, transition: IBinder, ): WindowContainerTransaction? { logV("handleFreeformTaskLaunch") val anyDeskActive = taskRepository.isAnyDeskActive(task.displayId) val forceEnterDesktop = forceEnterDesktop(task.displayId) logV( "handleFreeformTaskLaunch taskId=%d displayId=%d anyDeskActive=%b forceEnterDesktop=%b", task.taskId, task.displayId, anyDeskActive, forceEnterDesktop, ) if (keyguardManager.isKeyguardLocked) { // Do NOT handle freeform task launch when locked. // It will be launched in fullscreen windowing mode (Details: b/160925539) Loading @@ -2477,10 +2485,23 @@ class DesktopTasksController( return null } val deskId = getDefaultDeskId(task.displayId) val isKnownDesktopTask = taskRepository.isActiveTask(task.taskId) val shouldEnterDesktop = forceEnterDesktop // New tasks should be forced into desktop, while known desktop tasks should // be moved outside of desktop. || !isKnownDesktopTask logV( "handleFreeformTaskLaunch taskId=%d displayId=%d anyDeskActive=%b" + " isKnownDesktopTask=%b shouldEnterDesktop=%b", task.taskId, task.displayId, anyDeskActive, isKnownDesktopTask, shouldEnterDesktop, ) val wct = WindowContainerTransaction() if (shouldFreeformTaskLaunchSwitchToFullscreen(task)) { logD("Bring desktop tasks to front on transition=taskId=%d", task.taskId) if (taskRepository.isActiveTask(task.taskId) && !forceEnterDesktop(task.displayId)) { if (!anyDeskActive && !shouldEnterDesktop) { // We are outside of desktop mode and already existing desktop task is being // launched. We should make this task go to fullscreen instead of freeform. Note // that this means any re-launch of a freeform window outside of desktop will be in Loading @@ -2499,11 +2520,20 @@ class DesktopTasksController( runOnTransitStart?.invoke(transition) return wct } // At this point we're either already in desktop and this task is moving to it, or we're // about to enter desktop with this task in it. if (DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) { // Make sure the launching task is moved into the desk. desksOrganizer.moveTaskToDesk(wct, deskId, task) } if (!anyDeskActive) { // We are outside of desktop and should enter desktop. val runOnTransitStart = addDeskActivationChanges(deskId, wct, task) runOnTransitStart?.invoke(transition) wct.reorder(task.token, true) return wct } // We were already in desktop. val inheritedTaskBounds = getInheritedExistingTaskBounds(taskRepository, shellTaskOrganizer, task, deskId) if (!taskRepository.isActiveTask(task.taskId) && inheritedTaskBounds != null) { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +28 −0 Original line number Diff line number Diff line Loading @@ -4665,6 +4665,34 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() assertNull(result, "Should NOT handle request") } @Test @EnableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) fun handleRequest_freeformTask_notInDesktop_noForceEnterDesktop_movesTaskToDesk() { whenever(DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context)) .thenReturn(false) taskRepository.setDeskInactive(deskId = 0) val freeformTask = createFreeformTask(displayId = DEFAULT_DISPLAY) val result = controller.handleRequest(Binder(), createTransition(freeformTask)) assertNotNull(result) verify(desksOrganizer).moveTaskToDesk(result, deskId = 0, freeformTask) } @Test @EnableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) fun handleRequest_freeformTask_alreadyInDesktop_noForceEnterDesktop_movesTaskToDesk() { whenever(DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context)) .thenReturn(false) taskRepository.setActiveDesk(displayId = DEFAULT_DISPLAY, deskId = 0) val freeformTask = createFreeformTask(displayId = DEFAULT_DISPLAY) val result = controller.handleRequest(Binder(), createTransition(freeformTask)) assertNotNull(result) verify(desksOrganizer).moveTaskToDesk(result, deskId = 0, freeformTask) } @Test fun handleRequest_notOpenOrToFrontTransition_returnNull() { val task = Loading