Merge "Fix index error when app has extra custom actions"

This commit is contained in:
TreeHugger Robot
2021-12-10 20:31:49 +00:00
committed by Android (Google) Code Review
2 changed files with 3 additions and 3 deletions

View File

@@ -728,9 +728,9 @@ class MediaDataManager(
PlaybackState.ACTION_SKIP_TO_NEXT)
// Then, check for custom actions
val customActions = MutableList<MediaAction?>(4) { null }
val customActions = MutableList<MediaAction?>(MAX_CUSTOM_ACTIONS) { null }
var customCount = 0
for (i in 0..MAX_CUSTOM_ACTIONS) {
for (i in 0..(MAX_CUSTOM_ACTIONS - 1)) {
getCustomAction(state, packageName, controller, customCount)?.let {
customActions[customCount++] = it
}

View File

@@ -669,7 +669,7 @@ class MediaDataManagerTest : SysuiTestCase() {
@Test
fun testPlaybackActions_noPrevNext_usesCustom() {
val customDesc = arrayOf("custom 1", "custom 2", "custom 3", "custom 4")
val customDesc = arrayOf("custom 1", "custom 2", "custom 3", "custom 4", "custom 5")
whenever(mediaFlags.areMediaSessionActionsEnabled()).thenReturn(true)
val stateActions = PlaybackState.ACTION_PLAY
val stateBuilder = PlaybackState.Builder()