From 3a0a1b4c3ef9ec569a19f21e866d4fc64b12cc0a Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Thu, 23 May 2019 06:40:21 -0700 Subject: [PATCH] Update the flag in system UI rather than reposting the notif Test: manual - post a bubble, dismiss the bubble, tap on the notif => notif content click is activated Test: atest NotificationManagerServiceTest Bug: 131187135 Change-Id: I8db86041167cd2ff0e9c8a51bd7fc1d353c2e9c8 --- .../systemui/bubbles/BubbleController.java | 8 +++++-- .../NotificationManagerService.java | 7 ------ .../NotificationManagerServiceTest.java | 24 +++++++------------ 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index 4ec79a64b2a34..f80ca68d4e51c 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -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 */); diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 1160e33aca258..d6f5d96b68904 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -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); - } } } } diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index 87f221a181611..9e44d951fb711 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -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 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 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