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

Commit 7c2f9153 authored by Valentin Iftime's avatar Valentin Iftime Committed by Iavor-Valentin Iftime
Browse files

Exempt autogroup summaries from NMS#checkDisqualifyingFeatures

Do not count autogroup summaries towards notification limit.

Flag: EXEMPT bugfix

Test: atest NotificationManagerServiceTest
Bug: 421160533
Change-Id: I3d663fdc51bba6d850a860e994f74b8d8d6b45b9
parent d830c0dd
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -9333,8 +9333,9 @@ public class NotificationManagerService extends SystemService {
                }
            }
            // limit the number of non-fgs/uij outstanding notificationrecords an app can have
            if (!n.isFgsOrUij()) {
            // Limit the number of non-fgs/uij outstanding notificationrecords an app can have
            // Do not count autogroup summaries
            if (!n.isFgsOrUij() && !GroupHelper.isAggregatedGroup(r)) {
                int count = getNotificationCount(pkg, userId, id, tag);
                if (count >= MAX_PACKAGE_NOTIFICATIONS) {
                    mUsageStats.registerOverCountQuota(pkg);
+31 −0
Original line number Diff line number Diff line
@@ -15043,6 +15043,37 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isTrue();
    }
    @Test
    public void checkAutogroupSummaryExemptFromLimit() throws Exception {
        // Add maximum number of notifications per package
        for (int i = 0; i < NotificationManagerService.MAX_PACKAGE_NOTIFICATIONS; i++) {
            Notification n = new Notification.Builder(mContext, "").build();
            StatusBarNotification sbn = new StatusBarNotification(mPkg, mPkg, i, null, mUid, 0,
                    n, UserHandle.getUserHandleForUid(mUid), null, 0);
            NotificationRecord r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
            mService.addNotification(r);
        }
        // Check that next regular summary notification is diqualified from enqueueing
        StatusBarNotification sbn = generateSbn(mPkg, mUid, 0, UserHandle.getUserId(mUid));
        sbn.getNotification().flags |= FLAG_GROUP_SUMMARY;
        NotificationRecord summary = new NotificationRecord(mContext, sbn,
                mTestNotificationChannel);
        assertThat(mService.checkDisqualifyingFeatures(summary.getUserId(), summary.getUid(),
                summary.getSbn().getId(), summary.getSbn().getTag(), summary, true,
                false)).isFalse();
        // Check that next autogroup summary notification is exempt from checkDisqualifyingFeatures
        sbn = generateSbn(mPkg, mUid, 0, UserHandle.getUserId(mUid));
        sbn.getNotification().flags |= Notification.FLAG_AUTOGROUP_SUMMARY;
        summary = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        assertThat(mService.checkDisqualifyingFeatures(summary.getUserId(), summary.getUid(),
                summary.getSbn().getId(), summary.getSbn().getTag(), summary, true,
                false)).isTrue();
    }
    private Notification createBigPictureNotification(boolean isBigPictureStyle, boolean hasImage,
            boolean isImageBitmap) {
        Notification.Builder builder = new Notification.Builder(mContext)