summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-11-13 22:22:41 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-11-13 22:22:41 +0000
commit8c198a83c4bb444f04c947b5af310701c0b0a70a (patch)
treec6744ebe48ab799d6b505c4f12cf167442573451
parent8b3c10ac4388f30894ac5bbac28f7c95424ab5dc (diff)
parent72f50903a75a9f7ee901798b78f0ed8e29d45df5 (diff)
Merge "Show flyout if dismissed from shade. Add tests"
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java26
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java99
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java5
3 files changed, 124 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
index f4d48b2a71a7..2ca993bd200a 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
@@ -184,8 +184,9 @@ public class BubbleData {
if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "notificationEntryUpdated: " + entry);
}
+
Bubble bubble = getBubbleWithKey(entry.getKey());
- suppressFlyout = !entry.getRanking().visuallyInterruptive() || suppressFlyout;
+ suppressFlyout |= !shouldShowFlyout(entry);
if (bubble == null) {
// Create a new bubble
@@ -298,6 +299,15 @@ public class BubbleData {
return bubbleChildren;
}
+ private boolean shouldShowFlyout(NotificationEntry notif) {
+ if (notif.getRanking().visuallyInterruptive()) {
+ return true;
+ }
+ final boolean suppressedFromShade = hasBubbleWithKey(notif.getKey())
+ && !getBubbleWithKey(notif.getKey()).showInShadeWhenBubble();
+ return suppressedFromShade;
+ }
+
private void doAdd(Bubble bubble) {
if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "doAdd: " + bubble);
@@ -510,7 +520,7 @@ public class BubbleData {
* required to keep grouping intact.
*
* @param minPosition the first insert point to consider
- * @param newBubble the bubble to insert
+ * @param newBubble the bubble to insert
* @return the position where the bubble was inserted
*/
private int insertBubble(int minPosition, Bubble newBubble) {
@@ -683,15 +693,19 @@ public class BubbleData {
* Description of current bubble data state.
*/
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
- pw.print("selected: "); pw.println(mSelectedBubble != null
+ pw.print("selected: ");
+ pw.println(mSelectedBubble != null
? mSelectedBubble.getKey()
: "null");
- pw.print("expanded: "); pw.println(mExpanded);
- pw.print("count: "); pw.println(mBubbles.size());
+ pw.print("expanded: ");
+ pw.println(mExpanded);
+ pw.print("count: ");
+ pw.println(mBubbles.size());
for (Bubble bubble : mBubbles) {
bubble.dump(fd, pw, args);
}
- pw.print("summaryKeys: "); pw.println(mSuppressedGroupKeys.size());
+ pw.print("summaryKeys: ");
+ pw.println(mSuppressedGroupKeys.size());
for (String key : mSuppressedGroupKeys.keySet()) {
pw.println(" suppressing: " + key);
}
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 32361cd0c1d5..a9be30ba82a6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java
@@ -16,6 +16,8 @@
package com.android.systemui.bubbles;
+import static com.android.systemui.statusbar.NotificationEntryHelper.modifyRanking;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
@@ -72,6 +74,8 @@ public class BubbleDataTest extends SysuiTestCase {
private NotificationEntry mEntryB2;
private NotificationEntry mEntryB3;
private NotificationEntry mEntryC1;
+ private NotificationEntry mEntryInterruptive;
+ private NotificationEntry mEntryDismissed;
private Bubble mBubbleA1;
private Bubble mBubbleA2;
@@ -110,6 +114,13 @@ public class BubbleDataTest extends SysuiTestCase {
mEntryB3 = createBubbleEntry(1, "b3", "package.b");
mEntryC1 = createBubbleEntry(1, "c1", "package.c");
+ mEntryInterruptive = createBubbleEntry(1, "interruptive", "package.d");
+ modifyRanking(mEntryInterruptive)
+ .setVisuallyInterruptive(true)
+ .build();
+
+ mEntryDismissed = createBubbleEntry(1, "dismissed", "package.d");
+
mBubbleA1 = new Bubble(mContext, mEntryA1);
mBubbleA2 = new Bubble(mContext, mEntryA2);
mBubbleA3 = new Bubble(mContext, mEntryA3);
@@ -160,6 +171,77 @@ public class BubbleDataTest extends SysuiTestCase {
assertBubbleRemoved(mBubbleA1, BubbleController.DISMISS_USER_GESTURE);
}
+ @Test
+ public void ifSuppress_hideFlyout() {
+ // Setup
+ mBubbleData.setListener(mListener);
+
+ // Test
+ mBubbleData.notificationEntryUpdated(mEntryC1, /* suppressFlyout */ true, /* showInShade */
+ true);
+
+ // Verify
+ verifyUpdateReceived();
+ BubbleData.Update update = mUpdateCaptor.getValue();
+ assertThat(update.addedBubble.showFlyoutForBubble()).isFalse();
+ }
+
+ @Test
+ public void ifInterruptiveAndNotSuppressed_thenShowFlyout() {
+ // Setup
+ mBubbleData.setListener(mListener);
+
+ // Test
+ mBubbleData.notificationEntryUpdated(mEntryInterruptive, /* suppressFlyout */
+ false, /* showInShade */
+ true);
+
+ // Verify
+ verifyUpdateReceived();
+ BubbleData.Update update = mUpdateCaptor.getValue();
+ assertThat(update.addedBubble.showFlyoutForBubble()).isTrue();
+ }
+
+ @Test
+ public void sameUpdate_InShade_thenHideFlyout() {
+ // Setup
+ mBubbleData.setListener(mListener);
+
+ // Test
+ mBubbleData.notificationEntryUpdated(mEntryC1, /* suppressFlyout */ false, /* showInShade */
+ true);
+ verifyUpdateReceived();
+
+ mBubbleData.notificationEntryUpdated(mEntryC1, /* suppressFlyout */ false, /* showInShade */
+ true);
+ verifyUpdateReceived();
+
+ // Verify
+ BubbleData.Update update = mUpdateCaptor.getValue();
+ assertThat(update.updatedBubble.showFlyoutForBubble()).isFalse();
+ }
+
+ @Test
+ public void sameUpdate_NotInShade_showFlyout() {
+ // Setup
+ mBubbleData.setListener(mListener);
+ setMetadataFlags(mEntryDismissed,
+ Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, /* enableFlag */ true);
+
+ // Test
+ mBubbleData.notificationEntryUpdated(mEntryDismissed, /* suppressFlyout */ false,
+ /* showInShade */ false);
+ verifyUpdateReceived();
+
+ mBubbleData.notificationEntryUpdated(mEntryDismissed, /* suppressFlyout */
+ false, /* showInShade */ false);
+ verifyUpdateReceived();
+
+ // Verify
+ BubbleData.Update update = mUpdateCaptor.getValue();
+ assertThat(update.updatedBubble.showFlyoutForBubble()).isTrue();
+ }
+
// COLLAPSED / ADD
/**
@@ -854,6 +936,23 @@ public class BubbleDataTest extends SysuiTestCase {
}
/**
+ * Sets the bubble metadata flags for this entry. These flags are normally set by
+ * NotificationManagerService when the notification is sent, however, these tests do not
+ * go through that path so we set them explicitly when testing.
+ */
+ private void setMetadataFlags(NotificationEntry entry, int flag, boolean enableFlag) {
+ Notification.BubbleMetadata bubbleMetadata =
+ entry.getSbn().getNotification().getBubbleMetadata();
+ int flags = bubbleMetadata.getFlags();
+ if (enableFlag) {
+ flags |= flag;
+ } else {
+ flags &= ~flag;
+ }
+ bubbleMetadata.setFlags(flags);
+ }
+
+ /**
* No ExpandableNotificationRow is required to test BubbleData. This setup is all that is
* required for BubbleData functionality and verification. NotificationTestHelper is used only
* as a convenience to create a Notification w/BubbleMetadata.
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java
index 820f4652e685..d003b994f6dd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java
@@ -175,6 +175,11 @@ public class RankingBuilder {
return this;
}
+ public RankingBuilder setVisuallyInterruptive(boolean interruptive) {
+ mIsVisuallyInterruptive = interruptive;
+ return this;
+ }
+
public RankingBuilder setImportance(@Importance int importance) {
mImportance = importance;
return this;