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

Commit 3e781720 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove check_autogroup_before_post flag" into main

parents fa83c9b2 a57867ab
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -115,13 +115,6 @@ flag {
  bug: "299448097"
}

flag {
  name: "check_autogroup_before_post"
  namespace: "systemui"
  description: "Does a check to see if notification should be autogrouped before posting, and if so groups before post."
  bug: "330214226"
}

flag {
  name: "notification_expansion_optional"
  namespace: "systemui"
+8 −16
Original line number Diff line number Diff line
@@ -362,16 +362,12 @@ public class GroupHelper {
                        AUTOGROUP_KEY, Integer.MAX_VALUE, attr);
            }
            for (String keyToGroup : notificationsToGroup) {
                if (android.app.Flags.checkAutogroupBeforePost()) {
                if (keyToGroup.equals(sbn.getKey())) {
                    // Autogrouping for the provided notification is to be done synchronously.
                    sbnToBeAutogrouped = true;
                } else {
                    mCallback.addAutoGroup(keyToGroup, AUTOGROUP_KEY, /*requestSort=*/true);
                }
                } else {
                    mCallback.addAutoGroup(keyToGroup, AUTOGROUP_KEY, /*requestSort=*/true);
                }
            }
        }
        return sbnToBeAutogrouped;
@@ -647,7 +643,6 @@ public class GroupHelper {

                // add notification to aggregate group
                for (String keyToGroup : ungrouped.keySet()) {
                    if (android.app.Flags.checkAutogroupBeforePost()) {
                    if (keyToGroup.equals(record.getKey())) {
                        // Autogrouping for the posted notification is to be done synchronously.
                        sbnToBeAutogrouped = true;
@@ -655,9 +650,6 @@ public class GroupHelper {
                        mCallback.addAutoGroup(keyToGroup, fullAggregateGroupKey.toString(),
                                true);
                    }
                    } else {
                        mCallback.addAutoGroup(keyToGroup, fullAggregateGroupKey.toString(), true);
                    }
                }

                //cleanup mUngroupedAbuseNotifications
+40 −74
Original line number Diff line number Diff line
@@ -7524,7 +7524,7 @@ public class NotificationManagerService extends SystemService {
            addAutoGroupAdjustment(r, groupName);
            EventLogTags.writeNotificationAutogrouped(key);
            if (!android.app.Flags.checkAutogroupBeforePost() || requestSort) {
            if (requestSort) {
                mRankingHandler.requestSort();
            }
@@ -9892,7 +9892,6 @@ public class NotificationManagerService extends SystemService {
                    // Posts the notification if it has a small icon, and potentially autogroup
                    // the new notification.
                    if (android.app.Flags.checkAutogroupBeforePost()) {
                    if (notification.getSmallIcon() != null && !isCritical(r)) {
                        StatusBarNotification oldSbn = (old != null) ? old.getSbn() : null;
                        if (oldSbn == null || !Objects.equals(oldSbn.getGroup(), n.getGroup())
@@ -9903,8 +9902,8 @@ public class NotificationManagerService extends SystemService {
                                || !old.getChannel().getId().equals(r.getChannel().getId())) {
                            synchronized (mNotificationLock) {
                                final String autogroupName =
                                            notificationForceGrouping() ?
                                                GroupHelper.getFullAggregateGroupKey(r)
                                        notificationForceGrouping()
                                            ? GroupHelper.getFullAggregateGroupKey(r)
                                            : GroupHelper.AUTOGROUP_KEY;
                                boolean willBeAutogrouped =
                                        mGroupHelper.onNotificationPosted(r,
@@ -9933,8 +9932,6 @@ public class NotificationManagerService extends SystemService {
                                        }, key, DELAY_FORCE_REGROUP_TIME);
                                    }
                                }
                                }
                             }
                        }
                    }
@@ -9958,37 +9955,6 @@ public class NotificationManagerService extends SystemService {
                                        getGroupInstanceId(r.getSbn().getGroupKey()));
                        notifyListenersPostedAndLogLocked(r, old, mTracker, maybeReport);
                        posted = true;
                        if (!android.app.Flags.checkAutogroupBeforePost()) {
                            StatusBarNotification oldSbn = (old != null) ? old.getSbn() : null;
                            if (oldSbn == null
                                    || !Objects.equals(oldSbn.getGroup(), n.getGroup())
                                    || oldSbn.getNotification().flags
                                        != n.getNotification().flags) {
                                if (!isCritical(r)) {
                                    mHandler.post(() -> {
                                        synchronized (mNotificationLock) {
                                            mGroupHelper.onNotificationPosted(
                                                    r, hasAutoGroupSummaryLocked(r));
                                        }
                                    });
                                    if (notificationForceGrouping()) {
                                        mHandler.postDelayed(() -> {
                                            synchronized (mNotificationLock) {
                                                NotificationRecord record =
                                                        mNotificationsByKey.get(key);
                                                if (record != null) {
                                                    mGroupHelper.onNotificationPostedWithDelay(
                                                            record, mNotificationList,
                                                            mSummaryByGroupKey);
                                                }
                                            }
                                        }, key, DELAY_FORCE_REGROUP_TIME);
                                    }
                                }
                            }
                        }
                    } else {
                        Slog.e(TAG, "Not posting notification without small icon: " + notification);
                        if (old != null && !old.isCanceled) {
+11 −507

File changed.

Preview size limit exceeded, changes collapsed.

+5 −12
Original line number Diff line number Diff line
@@ -2930,8 +2930,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING,
            android.app.Flags.FLAG_CHECK_AUTOGROUP_BEFORE_POST})
    @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING})
    public void testOnlyForceGroupIfNeeded_newNotification_notAutogrouped() {
        NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, null, false);
        when(mGroupHelper.onNotificationPosted(any(), anyBoolean())).thenReturn(false);
@@ -2950,8 +2949,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING,
            android.app.Flags.FLAG_CHECK_AUTOGROUP_BEFORE_POST})
    @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING})
    public void testOnlyForceGroupIfNeeded_newNotification_wasAutogrouped() {
        NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, null, false);
        when(mGroupHelper.onNotificationPosted(any(), anyBoolean())).thenReturn(true);
