Loading api/current.txt +11 −9 Original line number Original line Diff line number Diff line Loading @@ -5668,13 +5668,13 @@ package android.app { public static final class Notification.BubbleMetadata implements android.os.Parcelable { public static final class Notification.BubbleMetadata implements android.os.Parcelable { method public int describeContents(); method public int describeContents(); method public boolean getAutoExpandBubble(); method public boolean getAutoExpandBubble(); method @Nullable public android.graphics.drawable.Icon getBubbleIcon(); method @Deprecated @Nullable public android.graphics.drawable.Icon getBubbleIcon(); method @Nullable public android.app.PendingIntent getBubbleIntent(); method @Deprecated @Nullable public android.app.PendingIntent getBubbleIntent(); method @Nullable public android.app.PendingIntent getDeleteIntent(); method @Nullable public android.app.PendingIntent getDeleteIntent(); method @Dimension(unit=android.annotation.Dimension.DP) public int getDesiredHeight(); method @Dimension(unit=android.annotation.Dimension.DP) public int getDesiredHeight(); method @DimenRes public int getDesiredHeightResId(); method @DimenRes public int getDesiredHeightResId(); method @Deprecated @NonNull public android.graphics.drawable.Icon getIcon(); method @Nullable public android.graphics.drawable.Icon getIcon(); method @Deprecated @NonNull public android.app.PendingIntent getIntent(); method @Nullable public android.app.PendingIntent getIntent(); method @Nullable public String getShortcutId(); method @Nullable public String getShortcutId(); method public boolean isNotificationSuppressed(); method public boolean isNotificationSuppressed(); method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int); Loading @@ -5682,16 +5682,18 @@ package android.app { } } public static final class Notification.BubbleMetadata.Builder { 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 build(); method @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 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 createShortcutBubble(@NonNull String); method @NonNull public android.app.Notification.BubbleMetadata.Builder setAutoExpandBubble(boolean); 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 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 setDesiredHeight(@Dimension(unit=android.annotation.Dimension.DP) int); method @NonNull public android.app.Notification.BubbleMetadata.Builder setDesiredHeightResId(@DimenRes 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 @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 setIntent(@NonNull android.app.PendingIntent); method @NonNull public android.app.Notification.BubbleMetadata.Builder setSuppressNotification(boolean); method @NonNull public android.app.Notification.BubbleMetadata.Builder setSuppressNotification(boolean); } } core/java/android/app/Notification.java +132 −69 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.SystemApi; import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.Context; Loading Loading @@ -2535,8 +2536,8 @@ public class Notification implements Parcelable } } } } if (mBubbleMetadata != null && mBubbleMetadata.getBubbleIcon() != null) { if (mBubbleMetadata != null && mBubbleMetadata.getIcon() != null) { final Icon icon = mBubbleMetadata.getBubbleIcon(); final Icon icon = mBubbleMetadata.getIcon(); final int iconType = icon.getType(); final int iconType = icon.getType(); if (iconType == TYPE_URI_ADAPTIVE_BITMAP || iconType == TYPE_URI) { if (iconType == TYPE_URI_ADAPTIVE_BITMAP || iconType == TYPE_URI) { visitor.accept(icon.getUri()); visitor.accept(icon.getUri()); Loading Loading @@ -3597,15 +3598,14 @@ public class Notification implements Parcelable * notification content, or don't show {@link android.content.pm.ShortcutManager shortcuts}. * notification content, or don't show {@link android.content.pm.ShortcutManager shortcuts}. * * * If this notification has {@link BubbleMetadata} attached that was created with * If this notification has {@link BubbleMetadata} attached that was created with * {@link BubbleMetadata.Builder#createShortcutBubble(String)} a check will be performed * a shortcutId a check will be performed to ensure the shortcutId supplied to bubble * to ensure the shortcutId supplied to bubble metadata matches the shortcutId set here, * metadata matches the shortcutId set here, if one was set. If the shortcutId's were * if one was set. If the shortcutId's were specified but do not match, an exception * specified but do not match, an exception is thrown. * is thrown. * * * @param shortcutId the {@link ShortcutInfo#getId() id} of the shortcut this notification * @param shortcutId the {@link ShortcutInfo#getId() id} of the shortcut this notification * supersedes * supersedes * * * @see BubbleMetadata.Builder#createShortcutBubble(String) * @see Notification.BubbleMetadata.Builder#Builder(String) */ */ @NonNull @NonNull public Builder setShortcutId(String shortcutId) { public Builder setShortcutId(String shortcutId) { Loading Loading @@ -5963,12 +5963,11 @@ public class Notification implements Parcelable * object. * object. * * * If this notification has {@link BubbleMetadata} attached that was created with * If this notification has {@link BubbleMetadata} attached that was created with * {@link BubbleMetadata.Builder#createShortcutBubble(String)} a check will be performed * a shortcutId a check will be performed to ensure the shortcutId supplied to bubble * to ensure the shortcutId supplied to bubble metadata matches the shortcutId set on the * metadata matches the shortcutId set on the notification builder, if one was set. * notification builder, if one was set. If the shortcutId's were specified but do not * If the shortcutId's were specified but do not match, an exception is thrown here. * match, an exception is thrown here. * * * @see BubbleMetadata.Builder#createShortcutBubble(String) * @see Notification.BubbleMetadata.Builder#Builder(String) * @see #setShortcutId(String) * @see #setShortcutId(String) */ */ @NonNull @NonNull Loading Loading @@ -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 * <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 * 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 * expanded state that displays an activity. These may be defined via * {@link BubbleMetadata.Builder#createIntentBubble(PendingIntent, Icon)} or they may * {@link Builder#Builder(PendingIntent, Icon)} or they may * be definied via an existing shortcut using * be defined via an existing shortcut using {@link Builder#Builder(String)}. * {@link BubbleMetadata.Builder#createShortcutBubble(String)}. * </p> * </p> * * * <b>Notifications with a valid and allowed bubble will display in collapsed state * <b>Notifications with a valid and allowed bubble will display in collapsed state Loading @@ -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 * 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 * in its expanded state. * window. * * * <p>This flag has no effect if the app posting the bubble is not in the foreground. * <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 * The app is considered foreground if it is visible and on the screen, note that Loading Loading @@ -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 @Nullable public String getShortcutId() { public String getShortcutId() { Loading @@ -8842,20 +8841,20 @@ public class Notification implements Parcelable } } /** /** * @deprecated use {@link #getBubbleIntent()} or use {@link #getShortcutId()} if created * @return the pending intent used to populate the floating window for this bubble, or * with a valid shortcut instead. * null if this bubble is created via {@link Builder#Builder(String)}. */ */ @Deprecated @SuppressLint("InvalidNullConversion") @NonNull @Nullable public PendingIntent getIntent() { public PendingIntent getIntent() { return mPendingIntent; return mPendingIntent; } } /** /** * @return the pending intent used to populate the floating window for this bubble, or * @deprecated use {@link #getIntent()} instead. * null if this bubble is shortcut based. */ */ @Nullable @Nullable @Deprecated public PendingIntent getBubbleIntent() { public PendingIntent getBubbleIntent() { return mPendingIntent; return mPendingIntent; } } Loading @@ -8869,27 +8868,27 @@ public class Notification implements Parcelable } } /** /** * @deprecated use {@link #getBubbleIcon()} or use {@link #getShortcutId()} if created * @return the icon that will be displayed for this bubble when it is collapsed, or null * with a valid shortcut instead. * if the bubble is created via {@link Builder#Builder(String)}. */ */ @Deprecated @SuppressLint("InvalidNullConversion") @NonNull @Nullable public Icon getIcon() { public Icon getIcon() { return mIcon; return mIcon; } } /** /** * @return the icon that will be displayed for this bubble when it is collapsed, or null * @deprecated use {@link #getIcon()} instead. * if the bubble is shortcut based. */ */ @Nullable @Nullable @Deprecated public Icon getBubbleIcon() { public Icon getBubbleIcon() { return mIcon; return mIcon; } } /** /** * @return the ideal height, in DPs, for the floating window that app content defined by * @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. * not been set. */ */ @Dimension(unit = DP) @Dimension(unit = DP) Loading @@ -8899,7 +8898,7 @@ public class Notification implements Parcelable /** /** * @return the resId of ideal height for the floating window that app content defined by * @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. * been provided for the desired height. */ */ @DimenRes @DimenRes Loading Loading @@ -9013,15 +9012,20 @@ public class Notification implements Parcelable private String mShortcutId; 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() { public Builder() { } } /** /** * Creates a {@link BubbleMetadata.Builder} based on a shortcut. Only * Creates a {@link BubbleMetadata.Builder} based on a {@link ShortcutInfo}. To create * {@link android.content.pm.ShortcutManager#addDynamicShortcuts(List)} shortcuts are * a shortcut bubble, ensure that the shortcut associated with the provided * supported. * {@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> * <p>The shortcut icon will be used to represent the bubble when it is collapsed.</p> * * Loading @@ -9032,19 +9036,17 @@ public class Notification implements Parcelable * no bubble will be produced. If the shortcut is deleted while the bubble is active, * no bubble will be produced. If the shortcut is deleted while the bubble is active, * the bubble will be removed.</p> * the bubble will be removed.</p> * * * <p>Calling this method will clear the contents of * @throws NullPointerException if shortcutId is null. * {@link #createIntentBubble(PendingIntent, Icon)} if it was previously called on * * this builder.</p> * @see ShortcutInfo * @see ShortcutInfo.Builder#setLongLived(boolean) * @see android.content.pm.ShortcutManager#addDynamicShortcuts(List) */ */ @NonNull public Builder(@NonNull String shortcutId) { public BubbleMetadata.Builder createShortcutBubble(@NonNull String shortcutId) { if (TextUtils.isEmpty(shortcutId)) { if (!TextUtils.isEmpty(shortcutId)) { throw new NullPointerException("Bubble requires a non-null shortcut id"); // If shortcut id is set, we don't use these if they were previously set. mPendingIntent = null; mIcon = null; } } mShortcutId = shortcutId; mShortcutId = shortcutId; return this; } } /** /** Loading @@ -9055,16 +9057,49 @@ public class Notification implements Parcelable * multiple bubbles, the icon should be unique for each of them.</p> * 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 * <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> * app content in a floating window over the existing foreground activity. The intent * should point to a resizable activity. </p> * * * <p>Calling this method will clear the contents of * @throws NullPointerException if intent is null. * {@link #createShortcutBubble(String)} if it was previously called on this builder. * @throws NullPointerException if icon is null. * </p> */ * public Builder(@NonNull PendingIntent intent, @NonNull Icon icon) { * @throws IllegalArgumentException if intent is null. if (intent == null) { * @throws IllegalArgumentException if icon is 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 @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, public BubbleMetadata.Builder createIntentBubble(@NonNull PendingIntent intent, @NonNull Icon icon) { @NonNull Icon icon) { if (intent == null) { if (intent == null) { Loading @@ -9086,31 +9121,61 @@ public class Notification implements Parcelable } } /** /** * @deprecated use {@link #createIntentBubble(PendingIntent, Icon)} * Sets the intent for the bubble. * or {@link #createShortcutBubble(String)} instead. * * <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 @NonNull public BubbleMetadata.Builder setIntent(@NonNull PendingIntent intent) { 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) { 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; mPendingIntent = intent; return this; return this; } } /** /** * @deprecated use {@link #createIntentBubble(PendingIntent, Icon)} * Sets the icon for the bubble. Can only be used if the bubble was created * or {@link #createShortcutBubble(String)} instead. * 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 @NonNull public BubbleMetadata.Builder setIcon(@NonNull Icon icon) { 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) { 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; mIcon = icon; return this; return this; } } Loading Loading @@ -9159,8 +9224,7 @@ public class Notification implements Parcelable } } /** /** * Sets whether the bubble will be posted in its expanded state (with the contents of * Sets whether the bubble will be posted in its expanded state. * {@link #getBubbleIntent()} in a floating window). * * * <p>This flag has no effect if the app posting the bubble is not in the foreground. * <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 * The app is considered foreground if it is visible and on the screen, note that Loading Loading @@ -9213,17 +9277,16 @@ public class Notification implements Parcelable /** /** * Creates the {@link BubbleMetadata} defined by this builder. * Creates the {@link BubbleMetadata} defined by this builder. * * * @throws IllegalStateException if neither {@link #createShortcutBubble(String)} or * @throws NullPointerException if required elements have not been set. * {@link #createIntentBubble(PendingIntent, Icon)} have been called on this builder. */ */ @NonNull @NonNull public BubbleMetadata build() { public BubbleMetadata build() { if (mShortcutId == null && mPendingIntent == null) { if (mShortcutId == null && mPendingIntent == null) { throw new IllegalStateException( throw new NullPointerException( "Must supply pending intent or shortcut to bubble"); "Must supply pending intent or shortcut to bubble"); } } if (mShortcutId == null && mIcon == null) { if (mShortcutId == null && mIcon == null) { throw new IllegalStateException( throw new NullPointerException( "Must supply an icon or shortcut for the bubble"); "Must supply an icon or shortcut for the bubble"); } } BubbleMetadata data = new BubbleMetadata(mPendingIntent, mDeleteIntent, BubbleMetadata data = new BubbleMetadata(mPendingIntent, mDeleteIntent, Loading packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -433,7 +433,7 @@ class Bubble implements BubbleViewProvider { PendingIntent getBubbleIntent() { PendingIntent getBubbleIntent() { Notification.BubbleMetadata data = mEntry.getBubbleMetadata(); Notification.BubbleMetadata data = mEntry.getBubbleMetadata(); if (data != null) { if (data != null) { return data.getBubbleIntent(); return data.getIntent(); } } return null; return null; } } Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -1305,7 +1305,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi */ */ static boolean canLaunchInActivityView(Context context, NotificationEntry entry) { static boolean canLaunchInActivityView(Context context, NotificationEntry entry) { PendingIntent intent = entry.getBubbleMetadata() != null PendingIntent intent = entry.getBubbleMetadata() != null ? entry.getBubbleMetadata().getBubbleIntent() ? entry.getBubbleMetadata().getIntent() : null; : null; if (entry.getBubbleMetadata() != null if (entry.getBubbleMetadata() != null && entry.getBubbleMetadata().getShortcutId() != null) { && entry.getBubbleMetadata().getShortcutId() != null) { Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java +2 −4 Original line number Original line Diff line number Diff line Loading @@ -256,8 +256,7 @@ public class BubbleExperimentConfig { } } } } if (intent != null) { if (intent != null) { return new Notification.BubbleMetadata.Builder() return new Notification.BubbleMetadata.Builder(intent, icon) .createIntentBubble(intent, icon) .setDesiredHeight(BUBBLE_HEIGHT) .setDesiredHeight(BUBBLE_HEIGHT) .build(); .build(); } } Loading @@ -265,9 +264,8 @@ public class BubbleExperimentConfig { } } static Notification.BubbleMetadata createForShortcut(String shortcutId) { static Notification.BubbleMetadata createForShortcut(String shortcutId) { return new Notification.BubbleMetadata.Builder() return new Notification.BubbleMetadata.Builder(shortcutId) .setDesiredHeight(BUBBLE_HEIGHT) .setDesiredHeight(BUBBLE_HEIGHT) .createShortcutBubble(shortcutId) .build(); .build(); } } Loading Loading
api/current.txt +11 −9 Original line number Original line Diff line number Diff line Loading @@ -5668,13 +5668,13 @@ package android.app { public static final class Notification.BubbleMetadata implements android.os.Parcelable { public static final class Notification.BubbleMetadata implements android.os.Parcelable { method public int describeContents(); method public int describeContents(); method public boolean getAutoExpandBubble(); method public boolean getAutoExpandBubble(); method @Nullable public android.graphics.drawable.Icon getBubbleIcon(); method @Deprecated @Nullable public android.graphics.drawable.Icon getBubbleIcon(); method @Nullable public android.app.PendingIntent getBubbleIntent(); method @Deprecated @Nullable public android.app.PendingIntent getBubbleIntent(); method @Nullable public android.app.PendingIntent getDeleteIntent(); method @Nullable public android.app.PendingIntent getDeleteIntent(); method @Dimension(unit=android.annotation.Dimension.DP) public int getDesiredHeight(); method @Dimension(unit=android.annotation.Dimension.DP) public int getDesiredHeight(); method @DimenRes public int getDesiredHeightResId(); method @DimenRes public int getDesiredHeightResId(); method @Deprecated @NonNull public android.graphics.drawable.Icon getIcon(); method @Nullable public android.graphics.drawable.Icon getIcon(); method @Deprecated @NonNull public android.app.PendingIntent getIntent(); method @Nullable public android.app.PendingIntent getIntent(); method @Nullable public String getShortcutId(); method @Nullable public String getShortcutId(); method public boolean isNotificationSuppressed(); method public boolean isNotificationSuppressed(); method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int); Loading @@ -5682,16 +5682,18 @@ package android.app { } } public static final class Notification.BubbleMetadata.Builder { 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 build(); method @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 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 createShortcutBubble(@NonNull String); method @NonNull public android.app.Notification.BubbleMetadata.Builder setAutoExpandBubble(boolean); 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 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 setDesiredHeight(@Dimension(unit=android.annotation.Dimension.DP) int); method @NonNull public android.app.Notification.BubbleMetadata.Builder setDesiredHeightResId(@DimenRes 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 @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 setIntent(@NonNull android.app.PendingIntent); method @NonNull public android.app.Notification.BubbleMetadata.Builder setSuppressNotification(boolean); method @NonNull public android.app.Notification.BubbleMetadata.Builder setSuppressNotification(boolean); } }
core/java/android/app/Notification.java +132 −69 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.SystemApi; import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.Context; Loading Loading @@ -2535,8 +2536,8 @@ public class Notification implements Parcelable } } } } if (mBubbleMetadata != null && mBubbleMetadata.getBubbleIcon() != null) { if (mBubbleMetadata != null && mBubbleMetadata.getIcon() != null) { final Icon icon = mBubbleMetadata.getBubbleIcon(); final Icon icon = mBubbleMetadata.getIcon(); final int iconType = icon.getType(); final int iconType = icon.getType(); if (iconType == TYPE_URI_ADAPTIVE_BITMAP || iconType == TYPE_URI) { if (iconType == TYPE_URI_ADAPTIVE_BITMAP || iconType == TYPE_URI) { visitor.accept(icon.getUri()); visitor.accept(icon.getUri()); Loading Loading @@ -3597,15 +3598,14 @@ public class Notification implements Parcelable * notification content, or don't show {@link android.content.pm.ShortcutManager shortcuts}. * notification content, or don't show {@link android.content.pm.ShortcutManager shortcuts}. * * * If this notification has {@link BubbleMetadata} attached that was created with * If this notification has {@link BubbleMetadata} attached that was created with * {@link BubbleMetadata.Builder#createShortcutBubble(String)} a check will be performed * a shortcutId a check will be performed to ensure the shortcutId supplied to bubble * to ensure the shortcutId supplied to bubble metadata matches the shortcutId set here, * metadata matches the shortcutId set here, if one was set. If the shortcutId's were * if one was set. If the shortcutId's were specified but do not match, an exception * specified but do not match, an exception is thrown. * is thrown. * * * @param shortcutId the {@link ShortcutInfo#getId() id} of the shortcut this notification * @param shortcutId the {@link ShortcutInfo#getId() id} of the shortcut this notification * supersedes * supersedes * * * @see BubbleMetadata.Builder#createShortcutBubble(String) * @see Notification.BubbleMetadata.Builder#Builder(String) */ */ @NonNull @NonNull public Builder setShortcutId(String shortcutId) { public Builder setShortcutId(String shortcutId) { Loading Loading @@ -5963,12 +5963,11 @@ public class Notification implements Parcelable * object. * object. * * * If this notification has {@link BubbleMetadata} attached that was created with * If this notification has {@link BubbleMetadata} attached that was created with * {@link BubbleMetadata.Builder#createShortcutBubble(String)} a check will be performed * a shortcutId a check will be performed to ensure the shortcutId supplied to bubble * to ensure the shortcutId supplied to bubble metadata matches the shortcutId set on the * metadata matches the shortcutId set on the notification builder, if one was set. * notification builder, if one was set. If the shortcutId's were specified but do not * If the shortcutId's were specified but do not match, an exception is thrown here. * match, an exception is thrown here. * * * @see BubbleMetadata.Builder#createShortcutBubble(String) * @see Notification.BubbleMetadata.Builder#Builder(String) * @see #setShortcutId(String) * @see #setShortcutId(String) */ */ @NonNull @NonNull Loading Loading @@ -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 * <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 * 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 * expanded state that displays an activity. These may be defined via * {@link BubbleMetadata.Builder#createIntentBubble(PendingIntent, Icon)} or they may * {@link Builder#Builder(PendingIntent, Icon)} or they may * be definied via an existing shortcut using * be defined via an existing shortcut using {@link Builder#Builder(String)}. * {@link BubbleMetadata.Builder#createShortcutBubble(String)}. * </p> * </p> * * * <b>Notifications with a valid and allowed bubble will display in collapsed state * <b>Notifications with a valid and allowed bubble will display in collapsed state Loading @@ -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 * 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 * in its expanded state. * window. * * * <p>This flag has no effect if the app posting the bubble is not in the foreground. * <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 * The app is considered foreground if it is visible and on the screen, note that Loading Loading @@ -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 @Nullable public String getShortcutId() { public String getShortcutId() { Loading @@ -8842,20 +8841,20 @@ public class Notification implements Parcelable } } /** /** * @deprecated use {@link #getBubbleIntent()} or use {@link #getShortcutId()} if created * @return the pending intent used to populate the floating window for this bubble, or * with a valid shortcut instead. * null if this bubble is created via {@link Builder#Builder(String)}. */ */ @Deprecated @SuppressLint("InvalidNullConversion") @NonNull @Nullable public PendingIntent getIntent() { public PendingIntent getIntent() { return mPendingIntent; return mPendingIntent; } } /** /** * @return the pending intent used to populate the floating window for this bubble, or * @deprecated use {@link #getIntent()} instead. * null if this bubble is shortcut based. */ */ @Nullable @Nullable @Deprecated public PendingIntent getBubbleIntent() { public PendingIntent getBubbleIntent() { return mPendingIntent; return mPendingIntent; } } Loading @@ -8869,27 +8868,27 @@ public class Notification implements Parcelable } } /** /** * @deprecated use {@link #getBubbleIcon()} or use {@link #getShortcutId()} if created * @return the icon that will be displayed for this bubble when it is collapsed, or null * with a valid shortcut instead. * if the bubble is created via {@link Builder#Builder(String)}. */ */ @Deprecated @SuppressLint("InvalidNullConversion") @NonNull @Nullable public Icon getIcon() { public Icon getIcon() { return mIcon; return mIcon; } } /** /** * @return the icon that will be displayed for this bubble when it is collapsed, or null * @deprecated use {@link #getIcon()} instead. * if the bubble is shortcut based. */ */ @Nullable @Nullable @Deprecated public Icon getBubbleIcon() { public Icon getBubbleIcon() { return mIcon; return mIcon; } } /** /** * @return the ideal height, in DPs, for the floating window that app content defined by * @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. * not been set. */ */ @Dimension(unit = DP) @Dimension(unit = DP) Loading @@ -8899,7 +8898,7 @@ public class Notification implements Parcelable /** /** * @return the resId of ideal height for the floating window that app content defined by * @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. * been provided for the desired height. */ */ @DimenRes @DimenRes Loading Loading @@ -9013,15 +9012,20 @@ public class Notification implements Parcelable private String mShortcutId; 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() { public Builder() { } } /** /** * Creates a {@link BubbleMetadata.Builder} based on a shortcut. Only * Creates a {@link BubbleMetadata.Builder} based on a {@link ShortcutInfo}. To create * {@link android.content.pm.ShortcutManager#addDynamicShortcuts(List)} shortcuts are * a shortcut bubble, ensure that the shortcut associated with the provided * supported. * {@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> * <p>The shortcut icon will be used to represent the bubble when it is collapsed.</p> * * Loading @@ -9032,19 +9036,17 @@ public class Notification implements Parcelable * no bubble will be produced. If the shortcut is deleted while the bubble is active, * no bubble will be produced. If the shortcut is deleted while the bubble is active, * the bubble will be removed.</p> * the bubble will be removed.</p> * * * <p>Calling this method will clear the contents of * @throws NullPointerException if shortcutId is null. * {@link #createIntentBubble(PendingIntent, Icon)} if it was previously called on * * this builder.</p> * @see ShortcutInfo * @see ShortcutInfo.Builder#setLongLived(boolean) * @see android.content.pm.ShortcutManager#addDynamicShortcuts(List) */ */ @NonNull public Builder(@NonNull String shortcutId) { public BubbleMetadata.Builder createShortcutBubble(@NonNull String shortcutId) { if (TextUtils.isEmpty(shortcutId)) { if (!TextUtils.isEmpty(shortcutId)) { throw new NullPointerException("Bubble requires a non-null shortcut id"); // If shortcut id is set, we don't use these if they were previously set. mPendingIntent = null; mIcon = null; } } mShortcutId = shortcutId; mShortcutId = shortcutId; return this; } } /** /** Loading @@ -9055,16 +9057,49 @@ public class Notification implements Parcelable * multiple bubbles, the icon should be unique for each of them.</p> * 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 * <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> * app content in a floating window over the existing foreground activity. The intent * should point to a resizable activity. </p> * * * <p>Calling this method will clear the contents of * @throws NullPointerException if intent is null. * {@link #createShortcutBubble(String)} if it was previously called on this builder. * @throws NullPointerException if icon is null. * </p> */ * public Builder(@NonNull PendingIntent intent, @NonNull Icon icon) { * @throws IllegalArgumentException if intent is null. if (intent == null) { * @throws IllegalArgumentException if icon is 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 @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, public BubbleMetadata.Builder createIntentBubble(@NonNull PendingIntent intent, @NonNull Icon icon) { @NonNull Icon icon) { if (intent == null) { if (intent == null) { Loading @@ -9086,31 +9121,61 @@ public class Notification implements Parcelable } } /** /** * @deprecated use {@link #createIntentBubble(PendingIntent, Icon)} * Sets the intent for the bubble. * or {@link #createShortcutBubble(String)} instead. * * <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 @NonNull public BubbleMetadata.Builder setIntent(@NonNull PendingIntent intent) { 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) { 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; mPendingIntent = intent; return this; return this; } } /** /** * @deprecated use {@link #createIntentBubble(PendingIntent, Icon)} * Sets the icon for the bubble. Can only be used if the bubble was created * or {@link #createShortcutBubble(String)} instead. * 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 @NonNull public BubbleMetadata.Builder setIcon(@NonNull Icon icon) { 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) { 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; mIcon = icon; return this; return this; } } Loading Loading @@ -9159,8 +9224,7 @@ public class Notification implements Parcelable } } /** /** * Sets whether the bubble will be posted in its expanded state (with the contents of * Sets whether the bubble will be posted in its expanded state. * {@link #getBubbleIntent()} in a floating window). * * * <p>This flag has no effect if the app posting the bubble is not in the foreground. * <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 * The app is considered foreground if it is visible and on the screen, note that Loading Loading @@ -9213,17 +9277,16 @@ public class Notification implements Parcelable /** /** * Creates the {@link BubbleMetadata} defined by this builder. * Creates the {@link BubbleMetadata} defined by this builder. * * * @throws IllegalStateException if neither {@link #createShortcutBubble(String)} or * @throws NullPointerException if required elements have not been set. * {@link #createIntentBubble(PendingIntent, Icon)} have been called on this builder. */ */ @NonNull @NonNull public BubbleMetadata build() { public BubbleMetadata build() { if (mShortcutId == null && mPendingIntent == null) { if (mShortcutId == null && mPendingIntent == null) { throw new IllegalStateException( throw new NullPointerException( "Must supply pending intent or shortcut to bubble"); "Must supply pending intent or shortcut to bubble"); } } if (mShortcutId == null && mIcon == null) { if (mShortcutId == null && mIcon == null) { throw new IllegalStateException( throw new NullPointerException( "Must supply an icon or shortcut for the bubble"); "Must supply an icon or shortcut for the bubble"); } } BubbleMetadata data = new BubbleMetadata(mPendingIntent, mDeleteIntent, BubbleMetadata data = new BubbleMetadata(mPendingIntent, mDeleteIntent, Loading
packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -433,7 +433,7 @@ class Bubble implements BubbleViewProvider { PendingIntent getBubbleIntent() { PendingIntent getBubbleIntent() { Notification.BubbleMetadata data = mEntry.getBubbleMetadata(); Notification.BubbleMetadata data = mEntry.getBubbleMetadata(); if (data != null) { if (data != null) { return data.getBubbleIntent(); return data.getIntent(); } } return null; return null; } } Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -1305,7 +1305,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi */ */ static boolean canLaunchInActivityView(Context context, NotificationEntry entry) { static boolean canLaunchInActivityView(Context context, NotificationEntry entry) { PendingIntent intent = entry.getBubbleMetadata() != null PendingIntent intent = entry.getBubbleMetadata() != null ? entry.getBubbleMetadata().getBubbleIntent() ? entry.getBubbleMetadata().getIntent() : null; : null; if (entry.getBubbleMetadata() != null if (entry.getBubbleMetadata() != null && entry.getBubbleMetadata().getShortcutId() != null) { && entry.getBubbleMetadata().getShortcutId() != null) { Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java +2 −4 Original line number Original line Diff line number Diff line Loading @@ -256,8 +256,7 @@ public class BubbleExperimentConfig { } } } } if (intent != null) { if (intent != null) { return new Notification.BubbleMetadata.Builder() return new Notification.BubbleMetadata.Builder(intent, icon) .createIntentBubble(intent, icon) .setDesiredHeight(BUBBLE_HEIGHT) .setDesiredHeight(BUBBLE_HEIGHT) .build(); .build(); } } Loading @@ -265,9 +264,8 @@ public class BubbleExperimentConfig { } } static Notification.BubbleMetadata createForShortcut(String shortcutId) { static Notification.BubbleMetadata createForShortcut(String shortcutId) { return new Notification.BubbleMetadata.Builder() return new Notification.BubbleMetadata.Builder(shortcutId) .setDesiredHeight(BUBBLE_HEIGHT) .setDesiredHeight(BUBBLE_HEIGHT) .createShortcutBubble(shortcutId) .build(); .build(); } } Loading