Merge "Some updates to DND logging"
diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java
index 169507c..787a81b 100644
--- a/core/java/android/service/notification/ZenModeConfig.java
+++ b/core/java/android/service/notification/ZenModeConfig.java
@@ -287,7 +287,7 @@
         }
 
         StringBuilder buffer = new StringBuilder(automaticRules.size() * 28);
-        buffer.append('{');
+        buffer.append("{\n");
         for (int i = 0; i < automaticRules.size(); i++) {
             if (i > 0) {
                 buffer.append(",\n");
@@ -1831,12 +1831,13 @@
         public String toString() {
             return new StringBuilder(ZenRule.class.getSimpleName()).append('[')
                     .append("id=").append(id)
+                    .append(",state=").append(condition == null ? "STATE_FALSE"
+                            : Condition.stateToString(condition.state))
                     .append(",enabled=").append(String.valueOf(enabled).toUpperCase())
                     .append(",snoozing=").append(snoozing)
                     .append(",name=").append(name)
                     .append(",zenMode=").append(Global.zenModeToString(zenMode))
                     .append(",conditionId=").append(conditionId)
-                    .append(",condition=").append(condition)
                     .append(",pkg=").append(pkg)
                     .append(",component=").append(component)
                     .append(",configActivity=").append(configurationActivity)
@@ -1844,6 +1845,7 @@
                     .append(",enabler=").append(enabler)
                     .append(",zenPolicy=").append(zenPolicy)
                     .append(",modified=").append(modified)
+                    .append(",condition=").append(condition)
                     .append(']').toString();
         }
 
@@ -2011,6 +2013,10 @@
         public Diff addLine(String item, Object from, Object to) {
             return addLine(item, from + "->" + to);
         }
+
+        public boolean isEmpty() {
+            return lines.isEmpty();
+        }
     }
 
     /**
diff --git a/services/core/java/com/android/server/notification/ZenLog.java b/services/core/java/com/android/server/notification/ZenLog.java
index 8f05636..f5d6489 100644
--- a/services/core/java/com/android/server/notification/ZenLog.java
+++ b/services/core/java/com/android/server/notification/ZenLog.java
@@ -39,7 +39,7 @@
     // the ZenLog is *very* verbose, so be careful about setting this to true
     private static final boolean DEBUG = false;
 
-    private static final int SIZE = Build.IS_DEBUGGABLE ? 100 : 20;
+    private static final int SIZE = Build.IS_DEBUGGABLE ? 200 : 100;
 
     private static final long[] TIMES = new long[SIZE];
     private static final int[] TYPES = new int[SIZE];
@@ -136,9 +136,14 @@
 
     public static void traceConfig(String reason, ZenModeConfig oldConfig,
             ZenModeConfig newConfig) {
-        append(TYPE_CONFIG, reason
-                + "," + (newConfig != null ? newConfig.toString() : null)
-                + "," + ZenModeConfig.diff(oldConfig, newConfig));
+        ZenModeConfig.Diff diff = ZenModeConfig.diff(oldConfig, newConfig);
+        if (diff.isEmpty()) {
+            append(TYPE_CONFIG, reason + " no changes");
+        } else {
+            append(TYPE_CONFIG, reason
+                    + ",\n" + (newConfig != null ? newConfig.toString() : null)
+                    + ",\n" + ZenModeConfig.diff(oldConfig, newConfig));
+        }
     }
 
     public static void traceDisableEffects(NotificationRecord record, String reason) {
diff --git a/services/core/java/com/android/server/notification/ZenModeConditions.java b/services/core/java/com/android/server/notification/ZenModeConditions.java
index 571f799..50b4d43 100644
--- a/services/core/java/com/android/server/notification/ZenModeConditions.java
+++ b/services/core/java/com/android/server/notification/ZenModeConditions.java
@@ -108,7 +108,7 @@
     @Override
     public void onServiceAdded(ComponentName component) {
         if (DEBUG) Log.d(TAG, "onServiceAdded " + component);
-        mHelper.setConfig(mHelper.getConfig(), component, "zmc.onServiceAdded");
+        mHelper.setConfig(mHelper.getConfig(), component, "zmc.onServiceAdded:" + component);
     }
 
     @Override