Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMixedTransitionHandler.kt +10 −6 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ 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.DesktopModeFlags import android.window.TransitionInfo Loading Loading @@ -197,8 +198,9 @@ class DesktopMixedTransitionHandler( logW("Should have closing desktop task") return false } if (isLastDesktopTask(closeChange)) { // Dispatch close desktop task animation to the default transition handlers. if (isWallpaperActivityClosing(info)) { // If the wallpaper activity is closing then the desktop is closing, animate the closing // desktop by dispatching to other transition handlers. return dispatchCloseLastDesktopTaskAnimation( transition, info, Loading Loading @@ -419,10 +421,12 @@ class DesktopMixedTransitionHandler( ) != null } private fun isLastDesktopTask(change: TransitionInfo.Change): Boolean = change.taskInfo?.let { desktopUserRepositories.getProfile(it.userId).getExpandedTaskCount(it.displayId) == 1 } ?: false private fun isWallpaperActivityClosing(info: TransitionInfo) = info.changes.any { change -> change.mode == TRANSIT_CLOSE && change.taskInfo != null && DesktopWallpaperActivity.isWallpaperTask(change.taskInfo!!) } private fun findCloseDesktopTaskChange(info: TransitionInfo): TransitionInfo.Change? { if (info.type != WindowManager.TRANSIT_CLOSE) return null Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopMixedTransitionHandlerTest.kt +42 −22 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM import android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN import android.app.WindowConfiguration.WindowingMode import android.content.Intent import android.os.Binder import android.os.Handler import android.os.IBinder Loading @@ -36,7 +37,9 @@ import android.view.WindowManager.TRANSIT_NONE import android.view.WindowManager.TRANSIT_OPEN import android.view.WindowManager.TRANSIT_TO_BACK import android.view.WindowManager.TransitionType import android.window.IWindowContainerToken import android.window.TransitionInfo import android.window.WindowContainerToken import android.window.WindowContainerTransaction import androidx.test.filters.SmallTest import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_EXIT_MODE_ON_LAST_WINDOW_CLOSE Loading Loading @@ -188,7 +191,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { fun startAnimation_withoutClosingDesktopTask_returnsFalse() { val transition = mock<IBinder>() val transitionInfo = createTransitionInfo( createCloseTransitionInfo( changeMode = TRANSIT_OPEN, task = createTask(WINDOWING_MODE_FREEFORM) ) Loading @@ -213,8 +216,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { fun startAnimation_withClosingDesktopTask_callsCloseTaskHandler() { val wct = WindowContainerTransaction() val transition = mock<IBinder>() val transitionInfo = createTransitionInfo(task = createTask(WINDOWING_MODE_FREEFORM)) whenever(desktopRepository.getExpandedTaskCount(any())).thenReturn(2) val transitionInfo = createCloseTransitionInfo(task = createTask(WINDOWING_MODE_FREEFORM)) whenever( closeDesktopTaskTransitionHandler.startAnimation(any(), any(), any(), any(), any()) ) Loading Loading @@ -243,8 +245,8 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { fun startAnimation_withClosingLastDesktopTask_dispatchesTransition() { val wct = WindowContainerTransaction() val transition = mock<IBinder>() val transitionInfo = createTransitionInfo(task = createTask(WINDOWING_MODE_FREEFORM)) whenever(desktopRepository.getExpandedTaskCount(any())).thenReturn(1) val transitionInfo = createCloseTransitionInfo( task = createTask(WINDOWING_MODE_FREEFORM), withWallpaper = true) whenever(transitions.dispatchTransition(any(), any(), any(), any(), any(), any())) .thenReturn(mock()) whenever(transitions.startTransition(WindowManager.TRANSIT_CLOSE, wct, mixedHandler)) Loading Loading @@ -355,7 +357,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val otherChange = createChange(createTask(WINDOWING_MODE_FREEFORM)) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange, otherChange) ), Loading Loading @@ -395,7 +397,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val immersiveChange = createChange(immersiveTask) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange, immersiveChange) ), Loading Loading @@ -437,7 +439,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { ) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange) ), Loading Loading @@ -471,7 +473,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { ) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange, minimizeChange) ), Loading Loading @@ -505,7 +507,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val started = mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(nonLaunchTaskChange) ), Loading Loading @@ -535,7 +537,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val started = mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(createChange(task, mode = TRANSIT_OPEN)) ), Loading Loading @@ -569,7 +571,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val openingChange = createChange(openingTask, mode = TRANSIT_OPEN) val started = mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(immersiveChange, openingChange) ), Loading Loading @@ -604,7 +606,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { ) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange) ), Loading Loading @@ -640,7 +642,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { ) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange, minimizeChange) ), Loading Loading @@ -670,7 +672,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val launchTaskChange = createChange(launchingTask) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange) ), Loading Loading @@ -727,7 +729,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val started = mixedHandler.startAnimation( transition = transition, info = createTransitionInfo( createCloseTransitionInfo( TRANSIT_TO_BACK, listOf(minimizingTaskChange) ), Loading Loading @@ -766,7 +768,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { mixedHandler.startAnimation( transition = transition, info = createTransitionInfo( createCloseTransitionInfo( TRANSIT_TO_BACK, listOf(minimizingTaskChange) ), Loading @@ -786,12 +788,12 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { ) } private fun createTransitionInfo( type: Int = WindowManager.TRANSIT_CLOSE, private fun createCloseTransitionInfo( changeMode: Int = WindowManager.TRANSIT_CLOSE, task: RunningTaskInfo task: RunningTaskInfo, withWallpaper: Boolean = false, ): TransitionInfo = TransitionInfo(type, 0 /* flags */).apply { TransitionInfo(WindowManager.TRANSIT_CLOSE, 0 /* flags */).apply { addChange( TransitionInfo.Change(mock(), closingTaskLeash).apply { mode = changeMode Loading @@ -799,9 +801,18 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { taskInfo = task } ) if (withWallpaper) { addChange( TransitionInfo.Change(/* container= */ mock(), /* leash= */ mock()).apply { mode = WindowManager.TRANSIT_CLOSE parent = null taskInfo = createWallpaperTask() } ) } } private fun createTransitionInfo( private fun createCloseTransitionInfo( @TransitionType type: Int, changes: List<TransitionInfo.Change> = emptyList() ): TransitionInfo = TransitionInfo(type, /* flags= */ 0).apply { Loading @@ -822,4 +833,13 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { .setActivityType(ACTIVITY_TYPE_STANDARD) .setWindowingMode(windowingMode) .build() private fun createWallpaperTask() = RunningTaskInfo().apply { token = WindowContainerToken(mock<IWindowContainerToken>()) baseIntent = Intent().apply { component = DesktopWallpaperActivity.wallpaperActivityComponent } } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMixedTransitionHandler.kt +10 −6 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ 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.DesktopModeFlags import android.window.TransitionInfo Loading Loading @@ -197,8 +198,9 @@ class DesktopMixedTransitionHandler( logW("Should have closing desktop task") return false } if (isLastDesktopTask(closeChange)) { // Dispatch close desktop task animation to the default transition handlers. if (isWallpaperActivityClosing(info)) { // If the wallpaper activity is closing then the desktop is closing, animate the closing // desktop by dispatching to other transition handlers. return dispatchCloseLastDesktopTaskAnimation( transition, info, Loading Loading @@ -419,10 +421,12 @@ class DesktopMixedTransitionHandler( ) != null } private fun isLastDesktopTask(change: TransitionInfo.Change): Boolean = change.taskInfo?.let { desktopUserRepositories.getProfile(it.userId).getExpandedTaskCount(it.displayId) == 1 } ?: false private fun isWallpaperActivityClosing(info: TransitionInfo) = info.changes.any { change -> change.mode == TRANSIT_CLOSE && change.taskInfo != null && DesktopWallpaperActivity.isWallpaperTask(change.taskInfo!!) } private fun findCloseDesktopTaskChange(info: TransitionInfo): TransitionInfo.Change? { if (info.type != WindowManager.TRANSIT_CLOSE) return null Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopMixedTransitionHandlerTest.kt +42 −22 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM import android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN import android.app.WindowConfiguration.WindowingMode import android.content.Intent import android.os.Binder import android.os.Handler import android.os.IBinder Loading @@ -36,7 +37,9 @@ import android.view.WindowManager.TRANSIT_NONE import android.view.WindowManager.TRANSIT_OPEN import android.view.WindowManager.TRANSIT_TO_BACK import android.view.WindowManager.TransitionType import android.window.IWindowContainerToken import android.window.TransitionInfo import android.window.WindowContainerToken import android.window.WindowContainerTransaction import androidx.test.filters.SmallTest import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_EXIT_MODE_ON_LAST_WINDOW_CLOSE Loading Loading @@ -188,7 +191,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { fun startAnimation_withoutClosingDesktopTask_returnsFalse() { val transition = mock<IBinder>() val transitionInfo = createTransitionInfo( createCloseTransitionInfo( changeMode = TRANSIT_OPEN, task = createTask(WINDOWING_MODE_FREEFORM) ) Loading @@ -213,8 +216,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { fun startAnimation_withClosingDesktopTask_callsCloseTaskHandler() { val wct = WindowContainerTransaction() val transition = mock<IBinder>() val transitionInfo = createTransitionInfo(task = createTask(WINDOWING_MODE_FREEFORM)) whenever(desktopRepository.getExpandedTaskCount(any())).thenReturn(2) val transitionInfo = createCloseTransitionInfo(task = createTask(WINDOWING_MODE_FREEFORM)) whenever( closeDesktopTaskTransitionHandler.startAnimation(any(), any(), any(), any(), any()) ) Loading Loading @@ -243,8 +245,8 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { fun startAnimation_withClosingLastDesktopTask_dispatchesTransition() { val wct = WindowContainerTransaction() val transition = mock<IBinder>() val transitionInfo = createTransitionInfo(task = createTask(WINDOWING_MODE_FREEFORM)) whenever(desktopRepository.getExpandedTaskCount(any())).thenReturn(1) val transitionInfo = createCloseTransitionInfo( task = createTask(WINDOWING_MODE_FREEFORM), withWallpaper = true) whenever(transitions.dispatchTransition(any(), any(), any(), any(), any(), any())) .thenReturn(mock()) whenever(transitions.startTransition(WindowManager.TRANSIT_CLOSE, wct, mixedHandler)) Loading Loading @@ -355,7 +357,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val otherChange = createChange(createTask(WINDOWING_MODE_FREEFORM)) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange, otherChange) ), Loading Loading @@ -395,7 +397,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val immersiveChange = createChange(immersiveTask) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange, immersiveChange) ), Loading Loading @@ -437,7 +439,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { ) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange) ), Loading Loading @@ -471,7 +473,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { ) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange, minimizeChange) ), Loading Loading @@ -505,7 +507,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val started = mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(nonLaunchTaskChange) ), Loading Loading @@ -535,7 +537,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val started = mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(createChange(task, mode = TRANSIT_OPEN)) ), Loading Loading @@ -569,7 +571,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val openingChange = createChange(openingTask, mode = TRANSIT_OPEN) val started = mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(immersiveChange, openingChange) ), Loading Loading @@ -604,7 +606,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { ) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange) ), Loading Loading @@ -640,7 +642,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { ) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange, minimizeChange) ), Loading Loading @@ -670,7 +672,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val launchTaskChange = createChange(launchingTask) mixedHandler.startAnimation( transition, createTransitionInfo( createCloseTransitionInfo( TRANSIT_OPEN, listOf(launchTaskChange) ), Loading Loading @@ -727,7 +729,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { val started = mixedHandler.startAnimation( transition = transition, info = createTransitionInfo( createCloseTransitionInfo( TRANSIT_TO_BACK, listOf(minimizingTaskChange) ), Loading Loading @@ -766,7 +768,7 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { mixedHandler.startAnimation( transition = transition, info = createTransitionInfo( createCloseTransitionInfo( TRANSIT_TO_BACK, listOf(minimizingTaskChange) ), Loading @@ -786,12 +788,12 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { ) } private fun createTransitionInfo( type: Int = WindowManager.TRANSIT_CLOSE, private fun createCloseTransitionInfo( changeMode: Int = WindowManager.TRANSIT_CLOSE, task: RunningTaskInfo task: RunningTaskInfo, withWallpaper: Boolean = false, ): TransitionInfo = TransitionInfo(type, 0 /* flags */).apply { TransitionInfo(WindowManager.TRANSIT_CLOSE, 0 /* flags */).apply { addChange( TransitionInfo.Change(mock(), closingTaskLeash).apply { mode = changeMode Loading @@ -799,9 +801,18 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { taskInfo = task } ) if (withWallpaper) { addChange( TransitionInfo.Change(/* container= */ mock(), /* leash= */ mock()).apply { mode = WindowManager.TRANSIT_CLOSE parent = null taskInfo = createWallpaperTask() } ) } } private fun createTransitionInfo( private fun createCloseTransitionInfo( @TransitionType type: Int, changes: List<TransitionInfo.Change> = emptyList() ): TransitionInfo = TransitionInfo(type, /* flags= */ 0).apply { Loading @@ -822,4 +833,13 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() { .setActivityType(ACTIVITY_TYPE_STANDARD) .setWindowingMode(windowingMode) .build() private fun createWallpaperTask() = RunningTaskInfo().apply { token = WindowContainerToken(mock<IWindowContainerToken>()) baseIntent = Intent().apply { component = DesktopWallpaperActivity.wallpaperActivityComponent } } }