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

Commit 7a4c4442 authored by Iavor-Valentin Iftime's avatar Iavor-Valentin Iftime Committed by Automerger Merge Worker
Browse files

Merge "Do not snooze autogroup summary notifications" into udc-dev am: 9dff0a45

parents 4cce29b2 9dff0a45
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -7429,6 +7429,7 @@ public class NotificationManagerService extends SystemService {
            cancelNotificationLocked(r, false, REASON_SNOOZED, wasPosted, null,
                    SystemClock.elapsedRealtime());
            updateLightsLocked();
            if (isSnoozable(r)) {
                if (mSnoozeCriterionId != null) {
                    mAssistants.notifyAssistantSnoozedLocked(r, mSnoozeCriterionId);
                    mSnoozeHelper.snooze(r, mSnoozeCriterionId);
@@ -7440,6 +7441,16 @@ public class NotificationManagerService extends SystemService {
            }
        }
        /**
         * Autogroup summaries are not snoozable
         * They will be recreated as needed when the group children are unsnoozed
         */
        private boolean isSnoozable(NotificationRecord record) {
            return !(record.getNotification().isGroupSummary() && GroupHelper.AUTOGROUP_KEY.equals(
                    record.getNotification().getGroup()));
        }
    }
    protected class CancelNotificationRunnable implements Runnable {
        private final int mCallingUid;
        private final int mCallingPid;
+31 −0
Original line number Diff line number Diff line
@@ -3774,6 +3774,37 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                mNotificationRecordLogger.event(1));
    }
    @Test
    public void testSnoozeRunnable_snoozeAutoGroupChild_summaryNotSnoozed() throws Exception {
        final NotificationRecord parent = generateNotificationRecord(
                mTestNotificationChannel, 1, GroupHelper.AUTOGROUP_KEY, true);
        final NotificationRecord child = generateNotificationRecord(
                mTestNotificationChannel, 2, GroupHelper.AUTOGROUP_KEY, false);
        mService.addNotification(parent);
        mService.addNotification(child);
        when(mSnoozeHelper.canSnooze(anyInt())).thenReturn(true);
        // snooze child only
        NotificationManagerService.SnoozeNotificationRunnable snoozeNotificationRunnable =
                mService.new SnoozeNotificationRunnable(
                        child.getKey(), 100, null);
        snoozeNotificationRunnable.run();
        // only child should be snoozed
        verify(mSnoozeHelper, times(1)).snooze(any(NotificationRecord.class), anyLong());
        // both group summary and child should be cancelled
        assertNull(mService.getNotificationRecord(parent.getKey()));
        assertNull(mService.getNotificationRecord(child.getKey()));
        assertEquals(4, mNotificationRecordLogger.numCalls());
        assertEquals(NotificationRecordLogger.NotificationEvent.NOTIFICATION_SNOOZED,
                mNotificationRecordLogger.event(0));
        assertEquals(
                NotificationRecordLogger.NotificationCancelledEvent.NOTIFICATION_CANCEL_SNOOZED,
                mNotificationRecordLogger.event(1));
    }
    @Test
    public void testPostGroupChild_unsnoozeParent() throws Exception {
        final NotificationRecord child = generateNotificationRecord(