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

Commit 2f10e0cc authored by Omar Elmekkawy's avatar Omar Elmekkawy
Browse files

Break tiling on minimizing tasks through an open task transition.

TRANSIT_OPEN can initiate a minimize task transition when the task limit
is reached, this CL ensures tiling is broken when that happens.

Flag: com.android.window.flags.enable_tile_resizing
Test: Unit tests and on device testing
Bug: 416383143
Change-Id: Iabf82781776d1921ba0bc04e9487364381e282f9
parent 3d3000cc
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -498,7 +498,8 @@ class DesktopTilingWindowDecoration(
    }

    private fun isMinimized(changeMode: Int, infoType: Int): Boolean {
        return changeMode == TRANSIT_TO_BACK && infoType == TRANSIT_MINIMIZE
        return changeMode == TRANSIT_TO_BACK &&
            (infoType == TRANSIT_MINIMIZE || infoType == TRANSIT_OPEN)
    }

    private fun isEnteringPip(change: Change, transitType: Int): Boolean {
+50 −0
Original line number Diff line number Diff line
@@ -25,7 +25,9 @@ import android.testing.AndroidTestingRunner
import android.view.MotionEvent
import android.view.SurfaceControl
import android.view.WindowManager.TRANSIT_CHANGE
import android.view.WindowManager.TRANSIT_OPEN
import android.view.WindowManager.TRANSIT_PIP
import android.view.WindowManager.TRANSIT_TO_BACK
import android.view.WindowManager.TRANSIT_TO_FRONT
import android.window.TransitionInfo
import android.window.TransitionInfo.Change
@@ -615,6 +617,39 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {
        verify(tiledTaskHelper, times(1)).dispose()
    }

    @Test
    fun taskTiled_shouldBeRemoved_whenBeingMinimisedAppLimit() {
        val task1 = createPipTask()
        val stableBounds = STABLE_BOUNDS_MOCK
        whenever(displayController.getDisplayLayout(any())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
            (i.arguments.first() as Rect).set(stableBounds)
        }
        whenever(context.resources).thenReturn(resources)
        whenever(resources.getDimensionPixelSize(any())).thenReturn(split_divider_width)
        whenever(tiledTaskHelper.taskInfo).thenReturn(task1)
        whenever(tiledTaskHelper.desktopModeWindowDecoration).thenReturn(desktopWindowDecoration)
        tilingDecoration.onAppTiled(
            task1,
            desktopWindowDecoration,
            DesktopTasksController.SnapPosition.LEFT,
            BOUNDS,
            destinationBoundsOverride = null,
        )
        tilingDecoration.leftTaskResizingHelper = tiledTaskHelper
        val changeInfo = createMinimiseOpenChangeTransition(task1)

        tilingDecoration.onTransitionReady(
            transition = mock(),
            info = changeInfo,
            startTransaction = mock(),
            finishTransaction = mock(),
        )

        assertThat(tilingDecoration.leftTaskResizingHelper).isNull()
        verify(tiledTaskHelper, times(1)).dispose()
    }

    @Test
    fun tilingDivider_shouldBeShown_whenTiledTasksBecomeVisible() {
        val task1 = createVisibleTask()
@@ -855,6 +890,21 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {
            )
        }

    private fun createMinimiseOpenChangeTransition(
        task: RunningTaskInfo?,
        type: Int = TRANSIT_OPEN,
    ) =
        TransitionInfo(type, /* flags= */ 0).apply {
            addChange(
                Change(mock(), mock()).apply {
                    mode = TRANSIT_TO_BACK
                    parent = null
                    taskInfo = task
                    flags = flags
                }
            )
        }

    private fun createTransitFrontTransition(
        task1: RunningTaskInfo?,
        task2: RunningTaskInfo?,