Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a0a1b4c authored by Mady Mellor's avatar Mady Mellor
Browse files

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
parent aa21a4a7
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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 */);
+0 −7
Original line number Diff line number Diff line
@@ -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);
                    }
                }
            }
        }
+8 −16
Original line number Diff line number Diff line
@@ -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