diff options
5 files changed, 21 insertions, 48 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index 3aa9f73939ac..a5aed87f5e21 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -395,7 +395,6 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe } if (shouldAutoBubbleForFlags(mContext, entry) || shouldBubble(entry)) { // TODO: handle group summaries - entry.setIsBubble(true); boolean suppressNotification = entry.getBubbleMetadata() != null && entry.getBubbleMetadata().getSuppressInitialNotification() && isForegroundApp(entry.notification.getPackageName()); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java index f1373d142402..4f4dcbc9ce92 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java @@ -21,6 +21,7 @@ import static android.app.Notification.CATEGORY_CALL; import static android.app.Notification.CATEGORY_EVENT; import static android.app.Notification.CATEGORY_MESSAGE; import static android.app.Notification.CATEGORY_REMINDER; +import static android.app.Notification.FLAG_BUBBLE; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST; @@ -146,11 +147,6 @@ public final class NotificationEntry { private boolean hasSentReply; /** - * Whether this notification should be displayed as a bubble. - */ - private boolean mIsBubble; - - /** * Whether this notification has been approved globally, at the app level, and at the channel * level for bubbling. */ @@ -222,12 +218,8 @@ public final class NotificationEntry { this.mHighPriority = highPriority; } - public void setIsBubble(boolean bubbleable) { - mIsBubble = bubbleable; - } - public boolean isBubble() { - return mIsBubble; + return (notification.getNotification().flags & FLAG_BUBBLE) != 0; } public void setBubbleDismissed(boolean userDismissed) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java index 9fa85d307d2a..5e16721fe548 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java @@ -18,9 +18,12 @@ package com.android.systemui.bubbles; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import static com.google.common.truth.Truth.assertThat; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; @@ -42,7 +45,6 @@ import android.widget.FrameLayout; import androidx.test.filters.SmallTest; -import com.android.internal.statusbar.NotificationVisibility; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import com.android.systemui.statusbar.NotificationTestHelper; @@ -96,9 +98,9 @@ public class BubbleControllerTest extends SysuiTestCase { private NotificationTestHelper mNotificationTestHelper; private ExpandableNotificationRow mRow; private ExpandableNotificationRow mRow2; - private ExpandableNotificationRow mNoChannelRow; private ExpandableNotificationRow mAutoExpandRow; private ExpandableNotificationRow mSuppressNotifRow; + private ExpandableNotificationRow mNonBubbleNotifRow; @Mock private NotificationData mNotificationData; @@ -107,9 +109,6 @@ public class BubbleControllerTest extends SysuiTestCase { @Mock private BubbleController.BubbleExpandListener mBubbleExpandListener; @Mock - NotificationVisibility mNotificationVisibility; - - @Mock private PendingIntent mDeleteIntent; private BubbleData mBubbleData; @@ -129,7 +128,7 @@ public class BubbleControllerTest extends SysuiTestCase { mNotificationTestHelper = new NotificationTestHelper(mContext); mRow = mNotificationTestHelper.createBubble(mDeleteIntent); mRow2 = mNotificationTestHelper.createBubble(mDeleteIntent); - mNoChannelRow = mNotificationTestHelper.createBubble(mDeleteIntent); + mNonBubbleNotifRow = mNotificationTestHelper.createRow(); // Some bubbles want to auto expand Notification.BubbleMetadata autoExpandMetadata = @@ -146,7 +145,6 @@ public class BubbleControllerTest extends SysuiTestCase { // Return non-null notification data from the NEM when(mNotificationEntryManager.getNotificationData()).thenReturn(mNotificationData); when(mNotificationData.getChannel(mRow.getEntry().key)).thenReturn(mRow.getEntry().channel); - when(mNotificationData.getChannel(mNoChannelRow.getEntry().key)).thenReturn(null); mBubbleData = new BubbleData(); mBubbleController = new TestableBubbleController(mContext, mStatusBarWindowController, @@ -391,8 +389,7 @@ public class BubbleControllerTest extends SysuiTestCase { mEntryListener.onPendingEntryAdded(mSuppressNotifRow.getEntry()); mBubbleController.updateBubble(mSuppressNotifRow.getEntry(), true /* updatePosition */); - // Should be a bubble & should show in shade because we weren't forground - assertTrue(mSuppressNotifRow.getEntry().isBubble()); + // Should show in shade because we weren't forground assertTrue(mSuppressNotifRow.getEntry().showInShadeWhenBubble()); // # of bubbles should change @@ -428,8 +425,7 @@ public class BubbleControllerTest extends SysuiTestCase { mEntryListener.onPendingEntryAdded(mSuppressNotifRow.getEntry()); mBubbleController.updateBubble(mSuppressNotifRow.getEntry(), true /* updatePosition */); - // Should be a bubble & should NOT show in shade because we were foreground - assertTrue(mSuppressNotifRow.getEntry().isBubble()); + // Should NOT show in shade because we were foreground assertFalse(mSuppressNotifRow.getEntry().showInShadeWhenBubble()); // # of bubbles should change @@ -444,8 +440,6 @@ public class BubbleControllerTest extends SysuiTestCase { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry(), true /* updatePosition */); - assertTrue(mRow.getEntry().isBubble()); - // Simulate notification cancellation. mEntryListener.onEntryRemoved(mRow.getEntry(), null /* notificationVisibility (unused) */, false /* removedbyUser */); @@ -454,15 +448,18 @@ public class BubbleControllerTest extends SysuiTestCase { } @Test - public void testMarkNewNotificationAsBubble() { + public void testMarkNewNotificationAsShowInShade() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); - assertTrue(mRow.getEntry().isBubble()); + assertTrue(mRow.getEntry().showInShadeWhenBubble()); } @Test - public void testMarkNewNotificationAsShowInShade() { - mEntryListener.onPendingEntryAdded(mRow.getEntry()); - assertTrue(mRow.getEntry().showInShadeWhenBubble()); + public void testAddNotif_notBubble() { + mEntryListener.onPendingEntryAdded(mNonBubbleNotifRow.getEntry()); + mEntryListener.onPreEntryUpdated(mNonBubbleNotifRow.getEntry()); + + verify(mBubbleStateChangeListener, never()).onHasBubblesChanged(anyBoolean()); + assertThat(mBubbleController.hasBubbles()).isFalse(); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java index 7e089a653b9e..8cc1571b925f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java @@ -16,6 +16,7 @@ package com.android.systemui.statusbar; +import static android.app.Notification.FLAG_BUBBLE; import static android.app.NotificationManager.IMPORTANCE_DEFAULT; import static android.app.NotificationManager.IMPORTANCE_HIGH; @@ -154,9 +155,7 @@ public class NotificationTestHelper { */ public ExpandableNotificationRow createBubble() throws Exception { - Notification n = createNotification(false /* isGroupSummary */, - null /* groupKey */, makeBubbleMetadata(null)); - return generateRow(n, PKG, UID, USER_HANDLE, 0 /* extraInflationFlags */, IMPORTANCE_HIGH); + return createBubble(makeBubbleMetadata(null), PKG); } /** @@ -166,21 +165,7 @@ public class NotificationTestHelper { */ public ExpandableNotificationRow createBubble(@Nullable PendingIntent deleteIntent) throws Exception { - Notification n = createNotification(false /* isGroupSummary */, - null /* groupKey */, makeBubbleMetadata(deleteIntent)); - return generateRow(n, PKG, UID, USER_HANDLE, 0 /* extraInflationFlags */, IMPORTANCE_HIGH); - } - - /** - * Returns an {@link ExpandableNotificationRow} that should be shown as a bubble. - * - * @param bubbleMetadata the {@link BubbleMetadata} to use - */ - public ExpandableNotificationRow createBubble(BubbleMetadata bubbleMetadata) - throws Exception { - Notification n = createNotification(false /* isGroupSummary */, - null /* groupKey */, bubbleMetadata); - return generateRow(n, PKG, UID, USER_HANDLE, 0 /* extraInflationFlags */, IMPORTANCE_HIGH); + return createBubble(makeBubbleMetadata(deleteIntent), PKG); } /** @@ -192,6 +177,7 @@ public class NotificationTestHelper { throws Exception { Notification n = createNotification(false /* isGroupSummary */, null /* groupKey */, bubbleMetadata); + n.flags |= FLAG_BUBBLE; return generateRow(n, pkg, UID, USER_HANDLE, 0 /* extraInflationFlags */, IMPORTANCE_HIGH); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java index 41e82cbeac36..51fb47bd049c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java @@ -152,7 +152,6 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { bubbleSbn.getNotification().contentIntent = mContentIntent; bubbleSbn.getNotification().flags |= Notification.FLAG_AUTO_CANCEL; // Do what BubbleController's NotificationEntryListener#onPendingEntryAdded does: - mBubbleNotificationRow.getEntry().setIsBubble(true); mBubbleNotificationRow.getEntry().setShowInShadeWhenBubble(true); mActiveNotifications = new ArrayList<>(); |