Remove the bubble if intent has an issue
This isn't very graceful & it's a bit jarring that the bubble is removed,
however, if the intent has an issue we can't really populate the view.
Test: manual - have a bubble whose intent uses FLAG_ONE_SHOT
- expand that bubble
- cause bubbles to crash (adb shell killall com.google.android.samples.bubbles)
- the stack should collapse, tap on that bubble
=> it gets removed (if there are other bubbles, stack still expands
if that was the only bubble the stack goes away).
Bug: 139025304
Change-Id: I23dcd6ac252e56f339b06fe8ba1d4b3dad61c3ae
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index a13b485..94d9ede 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -114,7 +114,7 @@
@Retention(SOURCE)
@IntDef({DISMISS_USER_GESTURE, DISMISS_AGED, DISMISS_TASK_FINISHED, DISMISS_BLOCKED,
DISMISS_NOTIF_CANCEL, DISMISS_ACCESSIBILITY_ACTION, DISMISS_NO_LONGER_BUBBLE,
- DISMISS_USER_CHANGED, DISMISS_GROUP_CANCELLED})
+ DISMISS_USER_CHANGED, DISMISS_GROUP_CANCELLED, DISMISS_INVALID_INTENT})
@Target({FIELD, LOCAL_VARIABLE, PARAMETER})
@interface DismissReason {}
@@ -127,6 +127,7 @@
static final int DISMISS_NO_LONGER_BUBBLE = 7;
static final int DISMISS_USER_CHANGED = 8;
static final int DISMISS_GROUP_CANCELLED = 9;
+ static final int DISMISS_INVALID_INTENT = 10;
public static final int MAX_BUBBLES = 5; // TODO: actually enforce this
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
index 18d9fe7..6f35525 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
@@ -127,7 +127,17 @@
Log.d(TAG, "onActivityViewReady: calling startActivity, "
+ "bubble=" + getBubbleKey());
}
- mActivityView.startActivity(mBubbleIntent, options);
+ try {
+ mActivityView.startActivity(mBubbleIntent, options);
+ } catch (RuntimeException e) {
+ // If there's a runtime exception here then there's something
+ // wrong with the intent, we can't really recover / try to populate
+ // the bubble again so we'll just remove it.
+ Log.w(TAG, "Exception while displaying bubble: " + getBubbleKey()
+ + ", " + e.getMessage() + "; removing bubble");
+ mBubbleController.removeBubble(mBubble.getKey(),
+ BubbleController.DISMISS_INVALID_INTENT);
+ }
});
mActivityViewStatus = ActivityViewStatus.ACTIVITY_STARTED;
}