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

Commit 45f279fb authored by Orhan Uysal's avatar Orhan Uysal Committed by Android (Google) Code Review
Browse files

Merge "Add animation for desktop to fullscreen." into main

parents 99166273 b74a1895
Loading
Loading
Loading
Loading
+4 −19
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME
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.WINDOWING_MODE_MULTI_WINDOW
import android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED
import android.app.WindowConfiguration.WindowingMode
import android.content.Context
@@ -321,24 +320,10 @@ class DesktopTasksController(
    }

    /** Move a task with given `taskId` to fullscreen */
    fun moveToFullscreen(taskId: Int) {
        shellTaskOrganizer.getRunningTaskInfo(taskId)?.let { task -> moveToFullscreen(task) }
    }

    /** Move a task to fullscreen */
    fun moveToFullscreen(task: RunningTaskInfo) {
        KtProtoLog.v(
            WM_SHELL_DESKTOP_MODE,
            "DesktopTasksController: moveToFullscreen taskId=%d",
            task.taskId
        )

        val wct = WindowContainerTransaction()
        addMoveToFullscreenChanges(wct, task)
        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
            transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */)
        } else {
            shellTaskOrganizer.applyTransaction(wct)
    fun moveToFullscreen(taskId: Int, windowDecor: DesktopModeWindowDecoration) {
        shellTaskOrganizer.getRunningTaskInfo(taskId)?.let { task ->
            windowDecor.incrementRelayoutBlock()
            moveToFullscreenWithAnimation(task, task.positionInParent)
        }
    }

+2 −1
Original line number Diff line number Diff line
@@ -428,7 +428,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                if (isTaskInSplitScreen(mTaskId)) {
                    mSplitScreenController.moveTaskToFullscreen(mTaskId);
                } else {
                    mDesktopTasksController.ifPresent(c -> c.moveToFullscreen(mTaskId));
                    mDesktopTasksController.ifPresent(c ->
                            c.moveToFullscreen(mTaskId, mWindowDecorByTaskId.get(mTaskId)));
                }
            } else if (id == R.id.split_screen_button) {
                decoration.closeHandleMenu();
+19 −7
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import com.android.wm.shell.sysui.ShellInit
import com.android.wm.shell.transition.OneShotRemoteHandler
import com.android.wm.shell.transition.Transitions
import com.android.wm.shell.transition.Transitions.ENABLE_SHELL_TRANSITIONS
import com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_DESKTOP_MODE
import com.android.wm.shell.transition.Transitions.TransitionHandler
import com.android.wm.shell.windowdecor.DesktopModeWindowDecoration
import com.google.common.truth.Truth.assertThat
@@ -392,8 +393,8 @@ class DesktopTasksControllerTest : ShellTestCase() {
    fun moveToFullscreen_displayFullscreen_windowingModeSetToUndefined() {
        val task = setUpFreeformTask()
        task.configuration.windowConfiguration.displayWindowingMode = WINDOWING_MODE_FULLSCREEN
        controller.moveToFullscreen(task)
        val wct = getLatestWct(type = TRANSIT_CHANGE)
        controller.moveToFullscreen(task.taskId, desktopModeWindowDecoration)
        val wct = getLatestExitDesktopWct()
        assertThat(wct.changes[task.token.asBinder()]?.windowingMode)
            .isEqualTo(WINDOWING_MODE_UNDEFINED)
    }
@@ -402,15 +403,15 @@ class DesktopTasksControllerTest : ShellTestCase() {
    fun moveToFullscreen_displayFreeform_windowingModeSetToFullscreen() {
        val task = setUpFreeformTask()
        task.configuration.windowConfiguration.displayWindowingMode = WINDOWING_MODE_FREEFORM
        controller.moveToFullscreen(task)
        val wct = getLatestWct(type = TRANSIT_CHANGE)
        controller.moveToFullscreen(task.taskId, desktopModeWindowDecoration)
        val wct = getLatestExitDesktopWct()
        assertThat(wct.changes[task.token.asBinder()]?.windowingMode)
                .isEqualTo(WINDOWING_MODE_FULLSCREEN)
    }

    @Test
    fun moveToFullscreen_nonExistentTask_doesNothing() {
        controller.moveToFullscreen(999)
        controller.moveToFullscreen(999, desktopModeWindowDecoration)
        verifyWCTNotExecuted()
    }

@@ -419,9 +420,9 @@ class DesktopTasksControllerTest : ShellTestCase() {
        val taskDefaultDisplay = setUpFreeformTask(displayId = DEFAULT_DISPLAY)
        val taskSecondDisplay = setUpFreeformTask(displayId = SECOND_DISPLAY)

        controller.moveToFullscreen(taskDefaultDisplay)
        controller.moveToFullscreen(taskDefaultDisplay.taskId, desktopModeWindowDecoration)

        with(getLatestWct(type = TRANSIT_CHANGE)) {
        with(getLatestExitDesktopWct()) {
            assertThat(changes.keys).contains(taskDefaultDisplay.token.asBinder())
            assertThat(changes.keys).doesNotContain(taskSecondDisplay.token.asBinder())
        }
@@ -808,6 +809,17 @@ class DesktopTasksControllerTest : ShellTestCase() {
        return arg.value
    }

    private fun getLatestExitDesktopWct(): WindowContainerTransaction {
        val arg = ArgumentCaptor.forClass(WindowContainerTransaction::class.java)
        if (ENABLE_SHELL_TRANSITIONS) {
            verify(exitDesktopTransitionHandler)
                    .startTransition(eq(TRANSIT_EXIT_DESKTOP_MODE), arg.capture(), any(), any())
        } else {
            verify(shellTaskOrganizer).applyTransaction(arg.capture())
        }
        return arg.value
    }

    private fun verifyWCTNotExecuted() {
        if (ENABLE_SHELL_TRANSITIONS) {
            verify(transitions, never()).startTransition(anyInt(), any(), isNull())