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

Commit d40c740f authored by Jorge Gil's avatar Jorge Gil
Browse files

Exit immersive state on rotation

Flag: com.android.window.flags.enable_fully_immersive_in_desktop
Fix: 373476314
Test: enter desktop immersive, rotation, check drag-move works
Change-Id: I1f9a8e93933e8379fb51adc94443dca776187f0d
parent 235d98ec
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -307,8 +307,8 @@ class DesktopFullImmersiveTransitionHandler(
        }

        // Check if this is a direct immersive enter/exit transition.
        val state = this.state ?: return
        if (transition == state.transition) {
        if (transition == state?.transition) {
            val state = requireState()
            val startBounds = info.changes.first { c -> c.taskInfo?.taskId == state.taskId }
                .startAbsBounds
            logV("Direct move for task ${state.taskId} in ${state.direction} direction verified")
@@ -334,6 +334,21 @@ class DesktopFullImmersiveTransitionHandler(
                    }
                }
            }
            return
        }

        // Check if this is an untracked exit transition, like display rotation.
        info.changes
            .filter { c -> c.taskInfo != null }
            .filter { c -> desktopRepository.isTaskInFullImmersiveState(c.taskInfo!!.taskId) }
            .filter { c -> c.startRotation != c.endRotation }
            .forEach { c ->
                logV("Detected immersive exit due to rotation for task: ${c.taskInfo!!.taskId}")
                desktopRepository.setTaskInFullImmersiveState(
                    displayId = c.taskInfo!!.displayId,
                    taskId = c.taskInfo!!.taskId,
                    immersive = false
                )
            }
    }

+25 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.SetFlagsRule
import android.testing.AndroidTestingRunner
import android.view.Display.DEFAULT_DISPLAY
import android.view.Surface
import android.view.SurfaceControl
import android.view.WindowManager.TRANSIT_CHANGE
import android.view.WindowManager.TransitionFlags
@@ -206,6 +207,30 @@ class DesktopFullImmersiveTransitionHandlerTest : ShellTestCase() {
        assertThat(desktopRepository.removeBoundsBeforeMaximize(task.taskId)).isNull()
    }

    @Test
    fun onTransitionReady_displayRotation_exitsImmersive() {
        val task = createFreeformTask()
        desktopRepository.setTaskInFullImmersiveState(
            displayId = task.displayId,
            taskId = task.taskId,
            immersive = true
        )

        immersiveHandler.onTransitionReady(
            transition = mock(IBinder::class.java),
            info = createTransitionInfo(
                changes = listOf(
                    TransitionInfo.Change(task.token, SurfaceControl()).apply {
                        taskInfo = task
                        setRotation(/* start= */ Surface.ROTATION_0, /* end= */ Surface.ROTATION_90)
                    }
                )
            )
        )

        assertThat(desktopRepository.isTaskInFullImmersiveState(task.taskId)).isFalse()
    }

    @Test
    fun enterImmersive_inProgress_ignores() {
        val task = createFreeformTask()