diff options
| author | 2020-03-20 19:24:24 -0700 | |
|---|---|---|
| committer | 2020-04-01 18:17:06 -0700 | |
| commit | b0fefa4c7df67a837333da32b9414b2aa03cc955 (patch) | |
| tree | 7719cf44acb651bcb20f688431ea15cdd4bdb0d1 | |
| parent | 273bb0df015e02279d2c3900d42ed7aef74c3360 (diff) | |
Fix modifying NBP callbacks in the callback
As callbacks can themselves request rebinds, they were modifying
NotifBindPipeline's callback list while it was still resolving the
previous pipeline completion. By marshalling all callbacks into a
scratch list and then iterating, we solve this issue.
Bug: 112656837
Test: atest NotifBindPipelineTest
Test: Notify apk group cancel test
Change-Id: I5a528d65a683a070c31b04da80b3a83d00dbce49
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotifBindPipeline.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotifBindPipeline.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotifBindPipeline.java index d744fc398d7a..2e70c59be0c9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotifBindPipeline.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotifBindPipeline.java @@ -31,6 +31,8 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.Co import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.InflationFlag; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Set; @@ -75,6 +77,7 @@ import javax.inject.Singleton; public final class NotifBindPipeline { private final Map<NotificationEntry, BindEntry> mBindEntries = new ArrayMap<>(); private final NotifBindPipelineLogger mLogger; + private final List<BindCallback> mScratchCallbacksList = new ArrayList<>(); private BindStage mStage; @Inject @@ -162,10 +165,15 @@ public final class NotifBindPipeline { mLogger.logFinishedPipeline(entry.getKey(), callbacks.size()); bindEntry.invalidated = false; - for (BindCallback cb : callbacks) { - cb.onBindFinished(entry); - } + // Move all callbacks to separate list as callbacks may themselves add/remove callbacks. + // TODO: Throw an exception for this re-entrant behavior once we deprecate + // NotificationGroupAlertTransferHelper + mScratchCallbacksList.addAll(callbacks); callbacks.clear(); + for (int i = 0; i < mScratchCallbacksList.size(); i++) { + mScratchCallbacksList.get(i).onBindFinished(entry); + } + mScratchCallbacksList.clear(); } private final NotifCollectionListener mCollectionListener = new NotifCollectionListener() { |