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

Commit d0eaaa79 authored by Darrell Shi's avatar Darrell Shi
Browse files

Do not show UMO resumption state in the hub

This will also allow the MediaCarouselController to properly reset the
"settings cog" when transitioning to the hub.

Bug: 322551201
Fix: 322551201
Test: manually; see video in bug
Flag: ACONFIG com.android.systemui.communal_hub STAGING
Change-Id: Id5f29f70f81e30c24525bdbd86ab975c2de0cfe8
parent 80094cc2
Loading
Loading
Loading
Loading
+8 −8
Original line number Original line Diff line number Diff line
@@ -72,7 +72,7 @@ class CommunalMediaRepositoryImplTest : SysuiTestCase() {
        testScope.runTest {
        testScope.runTest {
            val mediaModel = collectLastValue(underTest.mediaModel)
            val mediaModel = collectLastValue(underTest.mediaModel)
            runCurrent()
            runCurrent()
            assertThat(mediaModel()?.hasAnyMediaOrRecommendation).isFalse()
            assertThat(mediaModel()?.hasActiveMediaOrRecommendation).isFalse()
        }
        }


    @Test
    @Test
@@ -84,16 +84,16 @@ class CommunalMediaRepositoryImplTest : SysuiTestCase() {
            // Initial value is false.
            // Initial value is false.
            val mediaModel = collectLastValue(underTest.mediaModel)
            val mediaModel = collectLastValue(underTest.mediaModel)
            runCurrent()
            runCurrent()
            assertThat(mediaModel()?.hasAnyMediaOrRecommendation).isFalse()
            assertThat(mediaModel()?.hasActiveMediaOrRecommendation).isFalse()


            // Change to media available and notify the listener.
            // Change to media available and notify the listener.
            whenever(mediaDataManager.hasAnyMediaOrRecommendation()).thenReturn(true)
            whenever(mediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true)
            whenever(mediaData.createdTimestampMillis).thenReturn(1234L)
            whenever(mediaData.createdTimestampMillis).thenReturn(1234L)
            mediaDataListenerCaptor.value.onMediaDataLoaded("key", null, mediaData)
            mediaDataListenerCaptor.value.onMediaDataLoaded("key", null, mediaData)
            runCurrent()
            runCurrent()


            // Media active now returns true.
            // Media active now returns true.
            assertThat(mediaModel()?.hasAnyMediaOrRecommendation).isTrue()
            assertThat(mediaModel()?.hasActiveMediaOrRecommendation).isTrue()
            assertThat(mediaModel()?.createdTimestampMillis).isEqualTo(1234L)
            assertThat(mediaModel()?.createdTimestampMillis).isEqualTo(1234L)
        }
        }


@@ -104,20 +104,20 @@ class CommunalMediaRepositoryImplTest : SysuiTestCase() {
            verify(mediaDataManager).addListener(mediaDataListenerCaptor.capture())
            verify(mediaDataManager).addListener(mediaDataListenerCaptor.capture())


            // Change to media available and notify the listener.
            // Change to media available and notify the listener.
            whenever(mediaDataManager.hasAnyMediaOrRecommendation()).thenReturn(true)
            whenever(mediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true)
            mediaDataListenerCaptor.value.onMediaDataLoaded("key", null, mediaData)
            mediaDataListenerCaptor.value.onMediaDataLoaded("key", null, mediaData)
            runCurrent()
            runCurrent()


            // Media active now returns true.
            // Media active now returns true.
            val mediaModel = collectLastValue(underTest.mediaModel)
            val mediaModel = collectLastValue(underTest.mediaModel)
            assertThat(mediaModel()?.hasAnyMediaOrRecommendation).isTrue()
            assertThat(mediaModel()?.hasActiveMediaOrRecommendation).isTrue()


            // Change to media unavailable and notify the listener.
            // Change to media unavailable and notify the listener.
            whenever(mediaDataManager.hasAnyMediaOrRecommendation()).thenReturn(false)
            whenever(mediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(false)
            mediaDataListenerCaptor.value.onMediaDataRemoved("key")
            mediaDataListenerCaptor.value.onMediaDataRemoved("key")
            runCurrent()
            runCurrent()


            // Media active now returns false.
            // Media active now returns false.
            assertThat(mediaModel()?.hasAnyMediaOrRecommendation).isFalse()
            assertThat(mediaModel()?.hasActiveMediaOrRecommendation).isFalse()
        }
        }
}
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -21,21 +21,21 @@ import com.android.systemui.log.table.TableRowLogger


