summaryrefslogtreecommitdiff
path: root/java/com/android
diff options
context:
space:
mode:
authorsail <sail@google.com>2017-08-15 04:01:52 -0700
committerEric Erfanian <erfanian@google.com>2017-08-15 08:31:16 -0700
commitb608849c7034e1788a6fbeee30e29cf8f4761ebc (patch)
treec8c2832b0cee9889342736ae0ff116a6fba2c7f3 /java/com/android
parentf6ece054859eeac5265931a83ba122b85b6c89e3 (diff)
Log impression if Dialer logs posts many notifications
With this CL we now post HIGH_GLOBAL_NOTIFICATION_COUNT_REACHED once per process lifetime if we post more than 45 notifications. With this logging we'll have a better understanding of how many users get into this state. Note, the exact limit for notifications is 50. We could log an impression when we reach this limit exactly. This CL doesn't do that to avoid calling getActiveNotifications() on every notification. We also limit logging to once per process lifetime for performance reasons too. Bug: 62937258 Test: NotificationThrottlerTest.highGlobalNotificationCountReached PiperOrigin-RevId: 165291217 Change-Id: Iad3a8e84b10b9133870fc45579d98b1a0f922ed7
Diffstat (limited to 'java/com/android')
-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++;
}