Loading services/core/java/com/android/server/notification/NotificationManagerService.java +5 −5 Original line number Diff line number Diff line Loading @@ -1084,6 +1084,7 @@ public class NotificationManagerService extends SystemService { } int oldFlags = summary.getSbn().getNotification().flags; int newFlags = summaryAttr.flags != GroupHelper.FLAG_INVALID ? summaryAttr.flags : oldFlags; boolean attributesUpdated = !summaryAttr.icon.sameAs(summary.getSbn().getNotification().getSmallIcon()) Loading @@ -1093,7 +1094,7 @@ public class NotificationManagerService extends SystemService { summary.getSbn().getNotification().getGroupAlertBehavior(); if (notificationForceGrouping()) { summary.getNotification().flags |= Notification.FLAG_SILENT; newFlags |= Notification.FLAG_SILENT; if (!summary.getChannel().getId().equals(summaryAttr.channelId)) { NotificationChannel newChannel = mPreferencesHelper.getNotificationChannel(pkg, summary.getUid(), summaryAttr.channelId, false); Loading @@ -1104,9 +1105,8 @@ public class NotificationManagerService extends SystemService { } } if (oldFlags != summaryAttr.flags || attributesUpdated) { summary.getSbn().getNotification().flags = summaryAttr.flags != GroupHelper.FLAG_INVALID ? summaryAttr.flags : oldFlags; if (oldFlags != newFlags || attributesUpdated) { summary.getSbn().getNotification().flags = newFlags; summary.getSbn().getNotification().setSmallIcon(summaryAttr.icon); summary.getSbn().getNotification().color = summaryAttr.iconColor; summary.getSbn().getNotification().visibility = summaryAttr.visibility; Loading Loading @@ -7587,9 +7587,9 @@ public class NotificationManagerService extends SystemService { if (r.getSbn().isAppGroup()) { // Override group key early for forced grouped notifications r.setOverrideGroupKey(groupName); } r.getNotification().flags |= Notification.FLAG_SILENT; } } addAutoGroupAdjustment(r, groupName); EventLogTags.writeNotificationAutogrouped(key); Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +31 −1 Original line number Diff line number Diff line Loading @@ -125,6 +125,7 @@ import static android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATIO import static android.service.notification.Flags.FLAG_NOTIFICATION_CONVERSATION_CHANNEL_MANAGEMENT; import static android.service.notification.Flags.FLAG_NOTIFICATION_FORCE_GROUPING; import static android.service.notification.Flags.FLAG_NOTIFICATION_REGROUP_ON_CLASSIFICATION; import static android.service.notification.Flags.FLAG_NOTIFICATION_SILENT_FLAG; import static android.service.notification.Flags.FLAG_REDACT_SENSITIVE_NOTIFICATIONS_FROM_UNTRUSTED_LISTENERS; import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_ALERTING; import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_CONVERSATIONS; Loading Loading @@ -2631,7 +2632,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test @EnableFlags(FLAG_NOTIFICATION_FORCE_GROUPING) @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING, FLAG_NOTIFICATION_SILENT_FLAG}) public void testAggregatedSummary_updateSummaryAttributes() { final String aggregateGroupName = "Aggregate_Test"; final String newChannelId = "newChannelId"; Loading @@ -2647,6 +2648,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mService.mAutobundledSummaries.get(0).put(groupKey, summary.getKey()); when(mPreferencesHelper.getNotificationChannel(eq("pkg"), anyInt(), eq(newChannelId), anyBoolean())).thenReturn(newChannel); assertThat(summary.getNotification().isSilent()).isFalse(); mService.updateAutobundledSummaryLocked(0, "pkg", groupKey, new NotificationAttributes(GroupHelper.BASE_FLAGS | FLAG_ONGOING_EVENT, Loading @@ -2654,6 +2656,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { false); waitForIdle(); assertThat(summary.getNotification().isSilent()).isTrue(); assertTrue(summary.getSbn().isOngoing()); assertThat(summary.getNotification().getGroupAlertBehavior()).isEqualTo( GROUP_ALERT_CHILDREN); Loading @@ -2675,6 +2678,33 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { verify(mListeners, times(1)).notifyPostedLocked(eq(r), eq(r)); } @Test @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING, FLAG_NOTIFICATION_SILENT_FLAG}) public void testAddUngroupedAggregateNotification_silentFlagNotSet() throws Exception { final NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, null, false); assertThat(r.getNotification().isSilent()).isFalse(); mService.addNotification(r); mService.addAutogroupKeyLocked(r.getKey(), "AggregateGrp", true); assertThat(r.hasAdjustment(Adjustment.KEY_GROUP_KEY)).isTrue(); assertThat(r.getNotification().isSilent()).isFalse(); } @Test @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING, FLAG_NOTIFICATION_SILENT_FLAG}) public void testAddGroupedAggregateNotification_silentFlagSet() throws Exception { final String originalGroupName = "originalGroup"; final NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, originalGroupName, false); assertThat(r.getNotification().isSilent()).isFalse(); mService.addNotification(r); mService.addAutogroupKeyLocked(r.getKey(), "AggregateGrp", true); assertThat(r.getSbn().getOverrideGroupKey()).isEqualTo("AggregateGrp"); assertThat(r.getNotification().isSilent()).isTrue(); } @Test @EnableFlags(FLAG_NOTIFICATION_FORCE_GROUPING) public void testAddAggregateSummaryNotification_convertSummary() throws Exception { Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +5 −5 Original line number Diff line number Diff line Loading @@ -1084,6 +1084,7 @@ public class NotificationManagerService extends SystemService { } int oldFlags = summary.getSbn().getNotification().flags; int newFlags = summaryAttr.flags != GroupHelper.FLAG_INVALID ? summaryAttr.flags : oldFlags; boolean attributesUpdated = !summaryAttr.icon.sameAs(summary.getSbn().getNotification().getSmallIcon()) Loading @@ -1093,7 +1094,7 @@ public class NotificationManagerService extends SystemService { summary.getSbn().getNotification().getGroupAlertBehavior(); if (notificationForceGrouping()) { summary.getNotification().flags |= Notification.FLAG_SILENT; newFlags |= Notification.FLAG_SILENT; if (!summary.getChannel().getId().equals(summaryAttr.channelId)) { NotificationChannel newChannel = mPreferencesHelper.getNotificationChannel(pkg, summary.getUid(), summaryAttr.channelId, false); Loading @@ -1104,9 +1105,8 @@ public class NotificationManagerService extends SystemService { } } if (oldFlags != summaryAttr.flags || attributesUpdated) { summary.getSbn().getNotification().flags = summaryAttr.flags != GroupHelper.FLAG_INVALID ? summaryAttr.flags : oldFlags; if (oldFlags != newFlags || attributesUpdated) { summary.getSbn().getNotification().flags = newFlags; summary.getSbn().getNotification().setSmallIcon(summaryAttr.icon); summary.getSbn().getNotification().color = summaryAttr.iconColor; summary.getSbn().getNotification().visibility = summaryAttr.visibility; Loading Loading @@ -7587,9 +7587,9 @@ public class NotificationManagerService extends SystemService { if (r.getSbn().isAppGroup()) { // Override group key early for forced grouped notifications r.setOverrideGroupKey(groupName); } r.getNotification().flags |= Notification.FLAG_SILENT; } } addAutoGroupAdjustment(r, groupName); EventLogTags.writeNotificationAutogrouped(key); Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +31 −1 Original line number Diff line number Diff line Loading @@ -125,6 +125,7 @@ import static android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATIO import static android.service.notification.Flags.FLAG_NOTIFICATION_CONVERSATION_CHANNEL_MANAGEMENT; import static android.service.notification.Flags.FLAG_NOTIFICATION_FORCE_GROUPING; import static android.service.notification.Flags.FLAG_NOTIFICATION_REGROUP_ON_CLASSIFICATION; import static android.service.notification.Flags.FLAG_NOTIFICATION_SILENT_FLAG; import static android.service.notification.Flags.FLAG_REDACT_SENSITIVE_NOTIFICATIONS_FROM_UNTRUSTED_LISTENERS; import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_ALERTING; import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_CONVERSATIONS; Loading Loading @@ -2631,7 +2632,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test @EnableFlags(FLAG_NOTIFICATION_FORCE_GROUPING) @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING, FLAG_NOTIFICATION_SILENT_FLAG}) public void testAggregatedSummary_updateSummaryAttributes() { final String aggregateGroupName = "Aggregate_Test"; final String newChannelId = "newChannelId"; Loading @@ -2647,6 +2648,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mService.mAutobundledSummaries.get(0).put(groupKey, summary.getKey()); when(mPreferencesHelper.getNotificationChannel(eq("pkg"), anyInt(), eq(newChannelId), anyBoolean())).thenReturn(newChannel); assertThat(summary.getNotification().isSilent()).isFalse(); mService.updateAutobundledSummaryLocked(0, "pkg", groupKey, new NotificationAttributes(GroupHelper.BASE_FLAGS | FLAG_ONGOING_EVENT, Loading @@ -2654,6 +2656,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { false); waitForIdle(); assertThat(summary.getNotification().isSilent()).isTrue(); assertTrue(summary.getSbn().isOngoing()); assertThat(summary.getNotification().getGroupAlertBehavior()).isEqualTo( GROUP_ALERT_CHILDREN); Loading @@ -2675,6 +2678,33 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { verify(mListeners, times(1)).notifyPostedLocked(eq(r), eq(r)); } @Test @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING, FLAG_NOTIFICATION_SILENT_FLAG}) public void testAddUngroupedAggregateNotification_silentFlagNotSet() throws Exception { final NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, null, false); assertThat(r.getNotification().isSilent()).isFalse(); mService.addNotification(r); mService.addAutogroupKeyLocked(r.getKey(), "AggregateGrp", true); assertThat(r.hasAdjustment(Adjustment.KEY_GROUP_KEY)).isTrue(); assertThat(r.getNotification().isSilent()).isFalse(); } @Test @EnableFlags({FLAG_NOTIFICATION_FORCE_GROUPING, FLAG_NOTIFICATION_SILENT_FLAG}) public void testAddGroupedAggregateNotification_silentFlagSet() throws Exception { final String originalGroupName = "originalGroup"; final NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, originalGroupName, false); assertThat(r.getNotification().isSilent()).isFalse(); mService.addNotification(r); mService.addAutogroupKeyLocked(r.getKey(), "AggregateGrp", true); assertThat(r.getSbn().getOverrideGroupKey()).isEqualTo("AggregateGrp"); assertThat(r.getNotification().isSilent()).isTrue(); } @Test @EnableFlags(FLAG_NOTIFICATION_FORCE_GROUPING) public void testAddAggregateSummaryNotification_convertSummary() throws Exception { Loading