summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ned Burns <pixel@google.com> 2020-01-21 17:47:16 -0500
committer Ned Burns <pixel@google.com> 2020-01-28 14:46:30 -0500
commit7d2e9c1c2756294104d45ccbd9b59b2575c7bceb (patch)
tree71494a45594b7bf1e59774709a21df8934222455
parent56a0ea125ad595f6b306c490ad6e4bed86f90c65 (diff)
Example implementations of new logging system
Test: manual Change-Id: I5fe67e17ed10bc6ab9cd32a158cdbcf6778ece12
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java138
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java29
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescerLogger.kt62
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/ShadeListBuilderLogger.kt217
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/notifcollection/NotifCollectionLogger.kt62
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java8
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilderTest.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescerTest.java11
9 files changed, 417 insertions, 133 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
index 86c0d85829b5..92927cf104a0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java
@@ -44,7 +44,6 @@ import android.service.notification.NotificationListenerService.Ranking;
import android.service.notification.NotificationListenerService.RankingMap;
import android.service.notification.StatusBarNotification;
import android.util.ArrayMap;
-import android.util.Log;
import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.DumpController;
@@ -56,6 +55,7 @@ import com.android.systemui.statusbar.notification.collection.coalescer.GroupCoa
import com.android.systemui.statusbar.notification.collection.notifcollection.CollectionReadyForBuildListener;
import com.android.systemui.statusbar.notification.collection.notifcollection.DismissedByUserStats;
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener;
+import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionLogger;
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifLifetimeExtender;
import com.android.systemui.util.Assert;
@@ -100,6 +100,7 @@ import javax.inject.Singleton;
public class NotifCollection implements Dumpable {
private final IStatusBarService mStatusBarService;
private final FeatureFlags mFeatureFlags;
+ private final NotifCollectionLogger mLogger;
private final Map<String, NotificationEntry> mNotificationSet = new ArrayMap<>();
private final Collection<NotificationEntry> mReadOnlyNotificationSet =
@@ -116,9 +117,11 @@ public class NotifCollection implements Dumpable {
public NotifCollection(
IStatusBarService statusBarService,
DumpController dumpController,
- FeatureFlags featureFlags) {
+ FeatureFlags featureFlags,
+ NotifCollectionLogger logger) {
Assert.isMainThread();
mStatusBarService = statusBarService;
+ mLogger = logger;
dumpController.registerDumpable(TAG, this);
mFeatureFlags = featureFlags;
}
@@ -190,8 +193,8 @@ public class NotifCollection implements Dumpable {
private void onNotificationGroupPosted(List<CoalescedEvent> batch) {
Assert.isMainThread();
- Log.d(TAG, "POSTED GROUP " + batch.get(0).getSbn().getGroupKey()
- + " (" + batch.size() + " events)");
+ mLogger.logNotifGroupPosted(batch.get(0).getSbn().getGroupKey(), batch.size());
+
for (CoalescedEvent event : batch) {
postNotification(event.getSbn(), event.getRanking(), null);
}
@@ -204,7 +207,7 @@ public class NotifCollection implements Dumpable {
int reason) {
Assert.isMainThread();
- Log.d(TAG, "REMOVED " + sbn.getKey() + " reason=" + reason);
+ mLogger.logNotifRemoved(sbn.getKey(), reason);
removeNotification(sbn.getKey(), rankingMap, reason, null);
}
@@ -222,7 +225,7 @@ public class NotifCollection implements Dumpable {
if (entry == null) {
// A new notification!
- Log.d(TAG, "POSTED " + sbn.getKey());
+ mLogger.logNotifPosted(sbn.getKey());
entry = new NotificationEntry(sbn, ranking);
mNotificationSet.put(sbn.getKey(), entry);
@@ -234,7 +237,7 @@ public class NotifCollection implements Dumpable {
} else {
// Update to an existing entry
- Log.d(TAG, "UPDATED " + sbn.getKey());
+ mLogger.logNotifUpdated(sbn.getKey());
// Notification is updated so it is essentially re-added and thus alive again. Don't
// need to keep its lifetime extended.
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 97f8ec5f5bb7..9f8f42ee116c 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
@@ -32,19 +32,20 @@ import android.annotation.Nullable;
import android.util.ArrayMap;
import android.util.Pair;
+import androidx.annotation.NonNull;
+
import com.android.systemui.DumpController;
import com.android.systemui.Dumpable;
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener;
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeSortListener;
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeTransformGroupsListener;
import com.android.systemui.statusbar.notification.collection.listbuilder.PipelineState;
+import com.android.systemui.statusbar.notification.collection.listbuilder.ShadeListBuilderLogger;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection;
import com.android.systemui.statusbar.notification.collection.notifcollection.CollectionReadyForBuildListener;
-import com.android.systemui.statusbar.notification.logging.NotifEvent;
-import com.android.systemui.statusbar.notification.logging.NotifLog;
import com.android.systemui.util.Assert;
import com.android.systemui.util.time.SystemClock;
@@ -69,7 +70,7 @@ import javax.inject.Singleton;
@Singleton
public class ShadeListBuilder implements Dumpable {
private final SystemClock mSystemClock;
- private final NotifLog mNotifLog;
+ private final ShadeListBuilderLogger mLogger;
private List<ListEntry> mNotifList = new ArrayList<>();
private List<ListEntry> mNewNotifList = new ArrayList<>();
@@ -98,11 +99,11 @@ public class ShadeListBuilder implements Dumpable {
@Inject
public ShadeListBuilder(
SystemClock systemClock,
- NotifLog notifLog,
+ ShadeListBuilderLogger logger,
DumpController dumpController) {
Assert.isMainThread();
mSystemClock = systemClock;
- mNotifLog = notifLog;
+ mLogger = logger;
dumpController.registerDumpable(TAG, this);
}
@@ -205,8 +206,7 @@ public class ShadeListBuilder implements Dumpable {
Assert.isMainThread();
mPipelineState.requireIsBefore(STATE_BUILD_STARTED);
- mNotifLog.log(NotifEvent.ON_BUILD_LIST, "Request received from "
- + "NotifCollection");
+ mLogger.logOnBuildList();
mAllEntries = entries;
buildList();
}
@@ -215,21 +215,15 @@ public class ShadeListBuilder implements Dumpable {
private void onPreGroupFilterInvalidated(NotifFilter filter) {
Assert.isMainThread();
- mNotifLog.log(NotifEvent.PRE_GROUP_FILTER_INVALIDATED, String.format(
- "Filter \"%s\" invalidated; pipeline state is %d",
- filter.getName(),
- mPipelineState.getState()));
+ mLogger.logPreGroupFilterInvalidated(filter.getName(), mPipelineState.getState());
rebuildListIfBefore(STATE_PRE_GROUP_FILTERING);
}
- private void onPromoterInvalidated(NotifPromoter filter) {
+ private void onPromoterInvalidated(NotifPromoter promoter) {
Assert.isMainThread();
- mNotifLog.log(NotifEvent.PROMOTER_INVALIDATED, String.format(
- "NotifPromoter \"%s\" invalidated; pipeline state is %d",
- filter.getName(),
- mPipelineState.getState()));
+ mLogger.logPromoterInvalidated(promoter.getName(), mPipelineState.getState());
rebuildListIfBefore(STATE_TRANSFORMING);
}
@@ -237,10 +231,7 @@ public class ShadeListBuilder implements Dumpable {
private void onNotifSectionInvalidated(NotifSection section) {
Assert.isMainThread();
- mNotifLog.log(NotifEvent.SECTION_INVALIDATED, String.format(
- "Section \"%s\" invalidated; pipeline state is %d",
- section.getName(),
- mPipelineState.getState()));
+ mLogger.logNotifSectionInvalidated(section.getName(), mPipelineState.getState());
rebuildListIfBefore(STATE_SORTING);
}
@@ -248,10 +239,7 @@ public class ShadeListBuilder implements Dumpable {
private void onPreRenderFilterInvalidated(NotifFilter filter) {
Assert.isMainThread();
- mNotifLog.log(NotifEvent.PRE_RENDER_FILTER_INVALIDATED, String.format(
- "Filter \"%s\" invalidated; pipeline state is %d",
- filter.getName(),
- mPipelineState.getState()));
+ mLogger.logPreRenderFilterInvalidated(filter.getName(), mPipelineState.getState());
rebuildListIfBefore(STATE_PRE_RENDER_FILTERING);
}
@@ -259,10 +247,7 @@ public class ShadeListBuilder implements Dumpable {
private void onNotifComparatorInvalidated(NotifComparator comparator) {
Assert.isMainThread();
- mNotifLog.log(NotifEvent.COMPARATOR_INVALIDATED, String.format(
- "Comparator \"%s\" invalidated; pipeline state is %d",
- comparator.getName(),
- mPipelineState.getState()));
+ mLogger.logNotifComparatorInvalidated(comparator.getName(), mPipelineState.getState());
rebuildListIfBefore(STATE_SORTING);
}
@@ -288,7 +273,7 @@ public class ShadeListBuilder implements Dumpable {
* if we detect that behavior, we should crash instantly.
*/
private void buildList() {
- mNotifLog.log(NotifEvent.START_BUILD_LIST, "Run #" + mIterationCount + "...");
+ mLogger.logStartBuildList(mIterationCount);
mPipelineState.requireIsBefore(STATE_BUILD_STARTED);
mPipelineState.setState(STATE_BUILD_STARTED);
@@ -334,16 +319,16 @@ public class ShadeListBuilder implements Dumpable {
freeEmptyGroups();
// Step 6: Dispatch the new list, first to any listeners and then to the view layer
- mNotifLog.log(NotifEvent.DISPATCH_FINAL_LIST, "List finalized, is:\n"
- + ListDumper.dumpTree(mNotifList, false, "\t\t"));
+ if (mIterationCount % 10 == 0) {
+ mLogger.logFinalList(mNotifList);
+ }
dispatchOnBeforeRenderList(mReadOnlyNotifList);
if (mOnRenderListListener != null) {
mOnRenderListListener.onRenderList(mReadOnlyNotifList);
}
// Step 7: We're done!
- mNotifLog.log(NotifEvent.LIST_BUILD_COMPLETE,
- "Notif list build #" + mIterationCount + " completed");
+ mLogger.logEndBuildList(mIterationCount);
mPipelineState.setState(STATE_IDLE);
mIterationCount++;
}
@@ -429,11 +414,10 @@ public class ShadeListBuilder implements Dumpable {
if (existingSummary == null) {
group.setSummary(entry);
} else {
- mNotifLog.log(NotifEvent.WARN, String.format(
- "Duplicate summary for group '%s': '%s' vs. '%s'",
+ mLogger.logDuplicateSummary(
group.getKey(),
existingSummary.getKey(),
- entry.getKey()));
+ entry.getKey());
// Use whichever one was posted most recently
if (entry.getSbn().getPostTime()
@@ -452,8 +436,7 @@ public class ShadeListBuilder implements Dumpable {
final String topLevelKey = entry.getKey();
if (mGroups.containsKey(topLevelKey)) {
- mNotifLog.log(NotifEvent.WARN,
- "Duplicate non-group top-level key: " + topLevelKey);
+ mLogger.logDuplicateTopLevelKey(topLevelKey);
} else {
entry.setParent(ROOT_ENTRY);
out.add(entry);
@@ -617,24 +600,22 @@ public class ShadeListBuilder implements Dumpable {
private void logParentingChanges() {
for (NotificationEntry entry : mAllEntries) {
if (entry.getParent() != entry.getPreviousParent()) {
- mNotifLog.log(NotifEvent.PARENT_CHANGED, String.format(
- "%s: parent changed from %s to %s",
+ mLogger.logParentChanged(
entry.getKey(),
entry.getPreviousParent() == null
- ? "null" : entry.getPreviousParent().getKey(),
+ ? null : entry.getPreviousParent().getKey(),
entry.getParent() == null
- ? "null" : entry.getParent().getKey()));
+ ? null : entry.getParent().getKey());
}
}
for (GroupEntry group : mGroups.values()) {
if (group.getParent() != group.getPreviousParent()) {
- mNotifLog.log(NotifEvent.PARENT_CHANGED, String.format(
- "%s: parent changed from %s to %s",
+ mLogger.logParentChanged(
group.getKey(),
group.getPreviousParent() == null
- ? "null" : group.getPreviousParent().getKey(),
+ ? null : group.getPreviousParent().getKey(),
group.getParent() == null
- ? "null" : group.getParent().getKey()));
+ ? null : group.getParent().getKey());
}
}
}
@@ -684,23 +665,10 @@ public class ShadeListBuilder implements Dumpable {
NotifFilter filter = findRejectingFilter(entry, now, filters);
if (filter != entry.mExcludingFilter) {
- if (entry.mExcludingFilter == null) {
- mNotifLog.log(NotifEvent.FILTER_CHANGED, String.format(
- "%s: filtered out by '%s'",
- entry.getKey(),
- filter.getName()));
- } else if (filter == null) {
- mNotifLog.log(NotifEvent.FILTER_CHANGED, String.format(
- "%s: no longer filtered out (previous filter was '%s')",
- entry.getKey(),
- entry.mExcludingFilter.getName()));
- } else {
- mNotifLog.log(NotifEvent.FILTER_CHANGED, String.format(
- "%s: filter changed: '%s' -> '%s'",
- entry.getKey(),
- entry.mExcludingFilter,
- filter));
- }
+ mLogger.logFilterChanged(
+ entry.getKey(),
+ entry.mExcludingFilter != null ? entry.mExcludingFilter.getName() : null,
+ filter != null ? filter.getName() : null);
// Note that groups and summaries can also be filtered out later if they're part of a
// malformed group. We currently don't have a great way to track that beyond parenting
@@ -728,23 +696,10 @@ public class ShadeListBuilder implements Dumpable {
NotifPromoter promoter = findPromoter(entry);
if (promoter != entry.mNotifPromoter) {
- if (entry.mNotifPromoter == null) {
- mNotifLog.log(NotifEvent.PROMOTER_CHANGED, String.format(
- "%s: Entry promoted to top level by '%s'",
- entry.getKey(),
- promoter.getName()));
- } else if (promoter == null) {
- mNotifLog.log(NotifEvent.PROMOTER_CHANGED, String.format(
- "%s: Entry is no longer promoted to top level (previous promoter was '%s')",
- entry.getKey(),
- entry.mNotifPromoter.getName()));
- } else {
- mNotifLog.log(NotifEvent.PROMOTER_CHANGED, String.format(
- "%s: Top-level promoter changed: '%s' -> '%s'",
- entry.getKey(),
- entry.mNotifPromoter,
- promoter));
- }
+ mLogger.logPromoterChanged(
+ entry.getKey(),
+ entry.mNotifPromoter != null ? entry.mNotifPromoter.getName() : null,
+ promoter != null ? promoter.getName() : null);
entry.mNotifPromoter = promoter;
}
@@ -767,21 +722,12 @@ public class ShadeListBuilder implements Dumpable {
final Integer sectionIndex = sectionWithIndex.second;
if (section != entry.mNotifSection) {
- if (entry.mNotifSection == null) {
- mNotifLog.log(NotifEvent.SECTION_CHANGED, String.format(
- "%s: sectioned by '%s' [index=%d].",
- entry.getKey(),
- section.getName(),
- sectionIndex));
- } else {
- mNotifLog.log(NotifEvent.SECTION_CHANGED, String.format(
- "%s: section changed: '%s' [index=%d] -> '%s [index=%d]'.",
- entry.getKey(),
- entry.mNotifSection,
- entry.getSection(),
- section,
- sectionIndex));
- }
+ mLogger.logSectionChanged(
+ entry.getKey(),
+ entry.mNotifSection != null ? entry.mNotifSection.getName() : null,
+ entry.getSection(),
+ section.getName(),
+ sectionIndex);
entry.mNotifSection = section;
entry.setSection(sectionIndex);
@@ -826,7 +772,7 @@ public class ShadeListBuilder implements Dumpable {
}
@Override
- public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ public void dump(@NonNull FileDescriptor fd, PrintWriter pw, @NonNull String[] args) {
pw.println("\t" + TAG + " shade notifications:");
if (getShadeList().size() == 0) {
pw.println("\t\t None");
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java
index f5890386a14f..98c45ffd6afb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java
@@ -16,11 +16,6 @@
package com.android.systemui.statusbar.notification.collection.coalescer;
-import static com.android.systemui.statusbar.notification.logging.NotifEvent.BATCH_MAX_TIMEOUT;
-import static com.android.systemui.statusbar.notification.logging.NotifEvent.COALESCED_EVENT;
-import static com.android.systemui.statusbar.notification.logging.NotifEvent.EARLY_BATCH_EMIT;
-import static com.android.systemui.statusbar.notification.logging.NotifEvent.EMIT_EVENT_BATCH;
-
import static java.util.Objects.requireNonNull;
import android.annotation.MainThread;
@@ -35,7 +30,6 @@ import com.android.systemui.Dumpable;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationListener.NotificationHandler;
-import com.android.systemui.statusbar.notification.logging.NotifLog;
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.time.SystemClock;
@@ -71,7 +65,7 @@ import javax.inject.Inject;
public class GroupCoalescer implements Dumpable {
private final DelayableExecutor mMainExecutor;
private final SystemClock mClock;
- private final NotifLog mLog;
+ private final GroupCoalescerLogger mLogger;
private final long mMinGroupLingerDuration;
private final long mMaxGroupLingerDuration;
@@ -83,8 +77,9 @@ public class GroupCoalescer implements Dumpable {
@Inject
public GroupCoalescer(
@Main DelayableExecutor mainExecutor,
- SystemClock clock, NotifLog log) {
- this(mainExecutor, clock, log, MIN_GROUP_LINGER_DURATION, MAX_GROUP_LINGER_DURATION);
+ SystemClock clock,
+ GroupCoalescerLogger logger) {
+ this(mainExecutor, clock, logger, MIN_GROUP_LINGER_DURATION, MAX_GROUP_LINGER_DURATION);
}
/**
@@ -98,12 +93,12 @@ public class GroupCoalescer implements Dumpable {
GroupCoalescer(
@Main DelayableExecutor mainExecutor,
SystemClock clock,
- NotifLog log,
+ GroupCoalescerLogger logger,
long minGroupLingerDuration,
long maxGroupLingerDuration) {
mMainExecutor = mainExecutor;
mClock = clock;
- mLog = log;
+ mLogger = logger;
mMinGroupLingerDuration = minGroupLingerDuration;
mMaxGroupLingerDuration = maxGroupLingerDuration;
}
@@ -129,7 +124,7 @@ public class GroupCoalescer implements Dumpable {
final boolean shouldCoalesce = handleNotificationPosted(sbn, rankingMap);
if (shouldCoalesce) {
- mLog.log(COALESCED_EVENT, String.format("Coalesced notification %s", sbn.getKey()));
+ mLogger.logEventCoalesced(sbn.getKey());
mHandler.onNotificationRankingUpdate(rankingMap);
} else {
mHandler.onNotificationPosted(sbn, rankingMap);
@@ -164,15 +159,11 @@ public class GroupCoalescer implements Dumpable {
final CoalescedEvent event = mCoalescedEvents.get(sbn.getKey());
final EventBatch batch = mBatches.get(sbn.getGroupKey());
if (event != null) {
- mLog.log(EARLY_BATCH_EMIT,
- String.format("Modification of %s triggered early emit of batched group %s",
- sbn.getKey(), requireNonNull(event.getBatch()).mGroupKey));
+ mLogger.logEarlyEmit(sbn.getKey(), requireNonNull(event.getBatch()).mGroupKey);
emitBatch(requireNonNull(event.getBatch()));
} else if (batch != null
&& mClock.uptimeMillis() - batch.mCreatedTimestamp >= mMaxGroupLingerDuration) {
- mLog.log(BATCH_MAX_TIMEOUT,
- String.format("Modification of %s triggered timeout emit of batched group %s",
- sbn.getKey(), batch.mGroupKey));
+ mLogger.logMaxBatchTimeout(sbn.getKey(), batch.mGroupKey);
emitBatch(batch);
}
}
@@ -253,7 +244,7 @@ public class GroupCoalescer implements Dumpable {
}
events.sort(mEventComparator);
- mLog.log(EMIT_EVENT_BATCH, "Emitting event batch for group " + batch.mGroupKey);
+ mLogger.logEmitBatch(batch.mGroupKey);
mHandler.onNotificationBatchPosted(events);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescerLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescerLogger.kt
new file mode 100644
index 000000000000..6e8788db59d7
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescerLogger.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.notification.collection.coalescer
+
+import com.android.systemui.log.LogBuffer
+import com.android.systemui.log.LogLevel
+import com.android.systemui.log.dagger.NotificationLog
+import javax.inject.Inject
+
+class GroupCoalescerLogger @Inject constructor(
+ @NotificationLog private val buffer: LogBuffer
+) {
+ fun logEventCoalesced(key: String) {
+ buffer.log(TAG, LogLevel.INFO, {
+ str1 = key
+ }, {
+ "COALESCED: $str1"
+ })
+ }
+
+ fun logEmitBatch(groupKey: String) {
+ buffer.log(TAG, LogLevel.DEBUG, {
+ str1 = groupKey
+ }, {
+ "Emitting event batch for group $str1"
+ })
+ }
+
+ fun logEarlyEmit(modifiedKey: String, groupKey: String) {
+ buffer.log(TAG, LogLevel.DEBUG, {
+ str1 = modifiedKey
+ str2 = groupKey
+ }, {
+ "Modification of notif $str1 triggered early emit of batched group $str2"
+ })
+ }
+
+ fun logMaxBatchTimeout(modifiedKey: String, groupKey: String) {
+ buffer.log(TAG, LogLevel.INFO, {
+ str1 = modifiedKey
+ str2 = groupKey
+ }, {
+ "Modification of notif $str1 triggered TIMEOUT emit of batched group $str2"
+ })
+ }
+}
+
+private const val TAG = "GroupCoalescer" \ No newline at end of file
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
new file mode 100644
index 000000000000..6e15043973f7
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/ShadeListBuilderLogger.kt
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.notification.collection.listbuilder
+
+import com.android.systemui.log.LogBuffer
+import com.android.systemui.log.LogLevel.DEBUG
+import com.android.systemui.log.LogLevel.INFO
+import com.android.systemui.log.LogLevel.WARNING
+import com.android.systemui.log.dagger.NotificationLog
+import com.android.systemui.statusbar.notification.collection.GroupEntry
+import com.android.systemui.statusbar.notification.collection.ListEntry
+import javax.inject.Inject
+
+class ShadeListBuilderLogger @Inject constructor(
+ @NotificationLog private val buffer: LogBuffer
+) {
+ fun logOnBuildList() {
+ buffer.log(TAG, INFO, {
+ }, {
+ "Request received from NotifCollection"
+ })
+ }
+
+ fun logStartBuildList(iterationCount: Int) {
+ buffer.log(TAG, INFO, {
+ int1 = iterationCount
+ }, {
+ "Starting to build shade list (run #$int1)"
+ })
+ }
+
+ fun logEndBuildList(iterationCount: Int) {
+ buffer.log(TAG, INFO, {
+ int1 = iterationCount
+ }, {
+ "Finished building shade list (run #$int1)"
+ })
+ }
+
+ fun logPreGroupFilterInvalidated(filterName: String, pipelineState: Int) {
+ buffer.log(TAG, DEBUG, {
+ str1 = filterName
+ int1 = pipelineState
+ }, {
+ """Pre-group NotifFilter "$str1" invalidated; pipeline state is $int1"""
+ })
+ }
+
+ fun logPromoterInvalidated(name: String, pipelineState: Int) {
+ buffer.log(TAG, DEBUG, {
+ str1 = name
+ int1 = pipelineState
+ }, {
+ """NotifPromoter "$str1" invalidated; pipeline state is $int1"""
+ })
+ }
+
+ fun logNotifSectionInvalidated(name: String, pipelineState: Int) {
+ buffer.log(TAG, DEBUG, {
+ str1 = name
+ int1 = pipelineState
+ }, {
+ """NotifSection "$str1" invalidated; pipeline state is $int1"""
+ })
+ }
+
+ fun logNotifComparatorInvalidated(name: String, pipelineState: Int) {
+ buffer.log(TAG, DEBUG, {
+ str1 = name
+ int1 = pipelineState
+ }, {
+ """NotifComparator "$str1" invalidated; pipeline state is $int1"""
+ })
+ }
+
+ fun logPreRenderFilterInvalidated(name: String, pipelineState: Int) {
+ buffer.log(TAG, DEBUG, {
+ str1 = name
+ int1 = pipelineState
+ }, {
+ """Pre-render NotifFilter "$str1" invalidated; pipeline state is $int1"""
+ })
+ }
+
+ fun logDuplicateSummary(groupKey: String, existingKey: String, newKey: String) {
+ buffer.log(TAG, WARNING, {
+ str1 = groupKey
+ str2 = existingKey
+ str3 = newKey
+ }, {
+ """Duplicate summary for group "$str1": "$str2" vs. "$str3""""
+ })
+ }
+
+ fun logDuplicateTopLevelKey(topLevelKey: String) {
+ buffer.log(TAG, WARNING, {
+ str1 = topLevelKey
+ }, {
+ "Duplicate top-level key: $str1"
+ })
+ }
+
+ fun logParentChanged(key: String, prevParent: String?, newParent: String?) {
+ buffer.log(TAG, INFO, {
+ str1 = key
+ str2 = prevParent
+ str3 = newParent
+ }, {
+ "Parent change for $str1: $str2 -> $str3"
+ })
+ }
+
+ fun logFilterChanged(
+ key: String,
+ prevFilter: String?,
+ newFilter: String?
+ ) {
+ buffer.log(TAG, INFO, {
+ str1 = key
+ str2 = prevFilter
+ str3 = newFilter
+ }, {
+ "Filter changed for $str1: $str2 -> $str3"
+ })
+ }
+
+ fun logPromoterChanged(
+ key: String,
+ prevPromoter: String?,
+ newPromoter: String?
+ ) {
+ buffer.log(TAG, INFO, {
+ str1 = key
+ str2 = prevPromoter
+ str3 = newPromoter
+ }, {
+ "Promoter changed for $str1: $str2 -> $str3"
+ })
+ }
+
+ fun logSectionChanged(
+ key: String,
+ prevSection: String?,
+ prevIndex: Int,
+ section: String,
+ index: Int
+ ) {
+ buffer.log(TAG, INFO, {
+ str1 = key
+ str2 = section
+ int1 = index
+ str3 = prevSection
+ int2 = prevIndex
+ }, {
+ if (str3 == null) {
+ "Section assigned for $str1: '$str2' (#$int1)"
+ } else {
+ "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)" })
+ }
+ for (i in entries.indices) {
+ val entry = entries[i]
+ buffer.log(TAG, DEBUG, {
+ int1 = i
+ str1 = entry.key
+ }, {
+ "[$int1] $str1"
+ })
+
+ if (entry is GroupEntry) {
+ entry.summary?.let {
+ buffer.log(TAG, DEBUG, {
+ str1 = it.key
+ }, {
+ " [*] $str1 (summary)"
+ })
+ }
+ for (j in entry.children.indices) {
+ val child = entry.children[j]
+ buffer.log(TAG, DEBUG, {
+ int1 = j
+ str1 = child.key
+ }, {
+ " [$int1] $str1"
+ })
+ }
+ }
+ }
+ }
+}
+
+private const val TAG = "ShadeListBuilder" \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/notifcollection/NotifCollectionLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/notifcollection/NotifCollectionLogger.kt
new file mode 100644
index 000000000000..bd1bd860f80c
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/notifcollection/NotifCollectionLogger.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.notification.collection.notifcollection
+
+import com.android.systemui.log.LogBuffer
+import com.android.systemui.log.LogLevel
+import com.android.systemui.log.dagger.NotificationLog
+import javax.inject.Inject
+
+class NotifCollectionLogger @Inject constructor(
+ @NotificationLog private val buffer: LogBuffer
+) {
+ fun logNotifPosted(key: String) {
+ buffer.log(TAG, LogLevel.INFO, {
+ str1 = key
+ }, {
+ "POSTED $str1"
+ })
+ }
+
+ fun logNotifGroupPosted(groupKey: String, batchSize: Int) {
+ buffer.log(TAG, LogLevel.INFO, {
+ str1 = groupKey
+ int1 = batchSize
+ }, {
+ "POSTED GROUP $str1 ($int1 events)"
+ })
+ }
+
+ fun logNotifUpdated(key: String) {
+ buffer.log(TAG, LogLevel.INFO, {
+ str1 = key
+ }, {
+ "UPDATED $str1"
+ })
+ }
+
+ fun logNotifRemoved(key: String, reason: Int) {
+ buffer.log(TAG, LogLevel.INFO, {
+ str1 = key
+ int1 = reason
+ }, {
+ "REMOVED $str1 reason=$int1"
+ })
+ }
+}
+
+private const val TAG = "NotifCollection" \ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java
index 0251f2d0f542..9a7e97b5d55a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java
@@ -62,6 +62,7 @@ import com.android.systemui.statusbar.notification.collection.coalescer.GroupCoa
import com.android.systemui.statusbar.notification.collection.notifcollection.CollectionReadyForBuildListener;
import com.android.systemui.statusbar.notification.collection.notifcollection.DismissedByUserStats;
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener;
+import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionLogger;
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifLifetimeExtender;
import com.android.systemui.util.Assert;
@@ -85,6 +86,7 @@ import java.util.Map;
public class NotifCollectionTest extends SysuiTestCase {
@Mock private IStatusBarService mStatusBarService;
+ @Mock private NotifCollectionLogger mLogger;
@Mock private GroupCoalescer mGroupCoalescer;
@Spy private RecordingCollectionListener mCollectionListener;
@Mock private CollectionReadyForBuildListener mBuildListener;
@@ -111,9 +113,11 @@ public class NotifCollectionTest extends SysuiTestCase {
when(mFeatureFlags.isNewNotifPipelineRenderingEnabled()).thenReturn(true);
when(mFeatureFlags.isNewNotifPipelineEnabled()).thenReturn(true);
- mCollection = new NotifCollection(mStatusBarService,
+ mCollection = new NotifCollection(
+ mStatusBarService,
mock(DumpController.class),
- mFeatureFlags);
+ mFeatureFlags,
+ mLogger);
mCollection.attach(mGroupCoalescer);
mCollection.addCollectionListener(mCollectionListener);
mCollection.setBuildListener(mBuildListener);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilderTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilderTest.java
index e915be37705b..18f133f09811 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilderTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilderTest.java
@@ -45,12 +45,12 @@ import com.android.systemui.statusbar.notification.collection.ShadeListBuilder.O
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener;
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeSortListener;
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeTransformGroupsListener;
+import com.android.systemui.statusbar.notification.collection.listbuilder.ShadeListBuilderLogger;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection;
import com.android.systemui.statusbar.notification.collection.notifcollection.CollectionReadyForBuildListener;
-import com.android.systemui.statusbar.notification.logging.NotifLog;
import com.android.systemui.util.Assert;
import com.android.systemui.util.time.FakeSystemClock;
@@ -81,7 +81,7 @@ public class ShadeListBuilderTest extends SysuiTestCase {
private ShadeListBuilder mListBuilder;
private FakeSystemClock mSystemClock = new FakeSystemClock();
- @Mock private NotifLog mNotifLog;
+ @Mock private ShadeListBuilderLogger mLogger;
@Mock private NotifCollection mNotifCollection;
@Spy private OnBeforeTransformGroupsListener mOnBeforeTransformGroupsListener;
@Spy private OnBeforeSortListener mOnBeforeSortListener;
@@ -103,7 +103,7 @@ public class ShadeListBuilderTest extends SysuiTestCase {
MockitoAnnotations.initMocks(this);
Assert.sMainLooper = TestableLooper.get(this).getLooper();
- mListBuilder = new ShadeListBuilder(mSystemClock, mNotifLog, mock(DumpController.class));
+ mListBuilder = new ShadeListBuilder(mSystemClock, mLogger, mock(DumpController.class));
mListBuilder.setOnRenderListListener(mOnRenderListListener);
mListBuilder.attach(mNotifCollection);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescerTest.java
index 86c1eb97d186..ac9a57022f53 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescerTest.java
@@ -16,8 +16,6 @@
package com.android.systemui.statusbar.notification.collection.coalescer;
-import static com.android.internal.util.Preconditions.checkNotNull;
-
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.clearInvocations;
@@ -25,6 +23,8 @@ import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
+import static java.util.Objects.requireNonNull;
+
import android.service.notification.NotificationListenerService.Ranking;
import android.service.notification.NotificationListenerService.RankingMap;
import android.service.notification.StatusBarNotification;
@@ -39,7 +39,6 @@ import com.android.systemui.statusbar.RankingBuilder;
import com.android.systemui.statusbar.notification.collection.NoManSimulator;
import com.android.systemui.statusbar.notification.collection.NoManSimulator.NotifEvent;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
-import com.android.systemui.statusbar.notification.logging.NotifLog;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.time.FakeSystemClock;
@@ -63,7 +62,7 @@ public class GroupCoalescerTest extends SysuiTestCase {
@Mock private NotificationListener mListenerService;
@Mock private GroupCoalescer.BatchableNotificationHandler mListener;
- @Mock private NotifLog mLog;
+ @Mock private GroupCoalescerLogger mLogger;
@Captor private ArgumentCaptor<NotificationHandler> mListenerCaptor;
@@ -79,14 +78,14 @@ public class GroupCoalescerTest extends SysuiTestCase {
new GroupCoalescer(
mExecutor,
mClock,
- mLog,
+ mLogger,
MIN_LINGER_DURATION,
MAX_LINGER_DURATION);
mCoalescer.setNotificationHandler(mListener);
mCoalescer.attach(mListenerService);
verify(mListenerService).addNotificationHandler(mListenerCaptor.capture());
- NotificationHandler serviceListener = checkNotNull(mListenerCaptor.getValue());
+ NotificationHandler serviceListener = requireNonNull(mListenerCaptor.getValue());
mNoMan.addListener(serviceListener);
}