Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +20 −6 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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); } Loading packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java +99 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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 /** Loading Loading @@ -853,6 +935,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 Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java +5 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +20 −6 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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); } Loading
packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java +99 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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 /** Loading Loading @@ -853,6 +935,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 Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java +5 −0 Original line number Diff line number Diff line Loading @@ -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; Loading