Merge "Update the flag in system UI rather than reposting the notif" into qt-dev

am: 7babaf9060

Change-Id: Id564916fd6ed29174e5b269b8182b0a35eb5bef1
This commit is contained in:
Mady Mellor
2019-05-28 13:49:13 -07:00
committed by android-build-merger
3 changed files with 14 additions and 25 deletions

View File

@@ -16,6 +16,7 @@
package com.android.systemui.bubbles;
import static android.app.Notification.FLAG_BUBBLE;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK;
@@ -547,8 +548,11 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
mNotificationEntryManager.performRemoveNotification(bubble.entry.notification,
UNDEFINED_DISMISS_REASON);
} else {
// The notification is still in the shade but we've removed the bubble so
// lets make sure NoMan knows it's not a bubble anymore
// Update the flag for SysUI
bubble.entry.notification.getNotification().flags &= ~FLAG_BUBBLE;
// Make sure NoMan knows it's not a bubble anymore so anyone querying it will
// get right result back
try {
mBarService.onNotificationBubbleChanged(bubble.getKey(),
false /* isBubble */);

View File

@@ -1036,19 +1036,12 @@ public class NotificationManagerService extends SystemService {
final StatusBarNotification n = r.sbn;
final int callingUid = n.getUid();
final String pkg = n.getPackageName();
final boolean wasBubble = r.getNotification().isBubbleNotification();
if (isBubble && isNotificationAppropriateToBubble(r, pkg, callingUid,
null /* oldEntry */)) {
r.getNotification().flags |= FLAG_BUBBLE;
} else {
r.getNotification().flags &= ~FLAG_BUBBLE;
}
if (wasBubble != r.getNotification().isBubbleNotification()) {
// Add the "alert only once" flag so that the notification won't HUN
// unnecessarily just because the bubble flag was changed.
r.getNotification().flags |= FLAG_ONLY_ALERT_ONCE;
mListeners.notifyPostedLocked(r, r);
}
}
}
}

View File

@@ -22,7 +22,6 @@ import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIB
import static android.app.Notification.CATEGORY_CALL;
import static android.app.Notification.FLAG_BUBBLE;
import static android.app.Notification.FLAG_FOREGROUND_SERVICE;
import static android.app.Notification.FLAG_ONLY_ALERT_ONCE;
import static android.app.NotificationManager.EXTRA_BLOCKED_STATE;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_HIGH;
@@ -4963,13 +4962,10 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
mService.mNotificationDelegate.onNotificationBubbleChanged(nr.getKey(), false);
waitForIdle();
// Make sure we are not a bubble / reported as such to listeners
ArgumentCaptor<NotificationRecord> captor =
ArgumentCaptor.forClass(NotificationRecord.class);
verify(mListeners, times(1)).notifyPostedLocked(captor.capture(), any());
assertEquals((captor.getValue().getNotification().flags & FLAG_BUBBLE), 0);
assertTrue((captor.getValue().getNotification().flags & FLAG_ONLY_ALERT_ONCE) != 0);
// Make sure we are not a bubble
StatusBarNotification[] notifsAfter = mBinderService.getActiveNotifications(PKG);
assertEquals(1, notifsAfter.length);
assertEquals((notifsAfter[0].getNotification().flags & FLAG_BUBBLE), 0);
}
@Test
@@ -5000,13 +4996,10 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
mService.mNotificationDelegate.onNotificationBubbleChanged(nr.getKey(), true);
waitForIdle();
// Make sure we are a bubble / reported as such to listeners
ArgumentCaptor<NotificationRecord> captor =
ArgumentCaptor.forClass(NotificationRecord.class);
verify(mListeners, times(1)).notifyPostedLocked(captor.capture(), any());
assertTrue((captor.getValue().getNotification().flags & FLAG_BUBBLE) != 0);
assertTrue((captor.getValue().getNotification().flags & FLAG_ONLY_ALERT_ONCE) != 0);
// Make sure we are a bubble
StatusBarNotification[] notifsAfter = mBinderService.getActiveNotifications(PKG);
assertEquals(1, notifsAfter.length);
assertTrue((notifsAfter[0].getNotification().flags & FLAG_BUBBLE) != 0);
}
@Test
@@ -5037,7 +5030,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
StatusBarNotification[] notifsAfter = mBinderService.getActiveNotifications(PKG);
assertEquals(1, notifsAfter.length);
assertEquals((notifsAfter[0].getNotification().flags & FLAG_BUBBLE), 0);
verify(mListeners, times(0)).notifyPostedLocked(any(), any());
}
@Test