Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98ba093c authored by Ats Jenk's avatar Ats Jenk Committed by Automerger Merge Worker
Browse files

Merge "Remove windowing mode override from task when it matches display" into...

Merge "Remove windowing mode override from task when it matches display" into udc-qpr-dev am: 5f433062

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23624076



Change-Id: I4264619bce2643d2813ecc1838e36b3de9432835
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 3885ce35 5f433062
Loading
Loading
Loading
Loading
+31 −18
Original line number Original line Diff line number Diff line
@@ -38,7 +38,6 @@ import android.view.WindowManager.TRANSIT_OPEN
import android.view.WindowManager.TRANSIT_TO_FRONT
import android.view.WindowManager.TRANSIT_TO_FRONT
import android.window.TransitionInfo
import android.window.TransitionInfo
import android.window.TransitionRequestInfo
import android.window.TransitionRequestInfo
import android.window.WindowContainerToken
import android.window.WindowContainerTransaction
import android.window.WindowContainerTransaction
import androidx.annotation.BinderThread
import androidx.annotation.BinderThread
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
@@ -184,7 +183,7 @@ class DesktopTasksController(
        )
        )
        // Bring other apps to front first
        // Bring other apps to front first
        bringDesktopAppsToFront(task.displayId, wct)
        bringDesktopAppsToFront(task.displayId, wct)
        addMoveToDesktopChanges(wct, task.token)
        addMoveToDesktopChanges(wct, task)


        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
            transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)
            transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)
@@ -205,7 +204,7 @@ class DesktopTasksController(
        )
        )
        val wct = WindowContainerTransaction()
        val wct = WindowContainerTransaction()
        moveHomeTaskToFront(wct)
        moveHomeTaskToFront(wct)
        addMoveToDesktopChanges(wct, taskInfo.getToken())
        addMoveToDesktopChanges(wct, taskInfo)
        wct.setBounds(taskInfo.token, startBounds)
        wct.setBounds(taskInfo.token, startBounds)


        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
@@ -225,7 +224,7 @@ class DesktopTasksController(
        )
        )
        val wct = WindowContainerTransaction()
        val wct = WindowContainerTransaction()
        bringDesktopAppsToFront(taskInfo.displayId, wct)
        bringDesktopAppsToFront(taskInfo.displayId, wct)
        addMoveToDesktopChanges(wct, taskInfo.getToken())
        addMoveToDesktopChanges(wct, taskInfo)
        wct.setBounds(taskInfo.token, freeformBounds)
        wct.setBounds(taskInfo.token, freeformBounds)


        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
@@ -251,7 +250,7 @@ class DesktopTasksController(
        )
        )


        val wct = WindowContainerTransaction()
        val wct = WindowContainerTransaction()
        addMoveToFullscreenChanges(wct, task.token)
        addMoveToFullscreenChanges(wct, task)
        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
            transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)
            transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)
        } else {
        } else {
@@ -270,7 +269,7 @@ class DesktopTasksController(
                task.taskId
                task.taskId
        )
        )
        val wct = WindowContainerTransaction()
        val wct = WindowContainerTransaction()
        addMoveToFullscreenChanges(wct, task.token)
        addMoveToFullscreenChanges(wct, task)
        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
            enterDesktopTaskTransitionHandler.startCancelMoveToDesktopMode(wct, position,
            enterDesktopTaskTransitionHandler.startCancelMoveToDesktopMode(wct, position,
                    mOnAnimationFinishedCallback)
                    mOnAnimationFinishedCallback)
@@ -287,7 +286,7 @@ class DesktopTasksController(
                task.taskId
                task.taskId
        )
        )
        val wct = WindowContainerTransaction()
        val wct = WindowContainerTransaction()
        addMoveToFullscreenChanges(wct, task.token)
        addMoveToFullscreenChanges(wct, task)


        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
            exitDesktopTaskTransitionHandler.startTransition(
            exitDesktopTaskTransitionHandler.startTransition(
@@ -516,7 +515,7 @@ class DesktopTasksController(
                    task.taskId
                    task.taskId
            )
            )
            return WindowContainerTransaction().also { wct ->
            return WindowContainerTransaction().also { wct ->
                addMoveToFullscreenChanges(wct, task.token)
                addMoveToFullscreenChanges(wct, task)
            }
            }
        }
        }
        return null
        return null
