summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mady Mellor <madym@google.com> 2021-04-09 17:49:12 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-04-09 17:49:12 +0000
commit3c0890601d22aa47be87026e079be9f782abc95e (patch)
tree28f47a3d2e1b3e1bf653517b51930738ac3bc6c4
parent5429d038ffdca39f595307b9a9103c9b4ee6c8e8 (diff)
parent4da856e1ef375b21caf515004568516dcc5f7c8a (diff)
Merge "API feedback: setSuppressableBubble/setSuppressBubble" into sc-dev
-rw-r--r--core/api/current.txt2
-rw-r--r--core/java/android/app/Notification.java70
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java2
-rwxr-xr-xservices/core/java/com/android/server/notification/NotificationManagerService.java14
4 files changed, 54 insertions, 34 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index ef1d9efa6cda..1f7da095a1a7 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 fa35025d7d18..0ca0b8521568 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 <code>true</code> the notification is
+ * hidden, when <code>false</code> 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<BubbleMetadata> CREATOR =
new Parcelable.Creator<BubbleMetadata>() {
@@ -10128,20 +10172,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.
*/
public static final class Builder {
@@ -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 d6079b6ce984..0a15d8468983 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 2f4cbd558fb9..5bcda410f420 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,