diff --git a/core/api/current.txt b/core/api/current.txt
index ef1d9efa6cda2..1f7da095a1a7d 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -5883,8 +5883,8 @@ package android.app {
method @NonNull public android.app.Notification.BubbleMetadata.Builder setDesiredHeightResId(@DimenRes int);
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 setSuppressBubble(boolean);
method @NonNull public android.app.Notification.BubbleMetadata.Builder setSuppressNotification(boolean);
+ method @NonNull public android.app.Notification.BubbleMetadata.Builder setSuppressableBubble(boolean);
}
public static class Notification.Builder {
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index fa35025d7d18c..0ca0b85215684 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -9908,7 +9908,7 @@ public class Notification implements Parcelable
*
* @hide
*/
- public static final int FLAG_SHOULD_SUPPRESS_BUBBLE = 0x00000004;
+ public static final int FLAG_SUPPRESSABLE_BUBBLE = 0x00000004;
/**
* Indicates whether the bubble is visually suppressed from the bubble stack.
@@ -10070,21 +10070,65 @@ public class Notification implements Parcelable
* @return whether this bubble should be suppressed when the same content is visible
* outside of the bubble.
*
- * @see BubbleMetadata.Builder#setSuppressBubble(boolean)
+ * @see BubbleMetadata.Builder#setSuppressableBubble(boolean)
*/
public boolean isBubbleSuppressable() {
- return (mFlags & FLAG_SHOULD_SUPPRESS_BUBBLE) != 0;
+ return (mFlags & FLAG_SUPPRESSABLE_BUBBLE) != 0;
}
/**
* Indicates whether the bubble is currently visually suppressed from the bubble stack.
*
- * @see BubbleMetadata.Builder#setSuppressBubble(boolean)
+ * @see BubbleMetadata.Builder#setSuppressableBubble(boolean)
*/
public boolean isBubbleSuppressed() {
return (mFlags & FLAG_SUPPRESS_BUBBLE) != 0;
}
+ /**
+ * Sets whether the notification associated with the bubble is being visually
+ * suppressed from the notification shade. When true the notification is
+ * hidden, when false the notification shows as normal.
+ *
+ * @hide
+ */
+ public void setSuppressNotification(boolean suppressed) {
+ if (suppressed) {
+ mFlags |= Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION;
+ } else {
+ mFlags &= ~Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION;
+ }
+ }
+
+ /**
+ * Sets whether the bubble should be visually suppressed from the bubble stack if the
+ * user is viewing the same content outside of the bubble. For example, the user has a
+ * bubble with Alice and then opens up the main app and navigates to Alice's page.
+ *
+ * @hide
+ */
+ public void setSuppressBubble(boolean suppressed) {
+ if (suppressed) {
+ mFlags |= Notification.BubbleMetadata.FLAG_SUPPRESS_BUBBLE;
+ } else {
+ mFlags &= ~Notification.BubbleMetadata.FLAG_SUPPRESS_BUBBLE;
+ }
+ }
+
+ /**
+ * @hide
+ */
+ public void setFlags(int flags) {
+ mFlags = flags;
+ }
+
+ /**
+ * @hide
+ */
+ public int getFlags() {
+ return mFlags;
+ }
+
public static final @android.annotation.NonNull Parcelable.Creator CREATOR =
new Parcelable.Creator() {
@@ -10127,20 +10171,6 @@ public class Notification implements Parcelable
}
}
- /**
- * @hide
- */
- public void setFlags(int flags) {
- mFlags = flags;
- }
-
- /**
- * @hide
- */
- public int getFlags() {
- return mFlags;
- }
-
/**
* Builder to construct a {@link BubbleMetadata} object.
*/
@@ -10438,8 +10468,8 @@ public class Notification implements Parcelable
* {@link Activity#setLocusContext(LocusId, Bundle)}
*/
@NonNull
- public BubbleMetadata.Builder setSuppressBubble(boolean suppressBubble) {
- setFlag(FLAG_SHOULD_SUPPRESS_BUBBLE, suppressBubble);
+ public BubbleMetadata.Builder setSuppressableBubble(boolean suppressBubble) {
+ setFlag(FLAG_SUPPRESSABLE_BUBBLE, suppressBubble);
return this;
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java
index d6079b6ce9843..0a15d8468983b 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java
@@ -571,7 +571,7 @@ public class Bubble implements BubbleViewProvider {
* hide the bubble when in the same content).
*/
boolean isSuppressable() {
- return (mFlags & Notification.BubbleMetadata.FLAG_SHOULD_SUPPRESS_BUBBLE) != 0;
+ return (mFlags & Notification.BubbleMetadata.FLAG_SUPPRESSABLE_BUBBLE) != 0;
}
/**
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 2f4cbd558fb90..5bcda410f4209 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1332,26 +1332,16 @@ public class NotificationManagerService extends SystemService {
return;
}
- int flags = data.getFlags();
boolean flagChanged = false;
if (data.isNotificationSuppressed() != isNotifSuppressed) {
flagChanged = true;
- if (isNotifSuppressed) {
- flags |= Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION;
- } else {
- flags &= ~Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION;
- }
+ data.setSuppressNotification(isNotifSuppressed);
}
if (data.isBubbleSuppressed() != isBubbleSuppressed) {
flagChanged = true;
- if (isBubbleSuppressed) {
- flags |= Notification.BubbleMetadata.FLAG_SUPPRESS_BUBBLE;
- } else {
- flags &= ~Notification.BubbleMetadata.FLAG_SUPPRESS_BUBBLE;
- }
+ data.setSuppressBubble(isBubbleSuppressed);
}
if (flagChanged) {
- data.setFlags(flags);
r.getNotification().flags |= FLAG_ONLY_ALERT_ONCE;
mHandler.post(
new EnqueueNotificationRunnable(r.getUser().getIdentifier(), r,