Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt +31 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ class DesktopTasksTransitionObserver( data class CloseWallpaperTransition(val transition: IBinder, val displayId: Int) private var transitionToCloseWallpaper: CloseWallpaperTransition? = null private var closingTransitionToTransitionInfo = HashMap<IBinder, TransitionInfo>() private var currentProfileId: Int init { Loading Loading @@ -94,6 +95,7 @@ class DesktopTasksTransitionObserver( desktopMixedTransitionHandler.addPendingMixedTransition( DesktopMixedTransitionHandler.PendingMixedTransition.Close(transition) ) closingTransitionToTransitionInfo.put(transition, info) } removeWallpaperOnLastTaskClosingIfNeeded(transition, info) } Loading Loading @@ -175,6 +177,35 @@ class DesktopTasksTransitionObserver( } transitionToCloseWallpaper = null } // If a task is closing and is not handled by back navigation logic, remove it here with a // follow up transition fully so it doesn't show up on recents. // // The reason that this is done here and not on [DesktopTasksController#handleRequest] is // because for closing tasks we first need to check whether it's because of back navigation // so that we can minimize it if needed. val info = closingTransitionToTransitionInfo.remove(transition) ?: return removeClosingTask(info) } /** Finds the closing task in the change and removes it full by a [TRANSIT_CLOSE] transition. */ private fun removeClosingTask(info: TransitionInfo) { val task = info.changes .find { change -> change.mode == TRANSIT_CLOSE && change.taskInfo != null } ?.taskInfo ?: return transitions.startTransition( TRANSIT_CLOSE, WindowContainerTransaction().removeTask(task.token), null, ) ProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTasksTransitionObserver: removing closing task=%d fully", task.taskId, ) } private fun updateWallpaperToken(info: TransitionInfo) { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserverTest.kt +29 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.window.TransitionInfo import android.window.TransitionInfo.Change import android.window.WindowContainerToken import android.window.WindowContainerTransaction import android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_REMOVE_TASK import android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_REORDER import com.android.window.flags.Flags import com.android.wm.shell.MockToken Loading Loading @@ -275,6 +276,27 @@ class DesktopTasksTransitionObserverTest : ShellTestCase() { ) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX) fun closingTask_startsTransitionToRemoveFully() { val mockTransition = Mockito.mock(IBinder::class.java) val freeformTask = createTaskInfo(1) whenever(taskRepository.isAnyDeskActive(any())).thenReturn(true) whenever(mixedHandler.hasTransition(mockTransition)).thenReturn(false) transitionObserver.onTransitionReady( transition = mockTransition, info = createCloseTransition(freeformTask), startTransaction = mock(), finishTransaction = mock(), ) transitionObserver.onTransitionFinished(transition = mockTransition, aborted = false) val wct = getLatestWct(type = TRANSIT_CLOSE) assertThat(wct.hierarchyOps).hasSize(1) wct.assertRemoveAt(index = 0, freeformTask.token) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX) fun onTransitionReady_handlerHasTransition_notAddPendingMixedTransition() { Loading Loading @@ -396,6 +418,13 @@ class DesktopTasksTransitionObserverTest : ShellTestCase() { return arg.value } private fun WindowContainerTransaction.assertRemoveAt(index: Int, token: WindowContainerToken) { assertIndexInBounds(index) val op = hierarchyOps[index] assertThat(op.type).isEqualTo(HIERARCHY_OP_TYPE_REMOVE_TASK) assertThat(op.container).isEqualTo(token.asBinder()) } private fun WindowContainerTransaction.assertReorderAt( index: Int, token: WindowContainerToken, Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt +31 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ class DesktopTasksTransitionObserver( data class CloseWallpaperTransition(val transition: IBinder, val displayId: Int) private var transitionToCloseWallpaper: CloseWallpaperTransition? = null private var closingTransitionToTransitionInfo = HashMap<IBinder, TransitionInfo>() private var currentProfileId: Int init { Loading Loading @@ -94,6 +95,7 @@ class DesktopTasksTransitionObserver( desktopMixedTransitionHandler.addPendingMixedTransition( DesktopMixedTransitionHandler.PendingMixedTransition.Close(transition) ) closingTransitionToTransitionInfo.put(transition, info) } removeWallpaperOnLastTaskClosingIfNeeded(transition, info) } Loading Loading @@ -175,6 +177,35 @@ class DesktopTasksTransitionObserver( } transitionToCloseWallpaper = null } // If a task is closing and is not handled by back navigation logic, remove it here with a // follow up transition fully so it doesn't show up on recents. // // The reason that this is done here and not on [DesktopTasksController#handleRequest] is // because for closing tasks we first need to check whether it's because of back navigation // so that we can minimize it if needed. val info = closingTransitionToTransitionInfo.remove(transition) ?: return removeClosingTask(info) } /** Finds the closing task in the change and removes it full by a [TRANSIT_CLOSE] transition. */ private fun removeClosingTask(info: TransitionInfo) { val task = info.changes .find { change -> change.mode == TRANSIT_CLOSE && change.taskInfo != null } ?.taskInfo ?: return transitions.startTransition( TRANSIT_CLOSE, WindowContainerTransaction().removeTask(task.token), null, ) ProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTasksTransitionObserver: removing closing task=%d fully", task.taskId, ) } private fun updateWallpaperToken(info: TransitionInfo) { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserverTest.kt +29 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.window.TransitionInfo import android.window.TransitionInfo.Change import android.window.WindowContainerToken import android.window.WindowContainerTransaction import android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_REMOVE_TASK import android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP_TYPE_REORDER import com.android.window.flags.Flags import com.android.wm.shell.MockToken Loading Loading @@ -275,6 +276,27 @@ class DesktopTasksTransitionObserverTest : ShellTestCase() { ) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX) fun closingTask_startsTransitionToRemoveFully() { val mockTransition = Mockito.mock(IBinder::class.java) val freeformTask = createTaskInfo(1) whenever(taskRepository.isAnyDeskActive(any())).thenReturn(true) whenever(mixedHandler.hasTransition(mockTransition)).thenReturn(false) transitionObserver.onTransitionReady( transition = mockTransition, info = createCloseTransition(freeformTask), startTransaction = mock(), finishTransaction = mock(), ) transitionObserver.onTransitionFinished(transition = mockTransition, aborted = false) val wct = getLatestWct(type = TRANSIT_CLOSE) assertThat(wct.hierarchyOps).hasSize(1) wct.assertRemoveAt(index = 0, freeformTask.token) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_CLOSE_TASK_ANIMATION_IN_DTC_BUGFIX) fun onTransitionReady_handlerHasTransition_notAddPendingMixedTransition() { Loading Loading @@ -396,6 +418,13 @@ class DesktopTasksTransitionObserverTest : ShellTestCase() { return arg.value } private fun WindowContainerTransaction.assertRemoveAt(index: Int, token: WindowContainerToken) { assertIndexInBounds(index) val op = hierarchyOps[index] assertThat(op.type).isEqualTo(HIERARCHY_OP_TYPE_REMOVE_TASK) assertThat(op.container).isEqualTo(token.asBinder()) } private fun WindowContainerTransaction.assertReorderAt( index: Int, token: WindowContainerToken, Loading