diff options
| author | 2020-03-20 17:17:36 +0000 | |
|---|---|---|
| committer | 2020-03-20 17:17:36 +0000 | |
| commit | 5e2ddf0391fb95bd6c0cc7f44e3f14e8397c255a (patch) | |
| tree | ef6234767d54b939ebabdd21714dc30245b8db34 | |
| parent | 88e78ec6e2cd5cdab94bac518903ba77c3bd5878 (diff) | |
| parent | aa9ce17fa28484780f4334ce5481ca701beb1f90 (diff) | |
Merge "Bubbles API council feedback" into rvc-dev
15 files changed, 168 insertions, 108 deletions
diff --git a/api/current.txt b/api/current.txt index 7307bad7ef2b..db721f5f4a3c 100644 --- a/api/current.txt +++ b/api/current.txt @@ -5668,13 +5668,13 @@ package android.app { public static final class Notification.BubbleMetadata implements android.os.Parcelable { method public int describeContents(); method public boolean getAutoExpandBubble(); - method @Nullable public android.graphics.drawable.Icon getBubbleIcon(); - method @Nullable public android.app.PendingIntent getBubbleIntent(); + method @Deprecated @Nullable public android.graphics.drawable.Icon getBubbleIcon(); + method @Deprecated @Nullable public android.app.PendingIntent getBubbleIntent(); method @Nullable public android.app.PendingIntent getDeleteIntent(); method @Dimension(unit=android.annotation.Dimension.DP) public int getDesiredHeight(); method @DimenRes public int getDesiredHeightResId(); - method @Deprecated @NonNull public android.graphics.drawable.Icon getIcon(); - method @Deprecated @NonNull public android.app.PendingIntent getIntent(); + method @Nullable public android.graphics.drawable.Icon getIcon(); + method @Nullable public android.app.PendingIntent getIntent(); method @Nullable public String getShortcutId(); method public boolean isNotificationSuppressed(); method public void writeToParcel(android.os.Parcel, int); @@ -5682,16 +5682,18 @@ package android.app { } public static final class Notification.BubbleMetadata.Builder { - ctor public Notification.BubbleMetadata.Builder(); + ctor @Deprecated public Notification.BubbleMetadata.Builder(); + ctor public Notification.BubbleMetadata.Builder(@NonNull String); + ctor public Notification.BubbleMetadata.Builder(@NonNull android.app.PendingIntent, @NonNull android.graphics.drawable.Icon); method @NonNull public android.app.Notification.BubbleMetadata build(); - method @NonNull public android.app.Notification.BubbleMetadata.Builder createIntentBubble(@NonNull android.app.PendingIntent, @NonNull android.graphics.drawable.Icon); - method @NonNull public android.app.Notification.BubbleMetadata.Builder createShortcutBubble(@NonNull String); + method @Deprecated @NonNull public android.app.Notification.BubbleMetadata.Builder createIntentBubble(@NonNull android.app.PendingIntent, @NonNull android.graphics.drawable.Icon); + method @Deprecated @NonNull public android.app.Notification.BubbleMetadata.Builder createShortcutBubble(@NonNull String); method @NonNull public android.app.Notification.BubbleMetadata.Builder setAutoExpandBubble(boolean); method @NonNull public android.app.Notification.BubbleMetadata.Builder setDeleteIntent(@Nullable android.app.PendingIntent); method @NonNull public android.app.Notification.BubbleMetadata.Builder setDesiredHeight(@Dimension(unit=android.annotation.Dimension.DP) int); method @NonNull public android.app.Notification.BubbleMetadata.Builder setDesiredHeightResId(@DimenRes int); - method @Deprecated @NonNull public android.app.Notification.BubbleMetadata.Builder setIcon(@NonNull android.graphics.drawable.Icon); - method @Deprecated @NonNull public android.app.Notification.BubbleMetadata.Builder setIntent(@NonNull android.app.PendingIntent); + method @NonNull public android.app.Notification.BubbleMetadata.Builder setIcon(@NonNull android.graphics.drawable.Icon); + method @NonNull public android.app.Notification.BubbleMetadata.Builder setIntent(@NonNull android.app.PendingIntent); method @NonNull public android.app.Notification.BubbleMetadata.Builder setSuppressNotification(boolean); } diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 1320d1d89566..f6ab9af4b84f 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -33,6 +33,7 @@ import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; +import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; @@ -2535,8 +2536,8 @@ public class Notification implements Parcelable } } - if (mBubbleMetadata != null && mBubbleMetadata.getBubbleIcon() != null) { - final Icon icon = mBubbleMetadata.getBubbleIcon(); + if (mBubbleMetadata != null && mBubbleMetadata.getIcon() != null) { + final Icon icon = mBubbleMetadata.getIcon(); final int iconType = icon.getType(); if (iconType == TYPE_URI_ADAPTIVE_BITMAP || iconType == TYPE_URI) { visitor.accept(icon.getUri()); @@ -3597,15 +3598,14 @@ public class Notification implements Parcelable * notification content, or don't show {@link android.content.pm.ShortcutManager shortcuts}. * * If this notification has {@link BubbleMetadata} attached that was created with - * {@link BubbleMetadata.Builder#createShortcutBubble(String)} a check will be performed - * to ensure the shortcutId supplied to bubble metadata matches the shortcutId set here, - * if one was set. If the shortcutId's were specified but do not match, an exception - * is thrown. + * a shortcutId a check will be performed to ensure the shortcutId supplied to bubble + * metadata matches the shortcutId set here, if one was set. If the shortcutId's were + * specified but do not match, an exception is thrown. * * @param shortcutId the {@link ShortcutInfo#getId() id} of the shortcut this notification * supersedes * - * @see BubbleMetadata.Builder#createShortcutBubble(String) + * @see Notification.BubbleMetadata.Builder#Builder(String) */ @NonNull public Builder setShortcutId(String shortcutId) { @@ -5963,12 +5963,11 @@ public class Notification implements Parcelable * object. * * If this notification has {@link BubbleMetadata} attached that was created with - * {@link BubbleMetadata.Builder#createShortcutBubble(String)} a check will be performed - * to ensure the shortcutId supplied to bubble metadata matches the shortcutId set on the - * notification builder, if one was set. If the shortcutId's were specified but do not - * match, an exception is thrown here. + * a shortcutId a check will be performed to ensure the shortcutId supplied to bubble + * metadata matches the shortcutId set on the notification builder, if one was set. + * If the shortcutId's were specified but do not match, an exception is thrown here. * - * @see BubbleMetadata.Builder#createShortcutBubble(String) + * @see Notification.BubbleMetadata.Builder#Builder(String) * @see #setShortcutId(String) */ @NonNull @@ -8744,9 +8743,8 @@ public class Notification implements Parcelable * <p>A bubble is used to display app content in a floating window over the existing * foreground activity. A bubble has a collapsed state represented by an icon and an * expanded state that displays an activity. These may be defined via - * {@link BubbleMetadata.Builder#createIntentBubble(PendingIntent, Icon)} or they may - * be definied via an existing shortcut using - * {@link BubbleMetadata.Builder#createShortcutBubble(String)}. + * {@link Builder#Builder(PendingIntent, Icon)} or they may + * be defined via an existing shortcut using {@link Builder#Builder(String)}. * </p> * * <b>Notifications with a valid and allowed bubble will display in collapsed state @@ -8767,8 +8765,7 @@ public class Notification implements Parcelable /** * If set and the app creating the bubble is in the foreground, the bubble will be posted - * in its expanded state, with the contents of {@link #getBubbleIntent()} in a floating - * window. + * in its expanded state. * * <p>This flag has no effect if the app posting the bubble is not in the foreground. * The app is considered foreground if it is visible and on the screen, note that @@ -8834,7 +8831,9 @@ public class Notification implements Parcelable } /** - * @return the shortcut id used to populate the bubble, if it exists. + * @return the shortcut id used for this bubble if created via + * {@link Builder#Builder(String)} or null if created + * via {@link Builder#Builder(PendingIntent, Icon)}. */ @Nullable public String getShortcutId() { @@ -8842,20 +8841,20 @@ public class Notification implements Parcelable } /** - * @deprecated use {@link #getBubbleIntent()} or use {@link #getShortcutId()} if created - * with a valid shortcut instead. + * @return the pending intent used to populate the floating window for this bubble, or + * null if this bubble is created via {@link Builder#Builder(String)}. */ - @Deprecated - @NonNull + @SuppressLint("InvalidNullConversion") + @Nullable public PendingIntent getIntent() { return mPendingIntent; } /** - * @return the pending intent used to populate the floating window for this bubble, or - * null if this bubble is shortcut based. + * @deprecated use {@link #getIntent()} instead. */ @Nullable + @Deprecated public PendingIntent getBubbleIntent() { return mPendingIntent; } @@ -8869,27 +8868,27 @@ public class Notification implements Parcelable } /** - * @deprecated use {@link #getBubbleIcon()} or use {@link #getShortcutId()} if created - * with a valid shortcut instead. + * @return the icon that will be displayed for this bubble when it is collapsed, or null + * if the bubble is created via {@link Builder#Builder(String)}. */ - @Deprecated - @NonNull + @SuppressLint("InvalidNullConversion") + @Nullable public Icon getIcon() { return mIcon; } /** - * @return the icon that will be displayed for this bubble when it is collapsed, or null - * if the bubble is shortcut based. + * @deprecated use {@link #getIcon()} instead. */ @Nullable + @Deprecated public Icon getBubbleIcon() { return mIcon; } /** * @return the ideal height, in DPs, for the floating window that app content defined by - * {@link #getBubbleIntent()} for this bubble. A value of 0 indicates a desired height has + * {@link #getIntent()} for this bubble. A value of 0 indicates a desired height has * not been set. */ @Dimension(unit = DP) @@ -8899,7 +8898,7 @@ public class Notification implements Parcelable /** * @return the resId of ideal height for the floating window that app content defined by - * {@link #getBubbleIntent()} for this bubble. A value of 0 indicates a res value has not + * {@link #getIntent()} for this bubble. A value of 0 indicates a res value has not * been provided for the desired height. */ @DimenRes @@ -9013,15 +9012,20 @@ public class Notification implements Parcelable private String mShortcutId; /** - * Constructs a new builder object. + * @deprecated use {@link Builder#Builder(String)} for a bubble created via a + * {@link ShortcutInfo} or {@link Builder#Builder(PendingIntent, Icon)} for a bubble + * created via a {@link PendingIntent}. */ + @Deprecated public Builder() { } /** - * Creates a {@link BubbleMetadata.Builder} based on a shortcut. Only - * {@link android.content.pm.ShortcutManager#addDynamicShortcuts(List)} shortcuts are - * supported. + * Creates a {@link BubbleMetadata.Builder} based on a {@link ShortcutInfo}. To create + * a shortcut bubble, ensure that the shortcut associated with the provided + * {@param shortcutId} is published as a dynamic shortcut that was built with + * {@link ShortcutInfo.Builder#setLongLived(boolean)} being true, otherwise your + * notification will not be able to bubble. * * <p>The shortcut icon will be used to represent the bubble when it is collapsed.</p> * @@ -9032,19 +9036,17 @@ public class Notification implements Parcelable * no bubble will be produced. If the shortcut is deleted while the bubble is active, * the bubble will be removed.</p> * - * <p>Calling this method will clear the contents of - * {@link #createIntentBubble(PendingIntent, Icon)} if it was previously called on - * this builder.</p> + * @throws NullPointerException if shortcutId is null. + * + * @see ShortcutInfo + * @see ShortcutInfo.Builder#setLongLived(boolean) + * @see android.content.pm.ShortcutManager#addDynamicShortcuts(List) */ - @NonNull - public BubbleMetadata.Builder createShortcutBubble(@NonNull String shortcutId) { - if (!TextUtils.isEmpty(shortcutId)) { - // If shortcut id is set, we don't use these if they were previously set. - mPendingIntent = null; - mIcon = null; + public Builder(@NonNull String shortcutId) { + if (TextUtils.isEmpty(shortcutId)) { + throw new NullPointerException("Bubble requires a non-null shortcut id"); } mShortcutId = shortcutId; - return this; } /** @@ -9055,16 +9057,49 @@ public class Notification implements Parcelable * multiple bubbles, the icon should be unique for each of them.</p> * * <p>The intent that will be used when the bubble is expanded. This will display the - * app content in a floating window over the existing foreground activity.</p> - * - * <p>Calling this method will clear the contents of - * {@link #createShortcutBubble(String)} if it was previously called on this builder. - * </p> + * app content in a floating window over the existing foreground activity. The intent + * should point to a resizable activity. </p> * - * @throws IllegalArgumentException if intent is null. - * @throws IllegalArgumentException if icon is null. + * @throws NullPointerException if intent is null. + * @throws NullPointerException if icon is null. + */ + public Builder(@NonNull PendingIntent intent, @NonNull Icon icon) { + if (intent == null) { + throw new NullPointerException("Bubble requires non-null pending intent"); + } + if (icon == null) { + throw new NullPointerException("Bubbles require non-null icon"); + } + if (icon.getType() != TYPE_URI_ADAPTIVE_BITMAP + && icon.getType() != TYPE_URI) { + Log.w(TAG, "Bubbles work best with icons of TYPE_URI or " + + "TYPE_URI_ADAPTIVE_BITMAP. " + + "In the future, using an icon of this type will be required."); + } + mPendingIntent = intent; + mIcon = icon; + } + + /** + * @deprecated use {@link Builder#Builder(String)} instead. */ @NonNull + @Deprecated + public BubbleMetadata.Builder createShortcutBubble(@NonNull String shortcutId) { + if (!TextUtils.isEmpty(shortcutId)) { + // If shortcut id is set, we don't use these if they were previously set. + mPendingIntent = null; + mIcon = null; + } + mShortcutId = shortcutId; + return this; + } + + /** + * @deprecated use {@link Builder#Builder(PendingIntent, Icon)} instead. + */ + @NonNull + @Deprecated public BubbleMetadata.Builder createIntentBubble(@NonNull PendingIntent intent, @NonNull Icon icon) { if (intent == null) { @@ -9086,31 +9121,61 @@ public class Notification implements Parcelable } /** - * @deprecated use {@link #createIntentBubble(PendingIntent, Icon)} - * or {@link #createShortcutBubble(String)} instead. + * Sets the intent for the bubble. + * + * <p>The intent that will be used when the bubble is expanded. This will display the + * app content in a floating window over the existing foreground activity. The intent + * should point to a resizable activity. </p> + * + * @throws NullPointerException if intent is null. + * @throws IllegalStateException if this builder was created via + * {@link Builder#Builder(String)}. */ - @Deprecated @NonNull public BubbleMetadata.Builder setIntent(@NonNull PendingIntent intent) { + if (mShortcutId != null) { + throw new IllegalStateException("Created as a shortcut bubble, cannot set a " + + "PendingIntent. Consider using " + + "BubbleMetadata.Builder(PendingIntent,Icon) instead."); + } if (intent == null) { - throw new IllegalArgumentException("Bubble requires non-null pending intent"); + throw new NullPointerException("Bubble requires non-null pending intent"); } - mShortcutId = null; mPendingIntent = intent; return this; } /** - * @deprecated use {@link #createIntentBubble(PendingIntent, Icon)} - * or {@link #createShortcutBubble(String)} instead. + * Sets the icon for the bubble. Can only be used if the bubble was created + * via {@link Builder#Builder(PendingIntent, Icon)}. + * + * <p>The icon will be used to represent the bubble when it is collapsed. An icon + * should be representative of the content within the bubble. If your app produces + * multiple bubbles, the icon should be unique for each of them.</p> + * + * <p>It is recommended to use an {@link Icon} of type {@link Icon#TYPE_URI} + * or {@link Icon#TYPE_URI_ADAPTIVE_BITMAP}</p> + * + * @throws NullPointerException if icon is null. + * @throws IllegalStateException if this builder was created via + * {@link Builder#Builder(String)}. */ - @Deprecated @NonNull public BubbleMetadata.Builder setIcon(@NonNull Icon icon) { + if (mShortcutId != null) { + throw new IllegalStateException("Created as a shortcut bubble, cannot set an " + + "Icon. Consider using " + + "BubbleMetadata.Builder(PendingIntent,Icon) instead."); + } if (icon == null) { - throw new IllegalArgumentException("Bubbles require non-null icon"); + throw new NullPointerException("Bubbles require non-null icon"); + } + if (icon.getType() != TYPE_URI_ADAPTIVE_BITMAP + && icon.getType() != TYPE_URI) { + Log.w(TAG, "Bubbles work best with icons of TYPE_URI or " + + "TYPE_URI_ADAPTIVE_BITMAP. " + + "In the future, using an icon of this type will be required."); } - mShortcutId = null; mIcon = icon; return this; } @@ -9159,8 +9224,7 @@ public class Notification implements Parcelable } /** - * Sets whether the bubble will be posted in its expanded state (with the contents of - * {@link #getBubbleIntent()} in a floating window). + * Sets whether the bubble will be posted in its expanded state. * * <p>This flag has no effect if the app posting the bubble is not in the foreground. * The app is considered foreground if it is visible and on the screen, note that @@ -9213,17 +9277,16 @@ public class Notification implements Parcelable /** * Creates the {@link BubbleMetadata} defined by this builder. * - * @throws IllegalStateException if neither {@link #createShortcutBubble(String)} or - * {@link #createIntentBubble(PendingIntent, Icon)} have been called on this builder. + * @throws NullPointerException if required elements have not been set. */ @NonNull public BubbleMetadata build() { if (mShortcutId == null && mPendingIntent == null) { - throw new IllegalStateException( + throw new NullPointerException( "Must supply pending intent or shortcut to bubble"); } if (mShortcutId == null && mIcon == null) { - throw new IllegalStateException( + throw new NullPointerException( "Must supply an icon or shortcut for the bubble"); } BubbleMetadata data = new BubbleMetadata(mPendingIntent, mDeleteIntent, diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java index 7c4e61c0c175..726a7dd111d7 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java @@ -433,7 +433,7 @@ class Bubble implements BubbleViewProvider { 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 b39dd1aea4a9..c9ce8a10cca7 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 @@ public class BubbleController implements ConfigurationController.ConfigurationLi */ 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 b33eeba5da70..41dbb489c2f6 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 @@ public class BubbleExperimentConfig { } } 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 @@ public class BubbleExperimentConfig { } 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 5c536c34c35d..74231c648f00 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java @@ -58,7 +58,7 @@ public class BubbleIconFactory extends BaseIconFactory { int density = context.getResources().getConfiguration().densityDpi; return launcherApps.getShortcutIconDrawable(shortcutInfo, density); } else { - Icon ic = metadata.getBubbleIcon(); + Icon ic = metadata.getIcon(); if (ic != null) { if (ic.getType() == Icon.TYPE_URI || ic.getType() == Icon.TYPE_URI_ADAPTIVE_BITMAP) { 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 46d50441c06b..324bc923fb35 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 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter 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 866dfdc9c7e4..c86b5f76fc05 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 @@ public class BubbleDataTest extends SysuiTestCase { 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 7f67657e1109..72f816ff56b5 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 @@ public class BubbleTest extends SysuiTestCase { 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 f9c62e1ab604..5cbfcc1bcd06 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 @@ public class NotificationInterruptStateProviderImplTest extends SysuiTestCase { } 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 e1ab33a174ea..2e3a57af2adb 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 @@ public class NotificationConversationInfoTest extends SysuiTestCase { 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 077d86353266..2134a3d5af92 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 @@ -430,8 +430,7 @@ public class NotificationTestHelper { 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) diff --git a/services/core/java/com/android/server/notification/BubbleExtractor.java b/services/core/java/com/android/server/notification/BubbleExtractor.java index c96880cfebb8..e5cb5540b781 100644 --- a/services/core/java/com/android/server/notification/BubbleExtractor.java +++ b/services/core/java/com/android/server/notification/BubbleExtractor.java @@ -219,7 +219,7 @@ public class BubbleExtractor implements NotificationSignalExtractor { String shortcutId = metadata.getShortcutId(); boolean shortcutValid = shortcutId != null && mShortcutHelper.hasValidShortcutInfo(shortcutId, pkg, r.getUser()); - if (metadata.getBubbleIntent() == null && !shortcutValid) { + if (metadata.getIntent() == null && !shortcutValid) { // Should have a shortcut if intent is null logBubbleError(r.getKey(), "couldn't find valid shortcut for bubble with shortcutId: " + shortcutId); @@ -229,7 +229,7 @@ public class BubbleExtractor implements NotificationSignalExtractor { return true; } // no log: canLaunch method has the failure log - return canLaunchInActivityView(mContext, metadata.getBubbleIntent(), pkg); + return canLaunchInActivityView(mContext, metadata.getIntent(), pkg); } /** diff --git a/services/tests/uiservicestests/src/com/android/server/notification/BubbleCheckerTest.java b/services/tests/uiservicestests/src/com/android/server/notification/BubbleCheckerTest.java index 9636342c3f41..d7fc97c8722d 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/BubbleCheckerTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/BubbleCheckerTest.java @@ -104,7 +104,7 @@ public class BubbleCheckerTest extends UiServiceTestCase { void setUpIntentBubble() { when(mPendingIntent.getIntent()).thenReturn(mIntent); - when(mBubbleMetadata.getBubbleIntent()).thenReturn(mPendingIntent); + when(mBubbleMetadata.getIntent()).thenReturn(mPendingIntent); when(mBubbleMetadata.getShortcutId()).thenReturn(null); } @@ -112,7 +112,7 @@ public class BubbleCheckerTest extends UiServiceTestCase { when(mBubbleMetadata.getShortcutId()).thenReturn(SHORTCUT_ID); when(mShortcutHelper.hasValidShortcutInfo(SHORTCUT_ID, PKG, mUserHandle)) .thenReturn(isValid); - when(mBubbleMetadata.getBubbleIntent()).thenReturn(null); + when(mBubbleMetadata.getIntent()).thenReturn(null); } void setUpBubblesEnabled(boolean feature, boolean app, boolean channel) { @@ -160,7 +160,7 @@ public class BubbleCheckerTest extends UiServiceTestCase { @Test public void testCanBubble_false_noIntentNoShortcut() { setUpBubblesEnabled(true /* feature */, true /* app */, true /* channel */); - when(mBubbleMetadata.getBubbleIntent()).thenReturn(null); + when(mBubbleMetadata.getIntent()).thenReturn(null); when(mBubbleMetadata.getShortcutId()).thenReturn(null); assertFalse(mBubbleChecker.canBubble(mNr, PKG, USER_ID)); } diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index 2b8ce782fe16..9db7d5e3acdd 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -678,9 +678,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { private Notification.BubbleMetadata.Builder getBubbleMetadataBuilder() { PendingIntent pi = PendingIntent.getActivity(mContext, 0, new Intent(), 0); - return new Notification.BubbleMetadata.Builder() - .createIntentBubble(pi, - Icon.createWithResource(mContext, android.R.drawable.sym_def_app_icon)); + return new Notification.BubbleMetadata.Builder(pi, + Icon.createWithResource(mContext, android.R.drawable.sym_def_app_icon)); } private Notification.Builder getMessageStyleNotifBuilder(boolean addBubbleMetadata, @@ -6175,7 +6174,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { // Messaging notification with shortcut info Notification.BubbleMetadata metadata = - getBubbleMetadataBuilder().createShortcutBubble("someshortcutId").build(); + new Notification.BubbleMetadata.Builder("someshortcutId").build(); Notification.Builder nb = getMessageStyleNotifBuilder(false /* addDefaultMetadata */, null /* groupKey */, false /* isSummary */); nb.setBubbleMetadata(metadata); @@ -6232,8 +6231,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { ArgumentCaptor.forClass(LauncherApps.Callback.class); // Messaging notification with shortcut info - Notification.BubbleMetadata metadata = - getBubbleMetadataBuilder().createShortcutBubble("someshortcutId").build(); + Notification.BubbleMetadata metadata = new Notification.BubbleMetadata.Builder( + "someshortcutId").build(); Notification.Builder nb = getMessageStyleNotifBuilder(false /* addDefaultMetadata */, null /* groupKey */, false /* isSummary */); nb.setBubbleMetadata(metadata); |