Merge "Make FLAG_BUBBLE public; update some documentation" into qt-dev

This commit is contained in:
Mady Mellor
2019-04-10 17:33:20 +00:00
committed by Android (Google) Code Review
3 changed files with 39 additions and 6 deletions

View File

@@ -5335,6 +5335,7 @@ package android.app {
field public static final String EXTRA_TITLE = "android.title"; field public static final String EXTRA_TITLE = "android.title";
field public static final String EXTRA_TITLE_BIG = "android.title.big"; 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_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_FOREGROUND_SERVICE = 64; // 0x40
field public static final int FLAG_GROUP_SUMMARY = 512; // 0x200 field public static final int FLAG_GROUP_SUMMARY = 512; // 0x200
field @Deprecated public static final int FLAG_HIGH_PRIORITY = 128; // 0x80 field @Deprecated public static final int FLAG_HIGH_PRIORITY = 128; // 0x80

View File

@@ -618,9 +618,11 @@ public class Notification implements Parcelable
public static final int FLAG_CAN_COLORIZE = 0x00000800; public static final int FLAG_CAN_COLORIZE = 0x00000800;
/** /**
* Bit to be bitswised-ored into the {@link #flags} field that should be * Bit to be bitswised-ored into the {@link #flags} field that should be set if this
* set if this notification can be shown as a bubble. * notification is showing as a bubble. This will be set by the system if it is determined
* @hide * that your notification is allowed to be a bubble.
*
* @see {@link Notification.Builder#setBubbleMetadata(BubbleMetadata)}
*/ */
public static final int FLAG_BUBBLE = 0x00001000; public static final int FLAG_BUBBLE = 0x00001000;
@@ -3578,9 +3580,9 @@ public class Notification implements Parcelable
* <p>This data will be ignored unless the notification is posted to a channel that * <p>This data will be ignored unless the notification is posted to a channel that
* allows {@link NotificationChannel#canBubble() bubbles}.</p> * allows {@link NotificationChannel#canBubble() bubbles}.</p>
* *
* <b>Notifications with a valid and allowed bubble metadata will display in collapsed state * <p>Notifications allowed to bubble that have valid bubble metadata will display in
* outside of the notification shade on unlocked devices. When a user interacts with the * collapsed state outside of the notification shade on unlocked devices. When a user
* collapsed state, the bubble intent will be invoked and displayed.</b> * interacts with the collapsed state, the bubble intent will be invoked and displayed.</p>
*/ */
@NonNull @NonNull
public Builder setBubbleMetadata(@Nullable BubbleMetadata data) { public Builder setBubbleMetadata(@Nullable BubbleMetadata data) {

View File

@@ -4288,6 +4288,36 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
.onGranted(eq(xmlConfig), eq(0), eq(true)); .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 @Test
public void testFlagBubbleNotifs_flag_appForeground() throws RemoteException { public void testFlagBubbleNotifs_flag_appForeground() throws RemoteException {
// Bubbles are allowed! // Bubbles are allowed!