Tweak ShadeListBuilder to be slightly less verbose

Removes the "build started" message and adds a build ID to every log
that takes place during a build.

Test: atest, manual
Bug: 112656837
Change-Id: Ib302cbc2afb84186909d98542436fe5d17e43147
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java
index 19f7cef..fbabb58 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java
@@ -273,8 +273,6 @@
      * if we detect that behavior, we should crash instantly.
      */
     private void buildList() {
-        mLogger.logStartBuildList(mIterationCount);
-
         mPipelineState.requireIsBefore(STATE_BUILD_STARTED);
         mPipelineState.setState(STATE_BUILD_STARTED);
 
@@ -321,16 +319,16 @@
         freeEmptyGroups();
 
         // Step 8: Dispatch the new list, first to any listeners and then to the view layer
-        if (mIterationCount % 10 == 0) {
-            mLogger.logFinalList(mNotifList);
-        }
         dispatchOnBeforeRenderList(mReadOnlyNotifList);
         if (mOnRenderListListener != null) {
             mOnRenderListListener.onRenderList(mReadOnlyNotifList);
         }
 
         // Step 9: We're done!
-        mLogger.logEndBuildList(mIterationCount);
+        mLogger.logEndBuildList(mIterationCount, mReadOnlyNotifList.size());
+        if (mIterationCount % 10 == 0) {
+            mLogger.logFinalList(mNotifList);
+        }
         mPipelineState.setState(STATE_IDLE);
         mIterationCount++;
     }
