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

Commit 175290ce authored by Mady Mellor's avatar Mady Mellor Committed by Automerger Merge Worker
Browse files

Merge "Fix an issue where the bubble wasn't opening" into sc-dev am: 12a782b3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14724165

Change-Id: I9422925fa238a937ea9197b9aeac6fe26355dec5
parents 49ca8858 12a782b3
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -6859,12 +6859,14 @@ public class NotificationManagerService extends SystemService {
                        mUsageStats.registerClickedByUser(r);
                        mUsageStats.registerClickedByUser(r);
                    }
                    }


                    if (mReason == REASON_LISTENER_CANCEL
                    if ((mReason == REASON_LISTENER_CANCEL
                            && r.getNotification().isBubbleNotification()) {
                            && r.getNotification().isBubbleNotification())
                            || (mReason == REASON_CLICK && r.canBubble()
                            && r.isFlagBubbleRemoved())) {
                        boolean isBubbleSuppressed = r.getNotification().getBubbleMetadata() != null
                        boolean isBubbleSuppressed = r.getNotification().getBubbleMetadata() != null
                                && r.getNotification().getBubbleMetadata().isBubbleSuppressed();
                                && r.getNotification().getBubbleMetadata().isBubbleSuppressed();
                        mNotificationDelegate.onBubbleNotificationSuppressionChanged(
                        mNotificationDelegate.onBubbleNotificationSuppressionChanged(
                                r.getKey(), true /* suppressed */, isBubbleSuppressed);
                                r.getKey(), true /* notifSuppressed */, isBubbleSuppressed);
                        return;
                        return;
                    }
                    }


+41 −0
Original line number Original line Diff line number Diff line
@@ -7223,6 +7223,47 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                mNotificationRecordLogger.event(0));
                mNotificationRecordLogger.event(0));
    }
    }


    /**
     * When something is bubble'd and the bubble is dismissed, but the notification is still
     * visible, clicking on the notification shouldn't auto-cancel it because clicking on
     * it will produce a bubble.
     */
    @Test
    public void testNotificationBubbles_bubbleStays_whenClicked_afterBubbleDismissed()
            throws Exception {
        setUpPrefsForBubbles(PKG, mUid,
                true /* global */,
                BUBBLE_PREFERENCE_ALL /* app */,
                true /* channel */);

        // GIVEN a notification that has the auto cancels flag (cancel on click) and is a bubble
        final NotificationRecord nr = generateNotificationRecord(mTestNotificationChannel);
        nr.getSbn().getNotification().flags |= FLAG_BUBBLE | FLAG_AUTO_CANCEL;
        nr.setAllowBubble(true);
        mService.addNotification(nr);

        // And the bubble is dismissed
        mService.mNotificationDelegate.onNotificationBubbleChanged(nr.getKey(),
                false /* isBubble */, 0 /* bubbleFlags */);
        waitForIdle();
        assertTrue(nr.isFlagBubbleRemoved());

        // WHEN we click the notification
        final NotificationVisibility nv = NotificationVisibility.obtain(nr.getKey(), 1, 2, true);
        mService.mNotificationDelegate.onNotificationClick(mUid, Binder.getCallingPid(),
                nr.getKey(), nv);
        waitForIdle();

        // THEN the bubble should still exist
        StatusBarNotification[] notifsAfter = mBinderService.getActiveNotifications(PKG);
        assertEquals(1, notifsAfter.length);

        // Check we got the click log
        assertEquals(1, mNotificationRecordLogger.numCalls());
        assertEquals(NotificationRecordLogger.NotificationEvent.NOTIFICATION_CLICKED,
                mNotificationRecordLogger.event(0));
    }

    @Test
    @Test
    public void testLoadDefaultApprovedServices_emptyResources() {
    public void testLoadDefaultApprovedServices_emptyResources() {
        TestableResources tr = mContext.getOrCreateTestableResources();
        TestableResources tr = mContext.getOrCreateTestableResources();