diff options
| author | 2020-06-01 16:33:06 +0000 | |
|---|---|---|
| committer | 2020-06-01 16:33:06 +0000 | |
| commit | b60d52c691b11bed231eb242c173f40394d0243d (patch) | |
| tree | 81efb412f6c94e1b09e254d697c63d82812ccc56 | |
| parent | bef3cc88cd6b9310c52b34aca7de9b68ac4b6f72 (diff) | |
| parent | 1dbf98fb579185836df3c86da7d176054d33febf (diff) | |
Merge "Require shortcut to bubble" into rvc-dev am: 1dbf98fb57
Change-Id: I19def868c16ba2100d235e5e8ecb164283ab9777
3 files changed, 43 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/notification/BubbleExtractor.java b/services/core/java/com/android/server/notification/BubbleExtractor.java index 0fa339f65cdb..fd92c4c82f24 100644 --- a/services/core/java/com/android/server/notification/BubbleExtractor.java +++ b/services/core/java/com/android/server/notification/BubbleExtractor.java @@ -78,6 +78,7 @@ public class BubbleExtractor implements NotificationSignalExtractor { boolean canPresentAsBubble = canPresentAsBubble(record) && !mActivityManager.isLowRamDevice() && record.isConversation() + && record.getShortcutInfo() != null && (record.getNotification().flags & FLAG_FOREGROUND_SERVICE) == 0; if (!mConfig.bubblesEnabled() diff --git a/services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java b/services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java index 13457f0a284c..162b2c4ac2d0 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java @@ -431,7 +431,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { } @Test - public void testFlagBubble_false_notConversation() { + public void testFlagBubble_false_noShortcut() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, DEFAULT_ALLOW_BUBBLE /* channel */); @@ -439,7 +439,6 @@ public class BubbleExtractorTest extends UiServiceTestCase { setUpIntentBubble(true /* isValid */); NotificationRecord r = getNotificationRecord(true /* bubble */); - // No longer a conversation: r.setShortcutInfo(null); r.getNotification().extras.putString(Notification.EXTRA_TEMPLATE, null); @@ -451,6 +450,25 @@ public class BubbleExtractorTest extends UiServiceTestCase { } @Test + public void testFlagBubble_false_notConversation() { + setUpBubblesEnabled(true /* feature */, + BUBBLE_PREFERENCE_ALL /* app */, + DEFAULT_ALLOW_BUBBLE /* channel */); + when(mActivityManager.isLowRamDevice()).thenReturn(false); + setUpIntentBubble(true /* isValid */); + + NotificationRecord r = getNotificationRecord(true /* bubble */); + r.userDemotedAppFromConvoSpace(true); + r.getNotification().extras.putString(Notification.EXTRA_TEMPLATE, null); + + mBubbleExtractor.process(r); + + assertFalse(r.canBubble()); + assertNull(r.getNotification().getBubbleMetadata()); + assertFalse(r.getNotification().isBubbleNotification()); + } + + @Test public void testFlagBubble_false_lowRamDevice() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index cf636823d5f7..de9b77c68336 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -5309,6 +5309,28 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test + public void testFlagBubbleNotifs_noFlag_noShortcut() throws RemoteException { + setUpPrefsForBubbles(PKG, mUid, + true /* global */, + BUBBLE_PREFERENCE_ALL /* app */, + true /* channel */); + + Notification.Builder nb = getMessageStyleNotifBuilder(true, null, false); + nb.setShortcutId(null); + StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 1, + null, mUid, 0, + nb.build(), new UserHandle(mUid), null, 0); + + mBinderService.enqueueNotificationWithTag(PKG, PKG, sbn.getTag(), + sbn.getId(), sbn.getNotification(), sbn.getUserId()); + waitForIdle(); + + // no shortcut no bubble + assertFalse(mService.getNotificationRecord( + sbn.getKey()).getNotification().isBubbleNotification()); + } + + @Test public void testFlagBubbleNotifs_noFlag_messaging_appNotAllowed() throws RemoteException { setUpPrefsForBubbles(PKG, mUid, true /* global */, |