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

Commit a646052b authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Remove STLState.enableInterruptions (1/2)

Bug: 371951148
Test: atest PlatformComposeSceneTransitionLayoutTests
Flag: com.android.systemui.scene_container
Change-Id: Iaf06d1f8bd1ee30f5d7b07db67df6f469dee4b55
parent 3772e3fc
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -234,7 +234,6 @@ fun MutableSceneTransitionLayoutState(
    canHideOverlay: (OverlayKey) -> Boolean = { true },
    canReplaceOverlay: (from: OverlayKey, to: OverlayKey) -> Boolean = { _, _ -> true },
    stateLinks: List<StateLink> = emptyList(),
    enableInterruptions: Boolean = DEFAULT_INTERRUPTIONS_ENABLED,
): MutableSceneTransitionLayoutState {
    return MutableSceneTransitionLayoutStateImpl(
        initialScene,
@@ -245,7 +244,6 @@ fun MutableSceneTransitionLayoutState(
        canHideOverlay,
        canReplaceOverlay,
        stateLinks,
        enableInterruptions,
    )
}

@@ -261,9 +259,6 @@ internal class MutableSceneTransitionLayoutStateImpl(
        true
    },
    private val stateLinks: List<StateLink> = emptyList(),

    // TODO(b/290930950): Remove this flag.
    internal val enableInterruptions: Boolean = DEFAULT_INTERRUPTIONS_ENABLED,
) : MutableSceneTransitionLayoutState {
    private val creationThread: Thread = Thread.currentThread()

@@ -406,13 +401,6 @@ internal class MutableSceneTransitionLayoutStateImpl(
            transition.updateOverscrollSpecs(fromSpec = null, toSpec = null)
        }

        if (!enableInterruptions) {
            // Set the current transition.
            check(transitionStates.size == 1)
            transitionStates = listOf(transition)
            return
        }

        when (val currentState = transitionStates.last()) {
            is TransitionState.Idle -> {
                // Replace [Idle] by [transition].
@@ -755,9 +743,6 @@ internal class MutableSceneTransitionLayoutStateImpl(

private const val TAG = "SceneTransitionLayoutState"

/** Whether support for interruptions in enabled by default. */
internal const val DEFAULT_INTERRUPTIONS_ENABLED = true

/**
 * The max number of concurrent transitions. If the number of transitions goes past this number,
 * this probably means that there is a leak and we will Log.wtf before clearing the list of
+0 −4
Original line number Diff line number Diff line
@@ -337,10 +337,6 @@ sealed interface TransitionState {
        }

        internal open fun interruptionProgress(layoutImpl: SceneTransitionLayoutImpl): Float {
            if (!layoutImpl.state.enableInterruptions) {
                return 0f
            }

            if (replacedTransition != null) {
                return replacedTransition.interruptionProgress(layoutImpl)
            }
+6 −5
Original line number Diff line number Diff line
@@ -213,10 +213,6 @@ class ElementTest {
                        from(SceneA, to = SceneB) { spec = tween }
                        from(SceneB, to = SceneC) { spec = tween }
                    },

                    // Disable interruptions so that the current transition is directly removed
                    // when starting a new one.
                    enableInterruptions = false,
                )
            }

@@ -243,7 +239,12 @@ class ElementTest {
                onElement(TestElements.Bar).assertExists()

                // Start transition from SceneB to SceneC
                rule.runOnUiThread { state.setTargetScene(SceneC, coroutineScope) }
                rule.runOnUiThread {
                    // We snap to scene B so that the transition A => B is removed from the list of
                    // transitions.
                    state.snapToScene(SceneB)
                    state.setTargetScene(SceneC, coroutineScope)
                }
            }

            at(3 * frameDuration) { onElement(TestElements.Bar).assertIsNotDisplayed() }
+6 −9
Original line number Diff line number Diff line
@@ -85,15 +85,9 @@ class SceneTransitionLayoutTest {

    /** The content under test. */
    @Composable
    private fun TestContent(enableInterruptions: Boolean = true) {
    private fun TestContent() {
        coroutineScope = rememberCoroutineScope()
        layoutState = remember {
            MutableSceneTransitionLayoutState(
                SceneA,
                EmptyTestTransitions,
                enableInterruptions = enableInterruptions,
            )
        }
        layoutState = remember { MutableSceneTransitionLayoutState(SceneA, EmptyTestTransitions) }

        SceneTransitionLayout(state = layoutState, modifier = Modifier.size(LayoutSize)) {
            scene(SceneA, userActions = mapOf(Back to SceneB)) {
@@ -205,7 +199,7 @@ class SceneTransitionLayoutTest {

    @Test
    fun testSharedElement() {
        rule.setContent { TestContent(enableInterruptions = false) }
        rule.setContent { TestContent() }

        // In scene A, the shared element SharedFoo() is at the top end of the layout and has a size
        // of 50.dp.
@@ -253,6 +247,9 @@ class SceneTransitionLayoutTest {
            .isWithin(DpOffsetSubject.DefaultTolerance)
            .of(DpOffset(25.dp, 25.dp))

        // Finish the transition.
        rule.mainClock.advanceTimeBy(TestTransitionDuration / 2)

        // Animate to scene C, let the animation start then go to the middle of the transition.
        currentScene = SceneC
        rule.mainClock.advanceTimeByFrame()