Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +45 −17 Original line number Diff line number Diff line Loading @@ -2197,8 +2197,6 @@ class DesktopTasksController( launchingNewIntent = launchingTaskId == null, ) } val closingTopTransparentTaskId = deskId?.let { repository.getTopTransparentFullscreenTaskData(it)?.taskId } val exitImmersiveResult = desktopImmersiveController.exitImmersiveIfApplicable( wct = launchTransaction, Loading Loading @@ -2239,8 +2237,14 @@ class DesktopTasksController( } } // Remove top transparent fullscreen task if needed. val closingTopTransparentTaskId = deskId?.let { closeTopTransparentFullscreenTask(wct = launchTransaction, deskId = it, userId = userId) closeTopTransparentFullscreenTask( wct = launchTransaction, deskId = it, launchingTaskId = launchingTaskId, userId = userId, ) } val t = if (remoteTransition == null) { Loading Loading @@ -4070,8 +4074,12 @@ class DesktopTasksController( // flag val taskIdToMinimize = addAndGetMinimizeChanges(targetDeskId, wct, task.taskId) val closingTopTransparentTaskId = repository.getTopTransparentFullscreenTaskData(targetDeskId)?.taskId closeTopTransparentFullscreenTask(wct, targetDeskId, userId) closeTopTransparentFullscreenTask( wct, targetDeskId, launchingTaskId = task.taskId, userId, ) addPendingAppLaunchTransition( transition, task.taskId, Loading Loading @@ -4147,8 +4155,12 @@ class DesktopTasksController( addPendingTaskLimitTransition(transition, deskId, task.taskId) // Remove top transparent fullscreen task if needed. val closingTopTransparentTaskId = repository.getTopTransparentFullscreenTaskData(deskId)?.taskId closeTopTransparentFullscreenTask(wct, deskId, userId) closeTopTransparentFullscreenTask( wct, deskId, launchingTaskId = task.taskId, userId, ) // Also track the pending launching task. addPendingAppLaunchTransition( transition, Loading Loading @@ -4868,8 +4880,12 @@ class DesktopTasksController( if (newTask != null && addPendingLaunchTransition) { // Remove top transparent fullscreen task if needed. val closingTopTransparentTaskId = repository.getTopTransparentFullscreenTaskData(deskId)?.taskId closeTopTransparentFullscreenTask(wct, deskId, userId) closeTopTransparentFullscreenTask( wct, deskId, launchingTaskId = newTask.taskId, userId, ) addPendingAppLaunchTransition( transition, newTask.taskId, Loading Loading @@ -4954,18 +4970,30 @@ class DesktopTasksController( } } // returns the id of the task that was closed (if any) private fun closeTopTransparentFullscreenTask( wct: WindowContainerTransaction, deskId: Int, launchingTaskId: Int?, userId: Int, ) { if (!DesktopExperienceFlags.FORCE_CLOSE_TOP_TRANSPARENT_FULLSCREEN_TASK.isTrue) return ): Int? { if (!DesktopExperienceFlags.FORCE_CLOSE_TOP_TRANSPARENT_FULLSCREEN_TASK.isTrue) return null val repository = userRepositories.getProfile(userId) val data = repository.getTopTransparentFullscreenTaskData(deskId) if (data != null) { val data = repository.getTopTransparentFullscreenTaskData(deskId) ?: return null if (launchingTaskId != null && data.taskId == launchingTaskId) { logD( "closeTopTransparentFullscreenTask: task relaunching as freeform, not closing" + ", taskId=%d, deskId=%d", data.taskId, deskId, ) repository.clearTopTransparentFullscreenTaskData(deskId) return null } logD("closeTopTransparentFullscreenTask: taskId=%d, deskId=%d", data.taskId, deskId) wct.removeTask(data.token) } return data.taskId } /** Activates the desk at the given index if it exists. */ Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +16 −1 Original line number Diff line number Diff line Loading @@ -6624,6 +6624,20 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() ) } @Test @EnableFlags(Flags.FLAG_FORCE_CLOSE_TOP_TRANSPARENT_FULLSCREEN_TASK) fun handleRequest_newTaskLaunch_sameAsTopTransparentFullscreenTask_clearsTopTransparent() { val transition = Binder() val topTransparentTask = setUpFullscreenTask(displayId = DEFAULT_DISPLAY) taskRepository.setTopTransparentFullscreenTaskData(DEFAULT_DISPLAY, topTransparentTask) val task = setUpFreeformTask(displayId = DEFAULT_DISPLAY, taskId = topTransparentTask.taskId) controller.handleRequest(transition, createTransition(task)) assertThat(taskRepository.getTopTransparentFullscreenTaskData(DEFAULT_DISPLAY)).isNull() } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY) fun handleRequest_desktopNotShowing_topTransparentFullscreenTask_returnNull() { Loading Loading @@ -12417,8 +12431,9 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() active: Boolean = true, background: Boolean = false, deskId: Int? = null, taskId: Int? = null, ): RunningTaskInfo { val task = createFreeformTask(displayId, bounds, taskRepository.userId) val task = createFreeformTask(displayId, bounds, taskRepository.userId, taskId) val activityInfo = ActivityInfo() activityInfo.applicationInfo = ApplicationInfo() task.topActivityInfo = activityInfo Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTestHelpers.kt +2 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ object DesktopTestHelpers { displayId: Int = DEFAULT_DISPLAY, bounds: Rect? = null, userId: Int = ActivityManager.getCurrentUser(), taskId: Int? = null, ): RunningTaskInfo = TestRunningTaskInfoBuilder() .setDisplayId(displayId) Loading @@ -50,6 +51,7 @@ object DesktopTestHelpers { .setWindowingMode(WINDOWING_MODE_FREEFORM) .setLastActiveTime(100) .setUserId(userId) .apply { taskId?.let { setTaskId(it) } } .apply { bounds?.let { setBounds(it) } } .build() Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +45 −17 Original line number Diff line number Diff line Loading @@ -2197,8 +2197,6 @@ class DesktopTasksController( launchingNewIntent = launchingTaskId == null, ) } val closingTopTransparentTaskId = deskId?.let { repository.getTopTransparentFullscreenTaskData(it)?.taskId } val exitImmersiveResult = desktopImmersiveController.exitImmersiveIfApplicable( wct = launchTransaction, Loading Loading @@ -2239,8 +2237,14 @@ class DesktopTasksController( } } // Remove top transparent fullscreen task if needed. val closingTopTransparentTaskId = deskId?.let { closeTopTransparentFullscreenTask(wct = launchTransaction, deskId = it, userId = userId) closeTopTransparentFullscreenTask( wct = launchTransaction, deskId = it, launchingTaskId = launchingTaskId, userId = userId, ) } val t = if (remoteTransition == null) { Loading Loading @@ -4070,8 +4074,12 @@ class DesktopTasksController( // flag val taskIdToMinimize = addAndGetMinimizeChanges(targetDeskId, wct, task.taskId) val closingTopTransparentTaskId = repository.getTopTransparentFullscreenTaskData(targetDeskId)?.taskId closeTopTransparentFullscreenTask(wct, targetDeskId, userId) closeTopTransparentFullscreenTask( wct, targetDeskId, launchingTaskId = task.taskId, userId, ) addPendingAppLaunchTransition( transition, task.taskId, Loading Loading @@ -4147,8 +4155,12 @@ class DesktopTasksController( addPendingTaskLimitTransition(transition, deskId, task.taskId) // Remove top transparent fullscreen task if needed. val closingTopTransparentTaskId = repository.getTopTransparentFullscreenTaskData(deskId)?.taskId closeTopTransparentFullscreenTask(wct, deskId, userId) closeTopTransparentFullscreenTask( wct, deskId, launchingTaskId = task.taskId, userId, ) // Also track the pending launching task. addPendingAppLaunchTransition( transition, Loading Loading @@ -4868,8 +4880,12 @@ class DesktopTasksController( if (newTask != null && addPendingLaunchTransition) { // Remove top transparent fullscreen task if needed. val closingTopTransparentTaskId = repository.getTopTransparentFullscreenTaskData(deskId)?.taskId closeTopTransparentFullscreenTask(wct, deskId, userId) closeTopTransparentFullscreenTask( wct, deskId, launchingTaskId = newTask.taskId, userId, ) addPendingAppLaunchTransition( transition, newTask.taskId, Loading Loading @@ -4954,18 +4970,30 @@ class DesktopTasksController( } } // returns the id of the task that was closed (if any) private fun closeTopTransparentFullscreenTask( wct: WindowContainerTransaction, deskId: Int, launchingTaskId: Int?, userId: Int, ) { if (!DesktopExperienceFlags.FORCE_CLOSE_TOP_TRANSPARENT_FULLSCREEN_TASK.isTrue) return ): Int? { if (!DesktopExperienceFlags.FORCE_CLOSE_TOP_TRANSPARENT_FULLSCREEN_TASK.isTrue) return null val repository = userRepositories.getProfile(userId) val data = repository.getTopTransparentFullscreenTaskData(deskId) if (data != null) { val data = repository.getTopTransparentFullscreenTaskData(deskId) ?: return null if (launchingTaskId != null && data.taskId == launchingTaskId) { logD( "closeTopTransparentFullscreenTask: task relaunching as freeform, not closing" + ", taskId=%d, deskId=%d", data.taskId, deskId, ) repository.clearTopTransparentFullscreenTaskData(deskId) return null } logD("closeTopTransparentFullscreenTask: taskId=%d, deskId=%d", data.taskId, deskId) wct.removeTask(data.token) } return data.taskId } /** Activates the desk at the given index if it exists. */ Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +16 −1 Original line number Diff line number Diff line Loading @@ -6624,6 +6624,20 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() ) } @Test @EnableFlags(Flags.FLAG_FORCE_CLOSE_TOP_TRANSPARENT_FULLSCREEN_TASK) fun handleRequest_newTaskLaunch_sameAsTopTransparentFullscreenTask_clearsTopTransparent() { val transition = Binder() val topTransparentTask = setUpFullscreenTask(displayId = DEFAULT_DISPLAY) taskRepository.setTopTransparentFullscreenTaskData(DEFAULT_DISPLAY, topTransparentTask) val task = setUpFreeformTask(displayId = DEFAULT_DISPLAY, taskId = topTransparentTask.taskId) controller.handleRequest(transition, createTransition(task)) assertThat(taskRepository.getTopTransparentFullscreenTaskData(DEFAULT_DISPLAY)).isNull() } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY) fun handleRequest_desktopNotShowing_topTransparentFullscreenTask_returnNull() { Loading Loading @@ -12417,8 +12431,9 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() active: Boolean = true, background: Boolean = false, deskId: Int? = null, taskId: Int? = null, ): RunningTaskInfo { val task = createFreeformTask(displayId, bounds, taskRepository.userId) val task = createFreeformTask(displayId, bounds, taskRepository.userId, taskId) val activityInfo = ActivityInfo() activityInfo.applicationInfo = ApplicationInfo() task.topActivityInfo = activityInfo Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTestHelpers.kt +2 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ object DesktopTestHelpers { displayId: Int = DEFAULT_DISPLAY, bounds: Rect? = null, userId: Int = ActivityManager.getCurrentUser(), taskId: Int? = null, ): RunningTaskInfo = TestRunningTaskInfoBuilder() .setDisplayId(displayId) Loading @@ -50,6 +51,7 @@ object DesktopTestHelpers { .setWindowingMode(WINDOWING_MODE_FREEFORM) .setLastActiveTime(100) .setUserId(userId) .apply { taskId?.let { setTaskId(it) } } .apply { bounds?.let { setBounds(it) } } .build() Loading