Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopRepository.kt +9 −2 Original line number Diff line number Diff line Loading @@ -220,11 +220,18 @@ class DesktopRepository( fun isMinimizedTask(taskId: Int) = desktopTaskDataSequence().any { taskId in it.minimizedTasks } /** Checks if a task is the only visible, non-closing, non-minimized task on its display. */ fun isOnlyVisibleNonClosingTask(taskId: Int): Boolean = desktopTaskDataSequence().any { fun isOnlyVisibleNonClosingTask(taskId: Int, displayId: Int = INVALID_DISPLAY): Boolean { val seq = if (displayId != INVALID_DISPLAY) { sequenceOf(desktopTaskDataByDisplayId[displayId]).filterNotNull() } else { desktopTaskDataSequence() } return seq.any { it.visibleTasks.subtract(it.closingTasks).subtract(it.minimizedTasks).singleOrNull() == taskId } } fun getActiveTasks(displayId: Int): ArraySet<Int> = ArraySet(desktopTaskDataByDisplayId[displayId]?.activeTasks) Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +25 −8 Original line number Diff line number Diff line Loading @@ -571,7 +571,7 @@ class DesktopTasksController( ): ((IBinder) -> Unit)? { val taskId = taskInfo.taskId desktopTilingDecorViewModel.removeTaskIfTiled(displayId, taskId) performDesktopExitCleanupIfNeeded(taskId, wct) performDesktopExitCleanupIfNeeded(taskId, displayId, wct) taskRepository.addClosingTask(displayId, taskId) taskbarDesktopTaskListener?.onTaskbarCornerRoundingUpdate( doesAnyTaskRequireTaskbarRounding(displayId, taskId) Loading Loading @@ -610,7 +610,7 @@ class DesktopTasksController( val taskId = taskInfo.taskId val displayId = taskInfo.displayId val wct = WindowContainerTransaction() performDesktopExitCleanupIfNeeded(taskId, wct) performDesktopExitCleanupIfNeeded(taskId, displayId, wct) // Notify immersive handler as it might need to exit immersive state. val exitResult = desktopImmersiveController.exitImmersiveIfApplicable( Loading Loading @@ -864,6 +864,10 @@ class DesktopTasksController( if (!task.isFreeform) addMoveToDesktopChanges(wct, task, displayId) wct.reparent(task.token, displayAreaInfo.token, true /* onTop */) if (Flags.enablePerDisplayDesktopWallpaperActivity()) { performDesktopExitCleanupIfNeeded(task.taskId, task.displayId, wct) } transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */) } Loading Loading @@ -1348,10 +1352,23 @@ class DesktopTasksController( * Remove wallpaper activity if task provided is last task and wallpaper activity token is not * null */ private fun performDesktopExitCleanupIfNeeded(taskId: Int, wct: WindowContainerTransaction) { private fun performDesktopExitCleanupIfNeeded( taskId: Int, displayId: Int, wct: WindowContainerTransaction, ) { if (Flags.enablePerDisplayDesktopWallpaperActivity()) { if (!taskRepository.isOnlyVisibleNonClosingTask(taskId, displayId)) { return } if (displayId != DEFAULT_DISPLAY) { return } } else { if (!taskRepository.isOnlyVisibleNonClosingTask(taskId)) { return } } desktopModeEnterExitTransitionListener?.onExitDesktopModeTransitionStarted( FULLSCREEN_ANIMATION_DURATION ) Loading Loading @@ -1844,7 +1861,7 @@ class DesktopTasksController( if (!isDesktopModeShowing(task.displayId)) return null val wct = WindowContainerTransaction() performDesktopExitCleanupIfNeeded(task.taskId, wct) performDesktopExitCleanupIfNeeded(task.taskId, task.displayId, wct) if (!DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION.isTrue()) { taskRepository.addClosingTask(task.displayId, task.taskId) Loading Loading @@ -1927,7 +1944,7 @@ class DesktopTasksController( wct.setDensityDpi(taskInfo.token, getDefaultDensityDpi()) } performDesktopExitCleanupIfNeeded(taskInfo.taskId, wct) performDesktopExitCleanupIfNeeded(taskInfo.taskId, taskInfo.displayId, wct) } private fun cascadeWindow(bounds: Rect, displayLayout: DisplayLayout, displayId: Int) { Loading Loading @@ -1961,7 +1978,7 @@ class DesktopTasksController( // want it overridden in multi-window. wct.setDensityDpi(taskInfo.token, getDefaultDensityDpi()) performDesktopExitCleanupIfNeeded(taskInfo.taskId, wct) performDesktopExitCleanupIfNeeded(taskInfo.taskId, taskInfo.displayId, wct) } /** Returns the ID of the Task that will be minimized, or null if no task will be minimized. */ Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +25 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ import com.android.dx.mockito.inline.extended.ExtendedMockito.never import com.android.dx.mockito.inline.extended.StaticMockitoSession import com.android.internal.jank.InteractionJankMonitor import com.android.window.flags.Flags import com.android.window.flags.Flags.FLAG_ENABLE_PER_DISPLAY_DESKTOP_WALLPAPER_ACTIVITY import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE import com.android.window.flags.Flags.FLAG_ENABLE_FULLY_IMMERSIVE_IN_DESKTOP import com.android.wm.shell.MockToken Loading Loading @@ -1624,6 +1625,30 @@ class DesktopTasksControllerTest : ShellTestCase() { } } @Test @EnableFlags(FLAG_ENABLE_PER_DISPLAY_DESKTOP_WALLPAPER_ACTIVITY) fun moveToNextDisplay_removeWallpaper() { // Set up two display ids whenever(rootTaskDisplayAreaOrganizer.displayIds) .thenReturn(intArrayOf(DEFAULT_DISPLAY, SECOND_DISPLAY)) // Create a mock for the target display area: second display val secondDisplayArea = DisplayAreaInfo(MockToken().token(), SECOND_DISPLAY, 0) whenever(rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(SECOND_DISPLAY)) .thenReturn(secondDisplayArea) // Add a task and a wallpaper val task = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val wallpaperToken = MockToken().token() taskRepository.wallpaperActivityToken = wallpaperToken controller.moveToNextDisplay(task.taskId) with(getLatestWct(type = TRANSIT_CHANGE)) { val wallpaperChange = hierarchyOps.find { op -> op.container == wallpaperToken.asBinder() } assertThat(wallpaperChange).isNotNull() assertThat(wallpaperChange!!.type).isEqualTo(HIERARCHY_OP_TYPE_REMOVE_TASK) } } @Test fun getTaskWindowingMode() { val fullscreenTask = setUpFullscreenTask() Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopRepository.kt +9 −2 Original line number Diff line number Diff line Loading @@ -220,11 +220,18 @@ class DesktopRepository( fun isMinimizedTask(taskId: Int) = desktopTaskDataSequence().any { taskId in it.minimizedTasks } /** Checks if a task is the only visible, non-closing, non-minimized task on its display. */ fun isOnlyVisibleNonClosingTask(taskId: Int): Boolean = desktopTaskDataSequence().any { fun isOnlyVisibleNonClosingTask(taskId: Int, displayId: Int = INVALID_DISPLAY): Boolean { val seq = if (displayId != INVALID_DISPLAY) { sequenceOf(desktopTaskDataByDisplayId[displayId]).filterNotNull() } else { desktopTaskDataSequence() } return seq.any { it.visibleTasks.subtract(it.closingTasks).subtract(it.minimizedTasks).singleOrNull() == taskId } } fun getActiveTasks(displayId: Int): ArraySet<Int> = ArraySet(desktopTaskDataByDisplayId[displayId]?.activeTasks) Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +25 −8 Original line number Diff line number Diff line Loading @@ -571,7 +571,7 @@ class DesktopTasksController( ): ((IBinder) -> Unit)? { val taskId = taskInfo.taskId desktopTilingDecorViewModel.removeTaskIfTiled(displayId, taskId) performDesktopExitCleanupIfNeeded(taskId, wct) performDesktopExitCleanupIfNeeded(taskId, displayId, wct) taskRepository.addClosingTask(displayId, taskId) taskbarDesktopTaskListener?.onTaskbarCornerRoundingUpdate( doesAnyTaskRequireTaskbarRounding(displayId, taskId) Loading Loading @@ -610,7 +610,7 @@ class DesktopTasksController( val taskId = taskInfo.taskId val displayId = taskInfo.displayId val wct = WindowContainerTransaction() performDesktopExitCleanupIfNeeded(taskId, wct) performDesktopExitCleanupIfNeeded(taskId, displayId, wct) // Notify immersive handler as it might need to exit immersive state. val exitResult = desktopImmersiveController.exitImmersiveIfApplicable( Loading Loading @@ -864,6 +864,10 @@ class DesktopTasksController( if (!task.isFreeform) addMoveToDesktopChanges(wct, task, displayId) wct.reparent(task.token, displayAreaInfo.token, true /* onTop */) if (Flags.enablePerDisplayDesktopWallpaperActivity()) { performDesktopExitCleanupIfNeeded(task.taskId, task.displayId, wct) } transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */) } Loading Loading @@ -1348,10 +1352,23 @@ class DesktopTasksController( * Remove wallpaper activity if task provided is last task and wallpaper activity token is not * null */ private fun performDesktopExitCleanupIfNeeded(taskId: Int, wct: WindowContainerTransaction) { private fun performDesktopExitCleanupIfNeeded( taskId: Int, displayId: Int, wct: WindowContainerTransaction, ) { if (Flags.enablePerDisplayDesktopWallpaperActivity()) { if (!taskRepository.isOnlyVisibleNonClosingTask(taskId, displayId)) { return } if (displayId != DEFAULT_DISPLAY) { return } } else { if (!taskRepository.isOnlyVisibleNonClosingTask(taskId)) { return } } desktopModeEnterExitTransitionListener?.onExitDesktopModeTransitionStarted( FULLSCREEN_ANIMATION_DURATION ) Loading Loading @@ -1844,7 +1861,7 @@ class DesktopTasksController( if (!isDesktopModeShowing(task.displayId)) return null val wct = WindowContainerTransaction() performDesktopExitCleanupIfNeeded(task.taskId, wct) performDesktopExitCleanupIfNeeded(task.taskId, task.displayId, wct) if (!DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION.isTrue()) { taskRepository.addClosingTask(task.displayId, task.taskId) Loading Loading @@ -1927,7 +1944,7 @@ class DesktopTasksController( wct.setDensityDpi(taskInfo.token, getDefaultDensityDpi()) } performDesktopExitCleanupIfNeeded(taskInfo.taskId, wct) performDesktopExitCleanupIfNeeded(taskInfo.taskId, taskInfo.displayId, wct) } private fun cascadeWindow(bounds: Rect, displayLayout: DisplayLayout, displayId: Int) { Loading Loading @@ -1961,7 +1978,7 @@ class DesktopTasksController( // want it overridden in multi-window. wct.setDensityDpi(taskInfo.token, getDefaultDensityDpi()) performDesktopExitCleanupIfNeeded(taskInfo.taskId, wct) performDesktopExitCleanupIfNeeded(taskInfo.taskId, taskInfo.displayId, wct) } /** Returns the ID of the Task that will be minimized, or null if no task will be minimized. */ Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +25 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ import com.android.dx.mockito.inline.extended.ExtendedMockito.never import com.android.dx.mockito.inline.extended.StaticMockitoSession import com.android.internal.jank.InteractionJankMonitor import com.android.window.flags.Flags import com.android.window.flags.Flags.FLAG_ENABLE_PER_DISPLAY_DESKTOP_WALLPAPER_ACTIVITY import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE import com.android.window.flags.Flags.FLAG_ENABLE_FULLY_IMMERSIVE_IN_DESKTOP import com.android.wm.shell.MockToken Loading Loading @@ -1624,6 +1625,30 @@ class DesktopTasksControllerTest : ShellTestCase() { } } @Test @EnableFlags(FLAG_ENABLE_PER_DISPLAY_DESKTOP_WALLPAPER_ACTIVITY) fun moveToNextDisplay_removeWallpaper() { // Set up two display ids whenever(rootTaskDisplayAreaOrganizer.displayIds) .thenReturn(intArrayOf(DEFAULT_DISPLAY, SECOND_DISPLAY)) // Create a mock for the target display area: second display val secondDisplayArea = DisplayAreaInfo(MockToken().token(), SECOND_DISPLAY, 0) whenever(rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(SECOND_DISPLAY)) .thenReturn(secondDisplayArea) // Add a task and a wallpaper val task = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val wallpaperToken = MockToken().token() taskRepository.wallpaperActivityToken = wallpaperToken controller.moveToNextDisplay(task.taskId) with(getLatestWct(type = TRANSIT_CHANGE)) { val wallpaperChange = hierarchyOps.find { op -> op.container == wallpaperToken.asBinder() } assertThat(wallpaperChange).isNotNull() assertThat(wallpaperChange!!.type).isEqualTo(HIERARCHY_OP_TYPE_REMOVE_TASK) } } @Test fun getTaskWindowingMode() { val fullscreenTask = setUpFullscreenTask() Loading