Bubbles API council feedback
* un-deprecate getIntent/getIcon/setIntent/setIcon
* deprecate createIntentBubble & createShortcutBubble and make them
constructor methods & deprecate existing constructor
* clarify when intent / icon / shortcut id will be null or not
* use NPE instead of illegal argument exception
* use illegal state exception when using setIcon/setIntent on a builder
created with shortcut method
* updates usages of getBubbleIntent/getBubbleIcon to be getIntent/getIcon
* updates builder constructor usages as well
Fixes: 149911930
Test: treehugger
Change-Id: Ic85a475d463cb22cea7d7939fea4cf72465491b4
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
index 4240209c..ed74da8 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
@@ -417,7 +417,7 @@
PendingIntent getBubbleIntent() {
Notification.BubbleMetadata data = mEntry.getBubbleMetadata();
if (data != null) {
- return data.getBubbleIntent();
+ return data.getIntent();
}
return null;
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index b39dd1a..c9ce8a1 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -1305,7 +1305,7 @@
*/
static boolean canLaunchInActivityView(Context context, NotificationEntry entry) {
PendingIntent intent = entry.getBubbleMetadata() != null
- ? entry.getBubbleMetadata().getBubbleIntent()
+ ? entry.getBubbleMetadata().getIntent()
: null;
if (entry.getBubbleMetadata() != null
&& entry.getBubbleMetadata().getShortcutId() != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java
index b33eeba..41dbb48 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java
@@ -256,8 +256,7 @@
}
}
if (intent != null) {
- return new Notification.BubbleMetadata.Builder()
- .createIntentBubble(intent, icon)
+ return new Notification.BubbleMetadata.Builder(intent, icon)
.setDesiredHeight(BUBBLE_HEIGHT)
.build();
}
@@ -265,9 +264,8 @@
}
static Notification.BubbleMetadata createForShortcut(String shortcutId) {
- return new Notification.BubbleMetadata.Builder()
+ return new Notification.BubbleMetadata.Builder(shortcutId)
.setDesiredHeight(BUBBLE_HEIGHT)
- .createShortcutBubble(shortcutId)
.build();
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java
index 3b818db..9f573c3 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java
@@ -57,7 +57,7 @@
int density = context.getResources().getConfiguration().densityDpi;
return launcherApps.getShortcutIconDrawable(shortcutInfo, density);
} else {
- Icon ic = metadata.getBubbleIcon();
+ Icon ic = metadata.getIcon();
if (ic != null) {
return ic.loadDrawable(context);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java
index 46d5044..324bc92 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java
@@ -156,7 +156,7 @@
if (entry.getBubbleMetadata() == null
|| (entry.getBubbleMetadata().getShortcutId() == null
- && entry.getBubbleMetadata().getBubbleIntent() == null)) {
+ && entry.getBubbleMetadata().getIntent() == null)) {
if (DEBUG) {
Log.d(TAG, "No bubble up: notification: " + sbn.getKey()
+ " doesn't have valid metadata");
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java
index 866dfdc..c86b5f7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java
@@ -966,8 +966,8 @@
private NotificationEntry createBubbleEntry(int userId, String notifKey, String packageName,
long postTime) {
// BubbleMetadata
- Notification.BubbleMetadata bubbleMetadata = new Notification.BubbleMetadata.Builder()
- .createIntentBubble(mExpandIntent, Icon.createWithResource("", 0))
+ Notification.BubbleMetadata bubbleMetadata = new Notification.BubbleMetadata.Builder(
+ mExpandIntent, Icon.createWithResource("", 0))
.setDeleteIntent(mDeleteIntent)
.build();
// Notification -> BubbleMetadata
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleTest.java
index 7f67657..72f816f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleTest.java
@@ -74,8 +74,8 @@
mBubble = new Bubble(mEntry, mSuppressionListener);
Intent target = new Intent(mContext, BubblesTestActivity.class);
- Notification.BubbleMetadata metadata = new Notification.BubbleMetadata.Builder()
- .createIntentBubble(PendingIntent.getActivity(mContext, 0, target, 0),
+ Notification.BubbleMetadata metadata = new Notification.BubbleMetadata.Builder(
+ PendingIntent.getActivity(mContext, 0, target, 0),
Icon.createWithResource(mContext, R.drawable.android))
.build();
mEntry.setBubbleMetadata(metadata);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImplTest.java
index f9c62e1..5cbfcc1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImplTest.java
@@ -487,8 +487,8 @@
}
private NotificationEntry createBubble() {
- Notification.BubbleMetadata data = new Notification.BubbleMetadata.Builder()
- .createIntentBubble(PendingIntent.getActivity(mContext, 0, new Intent(), 0),
+ Notification.BubbleMetadata data = new Notification.BubbleMetadata.Builder(
+ PendingIntent.getActivity(mContext, 0, new Intent(), 0),
Icon.createWithResource(mContext.getResources(), R.drawable.android))
.build();
Notification n = new Notification.Builder(getContext(), "a")
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfoTest.java
index e1ab33a..2e3a57a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfoTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfoTest.java
@@ -203,9 +203,8 @@
PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0,
new Intent(mContext, BubblesTestActivity.class), 0);
mBubbleSbn = new SbnBuilder(mSbn).setBubbleMetadata(
- new Notification.BubbleMetadata.Builder()
- .createIntentBubble(bubbleIntent,
- Icon.createWithResource(mContext, R.drawable.android)).build())
+ new Notification.BubbleMetadata.Builder(bubbleIntent,
+ Icon.createWithResource(mContext, R.drawable.android)).build())
.build();
mBubbleEntry = new NotificationEntryBuilder()
.setSbn(mBubbleSbn)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java
index 5a89fc4..5ad3aa3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java
@@ -418,8 +418,7 @@
Intent target = new Intent(mContext, BubblesTestActivity.class);
PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0, target, 0);
- return new BubbleMetadata.Builder()
- .createIntentBubble(bubbleIntent,
+ return new BubbleMetadata.Builder(bubbleIntent,
Icon.createWithResource(mContext, R.drawable.android))
.setDeleteIntent(deleteIntent)
.setDesiredHeight(314)