From a61906457c647a49cda34aafebcff331b681f1a5 Mon Sep 17 00:00:00 2001 From: Kevin Han Date: Thu, 30 Apr 2020 15:22:16 -0700 Subject: [PATCH] Don't throw exception for inflation after removal There are some cases where we seem to be inflating after the removal of a notification, most likely related to a re-entrant call where we remove a notification as part of a notification update listener. This throws an exception since we assume a removed notification doesn't need to inflate anything. Until we fix the underlying issue, we loosen the guarantee and remove the exception and instead just return early. Bug: 155324756 Test: builds Change-Id: I702391311e9d06319f4d93dd584ecc2a4dd78a36 --- .../systemui/statusbar/notification/row/BindStage.java | 9 +++++++-- .../statusbar/notification/row/NotifBindPipeline.java | 8 +++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/BindStage.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/BindStage.java index 29447caa12407..cc917dda2a80e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/BindStage.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/BindStage.java @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.row; import android.annotation.MainThread; import android.util.ArrayMap; +import android.util.Log; import androidx.annotation.NonNull; @@ -66,8 +67,10 @@ public abstract class BindStage extends BindRequester { public final Params getStageParams(@NonNull NotificationEntry entry) { Params params = mContentParams.get(entry); if (params == null) { - throw new IllegalStateException( - String.format("Entry does not have any stage parameters. key: %s", + // TODO: This should throw an exception but there are some cases of re-entrant calls + // in NotificationEntryManager (e.g. b/155324756) that cause removal in update that + // lead to inflation after the notification is "removed". + Log.wtf(TAG, String.format("Entry does not have any stage parameters. key: %s", entry.getKey())); } return params; @@ -92,6 +95,8 @@ public abstract class BindStage extends BindRequester { */ protected abstract Params newStageParams(); + private static final String TAG = "BindStage"; + /** * Interface for callback. */ 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 e4e3ebcf7671b..3ee267362bc02 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 @@ -115,6 +115,9 @@ public final class NotifBindPipeline { mLogger.logManagedRow(entry.getKey()); final BindEntry bindEntry = getBindEntry(entry); + if (bindEntry == null) { + return; + } bindEntry.row = row; if (bindEntry.invalidated) { requestPipelineRun(entry); @@ -223,11 +226,6 @@ public final class NotifBindPipeline { private @NonNull BindEntry getBindEntry(NotificationEntry entry) { final BindEntry bindEntry = mBindEntries.get(entry); - if (bindEntry == null) { - throw new IllegalStateException( - String.format("Attempting bind on an inactive notification. key: %s", - entry.getKey())); - } return bindEntry; }