Adds StatsLatencyLogger library.

Test: build NexusLauncherDebug; wwdebug && wwlogcat
Change-Id: Ib1f1aeb78d1cb930ca680439341de6be5e5be2dd
This commit is contained in:
Thiru Ramasamy committed 2022-03-03 17:33:24 -08:00
1 parent ed6d3a47c0
commit b097f24610
2 files changed
+129 -1

No files matched your search

@@ -562,7 +562,7 @@ public class StatsLogManager implements ResourceBasedOverride {
}
/**
* Helps to construct and write the log message.
* Helps to construct and log launcher event.
*/
public interface StatsLogger {
@@ -661,6 +661,58 @@ public class StatsLogManager implements ResourceBasedOverride {
}
}
/**
* Helps to construct and log latency event.
*/
public interface StatsLatencyLogger {
enum LatencyType {
UNKNOWN(0),
COLD(1),
HOT(2);
private final int mId;
LatencyType(int id) {
this.mId = id;
}
public int getId() {
return mId;
}
}
/**
* Sets {@link InstanceId} of log message.
*/
default StatsLatencyLogger withInstanceId(InstanceId instanceId) {
return this;
}
/**
* Sets latency of the event.
*/
default StatsLatencyLogger withLatency(long latencyInMillis) {
return this;
}
/**
* Sets {@link LatencyType} of log message.
*/
default StatsLatencyLogger withType(LatencyType type) {
return this;
}
/**
* Builds the final message and logs it as {@link EventEnum}.
*/
default void log(EventEnum event) {
}
}
/**
* Returns new logger object.
*/
@@ -672,11 +724,27 @@ public class StatsLogManager implements ResourceBasedOverride {
return logger;
}
/**
* Returns new latency logger object.
*/
public StatsLatencyLogger latencyLogger() {
StatsLatencyLogger logger = createLatencyLogger();
if (mInstanceId != null) {
logger.withInstanceId(mInstanceId);
}
return logger;
}
protected StatsLogger createLogger() {
return new StatsLogger() {
};
}
protected StatsLatencyLogger createLatencyLogger() {
return new StatsLatencyLogger() {
};
}
/**
* Sets InstanceId to every new {@link StatsLogger} object returned by {@link #logger()} when
* not-null.