Merge "Require shortcut to bubble" into rvc-dev am: 1dbf98fb57

Change-Id: I19def868c16ba2100d235e5e8ecb164283ab9777
This commit is contained in:
Mady Mellor
2020-06-01 16:33:06 +00:00
committed by Automerger Merge Worker
3 changed files with 43 additions and 2 deletions

View File

@@ -78,6 +78,7 @@ public class BubbleExtractor implements NotificationSignalExtractor {
boolean canPresentAsBubble = canPresentAsBubble(record) boolean canPresentAsBubble = canPresentAsBubble(record)
&& !mActivityManager.isLowRamDevice() && !mActivityManager.isLowRamDevice()
&& record.isConversation() && record.isConversation()
&& record.getShortcutInfo() != null
&& (record.getNotification().flags & FLAG_FOREGROUND_SERVICE) == 0; && (record.getNotification().flags & FLAG_FOREGROUND_SERVICE) == 0;
if (!mConfig.bubblesEnabled() if (!mConfig.bubblesEnabled()

View File

@@ -430,6 +430,25 @@ public class BubbleExtractorTest extends UiServiceTestCase {
assertFalse(r.getNotification().isBubbleNotification()); assertFalse(r.getNotification().isBubbleNotification());
} }
@Test
public void testFlagBubble_false_noShortcut() {
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.setShortcutInfo(null);
r.getNotification().extras.putString(Notification.EXTRA_TEMPLATE, null);
mBubbleExtractor.process(r);
assertFalse(r.canBubble());
assertNull(r.getNotification().getBubbleMetadata());
assertFalse(r.getNotification().isBubbleNotification());
}
@Test @Test
public void testFlagBubble_false_notConversation() { public void testFlagBubble_false_notConversation() {
setUpBubblesEnabled(true /* feature */, setUpBubblesEnabled(true /* feature */,
@@ -439,8 +458,7 @@ public class BubbleExtractorTest extends UiServiceTestCase {
setUpIntentBubble(true /* isValid */); setUpIntentBubble(true /* isValid */);
NotificationRecord r = getNotificationRecord(true /* bubble */); NotificationRecord r = getNotificationRecord(true /* bubble */);
// No longer a conversation: r.userDemotedAppFromConvoSpace(true);
r.setShortcutInfo(null);
r.getNotification().extras.putString(Notification.EXTRA_TEMPLATE, null); r.getNotification().extras.putString(Notification.EXTRA_TEMPLATE, null);
mBubbleExtractor.process(r); mBubbleExtractor.process(r);

View File

@@ -5308,6 +5308,28 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
nr.getSbn().getKey()).getNotification().isBubbleNotification()); nr.getSbn().getKey()).getNotification().isBubbleNotification());
} }
@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 @Test
public void testFlagBubbleNotifs_noFlag_messaging_appNotAllowed() throws RemoteException { public void testFlagBubbleNotifs_noFlag_messaging_appNotAllowed() throws RemoteException {
setUpPrefsForBubbles(PKG, mUid, setUpPrefsForBubbles(PKG, mUid,