Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +34 −0 Original line number Diff line number Diff line Loading @@ -3482,6 +3482,18 @@ class DesktopTasksController( // If there is an active desk on the target display, then it is already in desktop // windowing so the new task should also be placed in desktop windowing. anyDeskActive -> true DesktopExperienceFlags.ENABLE_DESKTOP_FIRST_TOP_FULLSCREEN_BUGFIX.isTrue -> // Here we have no desk activated, but check if we really want to force a task // into desktop. if (rootTaskDisplayAreaOrganizer.isDisplayDesktopFirst(task.displayId)) { // In desktop-first mode, we force to activate desk only when the // desktop-first policy can be applied. shouldForceEnterDesktop } else { // In touch-first mode, new tasks should be forced into desktop, while known // desktop tasks should be moved outside of desktop. !isKnownDesktopTask } // If there is some desk on target display and it's been marked as a "desktop-first" // display, activate the desk and place the task in desktop windowing. shouldForceEnterDesktop -> true Loading Loading @@ -3771,6 +3783,28 @@ class DesktopTasksController( } val isDesktopFirst = rootTaskDisplayAreaOrganizer.isDisplayDesktopFirst(targetDisplayId) if (DesktopExperienceFlags.ENABLE_DESKTOP_FIRST_TOP_FULLSCREEN_BUGFIX.isTrue) { val anyDeskActive = isAnyDeskActive(targetDisplayId) val focusedTask = focusTransitionObserver.getFocusedTaskOnDisplay(targetDisplayId) val isFullscreenFocused = focusedTask?.isFullscreen == true val isNonHomeFocused = focusedTask?.activityType != ACTIVITY_TYPE_HOME logV( "shouldForceEnterDesktopByDesktopFirstPolicy: anyDeskActive=%s " + "isFullscreenFocused=%s isNonHomeFocused=%s", anyDeskActive, isFullscreenFocused, isNonHomeFocused, ) if (isDesktopFirst && !anyDeskActive && isFullscreenFocused && isNonHomeFocused) { logV( "shouldForceEnterDesktopByDesktopFirstPolicy: no switch as the other " + "fullscreen task is focused on desktop-first display#%s", targetDisplayId, ) return false } } if ( DesktopExperienceFlags.ENABLE_DESKTOP_FIRST_FULLSCREEN_REFOCUS_BUGFIX.isTrue && isDesktopFirst && Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +47 −0 Original line number Diff line number Diff line Loading @@ -5621,6 +5621,29 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() verify(desksOrganizer).moveTaskToDesk(wct, deskId, fullscreenTask) } @Test @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, Flags.FLAG_ENABLE_DESKTOP_FIRST_BASED_DEFAULT_TO_DESKTOP_BUGFIX, Flags.FLAG_ENABLE_DESKTOP_FIRST_TOP_FULLSCREEN_BUGFIX, ) fun handleRequest_fullscreenTask_fullscreenFocused_freeformDisplay_returnNull() { val deskId = 0 taskRepository.setDeskInactive(deskId) whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(null) val tda = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)!! tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM val focusedFullscreenTask = createFullscreenTask() whenever(focusTransitionObserver.getFocusedTaskOnDisplay(any())) .thenReturn(focusedFullscreenTask) val fullscreenTask = createFullscreenTask() assertThat(controller.handleRequest(Binder(), createTransition(fullscreenTask))).isNull() } @Test fun handleRequest_fullscreenTask_notInDesk_enforceDesktop_fullscreenDisplay_returnNull() { taskRepository.setDeskInactive(deskId = 0) Loading Loading @@ -5977,6 +6000,30 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() verify(desksOrganizer).moveTaskToDesk(result, deskId = 0, freeformTask) } @Test @EnableFlags( Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, Flags.FLAG_ENABLE_DESKTOP_FIRST_BASED_DEFAULT_TO_DESKTOP_BUGFIX, Flags.FLAG_ENABLE_DESKTOP_FIRST_TOP_FULLSCREEN_BUGFIX, ) fun handleRequest_freeformTask_fullscreenFocused_freeformDisplay_moveToFullscreen() { val deskId = 0 taskRepository.setDeskInactive(deskId) whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(null) val tda = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)!! tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM val focusedFullscreenTask = createFullscreenTask() whenever(focusTransitionObserver.getFocusedTaskOnDisplay(any())) .thenReturn(focusedFullscreenTask) val freeformTask = createFreeformTask(displayId = DEFAULT_DISPLAY) val wct = controller.handleRequest(Binder(), createTransition(freeformTask)) assertThat(wct?.changes[freeformTask.token.asBinder()]?.windowingMode) .isEqualTo(WINDOWING_MODE_FULLSCREEN) } @Test fun handleRequest_notOpenOrToFrontTransition_returnNull() { val task = Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +34 −0 Original line number Diff line number Diff line Loading @@ -3482,6 +3482,18 @@ class DesktopTasksController( // If there is an active desk on the target display, then it is already in desktop // windowing so the new task should also be placed in desktop windowing. anyDeskActive -> true DesktopExperienceFlags.ENABLE_DESKTOP_FIRST_TOP_FULLSCREEN_BUGFIX.isTrue -> // Here we have no desk activated, but check if we really want to force a task // into desktop. if (rootTaskDisplayAreaOrganizer.isDisplayDesktopFirst(task.displayId)) { // In desktop-first mode, we force to activate desk only when the // desktop-first policy can be applied. shouldForceEnterDesktop } else { // In touch-first mode, new tasks should be forced into desktop, while known // desktop tasks should be moved outside of desktop. !isKnownDesktopTask } // If there is some desk on target display and it's been marked as a "desktop-first" // display, activate the desk and place the task in desktop windowing. shouldForceEnterDesktop -> true Loading Loading @@ -3771,6 +3783,28 @@ class DesktopTasksController( } val isDesktopFirst = rootTaskDisplayAreaOrganizer.isDisplayDesktopFirst(targetDisplayId) if (DesktopExperienceFlags.ENABLE_DESKTOP_FIRST_TOP_FULLSCREEN_BUGFIX.isTrue) { val anyDeskActive = isAnyDeskActive(targetDisplayId) val focusedTask = focusTransitionObserver.getFocusedTaskOnDisplay(targetDisplayId) val isFullscreenFocused = focusedTask?.isFullscreen == true val isNonHomeFocused = focusedTask?.activityType != ACTIVITY_TYPE_HOME logV( "shouldForceEnterDesktopByDesktopFirstPolicy: anyDeskActive=%s " + "isFullscreenFocused=%s isNonHomeFocused=%s", anyDeskActive, isFullscreenFocused, isNonHomeFocused, ) if (isDesktopFirst && !anyDeskActive && isFullscreenFocused && isNonHomeFocused) { logV( "shouldForceEnterDesktopByDesktopFirstPolicy: no switch as the other " + "fullscreen task is focused on desktop-first display#%s", targetDisplayId, ) return false } } if ( DesktopExperienceFlags.ENABLE_DESKTOP_FIRST_FULLSCREEN_REFOCUS_BUGFIX.isTrue && isDesktopFirst && Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +47 −0 Original line number Diff line number Diff line Loading @@ -5621,6 +5621,29 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() verify(desksOrganizer).moveTaskToDesk(wct, deskId, fullscreenTask) } @Test @EnableFlags( Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY, Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, Flags.FLAG_ENABLE_DESKTOP_FIRST_BASED_DEFAULT_TO_DESKTOP_BUGFIX, Flags.FLAG_ENABLE_DESKTOP_FIRST_TOP_FULLSCREEN_BUGFIX, ) fun handleRequest_fullscreenTask_fullscreenFocused_freeformDisplay_returnNull() { val deskId = 0 taskRepository.setDeskInactive(deskId) whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(null) val tda = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)!! tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM val focusedFullscreenTask = createFullscreenTask() whenever(focusTransitionObserver.getFocusedTaskOnDisplay(any())) .thenReturn(focusedFullscreenTask) val fullscreenTask = createFullscreenTask() assertThat(controller.handleRequest(Binder(), createTransition(fullscreenTask))).isNull() } @Test fun handleRequest_fullscreenTask_notInDesk_enforceDesktop_fullscreenDisplay_returnNull() { taskRepository.setDeskInactive(deskId = 0) Loading Loading @@ -5977,6 +6000,30 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() verify(desksOrganizer).moveTaskToDesk(result, deskId = 0, freeformTask) } @Test @EnableFlags( Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, Flags.FLAG_ENABLE_DESKTOP_FIRST_BASED_DEFAULT_TO_DESKTOP_BUGFIX, Flags.FLAG_ENABLE_DESKTOP_FIRST_TOP_FULLSCREEN_BUGFIX, ) fun handleRequest_freeformTask_fullscreenFocused_freeformDisplay_moveToFullscreen() { val deskId = 0 taskRepository.setDeskInactive(deskId) whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(null) val tda = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(DEFAULT_DISPLAY)!! tda.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FREEFORM val focusedFullscreenTask = createFullscreenTask() whenever(focusTransitionObserver.getFocusedTaskOnDisplay(any())) .thenReturn(focusedFullscreenTask) val freeformTask = createFreeformTask(displayId = DEFAULT_DISPLAY) val wct = controller.handleRequest(Binder(), createTransition(freeformTask)) assertThat(wct?.changes[freeformTask.token.asBinder()]?.windowingMode) .isEqualTo(WINDOWING_MODE_FULLSCREEN) } @Test fun handleRequest_notOpenOrToFrontTransition_returnNull() { val task = Loading