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

Commit 03d3ea55 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge changes I71af353f,I293f27e0,I9c49c437,I4503d00f into main

* changes:
  Fix NPE for Groups within Bundles
  Fix NPE for BundleEntryAdapter when creating MenuViews
  Attach children to NodeSpec of BundleEntry
  Init and show bundle header and set ENR on entry
parents 7e705d7d f17a837b
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -33,8 +33,7 @@ class BundleEntry(spec: BundleSpec) : PipelineEntry(spec.key) {
    // TODO(b/394483200): move NotificationEntry's implementation to PipelineEntry?
    val isSensitive: MutableStateFlow<Boolean> = MutableStateFlow(false)

    // TODO (b/389839319): implement the row
    val row: ExpandableNotificationRow? = null
    var row: ExpandableNotificationRow? = null

    private val _children: MutableList<ListEntry> = ArrayList()
    val children: List<ListEntry> = Collections.unmodifiableList(_children)
+30 −25
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.RowInflaterTask
import com.android.systemui.statusbar.notification.row.RowInflaterTaskLogger
import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotificationRowComponent
import com.android.systemui.statusbar.notification.row.domain.interactor.BundleInteractor
import com.android.systemui.statusbar.notification.row.ui.viewmodel.BundleHeaderViewModel
import com.android.systemui.statusbar.notification.stack.NotificationListContainer
import com.android.systemui.util.time.SystemClock
import dagger.Lazy
@@ -35,11 +37,14 @@ import javax.inject.Provider

/**
 * Class that handles inflating BundleEntry view and controller, for use by NodeSpecBuilder.
 * TODO(b/402628023) Make this class dumpable and dump its map so that we can see the
 * "inflation pending" state per bundle
 *
 * TODO(b/402628023) Make this class dumpable and dump its map so that we can see the "inflation
 *   pending" state per bundle
 */
@SysUISingleton
class BundleBarn @Inject constructor(
class BundleBarn
@Inject
constructor(
    private val rowComponent: ExpandableNotificationRowComponent.Builder,
    private val rowInflaterTaskProvider: Provider<RowInflaterTask>,
    private val listContainer: NotificationListContainer,
@@ -47,13 +52,11 @@ class BundleBarn @Inject constructor(
    val systemClock: SystemClock,
    val logger: RowInflaterTaskLogger,
    val userTracker: UserTracker,
    private val presenterLazy: Lazy<NotificationPresenter?>? = null
    private val presenterLazy: Lazy<NotificationPresenter?>? = null,
) {
    /**
     * Map of [BundleEntry] key to [NodeController]:
     * no key -> not started
     * key maps to null -> inflating
     * key maps to controller -> inflated
     * Map of [BundleEntry] key to [NodeController]: no key -> not started key maps to null ->
     * inflating key maps to controller -> inflated
     */
    private val keyToControllerMap = mutableMapOf<String, NotifViewController?>()

@@ -61,9 +64,7 @@ class BundleBarn @Inject constructor(
        debugBundleLog(TAG, { s })
    }

    /**
     * Build view and controller for BundleEntry.
     */
    /** Build view and controller for BundleEntry. */
    fun inflateBundleEntry(bundleEntry: BundleEntry) {
        debugLog("inflateBundleEntry: ${bundleEntry.key}")
        if (keyToControllerMap.containsKey(bundleEntry.key)) {
@@ -75,36 +76,40 @@ class BundleBarn @Inject constructor(
        val inflationFinishedListener: (ExpandableNotificationRow) -> Unit = { row ->
            // A subset of NotificationRowBinderImpl.inflateViews
            debugLog("finished inflating: ${bundleEntry.key}")
            val component = rowComponent
            bundleEntry.row = row
            val component =
                rowComponent
                    .expandableNotificationRow(row)
                    .pipelineEntry(bundleEntry)
                    .onExpandClickListener(presenterLazy?.get())
                    .build()
            val controller =
                component.expandableNotificationRowController
            val controller = component.expandableNotificationRowController
            controller.init(bundleEntry)
            keyToControllerMap[bundleEntry.key] = controller

            // TODO(389839492): Construct BundleHeaderViewModel (or even ENRViewModel) by dagger
            row.initBundleHeader(
                BundleHeaderViewModel(BundleInteractor(bundleEntry.bundleRepository))
            )
        }
        debugLog("calling inflate: ${bundleEntry.key}")
        keyToControllerMap[bundleEntry.key] = null
        rowInflaterTaskProvider.get().inflate(
            context, parent, bundleEntry, inflationFinishedListener
        )
        rowInflaterTaskProvider
            .get()
            .inflate(context, parent, bundleEntry, inflationFinishedListener)
    }

    /**
     * Return true if finished inflating.
     */
    /** Return true if finished inflating. */
    fun isInflated(bundleEntry: BundleEntry): Boolean {
        return keyToControllerMap[bundleEntry.key] != null
    }

    /**
     * Return ExpandableNotificationRowController for BundleEntry.
     */
    /** Return ExpandableNotificationRowController for BundleEntry. */
    fun requireNodeController(bundleEntry: BundleEntry): NodeController {
        debugLog("requireNodeController: ${bundleEntry.key}" +
                "controller: ${keyToControllerMap[bundleEntry.key]}")
        debugLog(
            "requireNodeController: ${bundleEntry.key}" +
                "controller: ${keyToControllerMap[bundleEntry.key]}"
        )
        return keyToControllerMap[bundleEntry.key]
            ?: error("No view has been registered for bundle: ${bundleEntry.key}")
    }
+63 −59
Original line number Diff line number Diff line
@@ -16,24 +16,24 @@

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

import com.android.app.tracing.traceSection
import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager
import com.android.systemui.statusbar.notification.collection.BundleEntry
import com.android.systemui.statusbar.notification.collection.GroupEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection
import com.android.systemui.statusbar.notification.collection.provider.SectionHeaderVisibilityProvider
import com.android.systemui.util.Compile
import com.android.app.tracing.traceSection
import com.android.systemui.statusbar.notification.collection.BundleEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry

/**
 * Converts a notif list (the output of the ShadeListBuilder) into a NodeSpec, an abstract
 * representation of which views should be present in the shade. This spec will later be consumed
 * by the ViewDiffer, which will add and remove views until the shade matches the spec. Up until
 * this point, the pipeline has dealt with pure data representations of notifications (in the
 * form of NotificationEntries). In this step, NotificationEntries finally become associated with
 * the views that will represent them. In addition, we add in any non-notification views that also
 * need to present in the shade, notably the section headers.
 * representation of which views should be present in the shade. This spec will later be consumed by
 * the ViewDiffer, which will add and remove views until the shade matches the spec. Up until this
 * point, the pipeline has dealt with pure data representations of notifications (in the form of
 * NotificationEntries). In this step, NotificationEntries finally become associated with the views
 * that will represent them. In addition, we add in any non-notification views that also need to
 * present in the shade, notably the section headers.
 */
class NodeSpecBuilder(
    private val mediaContainerController: MediaContainerController,
@@ -41,14 +41,12 @@ class NodeSpecBuilder(
    private val sectionHeaderVisibilityProvider: SectionHeaderVisibilityProvider,
    private val viewBarn: NotifViewBarn,
    private val bundleBarn: BundleBarn,
    private val logger: NodeSpecBuilderLogger
    private val logger: NodeSpecBuilderLogger,
) {
    private var lastSections = setOf<NotifSection?>()

    fun buildNodeSpec(
        rootController: NodeController,
        notifList: List<PipelineEntry>
    ): NodeSpec = traceSection("NodeSpecBuilder.buildNodeSpec") {
    fun buildNodeSpec(rootController: NodeController, notifList: List<PipelineEntry>): NodeSpec =
        traceSection("NodeSpecBuilder.buildNodeSpec") {
            val root = NodeSpecImpl(null, rootController)

            // The media container should be added as the first child of the root node
@@ -72,7 +70,9 @@ class NodeSpecBuilder(

                // If this notif begins a new section, first add the section's header view
                if (section != currentSection) {
                if (section.headerController != currentSection?.headerController && showHeaders) {
                    if (
                        section.headerController != currentSection?.headerController && showHeaders
                    ) {
                        section.headerController?.let { headerController ->
                            root.children.add(NodeSpecImpl(root, headerController))
                            if (Compile.IS_DEBUG) {
@@ -102,12 +102,16 @@ class NodeSpecBuilder(
            return@traceSection root
        }

    private fun buildNotifNode(parent: NodeSpec, entry: PipelineEntry): NodeSpec = when (entry) {
    private fun buildNotifNode(parent: NodeSpec, entry: PipelineEntry): NodeSpec =
        when (entry) {
            is NotificationEntry -> NodeSpecImpl(parent, viewBarn.requireNodeController(entry))
            is GroupEntry ->
                NodeSpecImpl(parent, viewBarn.requireNodeController(checkNotNull(entry.summary)))
                    .apply { entry.children.forEach { children.add(buildNotifNode(this, it)) } }
        is BundleEntry -> NodeSpecImpl(parent, bundleBarn.requireNodeController(entry))
            is BundleEntry ->
                NodeSpecImpl(parent, bundleBarn.requireNodeController(entry)).apply {
                    entry.children.forEach { children.add(buildNotifNode(this, it)) }
                }
            else -> throw RuntimeException("Unexpected entry: $entry")
        }
}
+9 −3
Original line number Diff line number Diff line
@@ -285,6 +285,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private NotificationGuts mGuts;
    private NotificationEntry mEntry;
    private EntryAdapter mEntryAdapter;
    private boolean mIsBundle;
    private String mAppName;
    private NotificationRebindingTracker mRebindingTracker;
    private FalsingManager mFalsingManager;
@@ -2255,6 +2256,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

        if (NotificationBundleUi.isEnabled()) {
            mEntryAdapter = entryAdapter;
            mIsBundle = entryAdapter instanceof BundleEntryAdapter;
        } else {
            mEntry = (NotificationEntry) entry;
        }
@@ -2879,10 +2881,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mPrivateLayout.setVisibility(!mShowingPublic && !mIsSummaryWithChildren
                && !hideContentWhileLaunching ? VISIBLE : INVISIBLE);
        if (mChildrenContainer != null) {
            if (mIsBundle) {
                mChildrenContainer.setVisibility(!hideContentWhileLaunching ? VISIBLE : INVISIBLE);
            } else {
                mChildrenContainer.setVisibility(!mShowingPublic && mIsSummaryWithChildren
                        && !hideContentWhileLaunching ? VISIBLE
                        : INVISIBLE);
            }
        }
        // The limits might have changed if the view suddenly became a group or vice versa
        updateLimits();
    }
+1 −1
Original line number Diff line number Diff line
@@ -282,7 +282,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
        } else if (android.app.Flags.uiRichOngoing()
                && android.app.Flags.apiRichOngoing()
                && Flags.permissionHelperUiRichOngoing()
                && sbn.getNotification().isPromotedOngoing()) {
                && (sbn != null && sbn.getNotification().isPromotedOngoing())) {
            mInfoItem = createPromotedItem(mContext);
        }  else if (android.app.Flags.notificationClassificationUi() && isBundled) {
            mInfoItem = createBundledInfoItem(mContext);
Loading