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

Commit b7c83a6e authored by Julia Tuttle's avatar Julia Tuttle
Browse files

Don't crash trying to render ineligible AOD RONs

Fixes: 392058444
Test: manual: Notify.apk, music + ongoing + autobundle + colorize bg
Flag: com.android.systemui.aod_ui_rich_ongoing
Change-Id: I779850cddee4e0325b6bfcf17274af06fd1c8129
parent f5c98229
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -57,11 +57,13 @@ fun AODPromotedNotification(viewModelFactory: AODPromotedNotificationViewModel.F
    val content = viewModel.content ?: return

    key(content.identity) {
        val layoutResource = content.layoutResource ?: return

        AndroidView(
            factory = { context ->
                LayoutInflater.from(context)
                    .inflate(content.layoutResource, /* root= */ null)
                    .apply { setTag(viewUpdaterTagId, AODPromotedNotificationViewUpdater(this)) }
                LayoutInflater.from(context).inflate(layoutResource, /* root= */ null).apply {
                    setTag(viewUpdaterTagId, AODPromotedNotificationViewUpdater(this))
                }
            },
            update = { view ->
                (view.getTag(viewUpdaterTagId) as AODPromotedNotificationViewUpdater).update(
@@ -72,7 +74,7 @@ fun AODPromotedNotification(viewModelFactory: AODPromotedNotificationViewModel.F
    }
}

private val PromotedNotificationContentModel.layoutResource: Int
private val PromotedNotificationContentModel.layoutResource: Int?
    get() {
        return if (Flags.notificationsRedesignTemplates()) {
            when (style) {
@@ -80,7 +82,7 @@ private val PromotedNotificationContentModel.layoutResource: Int
                Style.BigText -> R.layout.notification_2025_template_expanded_big_text
                Style.Call -> R.layout.notification_2025_template_expanded_call
                Style.Progress -> R.layout.notification_2025_template_expanded_progress
                Style.Ineligible -> 0
                Style.Ineligible -> null
            }
        } else {
            when (style) {
@@ -88,7 +90,7 @@ private val PromotedNotificationContentModel.layoutResource: Int
                Style.BigText -> R.layout.notification_template_material_big_text
                Style.Call -> R.layout.notification_template_material_big_call
                Style.Progress -> R.layout.notification_template_material_progress
                Style.Ineligible -> 0
                Style.Ineligible -> null
            }
        }
    }