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

Commit 2e58b462 authored by Justin Weir's avatar Justin Weir
Browse files

Added MediaData.active to the media carousel comparator

Active apps should be prioritized above media recommendations in the media carousel based on go/media-teamfood-test.

Bug: 209148780
Test: augmented the sort test to fail without this change and pass with it
Change-Id: I556f45b423920a625418870355703ff167efaffd
parent fe8cf737
Loading
Loading
Loading
Loading
+10 −11
Original line number Diff line number Diff line
@@ -926,13 +926,12 @@ internal object MediaPlayerData {
        val isSsReactivated: Boolean = false
    )

    private val comparator =
            compareByDescending<MediaSortKey> { it.data.isPlaying == true &&
                        it.data.playbackLocation == MediaData.PLAYBACK_LOCAL }
                    .thenByDescending { it.data.isPlaying == true &&
                        it.data.playbackLocation == MediaData.PLAYBACK_CAST_LOCAL
                    }
                    .thenByDescending { if (shouldPrioritizeSs) it.isSsMediaRec else !it.isSsMediaRec }
    private val comparator = compareByDescending<MediaSortKey> {
            it.data.isPlaying == true && it.data.playbackLocation == MediaData.PLAYBACK_LOCAL }
        .thenByDescending {
            it.data.isPlaying == true && it.data.playbackLocation == MediaData.PLAYBACK_CAST_LOCAL }
        .thenByDescending { it.data.active }
        .thenByDescending { shouldPrioritizeSs == it.isSsMediaRec }
        .thenByDescending { !it.data.resumption }
        .thenByDescending { it.data.playbackLocation != MediaData.PLAYBACK_CAST_REMOTE }
        .thenByDescending { it.updateTime }
+9 −4
Original line number Diff line number Diff line
@@ -122,6 +122,11 @@ class MediaCarouselControllerTest : SysuiTestCase() {
                        playbackLocation = MediaData.PLAYBACK_CAST_REMOTE, resumption = false),
                5000L)

        val active = Triple("active",
            DATA.copy(active = true, isPlaying = false,
                playbackLocation = MediaData.PLAYBACK_LOCAL, resumption = true),
            250L)

        val resume1 = Triple("resume 1",
            DATA.copy(active = false, isPlaying = false,
                    playbackLocation = MediaData.PLAYBACK_LOCAL, resumption = true),
@@ -140,7 +145,7 @@ class MediaCarouselControllerTest : SysuiTestCase() {
        // Resume controls, by last active

        val expected = listOf(playingLocal, playingCast, pausedCast, pausedLocal, playingRcn,
                pausedRcn, resume2, resume1)
                pausedRcn, active, resume2, resume1)

        expected.forEach {
            clock.setCurrentTimeMillis(it.third)
@@ -173,9 +178,9 @@ class MediaCarouselControllerTest : SysuiTestCase() {
        MediaPlayerData.addMediaRecommendation(SMARTSPACE_KEY, EMPTY_SMARTSPACE_MEDIA_DATA, panel,
            false, clock)

        // Then it should be shown at the end of the carousel
        val size = MediaPlayerData.playerKeys().size
        assertTrue(MediaPlayerData.playerKeys().elementAt(size - 1).isSsMediaRec)
        // Then it should be shown at the end of the carousel's active entries
        val idx = MediaPlayerData.playerKeys().count { it.data.active } - 1
        assertTrue(MediaPlayerData.playerKeys().elementAt(idx).isSsMediaRec)
    }

    @Test