Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +31 −18 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ import android.view.WindowManager.TRANSIT_OPEN import android.view.WindowManager.TRANSIT_TO_FRONT import android.window.TransitionInfo import android.window.TransitionRequestInfo import android.window.WindowContainerToken import android.window.WindowContainerTransaction import androidx.annotation.BinderThread import com.android.wm.shell.RootTaskDisplayAreaOrganizer Loading Loading @@ -184,7 +183,7 @@ class DesktopTasksController( ) // Bring other apps to front first bringDesktopAppsToFront(task.displayId, wct) addMoveToDesktopChanges(wct, task.token) addMoveToDesktopChanges(wct, task) if (Transitions.ENABLE_SHELL_TRANSITIONS) { transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */) Loading @@ -205,7 +204,7 @@ class DesktopTasksController( ) val wct = WindowContainerTransaction() moveHomeTaskToFront(wct) addMoveToDesktopChanges(wct, taskInfo.getToken()) addMoveToDesktopChanges(wct, taskInfo) wct.setBounds(taskInfo.token, startBounds) if (Transitions.ENABLE_SHELL_TRANSITIONS) { Loading @@ -225,7 +224,7 @@ class DesktopTasksController( ) val wct = WindowContainerTransaction() bringDesktopAppsToFront(taskInfo.displayId, wct) addMoveToDesktopChanges(wct, taskInfo.getToken()) addMoveToDesktopChanges(wct, taskInfo) wct.setBounds(taskInfo.token, freeformBounds) if (Transitions.ENABLE_SHELL_TRANSITIONS) { Loading @@ -251,7 +250,7 @@ class DesktopTasksController( ) val wct = WindowContainerTransaction() addMoveToFullscreenChanges(wct, task.token) addMoveToFullscreenChanges(wct, task) if (Transitions.ENABLE_SHELL_TRANSITIONS) { transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */) } else { Loading @@ -270,7 +269,7 @@ class DesktopTasksController( task.taskId ) val wct = WindowContainerTransaction() addMoveToFullscreenChanges(wct, task.token) addMoveToFullscreenChanges(wct, task) if (Transitions.ENABLE_SHELL_TRANSITIONS) { enterDesktopTaskTransitionHandler.startCancelMoveToDesktopMode(wct, position, mOnAnimationFinishedCallback) Loading @@ -287,7 +286,7 @@ class DesktopTasksController( task.taskId ) val wct = WindowContainerTransaction() addMoveToFullscreenChanges(wct, task.token) addMoveToFullscreenChanges(wct, task) if (Transitions.ENABLE_SHELL_TRANSITIONS) { exitDesktopTaskTransitionHandler.startTransition( Loading Loading @@ -516,7 +515,7 @@ class DesktopTasksController( task.taskId ) return WindowContainerTransaction().also { wct -> addMoveToFullscreenChanges(wct, task.token) addMoveToFullscreenChanges(wct, task) } } return null Loading @@ -532,7 +531,7 @@ class DesktopTasksController( task.taskId ) return WindowContainerTransaction().also { wct -> addMoveToDesktopChanges(wct, task.token) addMoveToDesktopChanges(wct, task) } } return null Loading @@ -546,30 +545,44 @@ class DesktopTasksController( ) val wct = WindowContainerTransaction() bringDesktopAppsToFront(task.displayId, wct) addMoveToDesktopChanges(wct, task.token) addMoveToDesktopChanges(wct, task) desktopModeTaskRepository.setStashed(task.displayId, false) return wct } private fun addMoveToDesktopChanges( wct: WindowContainerTransaction, token: WindowContainerToken taskInfo: RunningTaskInfo ) { wct.setWindowingMode(token, WINDOWING_MODE_FREEFORM) wct.reorder(token, true /* onTop */) val displayWindowingMode = taskInfo.configuration.windowConfiguration.displayWindowingMode val targetWindowingMode = if (displayWindowingMode == WINDOWING_MODE_FREEFORM) { // Display windowing is freeform, set to undefined and inherit it WINDOWING_MODE_UNDEFINED } else { WINDOWING_MODE_FREEFORM } wct.setWindowingMode(taskInfo.token, targetWindowingMode) wct.reorder(taskInfo.token, true /* onTop */) if (isDesktopDensityOverrideSet()) { wct.setDensityDpi(token, getDesktopDensityDpi()) wct.setDensityDpi(taskInfo.token, getDesktopDensityDpi()) } } private fun addMoveToFullscreenChanges( wct: WindowContainerTransaction, token: WindowContainerToken taskInfo: RunningTaskInfo ) { wct.setWindowingMode(token, WINDOWING_MODE_FULLSCREEN) wct.setBounds(token, null) val displayWindowingMode = taskInfo.configuration.windowConfiguration.displayWindowingMode val targetWindowingMode = if (displayWindowingMode == WINDOWING_MODE_FULLSCREEN) { // Display windowing is fullscreen, set to undefined and inherit it WINDOWING_MODE_UNDEFINED } else { WINDOWING_MODE_FULLSCREEN } wct.setWindowingMode(taskInfo.token, targetWindowingMode) wct.setBounds(taskInfo.token, null) if (isDesktopDensityOverrideSet()) { wct.setDensityDpi(token, getFullscreenDensityDpi()) wct.setDensityDpi(taskInfo.token, getFullscreenDensityDpi()) } } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +25 −3 Original line number Diff line number Diff line Loading @@ -270,14 +270,25 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test fun moveToDesktop() { fun moveToDesktop_displayFullscreen_windowingModeSetToFreeform() { val task = setUpFullscreenTask() task.configuration.windowConfiguration.displayWindowingMode = WINDOWING_MODE_FULLSCREEN controller.moveToDesktop(task) val wct = getLatestWct(expectTransition = TRANSIT_CHANGE) assertThat(wct.changes[task.token.asBinder()]?.windowingMode) .isEqualTo(WINDOWING_MODE_FREEFORM) } @Test fun moveToDesktop_displayFreeform_windowingModeSetToUndefined() { val task = setUpFullscreenTask() task.configuration.windowConfiguration.displayWindowingMode = WINDOWING_MODE_FREEFORM controller.moveToDesktop(task) val wct = getLatestWct(expectTransition = TRANSIT_CHANGE) assertThat(wct.changes[task.token.asBinder()]?.windowingMode) .isEqualTo(WINDOWING_MODE_UNDEFINED) } @Test fun moveToDesktop_nonExistentTask_doesNothing() { controller.moveToDesktop(999) Loading Loading @@ -325,8 +336,19 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test fun moveToFullscreen() { fun moveToFullscreen_displayFullscreen_windowingModeSetToUndefined() { val task = setUpFreeformTask() task.configuration.windowConfiguration.displayWindowingMode = WINDOWING_MODE_FULLSCREEN controller.moveToFullscreen(task) val wct = getLatestWct(expectTransition = TRANSIT_CHANGE) assertThat(wct.changes[task.token.asBinder()]?.windowingMode) .isEqualTo(WINDOWING_MODE_UNDEFINED) } @Test fun moveToFullscreen_displayFreeform_windowingModeSetToFullscreen() { val task = setUpFreeformTask() task.configuration.windowConfiguration.displayWindowingMode = WINDOWING_MODE_FREEFORM controller.moveToFullscreen(task) val wct = getLatestWct(expectTransition = TRANSIT_CHANGE) assertThat(wct.changes[task.token.asBinder()]?.windowingMode) Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +31 −18 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ import android.view.WindowManager.TRANSIT_OPEN import android.view.WindowManager.TRANSIT_TO_FRONT import android.window.TransitionInfo import android.window.TransitionRequestInfo import android.window.WindowContainerToken import android.window.WindowContainerTransaction import androidx.annotation.BinderThread import com.android.wm.shell.RootTaskDisplayAreaOrganizer Loading Loading @@ -184,7 +183,7 @@ class DesktopTasksController( ) // Bring other apps to front first bringDesktopAppsToFront(task.displayId, wct) addMoveToDesktopChanges(wct, task.token) addMoveToDesktopChanges(wct, task) if (Transitions.ENABLE_SHELL_TRANSITIONS) { transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */) Loading @@ -205,7 +204,7 @@ class DesktopTasksController( ) val wct = WindowContainerTransaction() moveHomeTaskToFront(wct) addMoveToDesktopChanges(wct, taskInfo.getToken()) addMoveToDesktopChanges(wct, taskInfo) wct.setBounds(taskInfo.token, startBounds) if (Transitions.ENABLE_SHELL_TRANSITIONS) { Loading @@ -225,7 +224,7 @@ class DesktopTasksController( ) val wct = WindowContainerTransaction() bringDesktopAppsToFront(taskInfo.displayId, wct) addMoveToDesktopChanges(wct, taskInfo.getToken()) addMoveToDesktopChanges(wct, taskInfo) wct.setBounds(taskInfo.token, freeformBounds) if (Transitions.ENABLE_SHELL_TRANSITIONS) { Loading @@ -251,7 +250,7 @@ class DesktopTasksController( ) val wct = WindowContainerTransaction() addMoveToFullscreenChanges(wct, task.token) addMoveToFullscreenChanges(wct, task) if (Transitions.ENABLE_SHELL_TRANSITIONS) { transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */) } else { Loading @@ -270,7 +269,7 @@ class DesktopTasksController( task.taskId ) val wct = WindowContainerTransaction() addMoveToFullscreenChanges(wct, task.token) addMoveToFullscreenChanges(wct, task) if (Transitions.ENABLE_SHELL_TRANSITIONS) { enterDesktopTaskTransitionHandler.startCancelMoveToDesktopMode(wct, position, mOnAnimationFinishedCallback) Loading @@ -287,7 +286,7 @@ class DesktopTasksController( task.taskId ) val wct = WindowContainerTransaction() addMoveToFullscreenChanges(wct, task.token) addMoveToFullscreenChanges(wct, task) if (Transitions.ENABLE_SHELL_TRANSITIONS) { exitDesktopTaskTransitionHandler.startTransition( Loading Loading @@ -516,7 +515,7 @@ class DesktopTasksController( task.taskId ) return WindowContainerTransaction().also { wct -> addMoveToFullscreenChanges(wct, task.token) addMoveToFullscreenChanges(wct, task) } } return null Loading @@ -532,7 +531,7 @@ class DesktopTasksController( task.taskId ) return WindowContainerTransaction().also { wct -> addMoveToDesktopChanges(wct, task.token) addMoveToDesktopChanges(wct, task) } } return null Loading @@ -546,30 +545,44 @@ class DesktopTasksController( ) val wct = WindowContainerTransaction() bringDesktopAppsToFront(task.displayId, wct) addMoveToDesktopChanges(wct, task.token) addMoveToDesktopChanges(wct, task) desktopModeTaskRepository.setStashed(task.displayId, false) return wct } private fun addMoveToDesktopChanges( wct: WindowContainerTransaction, token: WindowContainerToken taskInfo: RunningTaskInfo ) { wct.setWindowingMode(token, WINDOWING_MODE_FREEFORM) wct.reorder(token, true /* onTop */) val displayWindowingMode = taskInfo.configuration.windowConfiguration.displayWindowingMode val targetWindowingMode = if (displayWindowingMode == WINDOWING_MODE_FREEFORM) { // Display windowing is freeform, set to undefined and inherit it WINDOWING_MODE_UNDEFINED } else { WINDOWING_MODE_FREEFORM } wct.setWindowingMode(taskInfo.token, targetWindowingMode) wct.reorder(taskInfo.token, true /* onTop */) if (isDesktopDensityOverrideSet()) { wct.setDensityDpi(token, getDesktopDensityDpi()) wct.setDensityDpi(taskInfo.token, getDesktopDensityDpi()) } } private fun addMoveToFullscreenChanges( wct: WindowContainerTransaction, token: WindowContainerToken taskInfo: RunningTaskInfo ) { wct.setWindowingMode(token, WINDOWING_MODE_FULLSCREEN) wct.setBounds(token, null) val displayWindowingMode = taskInfo.configuration.windowConfiguration.displayWindowingMode val targetWindowingMode = if (displayWindowingMode == WINDOWING_MODE_FULLSCREEN) { // Display windowing is fullscreen, set to undefined and inherit it WINDOWING_MODE_UNDEFINED } else { WINDOWING_MODE_FULLSCREEN } wct.setWindowingMode(taskInfo.token, targetWindowingMode) wct.setBounds(taskInfo.token, null) if (isDesktopDensityOverrideSet()) { wct.setDensityDpi(token, getFullscreenDensityDpi()) wct.setDensityDpi(taskInfo.token, getFullscreenDensityDpi()) } } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +25 −3 Original line number Diff line number Diff line Loading @@ -270,14 +270,25 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test fun moveToDesktop() { fun moveToDesktop_displayFullscreen_windowingModeSetToFreeform() { val task = setUpFullscreenTask() task.configuration.windowConfiguration.displayWindowingMode = WINDOWING_MODE_FULLSCREEN controller.moveToDesktop(task) val wct = getLatestWct(expectTransition = TRANSIT_CHANGE) assertThat(wct.changes[task.token.asBinder()]?.windowingMode) .isEqualTo(WINDOWING_MODE_FREEFORM) } @Test fun moveToDesktop_displayFreeform_windowingModeSetToUndefined() { val task = setUpFullscreenTask() task.configuration.windowConfiguration.displayWindowingMode = WINDOWING_MODE_FREEFORM controller.moveToDesktop(task) val wct = getLatestWct(expectTransition = TRANSIT_CHANGE) assertThat(wct.changes[task.token.asBinder()]?.windowingMode) .isEqualTo(WINDOWING_MODE_UNDEFINED) } @Test fun moveToDesktop_nonExistentTask_doesNothing() { controller.moveToDesktop(999) Loading Loading @@ -325,8 +336,19 @@ class DesktopTasksControllerTest : ShellTestCase() { } @Test fun moveToFullscreen() { fun moveToFullscreen_displayFullscreen_windowingModeSetToUndefined() { val task = setUpFreeformTask() task.configuration.windowConfiguration.displayWindowingMode = WINDOWING_MODE_FULLSCREEN controller.moveToFullscreen(task) val wct = getLatestWct(expectTransition = TRANSIT_CHANGE) assertThat(wct.changes[task.token.asBinder()]?.windowingMode) .isEqualTo(WINDOWING_MODE_UNDEFINED) } @Test fun moveToFullscreen_displayFreeform_windowingModeSetToFullscreen() { val task = setUpFreeformTask() task.configuration.windowConfiguration.displayWindowingMode = WINDOWING_MODE_FREEFORM controller.moveToFullscreen(task) val wct = getLatestWct(expectTransition = TRANSIT_CHANGE) assertThat(wct.changes[task.token.asBinder()]?.windowingMode) Loading