summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-12-05 05:06:47 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-12-05 05:06:47 +0000
commit8155e802254db5aaa59546ad3a89fbcdff0be8cc (patch)
treee2ca5af2d1df489dcf46d786402f3209f905fa05
parent93b3b42b65bdae2d1099145b93beeb4018300a5a (diff)
parent4f2a8bfe15176078979dba948c39728777e69180 (diff)
Merge "Revert "Recycle SysuiLogs + add NotifLogs""
-rw-r--r--packages/SystemUI/src/com/android/systemui/doze/DozeEvent.java26
-rw-r--r--packages/SystemUI/src/com/android/systemui/doze/DozeLog.java66
-rw-r--r--packages/SystemUI/src/com/android/systemui/log/Event.java29
-rw-r--r--packages/SystemUI/src/com/android/systemui/log/RichEvent.java48
-rw-r--r--packages/SystemUI/src/com/android/systemui/log/SysuiLog.java44
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImpl.java51
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifEvent.java200
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifLog.java92
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/log/RichEventTest.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/log/SysuiLogTest.java59
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java4
13 files changed, 285 insertions, 349 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeEvent.java b/packages/SystemUI/src/com/android/systemui/doze/DozeEvent.java
index d2fe39424875..ea1def07a309 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeEvent.java
@@ -28,12 +28,10 @@ import java.lang.annotation.RetentionPolicy;
* and triaging purposes.
*/
public class DozeEvent extends RichEvent {
- /**
- * Initializes a doze event
- */
- public DozeEvent init(@EventType int type, String reason) {
- super.init(DEBUG, type, reason);
- return this;
+ public static final int TOTAL_EVENT_TYPES = 19;
+
+ public DozeEvent(int logLevel, int type, String reason) {
+ super(logLevel, type, reason);
}
/**
@@ -91,6 +89,21 @@ public class DozeEvent extends RichEvent {
}
}
+ /**
+ * Builds a DozeEvent.
+ */
+ public static class DozeEventBuilder extends RichEvent.Builder<DozeEventBuilder> {
+ @Override
+ public DozeEventBuilder getBuilder() {
+ return this;
+ }
+
+ @Override
+ public RichEvent build() {
+ return new DozeEvent(mLogLevel, mType, mReason);
+ }
+ }
+
@IntDef({PICKUP_WAKEUP, PULSE_START, PULSE_FINISH, NOTIFICATION_PULSE, DOZING, FLING,
EMERGENCY_CALL, KEYGUARD_BOUNCER_CHANGED, SCREEN_ON, SCREEN_OFF, MISSED_TICK,
TIME_TICK_SCHEDULED, KEYGUARD_VISIBILITY_CHANGE, DOZE_STATE_CHANGED, WAKE_DISPLAY,
@@ -119,7 +132,6 @@ public class DozeEvent extends RichEvent {
public static final int PULSE_DROPPED = 16;
public static final int PULSE_DISABLED_BY_PROX = 17;
public static final int SENSOR_TRIGGERED = 18;
- public static final int TOTAL_EVENT_TYPES = 19;
public static final int TOTAL_REASONS = 10;
@IntDef({PULSE_REASON_NONE, PULSE_REASON_INTENT, PULSE_REASON_NOTIFICATION,
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
index fe504216b166..2e4466d47927 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
@@ -35,11 +35,9 @@ import javax.inject.Singleton;
* dependency DumpController DozeLog
*/
@Singleton
-public class DozeLog extends SysuiLog<DozeEvent> {
+public class DozeLog extends SysuiLog {
private static final String TAG = "DozeLog";
- private DozeEvent mRecycledEvent;
-
private boolean mPulsing;
private long mSince;
private SummaryStats mPickupPulseNearVibrationStats;
@@ -75,8 +73,8 @@ public class DozeLog extends SysuiLog<DozeEvent> {
* Appends pickup wakeup event to the logs
*/
public void tracePickupWakeUp(boolean withinVibrationThreshold) {
- log(DozeEvent.PICKUP_WAKEUP, "withinVibrationThreshold=" + withinVibrationThreshold);
- if (mEnabled) {
+ if (log(DozeEvent.PICKUP_WAKEUP,
+ "withinVibrationThreshold=" + withinVibrationThreshold)) {
(withinVibrationThreshold ? mPickupPulseNearVibrationStats
: mPickupPulseNotNearVibrationStats).append();
}
@@ -87,24 +85,27 @@ public class DozeLog extends SysuiLog<DozeEvent> {
* @param reason why the pulse started
*/
public void tracePulseStart(@DozeEvent.Reason int reason) {
- log(DozeEvent.PULSE_START, DozeEvent.reasonToString(reason));
- if (mEnabled) mPulsing = true;
+ if (log(DozeEvent.PULSE_START, DozeEvent.reasonToString(reason))) {
+ mPulsing = true;
+ }
}
/**
* Appends pulse finished event to the logs
*/
public void tracePulseFinish() {
- log(DozeEvent.PULSE_FINISH);
- if (mEnabled) mPulsing = false;
+ if (log(DozeEvent.PULSE_FINISH)) {
+ mPulsing = false;
+ }
}
/**
* Appends pulse event to the logs
*/
public void traceNotificationPulse() {
- log(DozeEvent.NOTIFICATION_PULSE);
- if (mEnabled) mNotificationPulseStats.append();
+ if (log(DozeEvent.NOTIFICATION_PULSE)) {
+ mNotificationPulseStats.append();
+ }
}
/**
@@ -112,8 +113,9 @@ public class DozeLog extends SysuiLog<DozeEvent> {
* @param dozing true if dozing, else false
*/
public void traceDozing(boolean dozing) {
- log(DozeEvent.DOZING, "dozing=" + dozing);
- if (mEnabled) mPulsing = false;
+ if (log(DozeEvent.DOZING, "dozing=" + dozing)) {
+ mPulsing = false;
+ }
}
/**
@@ -131,8 +133,9 @@ public class DozeLog extends SysuiLog<DozeEvent> {
* Appends emergency call event to the logs
*/
public void traceEmergencyCall() {
- log(DozeEvent.EMERGENCY_CALL);
- if (mEnabled) mEmergencyCallStats.append();
+ if (log(DozeEvent.EMERGENCY_CALL)) {
+ mEmergencyCallStats.append();
+ }
}
/**
@@ -147,8 +150,7 @@ public class DozeLog extends SysuiLog<DozeEvent> {
* Appends screen-on event to the logs
*/
public void traceScreenOn() {
- log(DozeEvent.SCREEN_ON, "pulsing=" + mPulsing);
- if (mEnabled) {
+ if (log(DozeEvent.SCREEN_ON, "pulsing=" + mPulsing)) {
(mPulsing ? mScreenOnPulsingStats : mScreenOnNotPulsingStats).append();
mPulsing = false;
}
@@ -186,8 +188,10 @@ public class DozeLog extends SysuiLog<DozeEvent> {
* @param showing whether the keyguard is now showing
*/
public void traceKeyguard(boolean showing) {
- log(DozeEvent.KEYGUARD_VISIBILITY_CHANGE, "showing=" + showing);
- if (mEnabled && !showing) mPulsing = false;
+ if (log(DozeEvent.KEYGUARD_VISIBILITY_CHANGE, "showing=" + showing)
+ && !showing) {
+ mPulsing = false;
+ }
}
/**
@@ -213,11 +217,12 @@ public class DozeLog extends SysuiLog<DozeEvent> {
* @param reason why proximity result was triggered
*/
public void traceProximityResult(boolean near, long millis, @DozeEvent.Reason int reason) {
- log(DozeEvent.PROXIMITY_RESULT,
+ if (log(DozeEvent.PROXIMITY_RESULT,
" reason=" + DozeEvent.reasonToString(reason)
- + " near=" + near
- + " millis=" + millis);
- if (mEnabled) mProxStats[reason][near ? 0 : 1].append();
+ + " near=" + near
+ + " millis=" + millis)) {
+ mProxStats[reason][near ? 0 : 1].append();
+ }
}
/**
@@ -245,16 +250,15 @@ public class DozeLog extends SysuiLog<DozeEvent> {
}
}
- private void log(@DozeEvent.EventType int eventType) {
- log(eventType, "");
+ private boolean log(@DozeEvent.EventType int eventType) {
+ return log(eventType, "");
}
- private void log(@DozeEvent.EventType int eventType, String msg) {
- if (mRecycledEvent != null) {
- mRecycledEvent = log(mRecycledEvent.init(eventType, msg));
- } else {
- mRecycledEvent = log(new DozeEvent().init(eventType, msg));
- }
+ private boolean log(@DozeEvent.EventType int eventType, String msg) {
+ return super.log(new DozeEvent.DozeEventBuilder()
+ .setType(eventType)
+ .setReason(msg)
+ .build());
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/log/Event.java b/packages/SystemUI/src/com/android/systemui/log/Event.java
index 7bc1abfbb0d8..92862a2bc74c 100644
--- a/packages/SystemUI/src/com/android/systemui/log/Event.java
+++ b/packages/SystemUI/src/com/android/systemui/log/Event.java
@@ -37,28 +37,20 @@ public class Event {
public static final int INFO = 4;
public static final int WARN = 5;
public static final int ERROR = 6;
- public static final @Level int DEFAULT_LOG_LEVEL = DEBUG;
private long mTimestamp;
- private @Level int mLogLevel = DEFAULT_LOG_LEVEL;
- private String mMessage = "";
+ private @Level int mLogLevel = DEBUG;
+ protected String mMessage;
- /**
- * initialize an event with a message
- */
- public Event init(String message) {
- init(DEFAULT_LOG_LEVEL, message);
- return this;
+ public Event(String message) {
+ mTimestamp = System.currentTimeMillis();
+ mMessage = message;
}
- /**
- * initialize an event with a logLevel and message
- */
- public Event init(@Level int logLevel, String message) {
+ public Event(@Level int logLevel, String message) {
mTimestamp = System.currentTimeMillis();
mLogLevel = logLevel;
mMessage = message;
- return this;
}
public String getMessage() {
@@ -72,13 +64,4 @@ public class Event {
public @Level int getLogLevel() {
return mLogLevel;
}
-
- /**
- * Recycle this event
- */
- void recycle() {
- mTimestamp = -1;
- mLogLevel = DEFAULT_LOG_LEVEL;
- mMessage = "";
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/log/RichEvent.java b/packages/SystemUI/src/com/android/systemui/log/RichEvent.java
index 470f2b0d1b98..acf761ed3936 100644
--- a/packages/SystemUI/src/com/android/systemui/log/RichEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/log/RichEvent.java
@@ -23,21 +23,23 @@ package com.android.systemui.log;
* Events are stored in {@link SysuiLog} and can be printed in a dumpsys.
*/
public abstract class RichEvent extends Event {
- private int mType;
+ private final int mType;
+ private final String mReason;
/**
- * Initializes a rich event that includes an event type that matches with an index in the array
+ * Create a rich event that includes an event type that matches with an index in the array
* getEventLabels().
*/
- public RichEvent init(@Event.Level int logLevel, int type, String reason) {
+ public RichEvent(@Event.Level int logLevel, int type, String reason) {
+ super(logLevel, null);
final int numEvents = getEventLabels().length;
if (type < 0 || type >= numEvents) {
throw new IllegalArgumentException("Unsupported event type. Events only supported"
+ " from 0 to " + (numEvents - 1) + ", but given type=" + type);
}
mType = type;
- super.init(logLevel, getEventLabels()[mType] + " " + reason);
- return this;
+ mReason = reason;
+ mMessage = getEventLabels()[mType] + " " + mReason;
}
/**
@@ -47,43 +49,25 @@ public abstract class RichEvent extends Event {
*/
public abstract String[] getEventLabels();
- @Override
- public void recycle() {
- super.recycle();
- mType = -1;
- }
-
public int getType() {
return mType;
}
+ public String getReason() {
+ return mReason;
+ }
+
/**
* Builder to build a RichEvent.
* @param <B> Log specific builder that is extending this builder
- * @param <E> Type of event we'll be building
*/
- public abstract static class Builder<B extends Builder<B, E>, E extends RichEvent> {
+ public abstract static class Builder<B extends Builder<B>> {
public static final int UNINITIALIZED = -1;
- public final SysuiLog mLog;
private B mBuilder = getBuilder();
- protected int mType;
+ protected int mType = UNINITIALIZED;
protected String mReason;
- protected @Level int mLogLevel;
-
- public Builder(SysuiLog sysuiLog) {
- mLog = sysuiLog;
- reset();
- }
-
- /**
- * Reset this builder's parameters so it can be reused to build another RichEvent.
- */
- public void reset() {
- mType = UNINITIALIZED;
- mReason = null;
- mLogLevel = VERBOSE;
- }
+ protected @Level int mLogLevel = VERBOSE;
/**
* Get the log-specific builder.
@@ -91,9 +75,9 @@ public abstract class RichEvent extends Event {
public abstract B getBuilder();
/**
- * Build the log-specific event given an event to populate.
+ * Build the log-specific event.
*/
- public abstract E build(E e);
+ public abstract RichEvent build();
/**
* Optional - set the log level. Defaults to DEBUG.
diff --git a/packages/SystemUI/src/com/android/systemui/log/SysuiLog.java b/packages/SystemUI/src/com/android/systemui/log/SysuiLog.java
index e41032a82c79..f094cb909cf2 100644
--- a/packages/SystemUI/src/com/android/systemui/log/SysuiLog.java
+++ b/packages/SystemUI/src/com/android/systemui/log/SysuiLog.java
@@ -20,7 +20,6 @@ import android.os.Build;
import android.os.SystemProperties;
import android.util.Log;
-import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.DumpController;
import com.android.systemui.Dumpable;
@@ -40,25 +39,22 @@ import java.util.Locale;
* To manually view the logs via adb:
* adb shell dumpsys activity service com.android.systemui/.SystemUIService \
* dependency DumpController <SysuiLogId>
- *
- * Logs can be disabled by setting the following SystemProperty and then restarting the device:
- * adb shell setprop persist.sysui.log.enabled.<id> true/false && adb reboot
- *
- * @param <E> Type of event we'll be logging
*/
-public class SysuiLog<E extends Event> implements Dumpable {
+public class SysuiLog implements Dumpable {
public static final SimpleDateFormat DATE_FORMAT =
new SimpleDateFormat("MM-dd HH:mm:ss", Locale.US);
- protected final Object mDataLock = new Object();
+ private final Object mDataLock = new Object();
private final String mId;
private final int mMaxLogs;
- protected boolean mEnabled;
+ private boolean mEnabled;
- @VisibleForTesting protected ArrayDeque<E> mTimeline;
+ @VisibleForTesting protected ArrayDeque<Event> mTimeline;
/**
* Creates a SysuiLog
+ * To enable or disable logs, set the system property and then restart the device:
+ * adb shell setprop sysui.log.enabled.<id> true/false && adb reboot
* @param dumpController where to register this logger's dumpsys
* @param id user-readable tag for this logger
* @param maxDebugLogs maximum number of logs to retain when {@link sDebuggable} is true
@@ -78,20 +74,23 @@ public class SysuiLog<E extends Event> implements Dumpable {
dumpController.registerDumpable(mId, this);
}
+ public SysuiLog(DumpController dumpController, String id) {
+ this(dumpController, id, DEFAULT_MAX_DEBUG_LOGS, DEFAULT_MAX_LOGS);
+ }
+
/**
* Logs an event to the timeline which can be printed by the dumpsys.
* May also log to logcat if enabled.
- * @return the last event that was discarded from the Timeline (can be recycled)
+ * @return true if event was logged, else false
*/
- public E log(E event) {
+ public boolean log(Event event) {
if (!mEnabled) {
- return null;
+ return false;
}
- E recycledEvent = null;
synchronized (mDataLock) {
if (mTimeline.size() >= mMaxLogs) {
- recycledEvent = mTimeline.removeFirst();
+ mTimeline.removeFirst();
}
mTimeline.add(event);
@@ -117,18 +116,13 @@ public class SysuiLog<E extends Event> implements Dumpable {
break;
}
}
-
- if (recycledEvent != null) {
- recycledEvent.recycle();
- }
-
- return recycledEvent;
+ return true;
}
/**
* @return user-readable string of the given event with timestamp
*/
- private String eventToTimestampedString(Event event) {
+ public String eventToTimestampedString(Event event) {
StringBuilder sb = new StringBuilder();
sb.append(SysuiLog.DATE_FORMAT.format(event.getTimestamp()));
sb.append(" ");
@@ -143,7 +137,9 @@ public class SysuiLog<E extends Event> implements Dumpable {
return event.getMessage();
}
- @GuardedBy("mDataLock")
+ /**
+ * only call on this method if you have the mDataLock
+ */
private void dumpTimelineLocked(PrintWriter pw) {
pw.println("\tTimeline:");
@@ -166,7 +162,7 @@ public class SysuiLog<E extends Event> implements Dumpable {
}
private static boolean sDebuggable = Build.IS_DEBUGGABLE;
- private static final String SYSPROP_ENABLED_PREFIX = "persist.sysui.log.enabled.";
+ private static final String SYSPROP_ENABLED_PREFIX = "sysui.log.enabled.";
private static final boolean LOG_TO_LOGCAT_ENABLED = sDebuggable;
private static final boolean DEFAULT_ENABLED = sDebuggable;
private static final int DEFAULT_MAX_DEBUG_LOGS = 100;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java b/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java
index 4c4112f83284..341c49a87156 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java
@@ -57,7 +57,7 @@ public class FeatureFlags {
}
public boolean isNewNotifPipelineEnabled() {
- return getDeviceConfigFlag("notification.newpipeline.enabled", true);
+ return getDeviceConfigFlag("notification.newpipeline.enabled", false);
}
private void onPropertiesChanged(@NonNull DeviceConfig.Properties properties) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
index d81743ab1f5d..7a58097f3ec1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
@@ -267,13 +267,14 @@ public class NotificationEntryManager implements
NotificationEntry entry = mPendingNotifications.get(key);
entry.abortTask();
mPendingNotifications.remove(key);
- mNotifLog.log(NotifEvent.INFLATION_ABORTED, entry, "PendingNotification aborted"
- + " reason=" + reason);
+ mNotifLog.log(NotifEvent.INFLATION_ABORTED, entry.getSbn(), null,
+ "PendingNotification aborted. " + reason);
}
NotificationEntry addedEntry = getActiveNotificationUnfiltered(key);
if (addedEntry != null) {
addedEntry.abortTask();
- mNotifLog.log(NotifEvent.INFLATION_ABORTED, addedEntry.getKey() + " " + reason);
+ mNotifLog.log(NotifEvent.INFLATION_ABORTED, addedEntry.getSbn(),
+ null, reason);
}
}
@@ -500,7 +501,7 @@ public class NotificationEntryManager implements
abortExistingInflation(key, "addNotification");
mPendingNotifications.put(key, entry);
- mNotifLog.log(NotifEvent.NOTIF_ADDED, entry);
+ mNotifLog.log(NotifEvent.NOTIF_ADDED, entry.getSbn());
for (NotificationEntryListener listener : mNotificationEntryListeners) {
listener.onPendingEntryAdded(entry);
}
@@ -535,7 +536,7 @@ public class NotificationEntryManager implements
entry.setSbn(notification);
mGroupManager.onEntryUpdated(entry, oldSbn);
- mNotifLog.log(NotifEvent.NOTIF_UPDATED, entry);
+ mNotifLog.log(NotifEvent.NOTIF_UPDATED, entry.getSbn(), entry.getRanking());
for (NotificationEntryListener listener : mNotificationEntryListeners) {
listener.onPreEntryUpdated(entry);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImpl.java
index a1cfb5424c08..21a4b4f895e5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImpl.java
@@ -29,6 +29,7 @@ import static com.android.systemui.statusbar.notification.collection.listbuilder
import android.annotation.MainThread;
import android.annotation.Nullable;
import android.util.ArrayMap;
+import android.util.Log;
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifListBuilder;
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener;
@@ -39,8 +40,6 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.plugga
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.SectionsProvider;
-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;
@@ -60,8 +59,8 @@ import javax.inject.Singleton;
@MainThread
@Singleton
public class NotifListBuilderImpl implements NotifListBuilder {
+
private final SystemClock mSystemClock;
- private final NotifLog mNotifLog;
private final List<ListEntry> mNotifList = new ArrayList<>();
@@ -87,10 +86,9 @@ public class NotifListBuilderImpl implements NotifListBuilder {
private final List<ListEntry> mReadOnlyNotifList = Collections.unmodifiableList(mNotifList);
@Inject
- public NotifListBuilderImpl(SystemClock systemClock, NotifLog notifLog) {
+ public NotifListBuilderImpl(SystemClock systemClock) {
Assert.isMainThread();
mSystemClock = systemClock;
- mNotifLog = notifLog;
}
/**
@@ -195,8 +193,7 @@ public class NotifListBuilderImpl implements NotifListBuilder {
Assert.isMainThread();
mPipelineState.requireIsBefore(STATE_BUILD_STARTED);
- mNotifLog.log(NotifEvent.ON_BUILD_LIST, "Request received from "
- + "NotifCollection");
+ Log.i(TAG, "Build request received from NotifCollection");
mAllEntries = entries;
buildList();
}
@@ -205,7 +202,8 @@ public class NotifListBuilderImpl implements NotifListBuilder {
private void onFilterInvalidated(NotifFilter filter) {
Assert.isMainThread();
- mNotifLog.log(NotifEvent.FILTER_INVALIDATED, String.format(
+ // TODO: Convert these log statements (here and elsewhere) into timeline logging
+ Log.i(TAG, String.format(
"Filter \"%s\" invalidated; pipeline state is %d",
filter.getName(),
mPipelineState.getState()));
@@ -216,7 +214,7 @@ public class NotifListBuilderImpl implements NotifListBuilder {
private void onPromoterInvalidated(NotifPromoter filter) {
Assert.isMainThread();
- mNotifLog.log(NotifEvent.PROMOTER_INVALIDATED, String.format(
+ Log.i(TAG, String.format(
"NotifPromoter \"%s\" invalidated; pipeline state is %d",
filter.getName(),
mPipelineState.getState()));
@@ -227,7 +225,7 @@ public class NotifListBuilderImpl implements NotifListBuilder {
private void onSectionsProviderInvalidated(SectionsProvider provider) {
Assert.isMainThread();
- mNotifLog.log(NotifEvent.SECTIONS_PROVIDER_INVALIDATED, String.format(
+ Log.i(TAG, String.format(
"Sections provider \"%s\" invalidated; pipeline state is %d",
provider.getName(),
mPipelineState.getState()));
@@ -238,7 +236,7 @@ public class NotifListBuilderImpl implements NotifListBuilder {
private void onNotifComparatorInvalidated(NotifComparator comparator) {
Assert.isMainThread();
- mNotifLog.log(NotifEvent.COMPARATOR_INVALIDATED, String.format(
+ Log.i(TAG, String.format(
"Comparator \"%s\" invalidated; pipeline state is %d",
comparator.getName(),
mPipelineState.getState()));
@@ -256,7 +254,7 @@ public class NotifListBuilderImpl implements NotifListBuilder {
* if we detect that behavior, we should crash instantly.
*/
private void buildList() {
- mNotifLog.log(NotifEvent.START_BUILD_LIST, "Run #" + mIterationCount + "...");
+ Log.i(TAG, "Starting notif list build #" + mIterationCount + "...");
mPipelineState.requireIsBefore(STATE_BUILD_STARTED);
mPipelineState.setState(STATE_BUILD_STARTED);
@@ -290,16 +288,15 @@ public class NotifListBuilderImpl implements NotifListBuilder {
freeEmptyGroups();
// Step 5: Dispatch the new list, first to any listeners and then to the view layer
- mNotifLog.log(NotifEvent.DISPATCH_FINAL_LIST, "List finalized, is:\n"
- + dumpList(mNotifList));
+ Log.i(TAG, "List finalized, is:\n" + dumpList(mNotifList));
+ Log.i(TAG, "Dispatching final list to listeners...");
dispatchOnBeforeRenderList(mReadOnlyNotifList);
if (mOnRenderListListener != null) {
mOnRenderListListener.onRenderList(mReadOnlyNotifList);
}
// Step 6: We're done!
- mNotifLog.log(NotifEvent.LIST_BUILD_COMPLETE,
- "Notif list build #" + mIterationCount + " completed");
+ Log.i(TAG, "Notif list build #" + mIterationCount + " completed");
mPipelineState.setState(STATE_IDLE);
mIterationCount++;
}
@@ -357,7 +354,7 @@ public class NotifListBuilderImpl implements NotifListBuilder {
if (existingSummary == null) {
group.setSummary(entry);
} else {
- mNotifLog.log(NotifEvent.WARN, String.format(
+ Log.w(TAG, String.format(
"Duplicate summary for group '%s': '%s' vs. '%s'",
group.getKey(),
existingSummary.getKey(),
@@ -380,8 +377,7 @@ public class NotifListBuilderImpl implements NotifListBuilder {
final String topLevelKey = entry.getKey();
if (mGroups.containsKey(topLevelKey)) {
- mNotifLog.log(NotifEvent.WARN,
- "Duplicate non-group top-level key: " + topLevelKey);
+ Log.wtf(TAG, "Duplicate non-group top-level key: " + topLevelKey);
} else {
entry.setParent(ROOT_ENTRY);
out.add(entry);
@@ -543,7 +539,7 @@ public class NotifListBuilderImpl implements NotifListBuilder {
private void logParentingChanges() {
for (NotificationEntry entry : mAllEntries) {
if (entry.getParent() != entry.getPreviousParent()) {
- mNotifLog.log(NotifEvent.PARENT_CHANGED, String.format(
+ Log.i(TAG, String.format(
"%s: parent changed from %s to %s",
entry.getKey(),
entry.getPreviousParent() == null
@@ -554,7 +550,7 @@ public class NotifListBuilderImpl implements NotifListBuilder {
}
for (GroupEntry group : mGroups.values()) {
if (group.getParent() != group.getPreviousParent()) {
- mNotifLog.log(NotifEvent.PARENT_CHANGED, String.format(
+ Log.i(TAG, String.format(
"%s: parent changed from %s to %s",
group.getKey(),
group.getPreviousParent() == null
@@ -611,17 +607,17 @@ public class NotifListBuilderImpl implements NotifListBuilder {
if (filter != entry.mExcludingFilter) {
if (entry.mExcludingFilter == null) {
- mNotifLog.log(NotifEvent.FILTER_CHANGED, String.format(
+ Log.i(TAG, String.format(
"%s: filtered out by '%s'",
entry.getKey(),
filter.getName()));
} else if (filter == null) {
- mNotifLog.log(NotifEvent.FILTER_CHANGED, String.format(
+ Log.i(TAG, String.format(
"%s: no longer filtered out (previous filter was '%s')",
entry.getKey(),
entry.mExcludingFilter.getName()));
} else {
- mNotifLog.log(NotifEvent.FILTER_CHANGED, String.format(
+ Log.i(TAG, String.format(
"%s: filter changed: '%s' -> '%s'",
entry.getKey(),
entry.mExcludingFilter,
@@ -652,22 +648,23 @@ public class NotifListBuilderImpl implements NotifListBuilder {
if (promoter != entry.mNotifPromoter) {
if (entry.mNotifPromoter == null) {
- mNotifLog.log(NotifEvent.PROMOTER_CHANGED, String.format(
+ Log.i(TAG, 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(
+ Log.i(TAG, 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(
+ Log.i(TAG, String.format(
"%s: Top-level promoter changed: '%s' -> '%s'",
entry.getKey(),
entry.mNotifPromoter,
promoter));
}
+
entry.mNotifPromoter = promoter;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifEvent.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifEvent.java
index 3b06220c7c9c..8ebbca26fa5b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifEvent.java
@@ -17,12 +17,10 @@
package com.android.systemui.statusbar.notification.logging;
import android.annotation.IntDef;
-import android.service.notification.NotificationListenerService;
+import android.service.notification.NotificationListenerService.Ranking;
import android.service.notification.StatusBarNotification;
import com.android.systemui.log.RichEvent;
-import com.android.systemui.statusbar.notification.NotificationEntryManager;
-import com.android.systemui.statusbar.notification.collection.listbuilder.NotifListBuilder;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -33,71 +31,103 @@ import java.lang.annotation.RetentionPolicy;
* here to mitigate memory usage.
*/
public class NotifEvent extends RichEvent {
+ public static final int TOTAL_EVENT_TYPES = 11;
+
/**
- * Initializes a rich event that includes an event type that matches with an index in the array
- * getEventLabels().
+ * Creates a NotifEvent with an event type that matches with an index in the array
+ * getSupportedEvents() and {@link EventType}.
+ *
+ * The status bar notification and ranking objects are stored as shallow copies of the current
+ * state of the event when this event occurred.
*/
- public NotifEvent init(@EventType int type, StatusBarNotification sbn,
- NotificationListenerService.Ranking ranking, String reason) {
- StringBuilder extraInfo = new StringBuilder(reason);
+ public NotifEvent(int logLevel, int type, String reason, StatusBarNotification sbn,
+ Ranking ranking) {
+ super(logLevel, type, reason);
+ mMessage += getExtraInfo(sbn, ranking);
+ }
+
+ private String getExtraInfo(StatusBarNotification sbn, Ranking ranking) {
+ StringBuilder extraInfo = new StringBuilder();
+
if (sbn != null) {
- extraInfo.append(" " + sbn.getKey());
+ extraInfo.append(" Sbn=");
+ extraInfo.append(sbn);
}
if (ranking != null) {
extraInfo.append(" Ranking=");
- extraInfo.append(ranking.getRank());
+ extraInfo.append(ranking);
}
- super.init(INFO, type, extraInfo.toString());
- return this;
+
+ return extraInfo.toString();
}
/**
- * Event labels for ListBuilderEvents
- * Index corresponds to an # in {@link EventType}
+ * Event labels for NotifEvents
+ * Index corresponds to the {@link EventType}
*/
@Override
public String[] getEventLabels() {
- assert (TOTAL_EVENT_LABELS == (TOTAL_NEM_EVENT_TYPES + TOTAL_LIST_BUILDER_EVENT_TYPES));
- return EVENT_LABELS;
+ final String[] events = new String[]{
+ "NotifAdded",
+ "NotifRemoved",
+ "NotifUpdated",
+ "Filter",
+ "Sort",
+ "FilterAndSort",
+ "NotifVisibilityChanged",
+ "LifetimeExtended",
+ "RemoveIntercepted",
+ "InflationAborted",
+ "Inflated"
+ };
+
+ if (events.length != TOTAL_EVENT_TYPES) {
+ throw new IllegalStateException("NotifEvents events.length should match "
+ + TOTAL_EVENT_TYPES
+ + " events.length=" + events.length
+ + " TOTAL_EVENT_LENGTH=" + TOTAL_EVENT_TYPES);
+ }
+ return events;
}
/**
- * @return if this event occurred in {@link NotifListBuilder}
+ * Builds a NotifEvent.
*/
- static boolean isListBuilderEvent(@EventType int type) {
- return isBetweenInclusive(type, 0, TOTAL_LIST_BUILDER_EVENT_TYPES);
- }
+ public static class NotifEventBuilder extends RichEvent.Builder<NotifEventBuilder> {
+ private StatusBarNotification mSbn;
+ private Ranking mRanking;
- /**
- * @return if this event occurred in {@link NotificationEntryManager}
- */
- static boolean isNemEvent(@EventType int type) {
- return isBetweenInclusive(type, TOTAL_LIST_BUILDER_EVENT_TYPES,
- TOTAL_LIST_BUILDER_EVENT_TYPES + TOTAL_NEM_EVENT_TYPES);
- }
+ @Override
+ public NotifEventBuilder getBuilder() {
+ return this;
+ }
+
+ /**
+ * Stores the status bar notification object. A shallow copy is stored in the NotifEvent's
+ * constructor.
+ */
+ public NotifEventBuilder setSbn(StatusBarNotification sbn) {
+ mSbn = sbn;
+ return this;
+ }
+
+ /**
+ * Stores the ranking object. A shallow copy is stored in the NotifEvent's
+ * constructor.
+ */
+ public NotifEventBuilder setRanking(Ranking ranking) {
+ mRanking = ranking;
+ return this;
+ }
- private static boolean isBetweenInclusive(int x, int a, int b) {
- return x >= a && x <= b;
+ @Override
+ public RichEvent build() {
+ return new NotifEvent(mLogLevel, mType, mReason, mSbn, mRanking);
+ }
}
- @IntDef({
- // NotifListBuilder events:
- WARN,
- ON_BUILD_LIST,
- START_BUILD_LIST,
- DISPATCH_FINAL_LIST,
- LIST_BUILD_COMPLETE,
- FILTER_INVALIDATED,
- PROMOTER_INVALIDATED,
- SECTIONS_PROVIDER_INVALIDATED,
- COMPARATOR_INVALIDATED,
- PARENT_CHANGED,
- FILTER_CHANGED,
- PROMOTER_CHANGED,
-
- // NotificationEntryManager events:
- NOTIF_ADDED,
+ @IntDef({NOTIF_ADDED,
NOTIF_REMOVED,
NOTIF_UPDATED,
FILTER,
@@ -109,72 +139,22 @@ public class NotifEvent extends RichEvent {
INFLATION_ABORTED,
INFLATED
})
- @Retention(RetentionPolicy.SOURCE)
- public @interface EventType {}
-
- private static final String[] EVENT_LABELS =
- new String[]{
- // NotifListBuilder labels:
- "Warning",
- "OnBuildList",
- "StartBuildList",
- "DispatchFinalList",
- "ListBuildComplete",
- "FilterInvalidated",
- "PromoterInvalidated",
- "SectionsProviderInvalidated",
- "ComparatorInvalidated",
- "ParentChanged",
- "FilterChanged",
- "PromoterChanged",
-
- // NEM event labels:
- "NotifAdded",
- "NotifRemoved",
- "NotifUpdated",
- "Filter",
- "Sort",
- "FilterAndSort",
- "NotifVisibilityChanged",
- "LifetimeExtended",
- "RemoveIntercepted",
- "InflationAborted",
- "Inflated"
- };
-
- private static final int TOTAL_EVENT_LABELS = EVENT_LABELS.length;
-
- /**
- * Events related to {@link NotifListBuilder}
- */
- public static final int WARN = 0;
- public static final int ON_BUILD_LIST = 1;
- public static final int START_BUILD_LIST = 2;
- public static final int DISPATCH_FINAL_LIST = 3;
- public static final int LIST_BUILD_COMPLETE = 4;
- public static final int FILTER_INVALIDATED = 5;
- public static final int PROMOTER_INVALIDATED = 6;
- public static final int SECTIONS_PROVIDER_INVALIDATED = 7;
- public static final int COMPARATOR_INVALIDATED = 8;
- public static final int PARENT_CHANGED = 9;
- public static final int FILTER_CHANGED = 10;
- public static final int PROMOTER_CHANGED = 11;
- private static final int TOTAL_LIST_BUILDER_EVENT_TYPES = 12;
/**
- * Events related to {@link NotificationEntryManager}
+ * Types of NotifEvents
*/
- public static final int NOTIF_ADDED = TOTAL_LIST_BUILDER_EVENT_TYPES + 0;
- public static final int NOTIF_REMOVED = TOTAL_LIST_BUILDER_EVENT_TYPES + 1;
- public static final int NOTIF_UPDATED = TOTAL_LIST_BUILDER_EVENT_TYPES + 2;
- public static final int FILTER = TOTAL_LIST_BUILDER_EVENT_TYPES + 3;
- public static final int SORT = TOTAL_LIST_BUILDER_EVENT_TYPES + 4;
- public static final int FILTER_AND_SORT = TOTAL_LIST_BUILDER_EVENT_TYPES + 5;
- public static final int NOTIF_VISIBILITY_CHANGED = TOTAL_LIST_BUILDER_EVENT_TYPES + 6;
- public static final int LIFETIME_EXTENDED = TOTAL_LIST_BUILDER_EVENT_TYPES + 7;
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface EventType {}
+ public static final int NOTIF_ADDED = 0;
+ public static final int NOTIF_REMOVED = 1;
+ public static final int NOTIF_UPDATED = 2;
+ public static final int FILTER = 3;
+ public static final int SORT = 4;
+ public static final int FILTER_AND_SORT = 5;
+ public static final int NOTIF_VISIBILITY_CHANGED = 6;
+ public static final int LIFETIME_EXTENDED = 7;
// unable to remove notif - removal intercepted by {@link NotificationRemoveInterceptor}
- public static final int REMOVE_INTERCEPTED = TOTAL_LIST_BUILDER_EVENT_TYPES + 8;
- public static final int INFLATION_ABORTED = TOTAL_LIST_BUILDER_EVENT_TYPES + 9;
- public static final int INFLATED = TOTAL_LIST_BUILDER_EVENT_TYPES + 10;
- private static final int TOTAL_NEM_EVENT_TYPES = 11;
+ public static final int REMOVE_INTERCEPTED = 8;
+ public static final int INFLATION_ABORTED = 9;
+ public static final int INFLATED = 10;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifLog.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifLog.java
index 299d628d0fd2..129283107894 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifLog.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifLog.java
@@ -16,7 +16,6 @@
package com.android.systemui.statusbar.notification.logging;
-import android.os.SystemProperties;
import android.service.notification.NotificationListenerService.Ranking;
import android.service.notification.StatusBarNotification;
@@ -34,82 +33,93 @@ import javax.inject.Singleton;
* dependency DumpController NotifLog
*/
@Singleton
-public class NotifLog extends SysuiLog<NotifEvent> {
+public class NotifLog extends SysuiLog {
private static final String TAG = "NotifLog";
- private static final boolean SHOW_NEM_LOGS =
- SystemProperties.getBoolean("persist.sysui.log.notif.nem", true);
- private static final boolean SHOW_LIST_BUILDER_LOGS =
- SystemProperties.getBoolean("persist.sysui.log.notif.listbuilder", true);
-
private static final int MAX_DOZE_DEBUG_LOGS = 400;
private static final int MAX_DOZE_LOGS = 50;
- private NotifEvent mRecycledEvent;
-
@Inject
public NotifLog(DumpController dumpController) {
super(dumpController, TAG, MAX_DOZE_DEBUG_LOGS, MAX_DOZE_LOGS);
}
/**
- * Logs a {@link NotifEvent} with a notification, ranking and message.
- * Uses the last recycled event if available.
+ * Logs a {@link NotifEvent} with a notification, ranking and message
* @return true if successfully logged, else false
*/
- public void log(@NotifEvent.EventType int eventType,
- StatusBarNotification sbn, Ranking ranking, String msg) {
- if (!mEnabled
- || (NotifEvent.isListBuilderEvent(eventType) && !SHOW_LIST_BUILDER_LOGS)
- || (NotifEvent.isNemEvent(eventType) && !SHOW_NEM_LOGS)) {
- return;
- }
-
- if (mRecycledEvent != null) {
- mRecycledEvent = log(mRecycledEvent.init(eventType, sbn, ranking, msg));
- } else {
- mRecycledEvent = log(new NotifEvent().init(eventType, sbn, ranking, msg));
- }
+ public boolean log(@NotifEvent.EventType int eventType, StatusBarNotification sbn,
+ Ranking ranking, String msg) {
+ return log(new NotifEvent.NotifEventBuilder()
+ .setType(eventType)
+ .setSbn(sbn)
+ .setRanking(ranking)
+ .setReason(msg)
+ .build());
}
/**
- * Logs a {@link NotifEvent} with no extra information aside from the event type
+ * Logs a {@link NotifEvent}
+ * @return true if successfully logged, else false
*/
- public void log(@NotifEvent.EventType int eventType) {
- log(eventType, null, null, "");
+ public boolean log(@NotifEvent.EventType int eventType) {
+ return log(eventType, null, null, null);
}
/**
* Logs a {@link NotifEvent} with a message
+ * @return true if successfully logged, else false
*/
- public void log(@NotifEvent.EventType int eventType, String msg) {
- log(eventType, null, null, msg);
+ public boolean log(@NotifEvent.EventType int eventType, String msg) {
+ return log(eventType, null, null, msg);
}
/**
- * Logs a {@link NotifEvent} with a entry
+ * Logs a {@link NotifEvent} with a notification
+ * @return true if successfully logged, else false
*/
- public void log(@NotifEvent.EventType int eventType, NotificationEntry entry) {
- log(eventType, entry.getSbn(), entry.getRanking(), "");
+ public boolean log(@NotifEvent.EventType int eventType, StatusBarNotification sbn) {
+ return log(eventType, sbn, null, "");
}
/**
- * Logs a {@link NotifEvent} with a NotificationEntry and message
+ * Logs a {@link NotifEvent} with a notification
+ * @return true if successfully logged, else false
*/
- public void log(@NotifEvent.EventType int eventType, NotificationEntry entry, String msg) {
- log(eventType, entry.getSbn(), entry.getRanking(), msg);
+ public boolean log(@NotifEvent.EventType int eventType, StatusBarNotification sbn, String msg) {
+ return log(eventType, sbn, null, msg);
}
/**
- * Logs a {@link NotifEvent} with a notification and message
+ * Logs a {@link NotifEvent} with a ranking
+ * @return true if successfully logged, else false
*/
- public void log(@NotifEvent.EventType int eventType, StatusBarNotification sbn, String msg) {
- log(eventType, sbn, null, msg);
+ public boolean log(@NotifEvent.EventType int eventType, Ranking ranking) {
+ return log(eventType, null, ranking, "");
}
/**
- * Logs a {@link NotifEvent} with a ranking and message
+ * Logs a {@link NotifEvent} with a notification and ranking
+ * @return true if successfully logged, else false
+ */
+ public boolean log(@NotifEvent.EventType int eventType, StatusBarNotification sbn,
+ Ranking ranking) {
+ return log(eventType, sbn, ranking, "");
+ }
+
+ /**
+ * Logs a {@link NotifEvent} with a notification entry
+ * @return true if successfully logged, else false
+ */
+ public boolean log(@NotifEvent.EventType int eventType, NotificationEntry entry) {
+ return log(eventType, entry.getSbn(), entry.getRanking(), "");
+ }
+
+ /**
+ * Logs a {@link NotifEvent} with a notification entry
+ * @return true if successfully logged, else false
*/
- public void log(@NotifEvent.EventType int eventType, Ranking ranking, String msg) {
- log(eventType, null, ranking, msg);
+ public boolean log(@NotifEvent.EventType int eventType, NotificationEntry entry,
+ String msg) {
+ return log(eventType, entry.getSbn(), entry.getRanking(), msg);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/log/RichEventTest.java b/packages/SystemUI/tests/src/com/android/systemui/log/RichEventTest.java
index 4a90bb91ca37..2f90641775e8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/log/RichEventTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/log/RichEventTest.java
@@ -57,7 +57,7 @@ public class RichEventTest extends SysuiTestCase {
class TestableRichEvent extends RichEvent {
TestableRichEvent(int logLevel, int type, String reason) {
- init(logLevel, type, reason);
+ super(logLevel, type, reason);
}
@Override
diff --git a/packages/SystemUI/tests/src/com/android/systemui/log/SysuiLogTest.java b/packages/SystemUI/tests/src/com/android/systemui/log/SysuiLogTest.java
index 0dfb7ba85ee1..378bba1afda3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/log/SysuiLogTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/log/SysuiLogTest.java
@@ -35,12 +35,11 @@ import org.mockito.MockitoAnnotations;
@RunWith(AndroidTestingRunner.class)
public class SysuiLogTest extends SysuiTestCase {
private static final String TEST_ID = "TestLogger";
- private static final String TEST_MSG = "msg";
private static final int MAX_LOGS = 5;
@Mock
private DumpController mDumpController;
- private SysuiLog<Event> mSysuiLog;
+ private SysuiLog mSysuiLog;
@Before
public void setup() {
@@ -49,63 +48,35 @@ public class SysuiLogTest extends SysuiTestCase {
@Test
public void testLogDisabled_noLogsWritten() {
- mSysuiLog = new TestSysuiLog(mDumpController, TEST_ID, MAX_LOGS, false);
- assertEquals(null, mSysuiLog.mTimeline);
+ mSysuiLog = new SysuiLog(mDumpController, TEST_ID, MAX_LOGS, false);
+ assertEquals(mSysuiLog.mTimeline, null);
- mSysuiLog.log(createEvent(TEST_MSG));
- assertEquals(null, mSysuiLog.mTimeline);
+ mSysuiLog.log(new Event("msg"));
+ assertEquals(mSysuiLog.mTimeline, null);
}
@Test
public void testLogEnabled_logWritten() {
- mSysuiLog = new TestSysuiLog(mDumpController, TEST_ID, MAX_LOGS, true);
- assertEquals(0, mSysuiLog.mTimeline.size());
+ mSysuiLog = new SysuiLog(mDumpController, TEST_ID, MAX_LOGS, true);
+ assertEquals(mSysuiLog.mTimeline.size(), 0);
- mSysuiLog.log(createEvent(TEST_MSG));
- assertEquals(1, mSysuiLog.mTimeline.size());
+ mSysuiLog.log(new Event("msg"));
+ assertEquals(mSysuiLog.mTimeline.size(), 1);
}
@Test
public void testMaxLogs() {
- mSysuiLog = new TestSysuiLog(mDumpController, TEST_ID, MAX_LOGS, true);
+ mSysuiLog = new SysuiLog(mDumpController, TEST_ID, MAX_LOGS, true);
assertEquals(mSysuiLog.mTimeline.size(), 0);
+ final String msg = "msg";
for (int i = 0; i < MAX_LOGS + 1; i++) {
- mSysuiLog.log(createEvent(TEST_MSG + i));
+ mSysuiLog.log(new Event(msg + i));
}
- assertEquals(MAX_LOGS, mSysuiLog.mTimeline.size());
-
- // check the first message (msg0) was replaced with msg1:
- assertEquals(TEST_MSG + "1", mSysuiLog.mTimeline.getFirst().getMessage());
- }
-
- @Test
- public void testRecycleLogs() {
- // GIVEN a SysuiLog with one log
- mSysuiLog = new TestSysuiLog(mDumpController, TEST_ID, MAX_LOGS, true);
- Event e = createEvent(TEST_MSG); // msg
- mSysuiLog.log(e); // Logs: [msg]
-
- Event recycledEvent = null;
- // WHEN we add MAX_LOGS after the first log
- for (int i = 0; i < MAX_LOGS; i++) {
- recycledEvent = mSysuiLog.log(createEvent(TEST_MSG + i));
- }
- // Logs: [msg1, msg2, msg3, msg4]
+ assertEquals(mSysuiLog.mTimeline.size(), MAX_LOGS);
- // THEN we see the recycledEvent is e
- assertEquals(e, recycledEvent);
- }
-
- private Event createEvent(String msg) {
- return new Event().init(msg);
- }
-
- public class TestSysuiLog extends SysuiLog<Event> {
- protected TestSysuiLog(DumpController dumpController, String id, int maxLogs,
- boolean enabled) {
- super(dumpController, id, maxLogs, enabled);
- }
+ // check the first message (msg0) is deleted:
+ assertEquals(mSysuiLog.mTimeline.getFirst().getMessage(), msg + "1");
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java
index 6d56b06fe72e..a25af84ca28e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java
@@ -47,7 +47,6 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.plugga
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.SectionsProvider;
-import com.android.systemui.statusbar.notification.logging.NotifLog;
import com.android.systemui.util.Assert;
import com.android.systemui.util.time.FakeSystemClock;
@@ -77,7 +76,6 @@ public class NotifListBuilderImplTest extends SysuiTestCase {
private NotifListBuilderImpl mListBuilder;
private FakeSystemClock mSystemClock = new FakeSystemClock();
- @Mock private NotifLog mNotifLog;
@Mock private NotifCollection mNotifCollection;
@Spy private OnBeforeTransformGroupsListener mOnBeforeTransformGroupsListener;
@Spy private OnBeforeSortListener mOnBeforeSortListener;
@@ -99,7 +97,7 @@ public class NotifListBuilderImplTest extends SysuiTestCase {
MockitoAnnotations.initMocks(this);
Assert.sMainLooper = TestableLooper.get(this).getLooper();
- mListBuilder = new NotifListBuilderImpl(mSystemClock, mNotifLog);
+ mListBuilder = new NotifListBuilderImpl(mSystemClock);
mListBuilder.setOnRenderListListener(mOnRenderListListener);
mListBuilder.attach(mNotifCollection);