summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/com/android/dialer/logging/dialer_impression.proto5
-rw-r--r--java/com/android/dialer/notification/NotificationThrottler.java22
2 files changed, 25 insertions, 2 deletions
diff --git a/java/com/android/dialer/logging/dialer_impression.proto b/java/com/android/dialer/logging/dialer_impression.proto
index 4422b9ce7..de38ff359 100644
--- a/java/com/android/dialer/logging/dialer_impression.proto
+++ b/java/com/android/dialer/logging/dialer_impression.proto
@@ -499,5 +499,10 @@ message DialerImpression {
// Found Lightbringer reachable contact when launching Dialer
HAS_LIGHTBRINGER_REACHABLE_CONTACTS = 1248;
+
+ // This impression is logged once per process when the number of
+ // notifications is very high and the system may suppress future
+ // notifications.
+ HIGH_GLOBAL_NOTIFICATION_COUNT_REACHED = 1249;
}
}
diff --git a/java/com/android/dialer/notification/NotificationThrottler.java b/java/com/android/dialer/notification/NotificationThrottler.java
index 7c2428737..661dec759 100644
--- a/java/com/android/dialer/notification/NotificationThrottler.java
+++ b/java/com/android/dialer/notification/NotificationThrottler.java
@@ -24,6 +24,8 @@ import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
+import com.android.dialer.logging.DialerImpression;
+import com.android.dialer.logging.Logger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -35,6 +37,9 @@ import java.util.List;
*/
/* package */ class NotificationThrottler {
private static final int MAX_NOTIFICATIONS_PER_TAG = 10;
+ private static final int HIGH_GLOBAL_NOTIFICATION_COUNT = 45;
+
+ private static boolean didLogHighGlobalNotificationCountReached;
/* package */ static void throttle(@NonNull Context context, @NonNull Notification notification) {
Assert.isNotNull(context);
@@ -46,9 +51,22 @@ import java.util.List;
return;
}
- int count = 0;
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
- for (StatusBarNotification currentNotification : notificationManager.getActiveNotifications()) {
+ StatusBarNotification[] activeNotifications = notificationManager.getActiveNotifications();
+ if (activeNotifications.length > HIGH_GLOBAL_NOTIFICATION_COUNT
+ && !didLogHighGlobalNotificationCountReached) {
+ LogUtil.i(
+ "NotificationThrottler.throttle",
+ "app has %d notifications, system may suppress future notifications",
+ activeNotifications.length);
+ didLogHighGlobalNotificationCountReached = true;
+ Logger.get(context)
+ .logImpression(DialerImpression.Type.HIGH_GLOBAL_NOTIFICATION_COUNT_REACHED);
+ }
+
+ // Count the number of notificatons for this group (excluding the summary).
+ int count = 0;
+ for (StatusBarNotification currentNotification : activeNotifications) {
if (isNotificationInGroup(currentNotification, groupKey)) {
count++;
}