Loading packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java +4 −1 Original line number Diff line number Diff line Loading @@ -297,7 +297,9 @@ class Bubble { * Whether the bubble for this notification should show a dot indicating updated content. */ boolean showDot() { return mShowBubbleUpdateDot && !mEntry.shouldSuppressNotificationDot(); return mShowBubbleUpdateDot && !mEntry.shouldSuppressNotificationDot() && !shouldSuppressNotification(); } /** Loading @@ -305,6 +307,7 @@ class Bubble { */ boolean showFlyout() { return !mSuppressFlyout && !mEntry.shouldSuppressPeek() && !shouldSuppressNotification() && !mEntry.shouldSuppressNotificationList(); } Loading packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +25 −11 Original line number Diff line number Diff line Loading @@ -479,7 +479,7 @@ public class BubbleControllerTest extends SysuiTestCase { } @Test public void testAutoExpand_FailsNotForeground() { public void testAutoExpand_fails_noFlag() { assertFalse(mBubbleController.isStackExpanded()); setMetadataFlags(mRow.getEntry(), Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, false /* enableFlag */); Loading @@ -498,7 +498,7 @@ public class BubbleControllerTest extends SysuiTestCase { } @Test public void testAutoExpand_SucceedsForeground() { public void testAutoExpand_succeeds_withFlag() { setMetadataFlags(mRow.getEntry(), Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, true /* enableFlag */); Loading @@ -516,38 +516,52 @@ public class BubbleControllerTest extends SysuiTestCase { } @Test public void testSuppressNotif_FailsNotForeground() { public void testSuppressNotif_onInitialNotif() { setMetadataFlags(mRow.getEntry(), Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, false /* enableFlag */); Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, true /* enableFlag */); // Add the suppress notif bubble mEntryListener.onPendingEntryAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Should not be suppressed because we weren't forground assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( // Notif should be suppressed because we were foreground assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( mRow.getEntry().getKey())); // Dot + flyout is hidden because notif is suppressed assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showDot()); assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showFlyout()); // # of bubbles should change verify(mBubbleStateChangeListener).onHasBubblesChanged(true /* hasBubbles */); } @Test public void testSuppressNotif_SucceedsForeground() { public void testSuppressNotif_onUpdateNotif() { mBubbleController.updateBubble(mRow.getEntry()); // Should not be suppressed assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( mRow.getEntry().getKey())); // Should show dot assertTrue(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showDot()); // Update to suppress notif setMetadataFlags(mRow.getEntry(), Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, true /* enableFlag */); // Add the suppress notif bubble mEntryListener.onPendingEntryAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Notif should be suppressed because we were foreground // Notif should be suppressed assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( mRow.getEntry().getKey())); // Dot + flyout is hidden because notif is suppressed assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showDot()); assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showFlyout()); // # of bubbles should change verify(mBubbleStateChangeListener).onHasBubblesChanged(true /* hasBubbles */); } @Test public void testExpandStackAndSelectBubble_removedFirst() { final String key = mRow.getEntry().getKey(); Loading packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java +17 −30 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import com.android.systemui.bubbles.BubbleData.TimeSource; import com.android.systemui.statusbar.NotificationEntryBuilder; import com.android.systemui.statusbar.NotificationTestHelper; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.google.common.collect.ImmutableList; Loading Loading @@ -119,7 +120,9 @@ public class BubbleDataTest extends SysuiTestCase { .setVisuallyInterruptive(true) .build(); ExpandableNotificationRow row = mNotificationTestHelper.createBubble(); mEntryDismissed = createBubbleEntry(1, "dismissed", "package.d"); mEntryDismissed.setRow(row); mBubbleA1 = new Bubble(mContext, mEntryA1); mBubbleA2 = new Bubble(mContext, mEntryA2); Loading Loading @@ -192,9 +195,8 @@ public class BubbleDataTest extends SysuiTestCase { mBubbleData.setListener(mListener); // Test mBubbleData.notificationEntryUpdated(mEntryInterruptive, /* suppressFlyout */ false, /* showInShade */ true); mBubbleData.notificationEntryUpdated(mEntryInterruptive, false /* suppressFlyout */, true /* showInShade */); // Verify verifyUpdateReceived(); Loading @@ -208,12 +210,12 @@ public class BubbleDataTest extends SysuiTestCase { mBubbleData.setListener(mListener); // Test mBubbleData.notificationEntryUpdated(mEntryC1, /* suppressFlyout */ false, /* showInShade */ true); mBubbleData.notificationEntryUpdated(mEntryC1, false /* suppressFlyout */, true /* showInShade */); verifyUpdateReceived(); mBubbleData.notificationEntryUpdated(mEntryC1, /* suppressFlyout */ false, /* showInShade */ true); mBubbleData.notificationEntryUpdated(mEntryC1, false /* suppressFlyout */, true /* showInShade */); verifyUpdateReceived(); // Verify Loading @@ -225,16 +227,18 @@ public class BubbleDataTest extends SysuiTestCase { 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); mBubbleData.notificationEntryUpdated(mEntryDismissed, false /* suppressFlyout */, false /* showInShade */); verifyUpdateReceived(); mBubbleData.notificationEntryUpdated(mEntryDismissed, /* suppressFlyout */ false, /* showInShade */ false); // Make it look like user swiped away row mEntryDismissed.getRow().dismiss(false /* refocusOnDismiss */); assertThat(mBubbleData.getBubbleWithKey(mEntryDismissed.getKey()).showInShade()).isFalse(); mBubbleData.notificationEntryUpdated(mEntryDismissed, false /* suppressFlyout */, false /* showInShade */); verifyUpdateReceived(); // Verify Loading Loading @@ -935,23 +939,6 @@ 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 Loading
packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java +4 −1 Original line number Diff line number Diff line Loading @@ -297,7 +297,9 @@ class Bubble { * Whether the bubble for this notification should show a dot indicating updated content. */ boolean showDot() { return mShowBubbleUpdateDot && !mEntry.shouldSuppressNotificationDot(); return mShowBubbleUpdateDot && !mEntry.shouldSuppressNotificationDot() && !shouldSuppressNotification(); } /** Loading @@ -305,6 +307,7 @@ class Bubble { */ boolean showFlyout() { return !mSuppressFlyout && !mEntry.shouldSuppressPeek() && !shouldSuppressNotification() && !mEntry.shouldSuppressNotificationList(); } Loading
packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +25 −11 Original line number Diff line number Diff line Loading @@ -479,7 +479,7 @@ public class BubbleControllerTest extends SysuiTestCase { } @Test public void testAutoExpand_FailsNotForeground() { public void testAutoExpand_fails_noFlag() { assertFalse(mBubbleController.isStackExpanded()); setMetadataFlags(mRow.getEntry(), Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, false /* enableFlag */); Loading @@ -498,7 +498,7 @@ public class BubbleControllerTest extends SysuiTestCase { } @Test public void testAutoExpand_SucceedsForeground() { public void testAutoExpand_succeeds_withFlag() { setMetadataFlags(mRow.getEntry(), Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, true /* enableFlag */); Loading @@ -516,38 +516,52 @@ public class BubbleControllerTest extends SysuiTestCase { } @Test public void testSuppressNotif_FailsNotForeground() { public void testSuppressNotif_onInitialNotif() { setMetadataFlags(mRow.getEntry(), Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, false /* enableFlag */); Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, true /* enableFlag */); // Add the suppress notif bubble mEntryListener.onPendingEntryAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Should not be suppressed because we weren't forground assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( // Notif should be suppressed because we were foreground assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( mRow.getEntry().getKey())); // Dot + flyout is hidden because notif is suppressed assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showDot()); assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showFlyout()); // # of bubbles should change verify(mBubbleStateChangeListener).onHasBubblesChanged(true /* hasBubbles */); } @Test public void testSuppressNotif_SucceedsForeground() { public void testSuppressNotif_onUpdateNotif() { mBubbleController.updateBubble(mRow.getEntry()); // Should not be suppressed assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( mRow.getEntry().getKey())); // Should show dot assertTrue(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showDot()); // Update to suppress notif setMetadataFlags(mRow.getEntry(), Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, true /* enableFlag */); // Add the suppress notif bubble mEntryListener.onPendingEntryAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Notif should be suppressed because we were foreground // Notif should be suppressed assertTrue(mBubbleController.isBubbleNotificationSuppressedFromShade( mRow.getEntry().getKey())); // Dot + flyout is hidden because notif is suppressed assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showDot()); assertFalse(mBubbleData.getBubbleWithKey(mRow.getEntry().getKey()).showFlyout()); // # of bubbles should change verify(mBubbleStateChangeListener).onHasBubblesChanged(true /* hasBubbles */); } @Test public void testExpandStackAndSelectBubble_removedFirst() { final String key = mRow.getEntry().getKey(); Loading
packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java +17 −30 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import com.android.systemui.bubbles.BubbleData.TimeSource; import com.android.systemui.statusbar.NotificationEntryBuilder; import com.android.systemui.statusbar.NotificationTestHelper; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.google.common.collect.ImmutableList; Loading Loading @@ -119,7 +120,9 @@ public class BubbleDataTest extends SysuiTestCase { .setVisuallyInterruptive(true) .build(); ExpandableNotificationRow row = mNotificationTestHelper.createBubble(); mEntryDismissed = createBubbleEntry(1, "dismissed", "package.d"); mEntryDismissed.setRow(row); mBubbleA1 = new Bubble(mContext, mEntryA1); mBubbleA2 = new Bubble(mContext, mEntryA2); Loading Loading @@ -192,9 +195,8 @@ public class BubbleDataTest extends SysuiTestCase { mBubbleData.setListener(mListener); // Test mBubbleData.notificationEntryUpdated(mEntryInterruptive, /* suppressFlyout */ false, /* showInShade */ true); mBubbleData.notificationEntryUpdated(mEntryInterruptive, false /* suppressFlyout */, true /* showInShade */); // Verify verifyUpdateReceived(); Loading @@ -208,12 +210,12 @@ public class BubbleDataTest extends SysuiTestCase { mBubbleData.setListener(mListener); // Test mBubbleData.notificationEntryUpdated(mEntryC1, /* suppressFlyout */ false, /* showInShade */ true); mBubbleData.notificationEntryUpdated(mEntryC1, false /* suppressFlyout */, true /* showInShade */); verifyUpdateReceived(); mBubbleData.notificationEntryUpdated(mEntryC1, /* suppressFlyout */ false, /* showInShade */ true); mBubbleData.notificationEntryUpdated(mEntryC1, false /* suppressFlyout */, true /* showInShade */); verifyUpdateReceived(); // Verify Loading @@ -225,16 +227,18 @@ public class BubbleDataTest extends SysuiTestCase { 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); mBubbleData.notificationEntryUpdated(mEntryDismissed, false /* suppressFlyout */, false /* showInShade */); verifyUpdateReceived(); mBubbleData.notificationEntryUpdated(mEntryDismissed, /* suppressFlyout */ false, /* showInShade */ false); // Make it look like user swiped away row mEntryDismissed.getRow().dismiss(false /* refocusOnDismiss */); assertThat(mBubbleData.getBubbleWithKey(mEntryDismissed.getKey()).showInShade()).isFalse(); mBubbleData.notificationEntryUpdated(mEntryDismissed, false /* suppressFlyout */, false /* showInShade */); verifyUpdateReceived(); // Verify Loading Loading @@ -935,23 +939,6 @@ 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