@@ -439,6 +437,7 @@
                         group.setSummary(entry);
                     } else {
                         mLogger.logDuplicateSummary(
+                                mIterationCount,
                                 group.getKey(),
                                 existingSummary.getKey(),
                                 entry.getKey());
@@ -460,7 +459,7 @@
 
                 final String topLevelKey = entry.getKey();
                 if (mGroups.containsKey(topLevelKey)) {
-                    mLogger.logDuplicateTopLevelKey(topLevelKey);
+                    mLogger.logDuplicateTopLevelKey(mIterationCount, topLevelKey);
                 } else {
                     entry.setParent(ROOT_ENTRY);
                     out.add(entry);
@@ -626,6 +625,7 @@
         for (NotificationEntry entry : mAllEntries) {
             if (entry.mExcludingFilter != entry.mPreviousExcludingFilter) {
                 mLogger.logFilterChanged(
+                        mIterationCount,
                         entry.getKey(),
                         entry.mPreviousExcludingFilter,
                         entry.mExcludingFilter);
@@ -637,6 +637,7 @@
         for (NotificationEntry entry : mAllEntries) {
             if (entry.getParent() != entry.getPreviousParent()) {
                 mLogger.logParentChanged(
+                        mIterationCount,
                         entry.getKey(),
                         entry.getPreviousParent() == null
                                 ? null : entry.getPreviousParent().getKey(),
@@ -647,6 +648,7 @@
         for (GroupEntry group : mGroups.values()) {
             if (group.getParent() != group.getPreviousParent()) {
                 mLogger.logParentChanged(
+                        mIterationCount,
                         group.getKey(),
                         group.getPreviousParent() == null
                                 ? null : group.getPreviousParent().getKey(),
@@ -720,6 +722,7 @@
 
         if (promoter != entry.mNotifPromoter) {
             mLogger.logPromoterChanged(
+                    mIterationCount,
                     entry.getKey(),
                     entry.mNotifPromoter != null ? entry.mNotifPromoter.getName() : null,
                     promoter != null ? promoter.getName() : null);
@@ -746,6 +749,7 @@
 
         if (section != entry.mNotifSection) {
             mLogger.logSectionChanged(
+                    mIterationCount,
                     entry.getKey(),
                     entry.mNotifSection != null ? entry.mNotifSection.getName() : null,
                     entry.getSection(),
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/ShadeListBuilderLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/ShadeListBuilderLogger.kt
index e946cf1..9ac40a1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/ShadeListBuilderLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/ShadeListBuilderLogger.kt
@@ -36,19 +36,12 @@
         })
     }
 
-    fun logStartBuildList(iterationCount: Int) {
+    fun logEndBuildList(iterationCount: Int, listLength: Int) {
         buffer.log(TAG, INFO, {
             int1 = iterationCount
+            int2 = listLength
         }, {
-            "Starting to build shade list (run #$int1)"
-        })
-    }
-
-    fun logEndBuildList(iterationCount: Int) {
-        buffer.log(TAG, INFO, {
-            int1 = iterationCount
-        }, {
-            "Finished building shade list (run #$int1)"
+            "(Build $int1) Finished building shade list ($int2 top-level entries)"
         })
     }
 
@@ -97,63 +90,71 @@
         })
     }
 
-    fun logDuplicateSummary(groupKey: String, existingKey: String, newKey: String) {
+    fun logDuplicateSummary(buildId: Int, groupKey: String, existingKey: String, newKey: String) {
         buffer.log(TAG, WARNING, {
+            int1 = buildId
             str1 = groupKey
             str2 = existingKey
             str3 = newKey
         }, {
-            """Duplicate summary for group "$str1": "$str2" vs. "$str3""""
+            """(Build $int1) Duplicate summary for group "$str1": "$str2" vs. "$str3""""
         })
     }
 
-    fun logDuplicateTopLevelKey(topLevelKey: String) {
+    fun logDuplicateTopLevelKey(buildId: Int, topLevelKey: String) {
         buffer.log(TAG, WARNING, {
+            int1 = buildId
             str1 = topLevelKey
         }, {
-            "Duplicate top-level key: $str1"
+            "(Build $int1) Duplicate top-level key: $str1"
         })
     }
 
-    fun logParentChanged(key: String, prevParent: String?, newParent: String?) {
+    fun logParentChanged(buildId: Int, key: String, prevParent: String?, newParent: String?) {
         buffer.log(TAG, INFO, {
+            int1 = buildId
             str1 = key
             str2 = prevParent
             str3 = newParent
         }, {
-            "Parent change for $str1: $str2 -> $str3"
+            "(Build $int1) Parent change for $str1: $str2 -> $str3"
         })
     }
 
     fun logFilterChanged(
+        buildId: Int,
         key: String,
         prevFilter: NotifFilter?,
         newFilter: NotifFilter?
     ) {
         buffer.log(TAG, INFO, {
+            int1 = buildId
             str1 = key
             str2 = prevFilter?.name
             str3 = newFilter?.name
         }, {
-            "Filter changed for $str1: $str2 -> $str3"
+            "(Build $int1) Filter changed for $str1: $str2 -> $str3"
         })
     }
 
     fun logPromoterChanged(
+        buildId: Int,
         key: String,
         prevPromoter: String?,
         newPromoter: String?
     ) {
         buffer.log(TAG, INFO, {
+            int1 = buildId
             str1 = key
             str2 = prevPromoter
             str3 = newPromoter
         }, {
-            "Promoter changed for $str1: $str2 -> $str3"
+            "(Build $int1) Promoter changed for $str1: $str2 -> $str3"
         })
     }
 
     fun logSectionChanged(
+        buildId: Int,
         key: String,
         prevSection: String?,
         prevIndex: Int,
@@ -161,6 +162,7 @@
         index: Int
     ) {
         buffer.log(TAG, INFO, {
+            long1 = buildId.toLong()
             str1 = key
             str2 = section
             int1 = index
@@ -168,19 +170,14 @@
             int2 = prevIndex
         }, {
             if (str3 == null) {
-                "Section assigned for $str1: '$str2' (#$int1)"
+                "(Build $long1) Section assigned for $str1: '$str2' (#$int1)"
             } else {
-                "Section changed for $str1: '$str3' (#$int2) -> '$str2' (#$int1)"
+                "(Build $long1) Section changed for $str1: '$str3' (#$int2) -> '$str2' (#$int1)"
             }
         })
     }
 
     fun logFinalList(entries: List<ListEntry>) {
-        buffer.log(TAG, DEBUG, {
-            int1 = entries.size
-        }, {
-            "List is finalized ($int1 top-level entries):"
-        })
         if (entries.isEmpty()) {
             buffer.log(TAG, DEBUG, {}, { "(empty list)" })
         }