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
This commit is contained in:
@@ -926,17 +926,16 @@ 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 }
|
||||
.thenByDescending { !it.data.resumption }
|
||||
.thenByDescending { it.data.playbackLocation != MediaData.PLAYBACK_CAST_REMOTE }
|
||||
.thenByDescending { it.updateTime }
|
||||
.thenByDescending { it.data.notificationKey }
|
||||
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 }
|
||||
.thenByDescending { it.data.notificationKey }
|
||||
|
||||
private val mediaPlayers = TreeMap<MediaSortKey, MediaControlPanel>(comparator)
|
||||
private val mediaData: MutableMap<String, MediaSortKey> = mutableMapOf()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user