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

Commit 2954353d authored by William Xiao's avatar William Xiao Committed by Android (Google) Code Review
Browse files

Merge "Allow UMO to show over the dream" into main

parents 7357cad0 5429e912
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -586,7 +586,7 @@ constructor(
        coroutineScope.launch {
            communalInteractor.isCommunalShowing.collect { value ->
                isCommunalShowing = value
                updateDesiredLocation(forceNoAnimation = true)
                updateDesiredLocation()
            }
        }
    }
@@ -1149,13 +1149,17 @@ 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
                isCommunalShowing && communalInteractor.isCommunalEnabled -> LOCATION_COMMUNAL_HUB

                // 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
            }
+52 −0
Original line number 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
    fun testQsExpandedChanged_noQqsMedia() {
        // When we are looking at QQS with active media