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

Commit 5bebc823 authored by lyn's avatar lyn
Browse files

Fix NPEs after ENRController initializes bundle row

Bug: 399736937
Test: compile and send bundled test notif
Flag: com.android.systemui.notification_bundle_ui
Change-Id: I36f190776b8656ba2ed9f0d12900ee4f88a5ab7a
parent ad044d91
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -690,6 +690,10 @@ public class NotificationShelf extends ActivatableNotificationView {
        StatusBarIconView icon = NotificationBundleUi.isEnabled()
                ? row.getEntryAdapter().getIcons().getShelfIcon()
                : row.getEntryLegacy().getIcons().getShelfIcon();
        if (icon == null) {
            // TODO(b/399736937) remove this when adding bundle icon implementation
            return;
        }
        boolean needsContinuousClipping = ViewState.isAnimatingY(icon) && !mAmbientState.isDozing();
        boolean isContinuousClipping = icon.getTag(TAG_CONTINUOUS_CLIPPING) != null;
        if (needsContinuousClipping && !isContinuousClipping) {
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ class BundleEntryAdapter(

    override fun getIcons(): IconPack? {
        // TODO(b/396446620): implement bundle icons
        return null
        return IconPack.buildEmptyPack(null)
    }

    override fun isColorized(): Boolean {
+14 −11
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.notification.collection.coordinator

import com.android.systemui.statusbar.notification.collection.BundleEntry
import com.android.systemui.statusbar.notification.collection.GroupEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry
import com.android.systemui.statusbar.notification.collection.NotifLiveDataStoreImpl
@@ -44,21 +45,23 @@ internal constructor(private val notifLiveDataStoreImpl: NotifLiveDataStoreImpl)
    }

    private fun onAfterRenderList(entries: List<PipelineEntry>) {
        val flatEntryList = flattenedEntryList(entries)
        val flatEntryList = flattenEntrySequence(entries).toList()
        notifLiveDataStoreImpl.setActiveNotifList(flatEntryList)
    }

    private fun flattenedEntryList(entries: List<PipelineEntry>) =
        mutableListOf<NotificationEntry>().also { list ->
    private fun flattenEntrySequence(entries: List<PipelineEntry>): Sequence<NotificationEntry> = sequence {
        entries.forEach { entry ->
            when (entry) {
                    is NotificationEntry -> list.add(entry)
                is NotificationEntry -> yield(entry)
                is GroupEntry -> {
                        list.add(entry.requireSummary)
                        list.addAll(entry.children)
                    yield(entry.requireSummary)
                    yieldAll(entry.children)
                }
                    else -> error("Unexpected entry $entry")
                is BundleEntry -> {
                    yieldAll(flattenEntrySequence(entry.children))
                }
            }
        }
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.notification.collection.coordinator
import com.android.app.tracing.traceSection
import com.android.server.notification.Flags.screenshareNotificationHiding
import com.android.systemui.Flags.screenshareNotificationHidingBugFix
import com.android.systemui.statusbar.notification.collection.BundleEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry
import com.android.systemui.statusbar.notification.collection.NotifPipeline
import com.android.systemui.statusbar.notification.collection.coordinator.dagger.CoordinatorScope
@@ -67,6 +68,10 @@ internal constructor(
                screenshareNotificationHidingBugFix() &&
                sensitiveNotificationProtectionController.isSensitiveStateActive
        entries.forEach {
            if (it is BundleEntry) {
                // TODO(b/399736937) calculate based on notifs inside bundle
                return@forEach
            }
            val section = checkNotNull(it.section) { "Null section for ${it.key}" }
            val entry = checkNotNull(it.representativeEntry) { "Null notif entry for ${it.key}" }
            val isSilent = section.bucket == BUCKET_SILENT
+11 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import com.android.systemui.log.core.LogLevel.DEBUG
import com.android.systemui.log.core.LogLevel.INFO
import com.android.systemui.log.core.LogLevel.WARNING
import com.android.systemui.statusbar.notification.NotifPipelineFlags
import com.android.systemui.statusbar.notification.collection.BundleEntry
import com.android.systemui.statusbar.notification.collection.GroupEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntry
@@ -310,6 +311,13 @@ class ShadeListBuilderLogger @Inject constructor(

    val logRankInFinalList = Compile.IS_DEBUG && notifPipelineFlags.isDevLoggingEnabled()

    private fun getRankString(entry: PipelineEntry): String {
        if (entry is BundleEntry) {
            return entry.key + ":" + entry.children.getOrNull(0)?.representativeEntry!!.ranking.rank
        }
        return entry.representativeEntry!!.ranking.rank.toString()
    }

    fun logFinalList(entries: List<PipelineEntry>) {
        if (entries.isEmpty()) {
            buffer.log(TAG, DEBUG, {}, { "(empty list)" })
@@ -320,11 +328,11 @@ class ShadeListBuilderLogger @Inject constructor(
                int1 = i
                str1 = entry.logKey
                bool1 = logRankInFinalList
                int2 = entry.representativeEntry!!.ranking.rank
                str2 = getRankString(entry)
            }, {
                "[$int1] $str1".let { if (bool1) "$it rank=$int2" else it }
                "[$int1] $str1".let { if (bool1) "$it rank=$str2" else it }
            })

            // TODO(b/399736937) rank bundles as -1 and log bundle children rankings
            if (entry is GroupEntry) {
                entry.summary?.let {
                    buffer.log(TAG, DEBUG, {
Loading