Merge "Require shortcut to bubble" into rvc-dev
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -430,6 +430,25 @@ public class BubbleExtractorTest extends UiServiceTestCase {
|
||||
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
|
||||
public void testFlagBubble_false_notConversation() {
|
||||
setUpBubblesEnabled(true /* feature */,
|
||||
@@ -439,8 +458,7 @@ public class BubbleExtractorTest extends UiServiceTestCase {
|
||||
setUpIntentBubble(true /* isValid */);
|
||||
|
||||
NotificationRecord r = getNotificationRecord(true /* bubble */);
|
||||
// No longer a conversation:
|
||||
r.setShortcutInfo(null);
|
||||
r.userDemotedAppFromConvoSpace(true);
|
||||
r.getNotification().extras.putString(Notification.EXTRA_TEMPLATE, null);
|
||||
|
||||
mBubbleExtractor.process(r);
|
||||
|
||||
@@ -5308,6 +5308,28 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
||||
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
|
||||
public void testFlagBubbleNotifs_noFlag_messaging_appNotAllowed() throws RemoteException {
|
||||
setUpPrefsForBubbles(PKG, mUid,
|
||||
|
||||
Reference in New Issue
Block a user