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

Commit 4f45fb6f authored by Toshiki Kikuchi's avatar Toshiki Kikuchi
Browse files

Handle only Task changes

This CL prevents non-Task changes being handled by MultiDisplayVRTP.
As the positioner as a player only resizes the task, non-task changes
are not interesting to the player.

Bug: 408997434
Test: atest MultiDisplayVeiledResizeTaskPositionerTest
Flag: com.android.window.flags.enable_connected_displays_window_drag
Change-Id: Ic8a500289d1c972bedda93b6495ee0c86a930830
parent a563d4de
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -332,6 +332,10 @@ class MultiDisplayVeiledResizeTaskPositioner(
        finishCallback: Transitions.TransitionFinishCallback,
        finishCallback: Transitions.TransitionFinishCallback,
    ): Boolean {
    ): Boolean {
        for (change in info.changes) {
        for (change in info.changes) {
            if (change.taskInfo == null) {
                // Ignore non-task (e.g., display, activity) changes.
                continue
            }
            val sc = change.leash
            val sc = change.leash
            val endBounds = change.endAbsBounds
            val endBounds = change.endAbsBounds
            val endPosition = change.endRelOffset
            val endPosition = change.endRelOffset
+23 −5
Original line number Original line Diff line number Diff line
@@ -623,16 +623,24 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() {
    }
    }


    @Test
    @Test
    fun testStartAnimation_useEndRelOffset() = runOnUiThread {
    fun testStartAnimation_updatesLeash() = runOnUiThread {
        val changeMock = mock(TransitionInfo.Change::class.java)
        val changeMock = mock(TransitionInfo.Change::class.java)
        val nonTaskChangeMock = mock(TransitionInfo.Change::class.java)
        val taskLeash = mock(SurfaceControl::class.java)
        val nonTaskLeash = mock(SurfaceControl::class.java)
        val startTransaction = mock(Transaction::class.java)
        val startTransaction = mock(Transaction::class.java)
        val finishTransaction = mock(Transaction::class.java)
        val finishTransaction = mock(Transaction::class.java)
        val point = Point(10, 20)
        val point = Point(10, 20)
        val bounds = Rect(1, 2, 3, 4)
        val bounds = Rect(1, 2, 3, 4)
        `when`(changeMock.leash).thenReturn(mock(SurfaceControl::class.java))
        `when`(changeMock.leash).thenReturn(taskLeash)
        `when`(changeMock.endRelOffset).thenReturn(point)
        `when`(changeMock.endRelOffset).thenReturn(point)
        `when`(changeMock.endAbsBounds).thenReturn(bounds)
        `when`(changeMock.endAbsBounds).thenReturn(bounds)
        `when`(mockTransitionInfo.changes).thenReturn(listOf(changeMock))
        `when`(changeMock.taskInfo).thenReturn(ActivityManager.RunningTaskInfo())
        `when`(nonTaskChangeMock.leash).thenReturn(nonTaskLeash)
        `when`(nonTaskChangeMock.endRelOffset).thenReturn(point)
        `when`(nonTaskChangeMock.endAbsBounds).thenReturn(bounds)
        `when`(nonTaskChangeMock.taskInfo).thenReturn(null)
        `when`(mockTransitionInfo.changes).thenReturn(listOf(changeMock, nonTaskChangeMock))
        `when`(startTransaction.setWindowCrop(any(), eq(bounds.width()), eq(bounds.height())))
        `when`(startTransaction.setWindowCrop(any(), eq(bounds.width()), eq(bounds.height())))
            .thenReturn(startTransaction)
            .thenReturn(startTransaction)
        `when`(finishTransaction.setWindowCrop(any(), eq(bounds.width()), eq(bounds.height())))
        `when`(finishTransaction.setWindowCrop(any(), eq(bounds.width()), eq(bounds.height())))
@@ -646,8 +654,18 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() {
            mockFinishCallback,
            mockFinishCallback,
        )
        )


        verify(startTransaction).setPosition(any(), eq(point.x.toFloat()), eq(point.y.toFloat()))
        verify(startTransaction).setPosition(
        verify(finishTransaction).setPosition(any(), eq(point.x.toFloat()), eq(point.y.toFloat()))
            eq(taskLeash),
            eq(point.x.toFloat()),
            eq(point.y.toFloat())
        )
        verify(finishTransaction).setPosition(
            eq(taskLeash),
            eq(point.x.toFloat()),
            eq(point.y.toFloat())
        )
        verify(startTransaction, never()).setPosition(eq(nonTaskLeash), any(), any())
        verify(finishTransaction, never()).setPosition(eq(nonTaskLeash), any(), any())
        verify(changeMock).endRelOffset
        verify(changeMock).endRelOffset
    }
    }