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

Commit 918aa7a0 authored by Mady Mellor's avatar Mady Mellor Committed by android-build-merger
Browse files

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

am: 7babaf90

Change-Id: Ied8dcf389bb31eb53356c844f084840b70a07833
parents abc14683 7babaf90
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.systemui.bubbles;
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_BADGE;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK;
@@ -547,8 +548,11 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
                    mNotificationEntryManager.performRemoveNotification(bubble.entry.notification,
                    mNotificationEntryManager.performRemoveNotification(bubble.entry.notification,
                            UNDEFINED_DISMISS_REASON);
                            UNDEFINED_DISMISS_REASON);
                } else {
                } else {
                    // The notification is still in the shade but we've removed the bubble so
                    // Update the flag for SysUI
                    // lets make sure NoMan knows it's not a bubble anymore
                    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 {
                    try {
                        mBarService.onNotificationBubbleChanged(bubble.getKey(),
                        mBarService.onNotificationBubbleChanged(bubble.getKey(),
                                false /* isBubble */);
                                false /* isBubble */);
+0 −7
Original line number Original line Diff line number Diff line
@@ -1036,19 +1036,12 @@ public class NotificationManagerService extends SystemService {
                    final StatusBarNotification n = r.sbn;
                    final StatusBarNotification n = r.sbn;
                    final int callingUid = n.getUid();
                    final int callingUid = n.getUid();
                    final String pkg = n.getPackageName();
                    final String pkg = n.getPackageName();
                    final boolean wasBubble = r.getNotification().isBubbleNotification();
                    if (isBubble && isNotificationAppropriateToBubble(r, pkg, callingUid,
                    if (isBubble && isNotificationAppropriateToBubble(r, pkg, callingUid,
                            null /* oldEntry */)) {
                            null /* oldEntry */)) {
                        r.getNotification().flags |= FLAG_BUBBLE;
                        r.getNotification().flags |= FLAG_BUBBLE;
                    } else {
                    } else {
                        r.getNotification().flags &= ~FLAG_BUBBLE;
                        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 Original line 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.CATEGORY_CALL;
import static android.app.Notification.FLAG_BUBBLE;
import static android.app.Notification.FLAG_BUBBLE;
import static android.app.Notification.FLAG_FOREGROUND_SERVICE;
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.EXTRA_BLOCKED_STATE;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.app.NotificationManager.IMPORTANCE_HIGH;
@@ -4963,13 +4962,10 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        mService.mNotificationDelegate.onNotificationBubbleChanged(nr.getKey(), false);
        mService.mNotificationDelegate.onNotificationBubbleChanged(nr.getKey(), false);
        waitForIdle();
        waitForIdle();


        // Make sure we are not a bubble / reported as such to listeners
        // Make sure we are not a bubble
        ArgumentCaptor<NotificationRecord> captor =
        StatusBarNotification[] notifsAfter = mBinderService.getActiveNotifications(PKG);
                ArgumentCaptor.forClass(NotificationRecord.class);
        assertEquals(1, notifsAfter.length);
        verify(mListeners, times(1)).notifyPostedLocked(captor.capture(), any());
        assertEquals((notifsAfter[0].getNotification().flags & FLAG_BUBBLE), 0);

        assertEquals((captor.getValue().getNotification().flags & FLAG_BUBBLE), 0);
        assertTrue((captor.getValue().getNotification().flags & FLAG_ONLY_ALERT_ONCE) != 0);
    }
    }


    @Test
    @Test
@@ -5000,13 +4996,10 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        mService.mNotificationDelegate.onNotificationBubbleChanged(nr.getKey(), true);
        mService.mNotificationDelegate.onNotificationBubbleChanged(nr.getKey(), true);
        waitForIdle();
        waitForIdle();


        // Make sure we are a bubble / reported as such to listeners
        // Make sure we are a bubble
        ArgumentCaptor<NotificationRecord> captor =
        StatusBarNotification[] notifsAfter = mBinderService.getActiveNotifications(PKG);
                ArgumentCaptor.forClass(NotificationRecord.class);
        assertEquals(1, notifsAfter.length);
        verify(mListeners, times(1)).notifyPostedLocked(captor.capture(), any());
        assertTrue((notifsAfter[0].getNotification().flags & FLAG_BUBBLE) != 0);

        assertTrue((captor.getValue().getNotification().flags & FLAG_BUBBLE) != 0);
        assertTrue((captor.getValue().getNotification().flags & FLAG_ONLY_ALERT_ONCE) != 0);
    }
    }


    @Test
    @Test
@@ -5037,7 +5030,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        StatusBarNotification[] notifsAfter = mBinderService.getActiveNotifications(PKG);
        StatusBarNotification[] notifsAfter = mBinderService.getActiveNotifications(PKG);
        assertEquals(1, notifsAfter.length);
        assertEquals(1, notifsAfter.length);
        assertEquals((notifsAfter[0].getNotification().flags & FLAG_BUBBLE), 0);
        assertEquals((notifsAfter[0].getNotification().flags & FLAG_BUBBLE), 0);
        verify(mListeners, times(0)).notifyPostedLocked(any(), any());
    }
    }


    @Test
    @Test