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

Commit e264d479 authored by William Xiao's avatar William Xiao
Browse files

Reland "Allow UMO to show over the dream"

This reverts commit 7669ab8e.

The bug that required this CL to be reverted (b/322549132) was caused
by allowing scene changes even when the hub is not available. Relanding
this CL as-is with scene changes disallowed when the hub is not
available.

Bug: 322549132
Fixed: 322549132
Test: atest MediaHierarchyManagerTest
Test: manually verified the UMO shows up properly on the lockscreen
Flag: ACONFIG com.android.systemui.communal_hub STAGING
Change-Id: Ic38ba43f8b9d0fcfbed39ac1bf6ca5f2475d76c9
parent ab6d1114
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.statusbar.policy.SplitShadeStateController
import com.android.systemui.util.animation.UniqueObjectHostView
import com.android.systemui.util.kotlin.BooleanFlowOperators.and
import com.android.systemui.util.settings.SecureSettings
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -583,11 +584,13 @@ constructor(
            UserHandle.USER_ALL
        )

        // Listen to the communal UI state.
        // Listen to the communal UI state. Make sure that communal UI is showing and hub itself is
        // available, ie. not disabled and able to be shown.
        coroutineScope.launch {
            communalInteractor.isCommunalShowing.collect { value ->
            and(communalInteractor.isCommunalShowing, communalInteractor.isCommunalAvailable)
                .collect { value ->
                    isCommunalShowing = value
                updateDesiredLocation(forceNoAnimation = true)
                    updateDesiredLocation()
                }
        }
    }
@@ -1150,12 +1153,16 @@ constructor(
            when {
                mediaFlags.isSceneContainerEnabled() -> desiredLocation
                dreamOverlayActive && dreamMediaComplicationActive -> LOCATION_DREAM_OVERLAY

                // UMO should show in communal unless the shade is expanding or visible.
                isCommunalShowing && qsExpansion == 0.0f -> LOCATION_COMMUNAL_HUB
                (qsExpansion > 0.0f || inSplitShade) && !onLockscreen -> LOCATION_QS
                qsExpansion > 0.4f && onLockscreen -> LOCATION_QS
                onLockscreen && isSplitShadeExpanding() -> LOCATION_QS
                onLockscreen && isTransformingToFullShadeAndInQQS() -> LOCATION_QQS
                // TODO(b/311234666): revisit logic once interactions between the hub and
                //  shade/keyguard state are finalized

                // Communal does not have its own StatusBarState so it should always have higher
                // priority for the UMO over the lockscreen.
                isCommunalShowing -> LOCATION_COMMUNAL_HUB
                onLockscreen && allowMediaPlayerOnLockScreen -> LOCATION_LOCKSCREEN
                else -> LOCATION_QQS
+60 −0
Original line number Diff line number Diff line
@@ -538,6 +538,66 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
                )
        }

    @Test
    fun testCommunalLocation_showsOverLockscreen() =
        testScope.runTest {
            mSetFlagsRule.enableFlags(Flags.FLAG_COMMUNAL_HUB)
            kosmos.setCommunalAvailable(true)
            runCurrent()

            // Device is on lock screen.
            whenever(statusBarStateController.state).thenReturn(StatusBarState.KEYGUARD)

            // UMO goes to communal even over the lock screen.
            communalInteractor.onSceneChanged(CommunalSceneKey.Communal)
            runCurrent()
            verify(mediaCarouselController)
                .onDesiredLocationChanged(
                    eq(MediaHierarchyManager.LOCATION_COMMUNAL_HUB),
                    nullable(),
                    eq(false),
                    anyLong(),
                    anyLong()
                )
        }

    @Test
    fun testCommunalLocation_showsUntilQsExpands() =
        testScope.runTest {
            mSetFlagsRule.enableFlags(Flags.FLAG_COMMUNAL_HUB)
            kosmos.setCommunalAvailable(true)
            runCurrent()

            // Device is on lock screen.
            whenever(statusBarStateController.state).thenReturn(StatusBarState.KEYGUARD)

            communalInteractor.onSceneChanged(CommunalSceneKey.Communal)
            runCurrent()
            verify(mediaCarouselController)
                .onDesiredLocationChanged(
                    eq(MediaHierarchyManager.LOCATION_COMMUNAL_HUB),
                    nullable(),
                    eq(false),
                    anyLong(),
                    anyLong()
                )
            clearInvocations(mediaCarouselController)

            // Start opening the shade.
            mediaHierarchyManager.qsExpansion = 0.1f
            runCurrent()

            // UMO goes to the shade instead.
            verify(mediaCarouselController)
                .onDesiredLocationChanged(
                    eq(MediaHierarchyManager.LOCATION_QS),
                    any(MediaHostState::class.java),
                    eq(false),
                    anyLong(),
                    anyLong()
                )
        }

    @Test
    fun testQsExpandedChanged_noQqsMedia() {
        // When we are looking at QQS with active media