Loading libs/WindowManager/Shell/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ android:name=".desktopmode.DesktopWallpaperActivity" android:excludeFromRecents="true" android:launchMode="singleInstance" android:showForAllUsers="true" android:theme="@style/DesktopWallpaperTheme" /> <activity Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMixedTransitionHandler.kt +1 −1 Original line number Diff line number Diff line Loading @@ -426,7 +426,7 @@ class DesktopMixedTransitionHandler( private fun isWallpaperActivityClosing(info: TransitionInfo) = info.changes.any { change -> change.mode == TRANSIT_CLOSE && TransitionUtil.isClosingMode(change.mode) && change.taskInfo != null && DesktopWallpaperActivity.isWallpaperTask(change.taskInfo!!) } Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +48 −23 Original line number Diff line number Diff line Loading @@ -1342,6 +1342,26 @@ class DesktopTasksController( private fun addWallpaperActivity(displayId: Int, wct: WindowContainerTransaction) { logV("addWallpaperActivity") if (Flags.enableDesktopWallpaperActivityOnSystemUser()) { val intent = Intent(context, DesktopWallpaperActivity::class.java) val options = ActivityOptions.makeBasic().apply { launchWindowingMode = WINDOWING_MODE_FULLSCREEN pendingIntentBackgroundActivityStartMode = ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS if (Flags.enableBugFixesForSecondaryDisplay()) { launchDisplayId = displayId } } val pendingIntent = PendingIntent.getActivity( context, /* requestCode = */ 0, intent, PendingIntent.FLAG_IMMUTABLE, ) wct.sendPendingIntent(pendingIntent, intent, options.toBundle()) } else { val userHandle = UserHandle.of(userId) val userContext = context.createContextAsUser(userHandle, /* flags= */ 0) val intent = Intent(userContext, DesktopWallpaperActivity::class.java) Loading @@ -1366,13 +1386,18 @@ class DesktopTasksController( ) wct.sendPendingIntent(pendingIntent, intent, options.toBundle()) } } private fun removeWallpaperActivity(wct: WindowContainerTransaction) { desktopWallpaperActivityTokenProvider.getToken()?.let { token -> logV("removeWallpaperActivity") if (Flags.enableDesktopWallpaperActivityOnSystemUser()) { wct.reorder(token, /* onTop= */ false) } else { wct.removeTask(token) } } } /** * Remove wallpaper activity if task provided is last task and wallpaper activity token is not Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt +15 −5 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVI import android.window.TransitionInfo import android.window.WindowContainerTransaction import com.android.internal.protolog.ProtoLog import com.android.window.flags.Flags import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.back.BackAnimationController import com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.isExitDesktopModeTransition Loading Loading @@ -235,12 +236,21 @@ class DesktopTasksTransitionObserver( if (transitionToCloseWallpaper == transition) { // TODO: b/362469671 - Handle merging the animation when desktop is also closing. desktopWallpaperActivityTokenProvider.getToken()?.let { wallpaperActivityToken -> if (Flags.enableDesktopWallpaperActivityOnSystemUser()) { transitions.startTransition( TRANSIT_TO_BACK, WindowContainerTransaction() .reorder(wallpaperActivityToken, /* onTop= */ false), null, ) } else { transitions.startTransition( TRANSIT_CLOSE, WindowContainerTransaction().removeTask(wallpaperActivityToken), null, ) } } transitionToCloseWallpaper = null } } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +63 −20 Original line number Diff line number Diff line Loading @@ -1494,6 +1494,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun moveToFullscreen_tdaFullscreen_windowingModeUndefined_removesWallpaperActivity() { val task = setUpFreeformTask() assertNotNull(rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)) Loading @@ -1509,7 +1510,7 @@ class DesktopTasksControllerTest : ShellTestCase() { .onExitDesktopModeTransitionStarted(FULLSCREEN_ANIMATION_DURATION) assertThat(taskChange.windowingMode).isEqualTo(WINDOWING_MODE_UNDEFINED) // Removes wallpaper activity when leaving desktop wct.assertRemoveAt(index = 0, wallpaperToken) wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading @@ -1526,6 +1527,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun moveToFullscreen_tdaFreeform_windowingModeFullscreen_removesWallpaperActivity() { val task = setUpFreeformTask() Loading @@ -1542,7 +1544,7 @@ class DesktopTasksControllerTest : ShellTestCase() { verify(desktopModeEnterExitTransitionListener) .onExitDesktopModeTransitionStarted(FULLSCREEN_ANIMATION_DURATION) // Removes wallpaper activity when leaving desktop wct.assertRemoveAt(index = 0, wallpaperToken) wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -1968,13 +1970,14 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onDesktopWindowClose_singleActiveTask_hasWallpaperActivityToken() { val task = setUpFreeformTask() val wct = WindowContainerTransaction() controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task) // Adds remove wallpaper operation wct.assertRemoveAt(index = 0, wallpaperToken) wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2013,6 +2016,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onDesktopWindowClose_multipleActiveTasks_isOnlyNonClosingTask() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() Loading @@ -2022,10 +2026,11 @@ class DesktopTasksControllerTest : ShellTestCase() { val wct = WindowContainerTransaction() controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task1) // Adds remove wallpaper operation wct.assertRemoveAt(index = 0, wallpaperToken) wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onDesktopWindowClose_multipleActiveTasks_hasMinimized() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() Loading @@ -2035,7 +2040,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val wct = WindowContainerTransaction() controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task1) // Adds remove wallpaper operation wct.assertRemoveAt(index = 0, wallpaperToken) wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2095,6 +2100,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onTaskMinimize_singleActiveTask_hasWallpaperActivityToken_removesWallpaper() { val task = setUpFreeformTask() val transition = Binder() Loading @@ -2107,7 +2113,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val captor = ArgumentCaptor.forClass(WindowContainerTransaction::class.java) verify(freeformTaskTransitionStarter).startMinimizedModeTransition(captor.capture()) // Adds remove wallpaper operation captor.value.assertRemoveAt(index = 0, wallpaperToken) captor.value.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2146,6 +2152,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onDesktopWindowMinimize_multipleActiveTasks_minimizesTheOnlyVisibleTask_removesWallpaper() { val task1 = setUpFreeformTask(active = true) val task2 = setUpFreeformTask(active = true) Loading @@ -2160,7 +2167,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val captor = ArgumentCaptor.forClass(WindowContainerTransaction::class.java) verify(freeformTaskTransitionStarter).startMinimizedModeTransition(captor.capture()) // Adds remove wallpaper operation captor.value.assertRemoveAt(index = 0, wallpaperToken) captor.value.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2804,7 +2811,10 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_backTransition_singleTaskWithToken_removesWallpaper() { val task = setUpFreeformTask() Loading @@ -2812,7 +2822,8 @@ class DesktopTasksControllerTest : ShellTestCase() { controller.handleRequest(Binder(), createTransition(task, type = TRANSIT_TO_BACK)) // Should create remove wallpaper transaction assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) assertNotNull(result, "Should handle request") .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2843,6 +2854,7 @@ class DesktopTasksControllerTest : ShellTestCase() { @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION, Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_backTransition_multipleTasksSingleNonClosing_removesWallpaperAndTask() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) Loading @@ -2853,11 +2865,15 @@ class DesktopTasksControllerTest : ShellTestCase() { controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_TO_BACK)) // Should create remove wallpaper transaction assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) assertNotNull(result, "Should handle request") .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_backTransition_multipleTasksSingleNonMinimized_removesWallpaperAndTask() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) Loading @@ -2867,7 +2883,8 @@ class DesktopTasksControllerTest : ShellTestCase() { controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_TO_BACK)) // Should create remove wallpaper transaction assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) assertNotNull(result, "Should handle request") .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2920,7 +2937,10 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_closeTransition_singleTaskWithToken_withWallpaper_removesWallpaper() { val task = setUpFreeformTask() Loading @@ -2928,7 +2948,8 @@ class DesktopTasksControllerTest : ShellTestCase() { controller.handleRequest(Binder(), createTransition(task, type = TRANSIT_CLOSE)) // Should create remove wallpaper transaction assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) assertNotNull(result, "Should handle request") .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2956,7 +2977,10 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_closeTransition_multipleTasksSingleNonClosing_removesWallpaper() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) Loading @@ -2966,11 +2990,15 @@ class DesktopTasksControllerTest : ShellTestCase() { controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_CLOSE)) // Should create remove wallpaper transaction assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) assertNotNull(result, "Should handle request") .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_closeTransition_multipleTasksSingleNonMinimized_removesWallpaper() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) Loading @@ -2980,7 +3008,8 @@ class DesktopTasksControllerTest : ShellTestCase() { controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_CLOSE)) // Should create remove wallpaper transaction assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) assertNotNull(result, "Should handle request") .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -3060,6 +3089,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun moveFocusedTaskToFullscreen_onlyVisibleNonMinimizedTask_removesWallpaperActivity() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() Loading @@ -3077,7 +3107,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val taskChange = assertNotNull(wct.changes[task2.token.asBinder()]) assertThat(taskChange.windowingMode) .isEqualTo(WINDOWING_MODE_UNDEFINED) // inherited FULLSCREEN wct.assertRemoveAt(index = 0, wallpaperToken) wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -3571,6 +3601,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun enterSplit_onlyVisibleNonMinimizedTask_removesWallpaperActivity() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() Loading @@ -3593,7 +3624,7 @@ class DesktopTasksControllerTest : ShellTestCase() { eq(task2.configuration.windowConfiguration.bounds), ) // Removes wallpaper activity when leaving desktop wctArgument.value.assertRemoveAt(index = 0, wallpaperToken) wctArgument.value.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -5048,6 +5079,18 @@ private fun WindowContainerTransaction.assertReorderAt( toTop?.let { assertThat(op.toTop).isEqualTo(it) } } private fun WindowContainerTransaction.assertReorderAt( index: Int, token: WindowContainerToken, toTop: Boolean? = null, ) { assertIndexInBounds(index) val op = hierarchyOps[index] assertThat(op.type).isEqualTo(HIERARCHY_OP_TYPE_REORDER) assertThat(op.container).isEqualTo(token.asBinder()) toTop?.let { assertThat(op.toTop).isEqualTo(it) } } private fun WindowContainerTransaction.assertReorderSequence(vararg tasks: RunningTaskInfo) { for (i in tasks.indices) { assertReorderAt(i, tasks[i]) Loading Loading
libs/WindowManager/Shell/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ android:name=".desktopmode.DesktopWallpaperActivity" android:excludeFromRecents="true" android:launchMode="singleInstance" android:showForAllUsers="true" android:theme="@style/DesktopWallpaperTheme" /> <activity Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMixedTransitionHandler.kt +1 −1 Original line number Diff line number Diff line Loading @@ -426,7 +426,7 @@ class DesktopMixedTransitionHandler( private fun isWallpaperActivityClosing(info: TransitionInfo) = info.changes.any { change -> change.mode == TRANSIT_CLOSE && TransitionUtil.isClosingMode(change.mode) && change.taskInfo != null && DesktopWallpaperActivity.isWallpaperTask(change.taskInfo!!) } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +48 −23 Original line number Diff line number Diff line Loading @@ -1342,6 +1342,26 @@ class DesktopTasksController( private fun addWallpaperActivity(displayId: Int, wct: WindowContainerTransaction) { logV("addWallpaperActivity") if (Flags.enableDesktopWallpaperActivityOnSystemUser()) { val intent = Intent(context, DesktopWallpaperActivity::class.java) val options = ActivityOptions.makeBasic().apply { launchWindowingMode = WINDOWING_MODE_FULLSCREEN pendingIntentBackgroundActivityStartMode = ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS if (Flags.enableBugFixesForSecondaryDisplay()) { launchDisplayId = displayId } } val pendingIntent = PendingIntent.getActivity( context, /* requestCode = */ 0, intent, PendingIntent.FLAG_IMMUTABLE, ) wct.sendPendingIntent(pendingIntent, intent, options.toBundle()) } else { val userHandle = UserHandle.of(userId) val userContext = context.createContextAsUser(userHandle, /* flags= */ 0) val intent = Intent(userContext, DesktopWallpaperActivity::class.java) Loading @@ -1366,13 +1386,18 @@ class DesktopTasksController( ) wct.sendPendingIntent(pendingIntent, intent, options.toBundle()) } } private fun removeWallpaperActivity(wct: WindowContainerTransaction) { desktopWallpaperActivityTokenProvider.getToken()?.let { token -> logV("removeWallpaperActivity") if (Flags.enableDesktopWallpaperActivityOnSystemUser()) { wct.reorder(token, /* onTop= */ false) } else { wct.removeTask(token) } } } /** * Remove wallpaper activity if task provided is last task and wallpaper activity token is not Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksTransitionObserver.kt +15 −5 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVI import android.window.TransitionInfo import android.window.WindowContainerTransaction import com.android.internal.protolog.ProtoLog import com.android.window.flags.Flags import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.back.BackAnimationController import com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.isExitDesktopModeTransition Loading Loading @@ -235,12 +236,21 @@ class DesktopTasksTransitionObserver( if (transitionToCloseWallpaper == transition) { // TODO: b/362469671 - Handle merging the animation when desktop is also closing. desktopWallpaperActivityTokenProvider.getToken()?.let { wallpaperActivityToken -> if (Flags.enableDesktopWallpaperActivityOnSystemUser()) { transitions.startTransition( TRANSIT_TO_BACK, WindowContainerTransaction() .reorder(wallpaperActivityToken, /* onTop= */ false), null, ) } else { transitions.startTransition( TRANSIT_CLOSE, WindowContainerTransaction().removeTask(wallpaperActivityToken), null, ) } } transitionToCloseWallpaper = null } } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +63 −20 Original line number Diff line number Diff line Loading @@ -1494,6 +1494,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun moveToFullscreen_tdaFullscreen_windowingModeUndefined_removesWallpaperActivity() { val task = setUpFreeformTask() assertNotNull(rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)) Loading @@ -1509,7 +1510,7 @@ class DesktopTasksControllerTest : ShellTestCase() { .onExitDesktopModeTransitionStarted(FULLSCREEN_ANIMATION_DURATION) assertThat(taskChange.windowingMode).isEqualTo(WINDOWING_MODE_UNDEFINED) // Removes wallpaper activity when leaving desktop wct.assertRemoveAt(index = 0, wallpaperToken) wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading @@ -1526,6 +1527,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun moveToFullscreen_tdaFreeform_windowingModeFullscreen_removesWallpaperActivity() { val task = setUpFreeformTask() Loading @@ -1542,7 +1544,7 @@ class DesktopTasksControllerTest : ShellTestCase() { verify(desktopModeEnterExitTransitionListener) .onExitDesktopModeTransitionStarted(FULLSCREEN_ANIMATION_DURATION) // Removes wallpaper activity when leaving desktop wct.assertRemoveAt(index = 0, wallpaperToken) wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -1968,13 +1970,14 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onDesktopWindowClose_singleActiveTask_hasWallpaperActivityToken() { val task = setUpFreeformTask() val wct = WindowContainerTransaction() controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task) // Adds remove wallpaper operation wct.assertRemoveAt(index = 0, wallpaperToken) wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2013,6 +2016,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onDesktopWindowClose_multipleActiveTasks_isOnlyNonClosingTask() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() Loading @@ -2022,10 +2026,11 @@ class DesktopTasksControllerTest : ShellTestCase() { val wct = WindowContainerTransaction() controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task1) // Adds remove wallpaper operation wct.assertRemoveAt(index = 0, wallpaperToken) wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onDesktopWindowClose_multipleActiveTasks_hasMinimized() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() Loading @@ -2035,7 +2040,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val wct = WindowContainerTransaction() controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task1) // Adds remove wallpaper operation wct.assertRemoveAt(index = 0, wallpaperToken) wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2095,6 +2100,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onTaskMinimize_singleActiveTask_hasWallpaperActivityToken_removesWallpaper() { val task = setUpFreeformTask() val transition = Binder() Loading @@ -2107,7 +2113,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val captor = ArgumentCaptor.forClass(WindowContainerTransaction::class.java) verify(freeformTaskTransitionStarter).startMinimizedModeTransition(captor.capture()) // Adds remove wallpaper operation captor.value.assertRemoveAt(index = 0, wallpaperToken) captor.value.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2146,6 +2152,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun onDesktopWindowMinimize_multipleActiveTasks_minimizesTheOnlyVisibleTask_removesWallpaper() { val task1 = setUpFreeformTask(active = true) val task2 = setUpFreeformTask(active = true) Loading @@ -2160,7 +2167,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val captor = ArgumentCaptor.forClass(WindowContainerTransaction::class.java) verify(freeformTaskTransitionStarter).startMinimizedModeTransition(captor.capture()) // Adds remove wallpaper operation captor.value.assertRemoveAt(index = 0, wallpaperToken) captor.value.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2804,7 +2811,10 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_backTransition_singleTaskWithToken_removesWallpaper() { val task = setUpFreeformTask() Loading @@ -2812,7 +2822,8 @@ class DesktopTasksControllerTest : ShellTestCase() { controller.handleRequest(Binder(), createTransition(task, type = TRANSIT_TO_BACK)) // Should create remove wallpaper transaction assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) assertNotNull(result, "Should handle request") .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2843,6 +2854,7 @@ class DesktopTasksControllerTest : ShellTestCase() { @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION, Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_backTransition_multipleTasksSingleNonClosing_removesWallpaperAndTask() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) Loading @@ -2853,11 +2865,15 @@ class DesktopTasksControllerTest : ShellTestCase() { controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_TO_BACK)) // Should create remove wallpaper transaction assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) assertNotNull(result, "Should handle request") .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_backTransition_multipleTasksSingleNonMinimized_removesWallpaperAndTask() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) Loading @@ -2867,7 +2883,8 @@ class DesktopTasksControllerTest : ShellTestCase() { controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_TO_BACK)) // Should create remove wallpaper transaction assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) assertNotNull(result, "Should handle request") .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2920,7 +2937,10 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_closeTransition_singleTaskWithToken_withWallpaper_removesWallpaper() { val task = setUpFreeformTask() Loading @@ -2928,7 +2948,8 @@ class DesktopTasksControllerTest : ShellTestCase() { controller.handleRequest(Binder(), createTransition(task, type = TRANSIT_CLOSE)) // Should create remove wallpaper transaction assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) assertNotNull(result, "Should handle request") .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -2956,7 +2977,10 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_closeTransition_multipleTasksSingleNonClosing_removesWallpaper() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) Loading @@ -2966,11 +2990,15 @@ class DesktopTasksControllerTest : ShellTestCase() { controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_CLOSE)) // Should create remove wallpaper transaction assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) assertNotNull(result, "Should handle request") .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY) @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER, ) fun handleRequest_closeTransition_multipleTasksSingleNonMinimized_removesWallpaper() { val task1 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) val task2 = setUpFreeformTask(displayId = DEFAULT_DISPLAY) Loading @@ -2980,7 +3008,8 @@ class DesktopTasksControllerTest : ShellTestCase() { controller.handleRequest(Binder(), createTransition(task1, type = TRANSIT_CLOSE)) // Should create remove wallpaper transaction assertNotNull(result, "Should handle request").assertRemoveAt(index = 0, wallpaperToken) assertNotNull(result, "Should handle request") .assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -3060,6 +3089,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun moveFocusedTaskToFullscreen_onlyVisibleNonMinimizedTask_removesWallpaperActivity() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() Loading @@ -3077,7 +3107,7 @@ class DesktopTasksControllerTest : ShellTestCase() { val taskChange = assertNotNull(wct.changes[task2.token.asBinder()]) assertThat(taskChange.windowingMode) .isEqualTo(WINDOWING_MODE_UNDEFINED) // inherited FULLSCREEN wct.assertRemoveAt(index = 0, wallpaperToken) wct.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -3571,6 +3601,7 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WALLPAPER_ACTIVITY_ON_SYSTEM_USER) fun enterSplit_onlyVisibleNonMinimizedTask_removesWallpaperActivity() { val task1 = setUpFreeformTask() val task2 = setUpFreeformTask() Loading @@ -3593,7 +3624,7 @@ class DesktopTasksControllerTest : ShellTestCase() { eq(task2.configuration.windowConfiguration.bounds), ) // Removes wallpaper activity when leaving desktop wctArgument.value.assertRemoveAt(index = 0, wallpaperToken) wctArgument.value.assertReorderAt(index = 0, wallpaperToken, toTop = false) } @Test Loading Loading @@ -5048,6 +5079,18 @@ private fun WindowContainerTransaction.assertReorderAt( toTop?.let { assertThat(op.toTop).isEqualTo(it) } } private fun WindowContainerTransaction.assertReorderAt( index: Int, token: WindowContainerToken, toTop: Boolean? = null, ) { assertIndexInBounds(index) val op = hierarchyOps[index] assertThat(op.type).isEqualTo(HIERARCHY_OP_TYPE_REORDER) assertThat(op.container).isEqualTo(token.asBinder()) toTop?.let { assertThat(op.toTop).isEqualTo(it) } } private fun WindowContainerTransaction.assertReorderSequence(vararg tasks: RunningTaskInfo) { for (i in tasks.indices) { assertReorderAt(i, tasks[i]) Loading