Loading core/java/android/app/NotificationChannel.java +13 −6 Original line number Diff line number Diff line Loading @@ -161,6 +161,19 @@ public final class NotificationChannel implements Parcelable { USER_LOCKED_ALLOW_BUBBLE }; /** * @hide */ public static final int DEFAULT_ALLOW_BUBBLE = -1; /** * @hide */ public static final int ALLOW_BUBBLE_ON = 1; /** * @hide */ public static final int ALLOW_BUBBLE_OFF = 0; private static final int DEFAULT_LIGHT_COLOR = 0; private static final int DEFAULT_VISIBILITY = NotificationManager.VISIBILITY_NO_OVERRIDE; Loading @@ -168,12 +181,6 @@ public final class NotificationChannel implements Parcelable { NotificationManager.IMPORTANCE_UNSPECIFIED; private static final boolean DEFAULT_DELETED = false; private static final boolean DEFAULT_SHOW_BADGE = true; /** * @hide */ public static final int DEFAULT_ALLOW_BUBBLE = -1; private static final int ALLOW_BUBBLE_ON = 1; private static final int ALLOW_BUBBLE_OFF = 0; @UnsupportedAppUsage private String mId; Loading services/core/java/com/android/server/notification/BubbleExtractor.java +2 −5 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package com.android.server.notification; import static android.app.Notification.FLAG_BUBBLE; import static android.app.Notification.FLAG_FOREGROUND_SERVICE; import static android.app.NotificationChannel.USER_LOCKED_ALLOW_BUBBLE; import static android.app.NotificationChannel.ALLOW_BUBBLE_OFF; import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL; import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE; import static android.app.NotificationManager.BUBBLE_PREFERENCE_SELECTED; Loading Loading @@ -82,10 +82,7 @@ public class BubbleExtractor implements NotificationSignalExtractor { // the app is allowed but there's no channel to check record.setAllowBubble(true); } else if (bubblePreference == BUBBLE_PREFERENCE_ALL) { // by default the channel is not allowed, only don't bubble if the user specified boolean userLockedNoBubbles = !recordChannel.canBubble() && (recordChannel.getUserLockedFields() & USER_LOCKED_ALLOW_BUBBLE) != 0; record.setAllowBubble(!userLockedNoBubbles); record.setAllowBubble(recordChannel.getAllowBubbles() != ALLOW_BUBBLE_OFF); } else if (bubblePreference == BUBBLE_PREFERENCE_SELECTED) { record.setAllowBubble(recordChannel.canBubble()); } Loading services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java +74 −34 Original line number Diff line number Diff line Loading @@ -15,10 +15,13 @@ */ package com.android.server.notification; import static android.app.NotificationChannel.USER_LOCKED_ALLOW_BUBBLE; import static android.app.NotificationChannel.ALLOW_BUBBLE_OFF; import static android.app.NotificationChannel.ALLOW_BUBBLE_ON; import static android.app.NotificationChannel.DEFAULT_ALLOW_BUBBLE; import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL; import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE; import static android.app.NotificationManager.BUBBLE_PREFERENCE_SELECTED; import static android.app.NotificationManager.IMPORTANCE_DEFAULT; import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE; import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE; Loading Loading @@ -59,6 +62,7 @@ import org.mockito.MockitoAnnotations; @RunWith(AndroidJUnit4.class) public class BubbleExtractorTest extends UiServiceTestCase { private static final String CHANNEL_ID = "bubbleExtractorChannelId"; private static final String SHORTCUT_ID = "shortcut"; private static final String PKG = "com.android.server.notification"; private static final String TAG = null; Loading @@ -68,12 +72,11 @@ public class BubbleExtractorTest extends UiServiceTestCase { UserHandle mUser = UserHandle.of(ActivityManager.getCurrentUser()); BubbleExtractor mBubbleExtractor; NotificationChannel mChannel; @Mock RankingConfig mConfig; @Mock NotificationChannel mChannel; @Mock Notification.BubbleMetadata mBubbleMetadata; @Mock PendingIntent mPendingIntent; Loading @@ -95,7 +98,8 @@ public class BubbleExtractorTest extends UiServiceTestCase { mBubbleExtractor.setShortcutHelper(mShortcutHelper); mBubbleExtractor.setActivityManager(mActivityManager); when(mConfig.getNotificationChannel(PKG, UID, "a", false)).thenReturn(mChannel); mChannel = new NotificationChannel(CHANNEL_ID, CHANNEL_ID, IMPORTANCE_DEFAULT); when(mConfig.getNotificationChannel(PKG, UID, CHANNEL_ID, false)).thenReturn(mChannel); when(mShortcutInfo.getId()).thenReturn(SHORTCUT_ID); } Loading Loading @@ -147,10 +151,10 @@ public class BubbleExtractorTest extends UiServiceTestCase { when(mShortcutHelper.getValidShortcutInfo(SHORTCUT_ID, PKG, mUser)).thenReturn(answer); } void setUpBubblesEnabled(boolean feature, int app, boolean channel) { void setUpBubblesEnabled(boolean feature, int app, int channel) { when(mConfig.bubblesEnabled()).thenReturn(feature); when(mConfig.getBubblePreference(anyString(), anyInt())).thenReturn(app); when(mChannel.canBubble()).thenReturn(channel); mChannel.setAllowBubbles(channel); } // Loading @@ -161,9 +165,8 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testAppYesChannelNo() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, false /* channel */); ALLOW_BUBBLE_OFF /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); when(mChannel.getUserLockedFields()).thenReturn(USER_LOCKED_ALLOW_BUBBLE); mBubbleExtractor.process(r); assertFalse(r.canBubble()); Loading @@ -171,23 +174,22 @@ public class BubbleExtractorTest extends UiServiceTestCase { } @Test public void testAppNoChannelYes() throws Exception { public void testAppYesChannelDefault() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_NONE /* app */, true /* channel */); BUBBLE_PREFERENCE_ALL /* app */, DEFAULT_ALLOW_BUBBLE /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); assertFalse(r.canBubble()); assertFalse(r.getNotification().isBubbleNotification()); assertTrue(r.canBubble()); } @Test public void testAppYesChannelYes() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); ALLOW_BUBBLE_ON /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); Loading @@ -196,10 +198,23 @@ public class BubbleExtractorTest extends UiServiceTestCase { } @Test public void testAppNoChannelNo() { public void testAppYesChannelYesFeatureNo() { setUpBubblesEnabled(false /* feature */, BUBBLE_PREFERENCE_ALL /* app */, ALLOW_BUBBLE_ON /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); assertFalse(r.canBubble()); assertFalse(r.getNotification().isBubbleNotification()); } @Test public void testAppNoChannelYes() throws Exception { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_NONE /* app */, false /* channel */); ALLOW_BUBBLE_ON /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); Loading @@ -209,10 +224,23 @@ public class BubbleExtractorTest extends UiServiceTestCase { } @Test public void testAppYesChannelYesUserNo() { setUpBubblesEnabled(false /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); public void testAppNoChannelDefault() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_NONE /* app */, DEFAULT_ALLOW_BUBBLE /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); assertFalse(r.canBubble()); assertFalse(r.getNotification().isBubbleNotification()); } @Test public void testAppSelectedChannelDefault() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_SELECTED /* app */, DEFAULT_ALLOW_BUBBLE /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); Loading @@ -225,7 +253,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testAppSelectedChannelNo() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_SELECTED /* app */, false /* channel */); ALLOW_BUBBLE_OFF /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); Loading @@ -238,15 +266,27 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testAppSeletedChannelYes() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_SELECTED /* app */, true /* channel */); ALLOW_BUBBLE_ON /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); when(mChannel.getUserLockedFields()).thenReturn(USER_LOCKED_ALLOW_BUBBLE); mBubbleExtractor.process(r); assertTrue(r.canBubble()); } @Test public void testAppSeletedChannelYesFeatureNo() { setUpBubblesEnabled(false /* feature */, BUBBLE_PREFERENCE_SELECTED /* app */, ALLOW_BUBBLE_ON /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); assertFalse(r.canBubble()); assertFalse(r.getNotification().isBubbleNotification()); } // // Tests for flagging it as a bubble. // Loading @@ -255,7 +295,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_previouslyRemoved() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); setUpShortcutBubble(true /* isValid */); Loading @@ -272,7 +312,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_true_shortcutBubble() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); setUpShortcutBubble(true /* isValid */); Loading @@ -287,7 +327,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_true_intentBubble() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); setUpIntentBubble(true /* isValid */); Loading @@ -302,7 +342,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_noIntentInvalidShortcut() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); setUpShortcutBubble(false /* isValid */); Loading @@ -318,7 +358,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_invalidIntentNoShortcut() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); setUpIntentBubble(false /* isValid */); Loading @@ -334,7 +374,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_noIntentNoShortcut() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); // Shortcut here is for the notification not the bubble Loading @@ -349,7 +389,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_noMetadata() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); NotificationRecord r = getNotificationRecord(false /* bubble */); Loading @@ -363,7 +403,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_notConversation() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); setUpIntentBubble(true /* isValid */); Loading @@ -382,7 +422,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_lowRamDevice() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(true); setUpIntentBubble(true /* isValid */); Loading @@ -397,7 +437,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_noIntent() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(true); setUpIntentBubble(true /* isValid */); when(mPendingIntent.getIntent()).thenReturn(null); Loading @@ -413,7 +453,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_noActivityInfo() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(true); setUpIntentBubble(true /* isValid */); when(mPendingIntent.getIntent()).thenReturn(mIntent); Loading Loading
core/java/android/app/NotificationChannel.java +13 −6 Original line number Diff line number Diff line Loading @@ -161,6 +161,19 @@ public final class NotificationChannel implements Parcelable { USER_LOCKED_ALLOW_BUBBLE }; /** * @hide */ public static final int DEFAULT_ALLOW_BUBBLE = -1; /** * @hide */ public static final int ALLOW_BUBBLE_ON = 1; /** * @hide */ public static final int ALLOW_BUBBLE_OFF = 0; private static final int DEFAULT_LIGHT_COLOR = 0; private static final int DEFAULT_VISIBILITY = NotificationManager.VISIBILITY_NO_OVERRIDE; Loading @@ -168,12 +181,6 @@ public final class NotificationChannel implements Parcelable { NotificationManager.IMPORTANCE_UNSPECIFIED; private static final boolean DEFAULT_DELETED = false; private static final boolean DEFAULT_SHOW_BADGE = true; /** * @hide */ public static final int DEFAULT_ALLOW_BUBBLE = -1; private static final int ALLOW_BUBBLE_ON = 1; private static final int ALLOW_BUBBLE_OFF = 0; @UnsupportedAppUsage private String mId; Loading
services/core/java/com/android/server/notification/BubbleExtractor.java +2 −5 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package com.android.server.notification; import static android.app.Notification.FLAG_BUBBLE; import static android.app.Notification.FLAG_FOREGROUND_SERVICE; import static android.app.NotificationChannel.USER_LOCKED_ALLOW_BUBBLE; import static android.app.NotificationChannel.ALLOW_BUBBLE_OFF; import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL; import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE; import static android.app.NotificationManager.BUBBLE_PREFERENCE_SELECTED; Loading Loading @@ -82,10 +82,7 @@ public class BubbleExtractor implements NotificationSignalExtractor { // the app is allowed but there's no channel to check record.setAllowBubble(true); } else if (bubblePreference == BUBBLE_PREFERENCE_ALL) { // by default the channel is not allowed, only don't bubble if the user specified boolean userLockedNoBubbles = !recordChannel.canBubble() && (recordChannel.getUserLockedFields() & USER_LOCKED_ALLOW_BUBBLE) != 0; record.setAllowBubble(!userLockedNoBubbles); record.setAllowBubble(recordChannel.getAllowBubbles() != ALLOW_BUBBLE_OFF); } else if (bubblePreference == BUBBLE_PREFERENCE_SELECTED) { record.setAllowBubble(recordChannel.canBubble()); } Loading
services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java +74 −34 Original line number Diff line number Diff line Loading @@ -15,10 +15,13 @@ */ package com.android.server.notification; import static android.app.NotificationChannel.USER_LOCKED_ALLOW_BUBBLE; import static android.app.NotificationChannel.ALLOW_BUBBLE_OFF; import static android.app.NotificationChannel.ALLOW_BUBBLE_ON; import static android.app.NotificationChannel.DEFAULT_ALLOW_BUBBLE; import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL; import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE; import static android.app.NotificationManager.BUBBLE_PREFERENCE_SELECTED; import static android.app.NotificationManager.IMPORTANCE_DEFAULT; import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE; import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE; Loading Loading @@ -59,6 +62,7 @@ import org.mockito.MockitoAnnotations; @RunWith(AndroidJUnit4.class) public class BubbleExtractorTest extends UiServiceTestCase { private static final String CHANNEL_ID = "bubbleExtractorChannelId"; private static final String SHORTCUT_ID = "shortcut"; private static final String PKG = "com.android.server.notification"; private static final String TAG = null; Loading @@ -68,12 +72,11 @@ public class BubbleExtractorTest extends UiServiceTestCase { UserHandle mUser = UserHandle.of(ActivityManager.getCurrentUser()); BubbleExtractor mBubbleExtractor; NotificationChannel mChannel; @Mock RankingConfig mConfig; @Mock NotificationChannel mChannel; @Mock Notification.BubbleMetadata mBubbleMetadata; @Mock PendingIntent mPendingIntent; Loading @@ -95,7 +98,8 @@ public class BubbleExtractorTest extends UiServiceTestCase { mBubbleExtractor.setShortcutHelper(mShortcutHelper); mBubbleExtractor.setActivityManager(mActivityManager); when(mConfig.getNotificationChannel(PKG, UID, "a", false)).thenReturn(mChannel); mChannel = new NotificationChannel(CHANNEL_ID, CHANNEL_ID, IMPORTANCE_DEFAULT); when(mConfig.getNotificationChannel(PKG, UID, CHANNEL_ID, false)).thenReturn(mChannel); when(mShortcutInfo.getId()).thenReturn(SHORTCUT_ID); } Loading Loading @@ -147,10 +151,10 @@ public class BubbleExtractorTest extends UiServiceTestCase { when(mShortcutHelper.getValidShortcutInfo(SHORTCUT_ID, PKG, mUser)).thenReturn(answer); } void setUpBubblesEnabled(boolean feature, int app, boolean channel) { void setUpBubblesEnabled(boolean feature, int app, int channel) { when(mConfig.bubblesEnabled()).thenReturn(feature); when(mConfig.getBubblePreference(anyString(), anyInt())).thenReturn(app); when(mChannel.canBubble()).thenReturn(channel); mChannel.setAllowBubbles(channel); } // Loading @@ -161,9 +165,8 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testAppYesChannelNo() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, false /* channel */); ALLOW_BUBBLE_OFF /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); when(mChannel.getUserLockedFields()).thenReturn(USER_LOCKED_ALLOW_BUBBLE); mBubbleExtractor.process(r); assertFalse(r.canBubble()); Loading @@ -171,23 +174,22 @@ public class BubbleExtractorTest extends UiServiceTestCase { } @Test public void testAppNoChannelYes() throws Exception { public void testAppYesChannelDefault() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_NONE /* app */, true /* channel */); BUBBLE_PREFERENCE_ALL /* app */, DEFAULT_ALLOW_BUBBLE /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); assertFalse(r.canBubble()); assertFalse(r.getNotification().isBubbleNotification()); assertTrue(r.canBubble()); } @Test public void testAppYesChannelYes() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); ALLOW_BUBBLE_ON /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); Loading @@ -196,10 +198,23 @@ public class BubbleExtractorTest extends UiServiceTestCase { } @Test public void testAppNoChannelNo() { public void testAppYesChannelYesFeatureNo() { setUpBubblesEnabled(false /* feature */, BUBBLE_PREFERENCE_ALL /* app */, ALLOW_BUBBLE_ON /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); assertFalse(r.canBubble()); assertFalse(r.getNotification().isBubbleNotification()); } @Test public void testAppNoChannelYes() throws Exception { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_NONE /* app */, false /* channel */); ALLOW_BUBBLE_ON /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); Loading @@ -209,10 +224,23 @@ public class BubbleExtractorTest extends UiServiceTestCase { } @Test public void testAppYesChannelYesUserNo() { setUpBubblesEnabled(false /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); public void testAppNoChannelDefault() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_NONE /* app */, DEFAULT_ALLOW_BUBBLE /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); assertFalse(r.canBubble()); assertFalse(r.getNotification().isBubbleNotification()); } @Test public void testAppSelectedChannelDefault() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_SELECTED /* app */, DEFAULT_ALLOW_BUBBLE /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); Loading @@ -225,7 +253,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testAppSelectedChannelNo() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_SELECTED /* app */, false /* channel */); ALLOW_BUBBLE_OFF /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); Loading @@ -238,15 +266,27 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testAppSeletedChannelYes() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_SELECTED /* app */, true /* channel */); ALLOW_BUBBLE_ON /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); when(mChannel.getUserLockedFields()).thenReturn(USER_LOCKED_ALLOW_BUBBLE); mBubbleExtractor.process(r); assertTrue(r.canBubble()); } @Test public void testAppSeletedChannelYesFeatureNo() { setUpBubblesEnabled(false /* feature */, BUBBLE_PREFERENCE_SELECTED /* app */, ALLOW_BUBBLE_ON /* channel */); NotificationRecord r = getNotificationRecord(true /* bubble */); mBubbleExtractor.process(r); assertFalse(r.canBubble()); assertFalse(r.getNotification().isBubbleNotification()); } // // Tests for flagging it as a bubble. // Loading @@ -255,7 +295,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_previouslyRemoved() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); setUpShortcutBubble(true /* isValid */); Loading @@ -272,7 +312,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_true_shortcutBubble() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); setUpShortcutBubble(true /* isValid */); Loading @@ -287,7 +327,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_true_intentBubble() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); setUpIntentBubble(true /* isValid */); Loading @@ -302,7 +342,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_noIntentInvalidShortcut() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); setUpShortcutBubble(false /* isValid */); Loading @@ -318,7 +358,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_invalidIntentNoShortcut() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); setUpIntentBubble(false /* isValid */); Loading @@ -334,7 +374,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_noIntentNoShortcut() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); // Shortcut here is for the notification not the bubble Loading @@ -349,7 +389,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_noMetadata() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); NotificationRecord r = getNotificationRecord(false /* bubble */); Loading @@ -363,7 +403,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_notConversation() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(false); setUpIntentBubble(true /* isValid */); Loading @@ -382,7 +422,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_lowRamDevice() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(true); setUpIntentBubble(true /* isValid */); Loading @@ -397,7 +437,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_noIntent() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(true); setUpIntentBubble(true /* isValid */); when(mPendingIntent.getIntent()).thenReturn(null); Loading @@ -413,7 +453,7 @@ public class BubbleExtractorTest extends UiServiceTestCase { public void testFlagBubble_false_noActivityInfo() { setUpBubblesEnabled(true /* feature */, BUBBLE_PREFERENCE_ALL /* app */, true /* channel */); DEFAULT_ALLOW_BUBBLE /* channel */); when(mActivityManager.isLowRamDevice()).thenReturn(true); setUpIntentBubble(true /* isValid */); when(mPendingIntent.getIntent()).thenReturn(mIntent); Loading