@@ -532,7 +531,7 @@ class DesktopTasksController(
                    task.taskId
                    task.taskId
            )
            )
            return WindowContainerTransaction().also { wct ->
            return WindowContainerTransaction().also { wct ->
                addMoveToDesktopChanges(wct, task.token)
                addMoveToDesktopChanges(wct, task)
            }
            }
        }
        }
        return null
        return null
@@ -546,30 +545,44 @@ class DesktopTasksController(
        )
        )
        val wct = WindowContainerTransaction()
        val wct = WindowContainerTransaction()
        bringDesktopAppsToFront(task.displayId, wct)
        bringDesktopAppsToFront(task.displayId, wct)
        addMoveToDesktopChanges(wct, task.token)
        addMoveToDesktopChanges(wct, task)
        desktopModeTaskRepository.setStashed(task.displayId, false)
        desktopModeTaskRepository.setStashed(task.displayId, false)
        return wct
        return wct
    }
    }


    private fun addMoveToDesktopChanges(
    private fun addMoveToDesktopChanges(
        wct: WindowContainerTransaction,
        wct: WindowContainerTransaction,
        token: WindowContainerToken
        taskInfo: RunningTaskInfo
    ) {
    ) {
        wct.setWindowingMode(token, WINDOWING_MODE_FREEFORM)
        val displayWindowingMode = taskInfo.configuration.windowConfiguration.displayWindowingMode
        wct.reorder(token, true /* onTop */)
        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()) {
        if (isDesktopDensityOverrideSet()) {
            wct.setDensityDpi(token, getDesktopDensityDpi())
            wct.setDensityDpi(taskInfo.token, getDesktopDensityDpi())
        }
        }
    }
    }


    private fun addMoveToFullscreenChanges(
    private fun addMoveToFullscreenChanges(
        wct: WindowContainerTransaction,
        wct: WindowContainerTransaction,
        token: WindowContainerToken
        taskInfo: RunningTaskInfo
    ) {
    ) {
        wct.setWindowingMode(token, WINDOWING_MODE_FULLSCREEN)
        val displayWindowingMode = taskInfo.configuration.windowConfiguration.displayWindowingMode
        wct.setBounds(token, null)
        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()) {
        if (isDesktopDensityOverrideSet()) {
            wct.setDensityDpi(token, getFullscreenDensityDpi())
            wct.setDensityDpi(taskInfo.token, getFullscreenDensityDpi())
        }
        }
    }
    }


+25 −3
Original line number Original line Diff line number Diff line
@@ -270,14 +270,25 @@ class DesktopTasksControllerTest : ShellTestCase() {
    }
    }


    @Test
    @Test
    fun moveToDesktop() {
    fun moveToDesktop_displayFullscreen_windowingModeSetToFreeform() {
        val task = setUpFullscreenTask()
        val task = setUpFullscreenTask()
        task.configuration.windowConfiguration.displayWindowingMode = WINDOWING_MODE_FULLSCREEN
        controller.moveToDesktop(task)
        controller.moveToDesktop(task)
        val wct = getLatestWct(expectTransition = TRANSIT_CHANGE)
        val wct = getLatestWct(expectTransition = TRANSIT_CHANGE)
        assertThat(wct.changes[task.token.asBinder()]?.windowingMode)
        assertThat(wct.changes[task.token.asBinder()]?.windowingMode)
            .isEqualTo(WINDOWING_MODE_FREEFORM)
            .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
    @Test
    fun moveToDesktop_nonExistentTask_doesNothing() {
    fun moveToDesktop_nonExistentTask_doesNothing() {
        controller.moveToDesktop(999)
        controller.moveToDesktop(999)
@@ -325,8 +336,19 @@ class DesktopTasksControllerTest : ShellTestCase() {
    }
    }


    @Test
    @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()
        val task = setUpFreeformTask()
        task.configuration.windowConfiguration.displayWindowingMode = WINDOWING_MODE_FREEFORM
        controller.moveToFullscreen(task)
        controller.moveToFullscreen(task)
        val wct = getLatestWct(expectTransition = TRANSIT_CHANGE)
        val wct = getLatestWct(expectTransition = TRANSIT_CHANGE)
        assertThat(wct.changes[task.token.asBinder()]?.windowingMode)
        assertThat(wct.changes[task.token.asBinder()]?.windowingMode)