@@ -2970,8 +2968,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING,
            android.app.Flags.FLAG_CHECK_AUTOGROUP_BEFORE_POST})
    @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING})
    public void testRemoveScheduledForceGroup_onNotificationCanceled() throws Exception {
        NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, "tag", null,
                false);
@@ -3133,8 +3130,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING,
            android.app.Flags.FLAG_CHECK_AUTOGROUP_BEFORE_POST})
    @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING})
    public void testScheduleGroupHelperWithDelay_onChildNotificationCanceled() throws Exception {
        // Post summary + 2 child notification
        final String originalGroupName = "originalGroup";
@@ -3173,8 +3169,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING,
            android.app.Flags.FLAG_CHECK_AUTOGROUP_BEFORE_POST})
    @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING})
    public void testCleanupScheduleGroupHelperWithDelay_onAllNotificationCanceled()
            throws Exception {
        // Post summary + 2 child notification
@@ -6753,7 +6748,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags(android.app.Flags.FLAG_CHECK_AUTOGROUP_BEFORE_POST)
    public void testAutogroupSuppressSort_noSort() throws Exception {
        final NotificationRecord r = generateNotificationRecord(mTestNotificationChannel);
        mService.addNotification(r);
@@ -6763,7 +6757,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags(android.app.Flags.FLAG_CHECK_AUTOGROUP_BEFORE_POST)
    public void testAutogroupOnPost_skipManualSort() throws Exception {
        final NotificationRecord r = generateNotificationRecord(mTestNotificationChannel);
        mService.addNotification(r);