@@ -9731,29 +9731,31 @@ private CensoredSendState getCensoredSendStateForNotification(NotificationRecord
97319731 return CensoredSendState.DONT_SEND;
97329732 }
97339733
9734- // Handles reoccurring update notifications (fixes issues like status update spamming).
9735- if (record.isUpdate && (record.getNotification().flags & FLAG_ONLY_ALERT_ONCE) != 0) {
9736- if (DBG) Slog.d(TAG, "not sending censored notif due to original being " +
9737- "an update that only alerts once");
9738- return CensoredSendState.DONT_SEND;
9739- }
9740-
9741- // Muted by listener
9742- final String disableEffects = mAttentionHelper.disableNotificationEffects(record, mListenerHints);
9743- if (disableEffects != null) {
9744- if (DBG) Slog.d(TAG, "not sending censored notif due to disableEffects");
9734+ final var signals = new NotificationAttentionHelper.Signals(false, mListenerHints);
9735+ @NotificationAttentionHelper.MuteReason
9736+ final int muteReason = mAttentionHelper.shouldMuteNotificationLocked(record, signals, true,
9737+ NotificationAttentionHelper.MuteReasonFetchingParam.of(true));
9738+ if (DBG) Slog.d(TAG, "acquired mute reason: " + muteReason +
9739+ " for querying most noisy censored send state possible");
9740+ final CensoredSendState mostNoisyCensoredSendStateAllowed = switch (muteReason) {
9741+ // Do Not Disturb checks is done separately, see later comments.
9742+ case NotificationAttentionHelper.MUTE_REASON_DND,
9743+ NotificationAttentionHelper.MUTE_REASON_NOT_MUTED
9744+ -> CensoredSendState.SEND_NORMAL;
9745+ case NotificationAttentionHelper.MUTE_REASON_SILENT_UPDATE,
9746+ NotificationAttentionHelper.MUTE_REASON_LISTENER_HINT,
9747+ NotificationAttentionHelper.MUTE_REASON_GROUP_ALERT
9748+ -> {
9749+ yield CensoredSendState.DONT_SEND;
9750+ }
9751+ default -> CensoredSendState.SEND_QUIET;
9752+ };
9753+ if (mostNoisyCensoredSendStateAllowed == CensoredSendState.DONT_SEND) {
9754+ if (DBG) Slog.d(TAG, "not sending censored notif: original notif is muted " +
9755+ "with reason ineligible for forwarding");
97459756 return CensoredSendState.DONT_SEND;
97469757 }
97479758
9748- // Suppressed because another notification in its group handles alerting
9749- if (record.getSbn().isGroup()) {
9750- if (record.getNotification().suppressAlertingDueToGrouping()) {
9751- if (DBG) Slog.d(TAG, "not sending censored notif due another" +
9752- "notification in its group handles alerting");
9753- return CensoredSendState.DONT_SEND;
9754- }
9755- }
9756-
97579759 // Check lock screen display settings.
97589760 if (!shouldShowNotificationOnKeyguardForUser(userId, record)) {
97599761 if (DBG) Slog.d(TAG, "not sending censored notif due lock screen settings");
@@ -9776,6 +9778,10 @@ private CensoredSendState getCensoredSendStateForNotification(NotificationRecord
97769778 if (DBG) Slog.d(TAG, "using SEND_QUIET");
97779779 return CensoredSendState.SEND_QUIET;
97789780 }
9781+ if (mostNoisyCensoredSendStateAllowed == CensoredSendState.SEND_QUIET) {
9782+ if (DBG) Slog.d(TAG, "using SEND_QUIET");
9783+ return CensoredSendState.SEND_QUIET;
9784+ }
97799785 return CensoredSendState.SEND_NORMAL;
97809786 case DONT_SEND: // fall through
97819787 default:
0 commit comments