From f75175ff9190ad597126bf1a6d39e2bacda61703 Mon Sep 17 00:00:00 2001 From: Beth Thibodeau Date: Thu, 21 May 2020 16:52:04 -0400 Subject: Make sure actions have icons This would crash if the icon was not set. Instead, skip actions if there is no icon associated with it. Fixes: 157247618 Test: manual Change-Id: Ib5ab5087ba109954f13dff818bd25b2918bc4f03 --- .../SystemUI/src/com/android/systemui/media/MediaDataManager.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt index 8cbe3ecf5387..009f5494cefe 100644 --- a/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt +++ b/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt @@ -199,12 +199,17 @@ class MediaDataManager @Inject constructor( val actionIcons: MutableList = ArrayList() val actions = notif.actions val actionsToShowCollapsed = notif.extras.getIntArray( - Notification.EXTRA_COMPACT_ACTIONS)?.toList() ?: emptyList() + Notification.EXTRA_COMPACT_ACTIONS)?.toMutableList() ?: mutableListOf() // TODO: b/153736623 look into creating actions when this isn't a media style notification val packageContext: Context = sbn.getPackageContext(context) if (actions != null) { - for (action in actions) { + for ((index, action) in actions.withIndex()) { + if (action.getIcon() == null) { + Log.i(TAG, "No icon for action $index ${action.title}") + actionsToShowCollapsed.remove(index) + continue + } val mediaAction = MediaAction( action.getIcon().loadDrawable(packageContext), action.actionIntent, -- cgit v1.2.3-59-g8ed1b