Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMixedTransitionHandler.kt +4 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.os.Handler import android.os.IBinder import android.view.SurfaceControl import android.view.WindowManager import android.view.WindowManager.TRANSIT_CLOSE import android.view.WindowManager.TRANSIT_OPEN import android.window.DesktopExperienceFlags import android.window.DesktopModeFlags Loading Loading @@ -171,6 +170,10 @@ class DesktopMixedTransitionHandler( pendingMixedTransitions.add(pendingMixedTransition) } /** Checks if a pending mixed transition already exists for the given [transition]. */ fun hasTransition(transition: IBinder): Boolean = pendingMixedTransitions.any { it.transition == transition } /** Returns null, as it only handles transitions started from Shell. */ override fun handleRequest( transition: IBinder, Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +0 −10 Original line number Diff line number Diff line Loading @@ -2986,10 +2986,6 @@ class DesktopTasksController( snapEventHandler.removeTaskIfTiled(task.displayId, task.taskId) } if (DesktopExperienceFlags.ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX.isTrue) { addPendingCloseTransition(transition) } taskbarDesktopTaskListener?.onTaskbarCornerRoundingUpdate( doesAnyTaskRequireTaskbarRounding(task.displayId, task.taskId) ) Loading Loading @@ -3320,12 +3316,6 @@ class DesktopTasksController( ) } private fun addPendingCloseTransition(transition: IBinder) { desktopMixedTransitionHandler.addPendingMixedTransition( DesktopMixedTransitionHandler.PendingMixedTransition.Close(transition) ) } private fun activateDefaultDeskInDisplay( displayId: Int, remoteTransition: RemoteTransition? = null, Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt +28 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,15 @@ class DesktopTasksTransitionObserver( handleBackNavigation(transition, info) removeTaskIfNeeded(info) } if ( DesktopExperienceFlags.ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX.isTrue && !desktopMixedTransitionHandler.hasTransition(transition) && isCloseTransition(info) ) { desktopMixedTransitionHandler.addPendingMixedTransition( DesktopMixedTransitionHandler.PendingMixedTransition.Close(transition) ) } removeWallpaperOnLastTaskClosingIfNeeded(transition, info) } Loading @@ -118,6 +127,25 @@ class DesktopTasksTransitionObserver( } } private fun isCloseTransition(info: TransitionInfo): Boolean { for (change in info.changes) { val taskInfo = change.taskInfo if (taskInfo == null || taskInfo.taskId == -1) { continue } val desktopRepository = desktopUserRepositories.getProfile(taskInfo.userId) val isInDesktop = desktopRepository.isAnyDeskActive(taskInfo.displayId) if ( isInDesktop && change.mode == TRANSIT_CLOSE && taskInfo.windowingMode == WINDOWING_MODE_FREEFORM ) { return true } } return false } private fun handleBackNavigation(transition: IBinder, info: TransitionInfo) { // When default back navigation happens, transition type is TO_BACK and the change is // TO_BACK. Mark the task going to back as minimized. Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +0 −16 Original line number Diff line number Diff line Loading @@ -5682,22 +5682,6 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX) fun handleRequest_closeTransition_addPendingMixedTransition() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val transition = Binder() taskRepository.addTask(DEFAULT_DISPLAY, taskId = 1, isVisible = true) controller.handleRequest(transition, createTransition(task2, type = TRANSIT_CLOSE)) verify(desktopMixedTransitionHandler) .addPendingMixedTransition( DesktopMixedTransitionHandler.PendingMixedTransition.Close(transition) ) } @Test @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserverTest.kt +46 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,7 @@ class DesktopTasksTransitionObserverTest : ShellTestCase() { fun backNavigation_taskMinimized() { val task = createTaskInfo(1) whenever(taskRepository.isAnyDeskActive(any())).thenReturn(true) whenever(mixedHandler.hasTransition(any())).thenReturn(true) transitionObserver.onTransitionReady( transition = mock(), Loading Loading @@ -387,6 +388,51 @@ class DesktopTasksTransitionObserverTest : ShellTestCase() { verify(desktopWallpaperActivityTokenProvider).removeToken(wallpaperTask.displayId) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX) fun onTransitionReady_noTransitionInHandler_addPendingMixedTransition() { val mockTransition = Mockito.mock(IBinder::class.java) val topTransparentTask = createTaskInfo(1) whenever(taskRepository.getTopTransparentFullscreenTaskId(any())) .thenReturn(topTransparentTask.taskId) whenever(taskRepository.isAnyDeskActive(any())).thenReturn(true) whenever(mixedHandler.hasTransition(mockTransition)).thenReturn(false) transitionObserver.onTransitionReady( transition = mockTransition, info = createCloseTransition(topTransparentTask), startTransaction = mock(), finishTransaction = mock(), ) verify(mixedHandler) .addPendingMixedTransition( DesktopMixedTransitionHandler.PendingMixedTransition.Close(mockTransition) ) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX) fun onTransitionReady_handlerHasTransition_notAddPendingMixedTransition() { val mockTransition = Mockito.mock(IBinder::class.java) val topTransparentTask = createTaskInfo(1) whenever(taskRepository.getTopTransparentFullscreenTaskId(any())) .thenReturn(topTransparentTask.taskId) whenever(mixedHandler.hasTransition(mockTransition)).thenReturn(true) transitionObserver.onTransitionReady( transition = mockTransition, info = createCloseTransition(topTransparentTask), startTransaction = mock(), finishTransaction = mock(), ) verify(mixedHandler, never()) .addPendingMixedTransition( DesktopMixedTransitionHandler.PendingMixedTransition.Close(mockTransition) ) } private fun createBackNavigationTransition( task: RunningTaskInfo?, type: Int = TRANSIT_TO_BACK, Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMixedTransitionHandler.kt +4 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.os.Handler import android.os.IBinder import android.view.SurfaceControl import android.view.WindowManager import android.view.WindowManager.TRANSIT_CLOSE import android.view.WindowManager.TRANSIT_OPEN import android.window.DesktopExperienceFlags import android.window.DesktopModeFlags Loading Loading @@ -171,6 +170,10 @@ class DesktopMixedTransitionHandler( pendingMixedTransitions.add(pendingMixedTransition) } /** Checks if a pending mixed transition already exists for the given [transition]. */ fun hasTransition(transition: IBinder): Boolean = pendingMixedTransitions.any { it.transition == transition } /** Returns null, as it only handles transitions started from Shell. */ override fun handleRequest( transition: IBinder, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +0 −10 Original line number Diff line number Diff line Loading @@ -2986,10 +2986,6 @@ class DesktopTasksController( snapEventHandler.removeTaskIfTiled(task.displayId, task.taskId) } if (DesktopExperienceFlags.ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX.isTrue) { addPendingCloseTransition(transition) } taskbarDesktopTaskListener?.onTaskbarCornerRoundingUpdate( doesAnyTaskRequireTaskbarRounding(task.displayId, task.taskId) ) Loading Loading @@ -3320,12 +3316,6 @@ class DesktopTasksController( ) } private fun addPendingCloseTransition(transition: IBinder) { desktopMixedTransitionHandler.addPendingMixedTransition( DesktopMixedTransitionHandler.PendingMixedTransition.Close(transition) ) } private fun activateDefaultDeskInDisplay( displayId: Int, remoteTransition: RemoteTransition? = null, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt +28 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,15 @@ class DesktopTasksTransitionObserver( handleBackNavigation(transition, info) removeTaskIfNeeded(info) } if ( DesktopExperienceFlags.ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX.isTrue && !desktopMixedTransitionHandler.hasTransition(transition) && isCloseTransition(info) ) { desktopMixedTransitionHandler.addPendingMixedTransition( DesktopMixedTransitionHandler.PendingMixedTransition.Close(transition) ) } removeWallpaperOnLastTaskClosingIfNeeded(transition, info) } Loading @@ -118,6 +127,25 @@ class DesktopTasksTransitionObserver( } } private fun isCloseTransition(info: TransitionInfo): Boolean { for (change in info.changes) { val taskInfo = change.taskInfo if (taskInfo == null || taskInfo.taskId == -1) { continue } val desktopRepository = desktopUserRepositories.getProfile(taskInfo.userId) val isInDesktop = desktopRepository.isAnyDeskActive(taskInfo.displayId) if ( isInDesktop && change.mode == TRANSIT_CLOSE && taskInfo.windowingMode == WINDOWING_MODE_FREEFORM ) { return true } } return false } private fun handleBackNavigation(transition: IBinder, info: TransitionInfo) { // When default back navigation happens, transition type is TO_BACK and the change is // TO_BACK. Mark the task going to back as minimized. Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +0 −16 Original line number Diff line number Diff line Loading @@ -5682,22 +5682,6 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX) fun handleRequest_closeTransition_addPendingMixedTransition() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val transition = Binder() taskRepository.addTask(DEFAULT_DISPLAY, taskId = 1, isVisible = true) controller.handleRequest(transition, createTransition(task2, type = TRANSIT_CLOSE)) verify(desktopMixedTransitionHandler) .addPendingMixedTransition( DesktopMixedTransitionHandler.PendingMixedTransition.Close(transition) ) } @Test @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserverTest.kt +46 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,7 @@ class DesktopTasksTransitionObserverTest : ShellTestCase() { fun backNavigation_taskMinimized() { val task = createTaskInfo(1) whenever(taskRepository.isAnyDeskActive(any())).thenReturn(true) whenever(mixedHandler.hasTransition(any())).thenReturn(true) transitionObserver.onTransitionReady( transition = mock(), Loading Loading @@ -387,6 +388,51 @@ class DesktopTasksTransitionObserverTest : ShellTestCase() { verify(desktopWallpaperActivityTokenProvider).removeToken(wallpaperTask.displayId) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX) fun onTransitionReady_noTransitionInHandler_addPendingMixedTransition() { val mockTransition = Mockito.mock(IBinder::class.java) val topTransparentTask = createTaskInfo(1) whenever(taskRepository.getTopTransparentFullscreenTaskId(any())) .thenReturn(topTransparentTask.taskId) whenever(taskRepository.isAnyDeskActive(any())).thenReturn(true) whenever(mixedHandler.hasTransition(mockTransition)).thenReturn(false) transitionObserver.onTransitionReady( transition = mockTransition, info = createCloseTransition(topTransparentTask), startTransaction = mock(), finishTransaction = mock(), ) verify(mixedHandler) .addPendingMixedTransition( DesktopMixedTransitionHandler.PendingMixedTransition.Close(mockTransition) ) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX) fun onTransitionReady_handlerHasTransition_notAddPendingMixedTransition() { val mockTransition = Mockito.mock(IBinder::class.java) val topTransparentTask = createTaskInfo(1) whenever(taskRepository.getTopTransparentFullscreenTaskId(any())) .thenReturn(topTransparentTask.taskId) whenever(mixedHandler.hasTransition(mockTransition)).thenReturn(true) transitionObserver.onTransitionReady( transition = mockTransition, info = createCloseTransition(topTransparentTask), startTransaction = mock(), finishTransaction = mock(), ) verify(mixedHandler, never()) .addPendingMixedTransition( DesktopMixedTransitionHandler.PendingMixedTransition.Close(mockTransition) ) } private fun createBackNavigationTransition( task: RunningTaskInfo?, type: Int = TRANSIT_TO_BACK, Loading