From a70829946265047ef9798829a176978d578a915c Mon Sep 17 00:00:00 2001 From: John Spurlock Date: Mon, 9 Mar 2015 12:19:23 -0400 Subject: [PATCH] ZenLog: Track changes to effect suppressorship. Bug: 19656287 Change-Id: Ibbb42bef68f4588beac4ca971db73a19678c2b4c --- .../notification/NotificationManagerService.java | 2 ++ .../com/android/server/notification/ZenLog.java | 24 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index bedcabe7246b..bb0aa65caa60 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -1026,6 +1026,7 @@ public class NotificationManagerService extends SystemService { private void updateListenerHintsLocked() { final int hints = mListenersDisablingEffects.isEmpty() ? 0 : HINT_HOST_DISABLE_EFFECTS; if (hints == mListenerHints) return; + ZenLog.traceListenerHintsChanged(mListenerHints, hints, mListenersDisablingEffects.size()); mListenerHints = hints; scheduleListenerHintsChanged(hints); } @@ -1034,6 +1035,7 @@ public class NotificationManagerService extends SystemService { final ComponentName suppressor = !mListenersDisablingEffects.isEmpty() ? mListenersDisablingEffects.valueAt(0).component : null; if (Objects.equals(suppressor, mEffectsSuppressor)) return; + ZenLog.traceEffectsSuppressorChanged(mEffectsSuppressor, suppressor); mEffectsSuppressor = suppressor; mZenModeHelper.setEffectsSuppressed(suppressor != null); getContext().sendBroadcast(new Intent(NotificationManager.ACTION_EFFECTS_SUPPRESSOR_CHANGED) diff --git a/services/core/java/com/android/server/notification/ZenLog.java b/services/core/java/com/android/server/notification/ZenLog.java index a83fbc32da15..1fc967f430ce 100644 --- a/services/core/java/com/android/server/notification/ZenLog.java +++ b/services/core/java/com/android/server/notification/ZenLog.java @@ -24,6 +24,7 @@ import android.os.RemoteException; import android.provider.Settings.Global; import android.service.notification.Condition; import android.service.notification.IConditionProvider; +import android.service.notification.NotificationListenerService; import android.service.notification.ZenModeConfig; import android.util.Slog; @@ -56,6 +57,8 @@ public class ZenLog { private static final int TYPE_CONFIG = 11; private static final int TYPE_NOT_INTERCEPTED = 12; private static final int TYPE_DISABLE_EFFECTS = 13; + private static final int TYPE_SUPPRESSOR_CHANGED = 14; + private static final int TYPE_LISTENER_HINTS_CHANGED = 15; private static int sNext; private static int sSize; @@ -120,6 +123,17 @@ public class ZenLog { append(TYPE_DISABLE_EFFECTS, record.getKey() + "," + reason); } + public static void traceEffectsSuppressorChanged(ComponentName oldSuppressor, + ComponentName newSuppressor) { + append(TYPE_SUPPRESSOR_CHANGED, componentToString(oldSuppressor) + "->" + + componentToString(newSuppressor)); + } + + public static void traceListenerHintsChanged(int oldHints, int newHints, int listenerCount) { + append(TYPE_LISTENER_HINTS_CHANGED, hintsToString(oldHints) + "->" + + hintsToString(newHints) + ",listeners=" + listenerCount); + } + private static String subscribeResult(IConditionProvider provider, RemoteException e) { return provider == null ? "no provider" : e != null ? e.getMessage() : "ok"; } @@ -139,6 +153,8 @@ public class ZenLog { case TYPE_CONFIG: return "config"; case TYPE_NOT_INTERCEPTED: return "not_intercepted"; case TYPE_DISABLE_EFFECTS: return "disable_effects"; + case TYPE_SUPPRESSOR_CHANGED: return "suppressor_changed"; + case TYPE_LISTENER_HINTS_CHANGED: return "listener_hints_changed"; default: return "unknown"; } } @@ -161,6 +177,14 @@ public class ZenLog { } } + private static String hintsToString(int hints) { + switch (hints) { + case 0 : return "none"; + case NotificationListenerService.HINT_HOST_DISABLE_EFFECTS : return "disable_effects"; + default: return Integer.toString(hints); + } + } + private static String componentToString(ComponentName component) { return component != null ? component.toShortString() : null; } -- 2.11.0