Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +39 −7 Original line number Original line Diff line number Diff line Loading @@ -477,7 +477,8 @@ class DesktopTasksController( displayId = DEFAULT_DISPLAY, displayId = DEFAULT_DISPLAY, willExitDesktop = true, willExitDesktop = true, shouldEndUpAtHome = true, shouldEndUpAtHome = true, fromRecentsTransition = true, // No need to clean up the wallpaper / home when coming from a recents transition. skipWallpaperAndHomeOrdering = true, ) ) runOnTransitStart?.invoke(transition) runOnTransitStart?.invoke(transition) } } Loading Loading @@ -2084,16 +2085,15 @@ class DesktopTasksController( displayId: Int, displayId: Int, willExitDesktop: Boolean, willExitDesktop: Boolean, shouldEndUpAtHome: Boolean = true, shouldEndUpAtHome: Boolean = true, fromRecentsTransition: Boolean = false, skipWallpaperAndHomeOrdering: Boolean = false, ): RunOnTransitStart? { ): RunOnTransitStart? { if (!willExitDesktop) return null if (!willExitDesktop) return null desktopModeEnterExitTransitionListener?.onExitDesktopModeTransitionStarted( desktopModeEnterExitTransitionListener?.onExitDesktopModeTransitionStarted( FULLSCREEN_ANIMATION_DURATION, FULLSCREEN_ANIMATION_DURATION, shouldEndUpAtHome, shouldEndUpAtHome, ) ) // No need to clean up the wallpaper / reorder home when coming from a recents transition. if ( if ( !fromRecentsTransition || !skipWallpaperAndHomeOrdering || !DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue !DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue ) { ) { removeWallpaperActivity(wct, displayId) removeWallpaperActivity(wct, displayId) Loading Loading @@ -2173,8 +2173,15 @@ class DesktopTasksController( reason = "transition type not handled (${request.type})" reason = "transition type not handled (${request.type})" false false } } // Only handle standard type tasks // Home launches are only handled with multiple desktops enabled. triggerTask.activityType != ACTIVITY_TYPE_STANDARD -> { triggerTask.activityType == ACTIVITY_TYPE_HOME && !DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue -> { reason = "ACTIVITY_TYPE_HOME not handled" false } // Only handle standard and home tasks types. triggerTask.activityType != ACTIVITY_TYPE_STANDARD && triggerTask.activityType != ACTIVITY_TYPE_HOME -> { reason = "activityType not handled (${triggerTask.activityType})" reason = "activityType not handled (${triggerTask.activityType})" false false } } Loading @@ -2194,6 +2201,8 @@ class DesktopTasksController( val result = val result = when { when { triggerTask.activityType == ACTIVITY_TYPE_HOME -> handleHomeTaskLaunch(triggerTask, transition) // Check if freeform task launch during recents should be handled // Check if freeform task launch during recents should be handled shouldHandleMidRecentsFreeformLaunch -> shouldHandleMidRecentsFreeformLaunch -> handleMidRecentsFreeformTaskLaunch(triggerTask, transition) handleMidRecentsFreeformTaskLaunch(triggerTask, transition) Loading Loading @@ -2309,7 +2318,8 @@ class DesktopTasksController( private fun shouldHandleTaskClosing(request: TransitionRequestInfo): Boolean = private fun shouldHandleTaskClosing(request: TransitionRequestInfo): Boolean = ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue() && ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue() && TransitionUtil.isClosingType(request.type) && TransitionUtil.isClosingType(request.type) && request.triggerTask != null request.triggerTask != null && request.triggerTask?.activityType != ACTIVITY_TYPE_HOME /** Open an existing instance of an app. */ /** Open an existing instance of an app. */ fun openInstance(callingTask: RunningTaskInfo, requestedTaskId: Int) { fun openInstance(callingTask: RunningTaskInfo, requestedTaskId: Int) { Loading Loading @@ -2440,6 +2450,28 @@ class DesktopTasksController( } } } } private fun handleHomeTaskLaunch( task: RunningTaskInfo, transition: IBinder, ): WindowContainerTransaction? { logV("DesktopTasksController: handleHomeTaskLaunch") val activeDeskId = taskRepository.getActiveDeskId(task.displayId) ?: return null val wct = WindowContainerTransaction() // TODO: b/393978539 - desktop-first displays may need to keep the desk active. val runOnTransitStart = performDesktopExitCleanUp( wct = wct, deskId = activeDeskId, displayId = task.displayId, willExitDesktop = true, shouldEndUpAtHome = true, // No need to clean up the wallpaper / home order if Home is launching directly. skipWallpaperAndHomeOrdering = true, ) runOnTransitStart?.invoke(transition) return wct } /** /** * Handles the case where a freeform task is launched from recents. * Handles the case where a freeform task is launched from recents. * * Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +38 −0 Original line number Original line Diff line number Diff line Loading @@ -7556,6 +7556,44 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() .exitImmersiveIfApplicable(eq(binder), any(), eq(task.displayId), any()) .exitImmersiveIfApplicable(eq(binder), any(), eq(task.displayId), any()) } } @Test @DisableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) fun handleRequest_homeTask_notHandled() { val home = createHomeTask(DEFAULT_DISPLAY) val transition = Binder() val result = controller.handleRequest(transition, createTransition(home)) assertNull(result) } @Test @EnableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) fun handleRequest_homeTask_activeDesk_deactivates() { taskRepository.setActiveDesk(DEFAULT_DISPLAY, deskId = 0) val home = createHomeTask(DEFAULT_DISPLAY) val transition = Binder() val result = controller.handleRequest(transition, createTransition(home)) assertNotNull(result) verify(desksOrganizer).deactivateDesk(result, deskId = 0) verify(desksTransitionsObserver) .addPendingTransition(DeskTransition.DeactivateDesk(token = transition, deskId = 0)) } @Test @EnableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) fun handleRequest_homeTask_closing_notHandled() { taskRepository.setActiveDesk(DEFAULT_DISPLAY, deskId = 0) val home = createHomeTask(DEFAULT_DISPLAY) val transition = Binder() val result = controller.handleRequest(transition, createTransition(home, TRANSIT_CLOSE)) assertNull(result) } @Test @Test @EnableFlags(Flags.FLAG_ENABLE_FULLY_IMMERSIVE_IN_DESKTOP) @EnableFlags(Flags.FLAG_ENABLE_FULLY_IMMERSIVE_IN_DESKTOP) fun shouldPlayDesktopAnimation_notShowingDesktop_doesNotPlay() { fun shouldPlayDesktopAnimation_notShowingDesktop_doesNotPlay() { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +39 −7 Original line number Original line Diff line number Diff line Loading @@ -477,7 +477,8 @@ class DesktopTasksController( displayId = DEFAULT_DISPLAY, displayId = DEFAULT_DISPLAY, willExitDesktop = true, willExitDesktop = true, shouldEndUpAtHome = true, shouldEndUpAtHome = true, fromRecentsTransition = true, // No need to clean up the wallpaper / home when coming from a recents transition. skipWallpaperAndHomeOrdering = true, ) ) runOnTransitStart?.invoke(transition) runOnTransitStart?.invoke(transition) } } Loading Loading @@ -2084,16 +2085,15 @@ class DesktopTasksController( displayId: Int, displayId: Int, willExitDesktop: Boolean, willExitDesktop: Boolean, shouldEndUpAtHome: Boolean = true, shouldEndUpAtHome: Boolean = true, fromRecentsTransition: Boolean = false, skipWallpaperAndHomeOrdering: Boolean = false, ): RunOnTransitStart? { ): RunOnTransitStart? { if (!willExitDesktop) return null if (!willExitDesktop) return null desktopModeEnterExitTransitionListener?.onExitDesktopModeTransitionStarted( desktopModeEnterExitTransitionListener?.onExitDesktopModeTransitionStarted( FULLSCREEN_ANIMATION_DURATION, FULLSCREEN_ANIMATION_DURATION, shouldEndUpAtHome, shouldEndUpAtHome, ) ) // No need to clean up the wallpaper / reorder home when coming from a recents transition. if ( if ( !fromRecentsTransition || !skipWallpaperAndHomeOrdering || !DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue !DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue ) { ) { removeWallpaperActivity(wct, displayId) removeWallpaperActivity(wct, displayId) Loading Loading @@ -2173,8 +2173,15 @@ class DesktopTasksController( reason = "transition type not handled (${request.type})" reason = "transition type not handled (${request.type})" false false } } // Only handle standard type tasks // Home launches are only handled with multiple desktops enabled. triggerTask.activityType != ACTIVITY_TYPE_STANDARD -> { triggerTask.activityType == ACTIVITY_TYPE_HOME && !DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue -> { reason = "ACTIVITY_TYPE_HOME not handled" false } // Only handle standard and home tasks types. triggerTask.activityType != ACTIVITY_TYPE_STANDARD && triggerTask.activityType != ACTIVITY_TYPE_HOME -> { reason = "activityType not handled (${triggerTask.activityType})" reason = "activityType not handled (${triggerTask.activityType})" false false } } Loading @@ -2194,6 +2201,8 @@ class DesktopTasksController( val result = val result = when { when { triggerTask.activityType == ACTIVITY_TYPE_HOME -> handleHomeTaskLaunch(triggerTask, transition) // Check if freeform task launch during recents should be handled // Check if freeform task launch during recents should be handled shouldHandleMidRecentsFreeformLaunch -> shouldHandleMidRecentsFreeformLaunch -> handleMidRecentsFreeformTaskLaunch(triggerTask, transition) handleMidRecentsFreeformTaskLaunch(triggerTask, transition) Loading Loading @@ -2309,7 +2318,8 @@ class DesktopTasksController( private fun shouldHandleTaskClosing(request: TransitionRequestInfo): Boolean = private fun shouldHandleTaskClosing(request: TransitionRequestInfo): Boolean = ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue() && ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue() && TransitionUtil.isClosingType(request.type) && TransitionUtil.isClosingType(request.type) && request.triggerTask != null request.triggerTask != null && request.triggerTask?.activityType != ACTIVITY_TYPE_HOME /** Open an existing instance of an app. */ /** Open an existing instance of an app. */ fun openInstance(callingTask: RunningTaskInfo, requestedTaskId: Int) { fun openInstance(callingTask: RunningTaskInfo, requestedTaskId: Int) { Loading Loading @@ -2440,6 +2450,28 @@ class DesktopTasksController( } } } } private fun handleHomeTaskLaunch( task: RunningTaskInfo, transition: IBinder, ): WindowContainerTransaction? { logV("DesktopTasksController: handleHomeTaskLaunch") val activeDeskId = taskRepository.getActiveDeskId(task.displayId) ?: return null val wct = WindowContainerTransaction() // TODO: b/393978539 - desktop-first displays may need to keep the desk active. val runOnTransitStart = performDesktopExitCleanUp( wct = wct, deskId = activeDeskId, displayId = task.displayId, willExitDesktop = true, shouldEndUpAtHome = true, // No need to clean up the wallpaper / home order if Home is launching directly. skipWallpaperAndHomeOrdering = true, ) runOnTransitStart?.invoke(transition) return wct } /** /** * Handles the case where a freeform task is launched from recents. * Handles the case where a freeform task is launched from recents. * * Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +38 −0 Original line number Original line Diff line number Diff line Loading @@ -7556,6 +7556,44 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() .exitImmersiveIfApplicable(eq(binder), any(), eq(task.displayId), any()) .exitImmersiveIfApplicable(eq(binder), any(), eq(task.displayId), any()) } } @Test @DisableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) fun handleRequest_homeTask_notHandled() { val home = createHomeTask(DEFAULT_DISPLAY) val transition = Binder() val result = controller.handleRequest(transition, createTransition(home)) assertNull(result) } @Test @EnableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) fun handleRequest_homeTask_activeDesk_deactivates() { taskRepository.setActiveDesk(DEFAULT_DISPLAY, deskId = 0) val home = createHomeTask(DEFAULT_DISPLAY) val transition = Binder() val result = controller.handleRequest(transition, createTransition(home)) assertNotNull(result) verify(desksOrganizer).deactivateDesk(result, deskId = 0) verify(desksTransitionsObserver) .addPendingTransition(DeskTransition.DeactivateDesk(token = transition, deskId = 0)) } @Test @EnableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) fun handleRequest_homeTask_closing_notHandled() { taskRepository.setActiveDesk(DEFAULT_DISPLAY, deskId = 0) val home = createHomeTask(DEFAULT_DISPLAY) val transition = Binder() val result = controller.handleRequest(transition, createTransition(home, TRANSIT_CLOSE)) assertNull(result) } @Test @Test @EnableFlags(Flags.FLAG_ENABLE_FULLY_IMMERSIVE_IN_DESKTOP) @EnableFlags(Flags.FLAG_ENABLE_FULLY_IMMERSIVE_IN_DESKTOP) fun shouldPlayDesktopAnimation_notShowingDesktop_doesNotPlay() { fun shouldPlayDesktopAnimation_notShowingDesktop_doesNotPlay() { Loading