/** Data model of media on the communal hub. */
/** Data model of media on the communal hub. */
data class CommunalMediaModel(
data class CommunalMediaModel(
    val hasAnyMediaOrRecommendation: Boolean,
    val hasActiveMediaOrRecommendation: Boolean,
    val createdTimestampMillis: Long = 0L,
    val createdTimestampMillis: Long = 0L,
) : Diffable<CommunalMediaModel> {
) : Diffable<CommunalMediaModel> {
    companion object {
    companion object {
        val INACTIVE =
        val INACTIVE =
            CommunalMediaModel(
            CommunalMediaModel(
                hasAnyMediaOrRecommendation = false,
                hasActiveMediaOrRecommendation = false,
            )
            )
    }
    }


    override fun logDiffs(prevVal: CommunalMediaModel, row: TableRowLogger) {
    override fun logDiffs(prevVal: CommunalMediaModel, row: TableRowLogger) {
        if (hasAnyMediaOrRecommendation != prevVal.hasAnyMediaOrRecommendation) {
        if (hasActiveMediaOrRecommendation != prevVal.hasActiveMediaOrRecommendation) {
            row.logChange(
            row.logChange(
                columnName = "isMediaActive",
                columnName = "isMediaActive",
                value = hasAnyMediaOrRecommendation,
                value = hasActiveMediaOrRecommendation,
            )
            )
        }
        }


+2 −2
Original line number Original line Diff line number Diff line
@@ -73,10 +73,10 @@ constructor(
        )
        )


    private fun updateMediaModel(data: MediaData? = null) {
    private fun updateMediaModel(data: MediaData? = null) {
        if (mediaDataManager.hasAnyMediaOrRecommendation()) {
        if (mediaDataManager.hasActiveMediaOrRecommendation()) {
            _mediaModel.value =
            _mediaModel.value =
                CommunalMediaModel(
                CommunalMediaModel(
                    hasAnyMediaOrRecommendation = true,
                    hasActiveMediaOrRecommendation = true,
                    createdTimestampMillis = data?.createdTimestampMillis ?: 0L,
                    createdTimestampMillis = data?.createdTimestampMillis ?: 0L,
                )
                )
        } else {
        } else {
+1 −1
Original line number Original line Diff line number Diff line
@@ -318,7 +318,7 @@ constructor(
            )
            )


            // Add UMO
            // Add UMO
            if (media.hasAnyMediaOrRecommendation) {
            if (media.hasActiveMediaOrRecommendation) {
                ongoingContent.add(
                ongoingContent.add(
                    CommunalContentModel.Umo(
                    CommunalContentModel.Umo(
                        createdTimestampMillis = media.createdTimestampMillis,
                        createdTimestampMillis = media.createdTimestampMillis,
+1 −1
Original line number Original line Diff line number Diff line
@@ -87,7 +87,7 @@ constructor(
        with(mediaHost) {
        with(mediaHost) {
            expansion = MediaHostState.EXPANDED
            expansion = MediaHostState.EXPANDED
            expandedMatchesParentHeight = true
            expandedMatchesParentHeight = true
            showsOnlyActiveMedia = false
            showsOnlyActiveMedia = true
            falsingProtectionNeeded = false
            falsingProtectionNeeded = false
            init(MediaHierarchyManager.LOCATION_COMMUNAL_HUB)
            init(MediaHierarchyManager.LOCATION_COMMUNAL_HUB)
        }
        }
Loading