Fix sound rate limiting issue

Don't count notifications that were muted by some other criteria
(like dnd or group alerting) against an app

Test: runtest systemui-notification
Change-Id: I9c94d342400306c2618c458e2ad530cd9373b3b8
Fixes: 63819441
This commit is contained in:
Julia Reynolds
2017-07-20 09:19:20 -04:00
parent 4dfb200d1b
commit 65b85cf3a2
2 changed files with 17 additions and 7 deletions

View File

@@ -3828,13 +3828,6 @@ public class NotificationManagerService extends SystemService {
return true;
}
// Suppressed for being too recently noisy
final String pkg = record.sbn.getPackageName();
if (mUsageStats.isAlertRateLimited(pkg)) {
Slog.e(TAG, "Muting recently noisy " + record.getKey());
return true;
}
// muted by listener
final String disableEffects = disableNotificationEffects(record);
if (disableEffects != null) {
@@ -3852,6 +3845,13 @@ public class NotificationManagerService extends SystemService {
return notification.suppressAlertingDueToGrouping();
}
// Suppressed for being too recently noisy
final String pkg = record.sbn.getPackageName();
if (mUsageStats.isAlertRateLimited(pkg)) {
Slog.e(TAG, "Muting recently noisy " + record.getKey());
return true;
}
return false;
}

View File

@@ -830,6 +830,16 @@ public class BuzzBeepBlinkTest extends NotificationTestCase {
verify(mUsageStats, never()).isAlertRateLimited(any());
}
@Test
public void testPostingGroupSuppressedDoesNotAffectRateLimiting() throws Exception {
NotificationRecord summary = getBeepyNotificationRecord("a", GROUP_ALERT_CHILDREN);
summary.getNotification().flags |= Notification.FLAG_GROUP_SUMMARY;
mService.buzzBeepBlinkLocked(summary);
verify(mUsageStats, never()).isAlertRateLimited(any());
}
@Test
public void testCrossUserSoundMuted() throws Exception {
final Notification n = new Builder(getContext(), "test")