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

Commit 5429e912 authored by William Xiao's avatar William Xiao
Browse files

Allow UMO to show over the dream

When dreaming, the shade can be pulled down from the top of the screen
and the UMO should appear there. In MediaHierarcyManager, this case is
handled by the condition of:
(qsExpansion > 0.0f || inSplitShade) && !onLockscreen
Since Tangor uses split shade, this condition will be true when
dreaming.

The glanceable hub can be opened from on top of the dream, so in order
to allow the UMO to show up there, we change the logic so the hub has a
higher priority, as long as the shade is closed.

Bug: 322549132
Fixed: 322549132
Test: atest MediaHierarchyManagerTest
Flag: ACONFIG com.android.systemui.communal_hub STAGING
Change-Id: I01098d16cdf8fe9f511c18aed95b411d2ba6f969
parent 976207c4
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -586,7 +586,7 @@ constructor(
        coroutineScope.launch {
        coroutineScope.launch {
            communalInteractor.isCommunalShowing.collect { value ->
            communalInteractor.isCommunalShowing.collect { value ->
                isCommunalShowing = value
                isCommunalShowing = value
                updateDesiredLocation(forceNoAnimation = true)
                updateDesiredLocation()
            }
            }
        }
        }
    }
    }
@@ -1149,13 +1149,17 @@ constructor(
            when {
            when {
                mediaFlags.isSceneContainerEnabled() -> desiredLocation
                mediaFlags.isSceneContainerEnabled() -> desiredLocation
                dreamOverlayActive && dreamMediaComplicationActive -> LOCATION_DREAM_OVERLAY
                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.0f || inSplitShade) && !onLockscreen -> LOCATION_QS
                qsExpansion > 0.4f && onLockscreen -> LOCATION_QS
                qsExpansion > 0.4f && onLockscreen -> LOCATION_QS
                onLockscreen && isSplitShadeExpanding() -> LOCATION_QS
                onLockscreen && isSplitShadeExpanding() -> LOCATION_QS
                onLockscreen && isTransformingToFullShadeAndInQQS() -> LOCATION_QQS
                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
                isCommunalShowing && communalInteractor.isCommunalEnabled -> LOCATION_COMMUNAL_HUB
                // priority for the UMO over the lockscreen.
                isCommunalShowing -> LOCATION_COMMUNAL_HUB
                onLockscreen && allowMediaPlayerOnLockScreen -> LOCATION_LOCKSCREEN
                onLockscreen && allowMediaPlayerOnLockScreen -> LOCATION_LOCKSCREEN
                else -> LOCATION_QQS
                else -> LOCATION_QQS
            }
            }
+52 −0
Original line number Original line Diff line number Diff line
@@ -531,6 +531,58 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
                )
                )
        }
        }


    @Test
    fun testCommunalLocation_showsOverLockscreen() =
        testScope.runTest {
            // 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 {
            // 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
    @Test
    fun testQsExpandedChanged_noQqsMedia() {
    fun testQsExpandedChanged_noQqsMedia() {
        // When we are looking at QQS with active media
        // When we are looking at QQS with active media