From a9f16586c4d36723e0aa238197bb82469714a6d5 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Thu, 11 May 2023 09:28:57 -0700 Subject: [PATCH] Fix potential NPE when removing bubble The icon view on the bubble might be cleaned up somehow before we try to remove it, grab it before the animation starts and ensure it's not null before removing it from the view. Bug: 281891504 Test: none / couldn't repro locally Change-Id: Ic2a2b01cc0270ba00c8a5c1ad07c1256bbc1b351 --- .../src/com/android/wm/shell/bubbles/BubbleStackView.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index e7ec7aa164e9b..f827e07bc50ce 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -1784,10 +1784,13 @@ public class BubbleStackView extends FrameLayout // We're expanded while the last bubble is being removed. Let the scrim animate away // and then remove our views (removing the icon view triggers the removal of the // bubble window so do that at the end of the animation so we see the scrim animate). + BadgedImageView iconView = bubble.getIconView(); showScrim(false, () -> { mRemovingLastBubbleWhileExpanded = false; bubble.cleanupExpandedView(); - mBubbleContainer.removeView(bubble.getIconView()); + if (iconView != null) { + mBubbleContainer.removeView(iconView); + } bubble.cleanupViews(); // cleans up the icon view updateExpandedView(); // resets state for no expanded bubble });