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

Commit f75175ff authored by Beth Thibodeau's avatar Beth Thibodeau
Browse files

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
parent 175d91f6
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -199,12 +199,17 @@ class MediaDataManager @Inject constructor(
        val actionIcons: MutableList<MediaAction> = ArrayList()
        val actions = notif.actions
        val actionsToShowCollapsed = notif.extras.getIntArray(
                Notification.EXTRA_COMPACT_ACTIONS)?.toList() ?: emptyList()
                Notification.EXTRA_COMPACT_ACTIONS)?.toMutableList() ?: mutableListOf<Int>()
        // 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,