From 8fdf47d10af5c213363d6e7b50cfff871cb3c681 Mon Sep 17 00:00:00 2001 From: Beth Thibodeau Date: Fri, 10 Dec 2021 13:15:26 -0500 Subject: [PATCH] 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 --- .../src/com/android/systemui/media/MediaDataManager.kt | 4 ++-- .../src/com/android/systemui/media/MediaDataManagerTest.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt index 49a63c3eaa575..d926e7de358da 100644 --- a/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt +++ b/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt @@ -728,9 +728,9 @@ class MediaDataManager( PlaybackState.ACTION_SKIP_TO_NEXT) // Then, check for custom actions - val customActions = MutableList(4) { null } + val customActions = MutableList(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 } diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/MediaDataManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/MediaDataManagerTest.kt index d0b957c6e5f92..649ee872c99e2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/MediaDataManagerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/media/MediaDataManagerTest.kt @@ -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()