Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +13 −9 Original line number Diff line number Diff line Loading @@ -305,13 +305,18 @@ class DesktopTasksController( private fun getSplitFocusedTask(task1: RunningTaskInfo, task2: RunningTaskInfo) = if (task1.taskId == task2.parentTaskId) task2 else task1 private fun isFreeformDisplay(displayId: Int): Boolean { private fun forceEnterDesktop(displayId: Int): Boolean { if (!DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context)) { return false } val tdaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId) requireNotNull(tdaInfo) { "This method can only be called with the ID of a display having non-null DisplayArea." } val tdaWindowingMode = tdaInfo.configuration.windowConfiguration.windowingMode return tdaWindowingMode == WINDOWING_MODE_FREEFORM val isFreeformDisplay = tdaWindowingMode == WINDOWING_MODE_FREEFORM return isFreeformDisplay } /** Moves task to desktop mode if task is running, else launches it in desktop mode. */ Loading Loading @@ -1191,10 +1196,11 @@ class DesktopTasksController( val wct = WindowContainerTransaction() if (!isDesktopModeShowing(task.displayId)) { logD("Bring desktop tasks to front on transition=taskId=%d", task.taskId) // 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 fullscreen. if (taskRepository.isActiveTask(task.taskId)) { if (taskRepository.isActiveTask(task.taskId) && !forceEnterDesktop(task.displayId)) { // 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 // fullscreen as long as default-desktop flag is disabled. addMoveToFullscreenChanges(wct, task) return wct } Loading Loading @@ -1231,9 +1237,7 @@ class DesktopTasksController( transition: IBinder ): WindowContainerTransaction? { logV("handleFullscreenTaskLaunch") val forceEnterDesktop = DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context) && isFreeformDisplay(task.displayId) if (isDesktopModeShowing(task.displayId) || forceEnterDesktop) { if (isDesktopModeShowing(task.displayId) || forceEnterDesktop(task.displayId)) { logD("Switch fullscreen task to freeform on transition: taskId=%d", task.taskId) return WindowContainerTransaction().also { wct -> addMoveToDesktopChanges(wct, task) Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +39 −0 Original line number Diff line number Diff line Loading @@ -1763,6 +1763,37 @@ class DesktopTasksControllerTest : ShellTestCase() { .isEqualTo(WINDOWING_MODE_UNDEFINED) } @Test fun handleRequest_freeformTask_relaunchTask_enforceDesktop_freeformDisplay_noWinModeChange() { assumeTrue(ENABLE_SHELL_TRANSITIONS) whenever(DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context)).thenReturn(true) val tda = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)!! tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM val freeformTask = setUpFreeformTask() markTaskHidden(freeformTask) val wct = controller.handleRequest(Binder(), createTransition(freeformTask)) assertNotNull(wct, "should handle request") assertFalse(wct.anyWindowingModeChange(freeformTask.token)) } @Test fun handleRequest_freeformTask_relaunchTask_enforceDesktop_fullscreenDisplay_becomesUndefined() { assumeTrue(ENABLE_SHELL_TRANSITIONS) whenever(DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context)).thenReturn(true) val tda = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)!! tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FULLSCREEN val freeformTask = setUpFreeformTask() markTaskHidden(freeformTask) val wct = controller.handleRequest(Binder(), createTransition(freeformTask)) assertNotNull(wct, "should handle request") assertThat(wct.changes[freeformTask.token.asBinder()]?.windowingMode) .isEqualTo(WINDOWING_MODE_UNDEFINED) } @Test @DisableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) fun handleRequest_freeformTask_desktopWallpaperDisabled_freeformNotVisible_reorderedToTop() { Loading Loading @@ -3493,6 +3524,14 @@ private fun WindowContainerTransaction?.anyDensityConfigChange( } ?: false } private fun WindowContainerTransaction?.anyWindowingModeChange( token: WindowContainerToken ): Boolean { return this?.changes?.any { change -> change.key == token.asBinder() && change.value.windowingMode >= 0 } ?: false } private fun createTaskInfo(id: Int) = RecentTaskInfo().apply { taskId = id Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +13 −9 Original line number Diff line number Diff line Loading @@ -305,13 +305,18 @@ class DesktopTasksController( private fun getSplitFocusedTask(task1: RunningTaskInfo, task2: RunningTaskInfo) = if (task1.taskId == task2.parentTaskId) task2 else task1 private fun isFreeformDisplay(displayId: Int): Boolean { private fun forceEnterDesktop(displayId: Int): Boolean { if (!DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context)) { return false } val tdaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId) requireNotNull(tdaInfo) { "This method can only be called with the ID of a display having non-null DisplayArea." } val tdaWindowingMode = tdaInfo.configuration.windowConfiguration.windowingMode return tdaWindowingMode == WINDOWING_MODE_FREEFORM val isFreeformDisplay = tdaWindowingMode == WINDOWING_MODE_FREEFORM return isFreeformDisplay } /** Moves task to desktop mode if task is running, else launches it in desktop mode. */ Loading Loading @@ -1191,10 +1196,11 @@ class DesktopTasksController( val wct = WindowContainerTransaction() if (!isDesktopModeShowing(task.displayId)) { logD("Bring desktop tasks to front on transition=taskId=%d", task.taskId) // 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 fullscreen. if (taskRepository.isActiveTask(task.taskId)) { if (taskRepository.isActiveTask(task.taskId) && !forceEnterDesktop(task.displayId)) { // 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 // fullscreen as long as default-desktop flag is disabled. addMoveToFullscreenChanges(wct, task) return wct } Loading Loading @@ -1231,9 +1237,7 @@ class DesktopTasksController( transition: IBinder ): WindowContainerTransaction? { logV("handleFullscreenTaskLaunch") val forceEnterDesktop = DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context) && isFreeformDisplay(task.displayId) if (isDesktopModeShowing(task.displayId) || forceEnterDesktop) { if (isDesktopModeShowing(task.displayId) || forceEnterDesktop(task.displayId)) { logD("Switch fullscreen task to freeform on transition: taskId=%d", task.taskId) return WindowContainerTransaction().also { wct -> addMoveToDesktopChanges(wct, task) Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +39 −0 Original line number Diff line number Diff line Loading @@ -1763,6 +1763,37 @@ class DesktopTasksControllerTest : ShellTestCase() { .isEqualTo(WINDOWING_MODE_UNDEFINED) } @Test fun handleRequest_freeformTask_relaunchTask_enforceDesktop_freeformDisplay_noWinModeChange() { assumeTrue(ENABLE_SHELL_TRANSITIONS) whenever(DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context)).thenReturn(true) val tda = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)!! tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM val freeformTask = setUpFreeformTask() markTaskHidden(freeformTask) val wct = controller.handleRequest(Binder(), createTransition(freeformTask)) assertNotNull(wct, "should handle request") assertFalse(wct.anyWindowingModeChange(freeformTask.token)) } @Test fun handleRequest_freeformTask_relaunchTask_enforceDesktop_fullscreenDisplay_becomesUndefined() { assumeTrue(ENABLE_SHELL_TRANSITIONS) whenever(DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(context)).thenReturn(true) val tda = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)!! tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FULLSCREEN val freeformTask = setUpFreeformTask() markTaskHidden(freeformTask) val wct = controller.handleRequest(Binder(), createTransition(freeformTask)) assertNotNull(wct, "should handle request") assertThat(wct.changes[freeformTask.token.asBinder()]?.windowingMode) .isEqualTo(WINDOWING_MODE_UNDEFINED) } @Test @DisableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) fun handleRequest_freeformTask_desktopWallpaperDisabled_freeformNotVisible_reorderedToTop() { Loading Loading @@ -3493,6 +3524,14 @@ private fun WindowContainerTransaction?.anyDensityConfigChange( } ?: false } private fun WindowContainerTransaction?.anyWindowingModeChange( token: WindowContainerToken ): Boolean { return this?.changes?.any { change -> change.key == token.asBinder() && change.value.windowingMode >= 0 } ?: false } private fun createTaskInfo(id: Int) = RecentTaskInfo().apply { taskId = id Loading