From 7ae3d2b12a2027a2f4605ef36b7e2ec47a33909e Mon Sep 17 00:00:00 2001 From: Ibrahim Yilmaz Date: Thu, 16 Mar 2023 16:55:58 +0000 Subject: [PATCH] Cache NotifCollection for next pipeline run NotifCollection may change during pipeline run. This change will help us cover NotifCollection changes during pipeline run. Basically we cache incoming entries into pending entries and we only schedule non re-entrant build when there is ongoing pipeline run on NotifCollection change. Bug: 272046092 Test: atest ShadeListBuilderTest Change-Id: I6c9bf228e5f2657a0b0fa7fd85487b871c8902f8 --- .../notification/collection/ShadeListBuilder.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java index 4065b98ab0c8a..02055237c2b3b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java @@ -110,6 +110,8 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable { private final PipelineState mPipelineState = new PipelineState(); private final Map mGroups = new ArrayMap<>(); private Collection mAllEntries = Collections.emptyList(); + @Nullable + private Collection mPendingEntries = null; private int mIterationCount = 0; private final List mNotifPreGroupFilters = new ArrayList<>(); @@ -317,11 +319,9 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable { @Override public void onBuildList(Collection entries, String reason) { Assert.isMainThread(); - mPipelineState.requireIsBefore(STATE_BUILD_STARTED); - + mPendingEntries = new ArrayList<>(entries); mLogger.logOnBuildList(reason); - mAllEntries = entries; - scheduleRebuild(/* reentrant = */ false); + rebuildListIfBefore(STATE_BUILD_STARTED); } }; @@ -398,6 +398,11 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable { Trace.beginSection("ShadeListBuilder.buildList"); mPipelineState.requireIsBefore(STATE_BUILD_STARTED); + if (mPendingEntries != null) { + mAllEntries = mPendingEntries; + mPendingEntries = null; + } + if (!mNotifStabilityManager.isPipelineRunAllowed()) { mLogger.logPipelineRunSuppressed(); Trace.endSection();