Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -5335,6 +5335,7 @@ package android.app { field public static final String EXTRA_TITLE = "android.title"; field public static final String EXTRA_TITLE_BIG = "android.title.big"; field public static final int FLAG_AUTO_CANCEL = 16; // 0x10 field public static final int FLAG_BUBBLE = 4096; // 0x1000 field public static final int FLAG_FOREGROUND_SERVICE = 64; // 0x40 field public static final int FLAG_GROUP_SUMMARY = 512; // 0x200 field @Deprecated public static final int FLAG_HIGH_PRIORITY = 128; // 0x80 core/java/android/app/Notification.java +8 −6 Original line number Diff line number Diff line Loading @@ -618,9 +618,11 @@ public class Notification implements Parcelable public static final int FLAG_CAN_COLORIZE = 0x00000800; /** * Bit to be bitswised-ored into the {@link #flags} field that should be * set if this notification can be shown as a bubble. * @hide * Bit to be bitswised-ored into the {@link #flags} field that should be set if this * notification is showing as a bubble. This will be set by the system if it is determined * that your notification is allowed to be a bubble. * * @see {@link Notification.Builder#setBubbleMetadata(BubbleMetadata)} */ public static final int FLAG_BUBBLE = 0x00001000; Loading Loading @@ -3578,9 +3580,9 @@ public class Notification implements Parcelable * <p>This data will be ignored unless the notification is posted to a channel that * allows {@link NotificationChannel#canBubble() bubbles}.</p> * * <b>Notifications with a valid and allowed bubble metadata will display in collapsed state * outside of the notification shade on unlocked devices. When a user interacts with the * collapsed state, the bubble intent will be invoked and displayed.</b> * <p>Notifications allowed to bubble that have valid bubble metadata will display in * collapsed state outside of the notification shade on unlocked devices. When a user * interacts with the collapsed state, the bubble intent will be invoked and displayed.</p> */ @NonNull public Builder setBubbleMetadata(@Nullable BubbleMetadata data) { Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -4288,6 +4288,36 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { .onGranted(eq(xmlConfig), eq(0), eq(true)); } @Test public void testFlagBubble() throws RemoteException { // Bubbles are allowed! mService.setPreferencesHelper(mPreferencesHelper); when(mPreferencesHelper.areBubblesAllowed(anyString(), anyInt())).thenReturn(true); when(mPreferencesHelper.getNotificationChannel( anyString(), anyInt(), anyString(), anyBoolean())).thenReturn( mTestNotificationChannel); when(mPreferencesHelper.getImportance(anyString(), anyInt())).thenReturn( mTestNotificationChannel.getImportance()); // Notif with bubble metadata but not our other misc requirements NotificationRecord nr = generateNotificationRecord(mTestNotificationChannel, null /* tvExtender */, true /* isBubble */); // Say we're foreground when(mActivityManager.getPackageImportance(nr.sbn.getPackageName())).thenReturn( IMPORTANCE_FOREGROUND); mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag", nr.sbn.getId(), nr.sbn.getNotification(), nr.sbn.getUserId()); waitForIdle(); StatusBarNotification[] notifs = mBinderService.getActiveNotifications(PKG); assertEquals(1, notifs.length); assertTrue((notifs[0].getNotification().flags & FLAG_BUBBLE) != 0); assertTrue(mService.getNotificationRecord( nr.sbn.getKey()).getNotification().isBubbleNotification()); } @Test public void testFlagBubbleNotifs_flag_appForeground() throws RemoteException { // Bubbles are allowed! Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -5335,6 +5335,7 @@ package android.app { field public static final String EXTRA_TITLE = "android.title"; field public static final String EXTRA_TITLE_BIG = "android.title.big"; field public static final int FLAG_AUTO_CANCEL = 16; // 0x10 field public static final int FLAG_BUBBLE = 4096; // 0x1000 field public static final int FLAG_FOREGROUND_SERVICE = 64; // 0x40 field public static final int FLAG_GROUP_SUMMARY = 512; // 0x200 field @Deprecated public static final int FLAG_HIGH_PRIORITY = 128; // 0x80
core/java/android/app/Notification.java +8 −6 Original line number Diff line number Diff line Loading @@ -618,9 +618,11 @@ public class Notification implements Parcelable public static final int FLAG_CAN_COLORIZE = 0x00000800; /** * Bit to be bitswised-ored into the {@link #flags} field that should be * set if this notification can be shown as a bubble. * @hide * Bit to be bitswised-ored into the {@link #flags} field that should be set if this * notification is showing as a bubble. This will be set by the system if it is determined * that your notification is allowed to be a bubble. * * @see {@link Notification.Builder#setBubbleMetadata(BubbleMetadata)} */ public static final int FLAG_BUBBLE = 0x00001000; Loading Loading @@ -3578,9 +3580,9 @@ public class Notification implements Parcelable * <p>This data will be ignored unless the notification is posted to a channel that * allows {@link NotificationChannel#canBubble() bubbles}.</p> * * <b>Notifications with a valid and allowed bubble metadata will display in collapsed state * outside of the notification shade on unlocked devices. When a user interacts with the * collapsed state, the bubble intent will be invoked and displayed.</b> * <p>Notifications allowed to bubble that have valid bubble metadata will display in * collapsed state outside of the notification shade on unlocked devices. When a user * interacts with the collapsed state, the bubble intent will be invoked and displayed.</p> */ @NonNull public Builder setBubbleMetadata(@Nullable BubbleMetadata data) { Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -4288,6 +4288,36 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { .onGranted(eq(xmlConfig), eq(0), eq(true)); } @Test public void testFlagBubble() throws RemoteException { // Bubbles are allowed! mService.setPreferencesHelper(mPreferencesHelper); when(mPreferencesHelper.areBubblesAllowed(anyString(), anyInt())).thenReturn(true); when(mPreferencesHelper.getNotificationChannel( anyString(), anyInt(), anyString(), anyBoolean())).thenReturn( mTestNotificationChannel); when(mPreferencesHelper.getImportance(anyString(), anyInt())).thenReturn( mTestNotificationChannel.getImportance()); // Notif with bubble metadata but not our other misc requirements NotificationRecord nr = generateNotificationRecord(mTestNotificationChannel, null /* tvExtender */, true /* isBubble */); // Say we're foreground when(mActivityManager.getPackageImportance(nr.sbn.getPackageName())).thenReturn( IMPORTANCE_FOREGROUND); mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag", nr.sbn.getId(), nr.sbn.getNotification(), nr.sbn.getUserId()); waitForIdle(); StatusBarNotification[] notifs = mBinderService.getActiveNotifications(PKG); assertEquals(1, notifs.length); assertTrue((notifs[0].getNotification().flags & FLAG_BUBBLE) != 0); assertTrue(mService.getNotificationRecord( nr.sbn.getKey()).getNotification().isBubbleNotification()); } @Test public void testFlagBubbleNotifs_flag_appForeground() throws RemoteException { // Bubbles are allowed! Loading