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

Commit 8fdf47d1 authored by Beth Thibodeau's avatar Beth Thibodeau
Browse files

Fix index error when app has extra custom actions

Fixes: 210080665
Test: atest MediaDataManagerTest
Test: manual - turn on flag, play from app
Change-Id: Ie3fe59abdbe3dcd7b5441a92466c486d869b994e
parent a933cf1b
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -728,9 +728,9 @@ class MediaDataManager(
                    PlaybackState.ACTION_SKIP_TO_NEXT)
                    PlaybackState.ACTION_SKIP_TO_NEXT)


            // Then, check for custom actions
            // Then, check for custom actions
            val customActions = MutableList<MediaAction?>(4) { null }
            val customActions = MutableList<MediaAction?>(MAX_CUSTOM_ACTIONS) { null }
            var customCount = 0
            var customCount = 0
            for (i in 0..MAX_CUSTOM_ACTIONS) {
            for (i in 0..(MAX_CUSTOM_ACTIONS - 1)) {
                getCustomAction(state, packageName, controller, customCount)?.let {
                getCustomAction(state, packageName, controller, customCount)?.let {
                    customActions[customCount++] = it
                    customActions[customCount++] = it
                }
                }
+1 −1
Original line number Original line Diff line number Diff line
@@ -669,7 +669,7 @@ class MediaDataManagerTest : SysuiTestCase() {


    @Test
    @Test
    fun testPlaybackActions_noPrevNext_usesCustom() {
    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)
        whenever(mediaFlags.areMediaSessionActionsEnabled()).thenReturn(true)
        val stateActions = PlaybackState.ACTION_PLAY
        val stateActions = PlaybackState.ACTION_PLAY
        val stateBuilder = PlaybackState.Builder()
        val stateBuilder = PlaybackState.Builder()