Migrate pullLooperStats
Test: atest UidAtomTests#testLooperStats Test: adb shell cmd stats pull-source 10024 Change-Id: I9fb11f78a9e3e7b3616185b4f62ff925c547b9df
This commit is contained in:
@@ -722,36 +722,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
||||
pulledData.add(e);
|
||||
}
|
||||
|
||||
private void pullLooperStats(int tagId, long elapsedNanos, long wallClockNanos,
|
||||
List<StatsLogEventWrapper> pulledData) {
|
||||
LooperStats looperStats = LocalServices.getService(LooperStats.class);
|
||||
if (looperStats == null) {
|
||||
throw new IllegalStateException("looperStats null");
|
||||
}
|
||||
|
||||
List<LooperStats.ExportedEntry> entries = looperStats.getEntries();
|
||||
looperStats.reset();
|
||||
for (LooperStats.ExportedEntry entry : entries) {
|
||||
StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
|
||||
e.writeInt(entry.workSourceUid);
|
||||
e.writeString(entry.handlerClassName);
|
||||
e.writeString(entry.threadName);
|
||||
e.writeString(entry.messageName);
|
||||
e.writeLong(entry.messageCount);
|
||||
e.writeLong(entry.exceptionCount);
|
||||
e.writeLong(entry.recordedMessageCount);
|
||||
e.writeLong(entry.totalLatencyMicros);
|
||||
e.writeLong(entry.cpuUsageMicros);
|
||||
e.writeBoolean(entry.isInteractive);
|
||||
e.writeLong(entry.maxCpuUsageMicros);
|
||||
e.writeLong(entry.maxLatencyMicros);
|
||||
e.writeLong(entry.recordedDelayMessageCount);
|
||||
e.writeLong(entry.delayMillis);
|
||||
e.writeLong(entry.maxDelayMillis);
|
||||
pulledData.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void pullDiskStats(int tagId, long elapsedNanos, long wallClockNanos,
|
||||
List<StatsLogEventWrapper> pulledData) {
|
||||
// Run a quick-and-dirty performance test: write 512 bytes
|
||||
@@ -1579,11 +1549,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
||||
break;
|
||||
}
|
||||
|
||||
case StatsLog.LOOPER_STATS: {
|
||||
pullLooperStats(tagId, elapsedNanos, wallClockNanos, ret);
|
||||
break;
|
||||
}
|
||||
|
||||
case StatsLog.DISK_STATS: {
|
||||
pullDiskStats(tagId, elapsedNanos, wallClockNanos, ret);
|
||||
break;
|
||||
|
||||
@@ -95,11 +95,6 @@ std::map<PullerKey, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
|
||||
{{.atomTag = android::util::BATTERY_CYCLE_COUNT},
|
||||
{.puller = new ResourceHealthManagerPuller(android::util::BATTERY_CYCLE_COUNT)}},
|
||||
|
||||
// looper_stats
|
||||
{{.atomTag = android::util::LOOPER_STATS},
|
||||
{.additiveFields = {5, 6, 7, 8, 9},
|
||||
.puller = new StatsCompanionServicePuller(android::util::LOOPER_STATS)}},
|
||||
|
||||
// Disk Stats
|
||||
{{.atomTag = android::util::DISK_STATS},
|
||||
{.puller = new StatsCompanionServicePuller(android::util::DISK_STATS)}},
|
||||
|
||||
@@ -1426,11 +1426,48 @@ public class StatsPullAtomService extends SystemService {
|
||||
}
|
||||
|
||||
private void registerLooperStats() {
|
||||
// No op.
|
||||
int tagId = StatsLog.LOOPER_STATS;
|
||||
PullAtomMetadata metadata = PullAtomMetadata.newBuilder()
|
||||
.setAdditiveFields(new int[] {5, 6, 7, 8, 9})
|
||||
.build();
|
||||
mStatsManager.registerPullAtomCallback(
|
||||
tagId,
|
||||
metadata,
|
||||
(atomTag, data) -> pullLooperStats(atomTag, data),
|
||||
BackgroundThread.getExecutor()
|
||||
);
|
||||
}
|
||||
|
||||
private void pullLooperStats() {
|
||||
// No op.
|
||||
private int pullLooperStats(int atomTag, List<StatsEvent> pulledData) {
|
||||
LooperStats looperStats = LocalServices.getService(LooperStats.class);
|
||||
if (looperStats == null) {
|
||||
return StatsManager.PULL_SKIP;
|
||||
}
|
||||
|
||||
List<LooperStats.ExportedEntry> entries = looperStats.getEntries();
|
||||
looperStats.reset();
|
||||
for (LooperStats.ExportedEntry entry : entries) {
|
||||
StatsEvent e = StatsEvent.newBuilder()
|
||||
.setAtomId(atomTag)
|
||||
.writeInt(entry.workSourceUid)
|
||||
.writeString(entry.handlerClassName)
|
||||
.writeString(entry.threadName)
|
||||
.writeString(entry.messageName)
|
||||
.writeLong(entry.messageCount)
|
||||
.writeLong(entry.exceptionCount)
|
||||
.writeLong(entry.recordedMessageCount)
|
||||
.writeLong(entry.totalLatencyMicros)
|
||||
.writeLong(entry.cpuUsageMicros)
|
||||
.writeBoolean(entry.isInteractive)
|
||||
.writeLong(entry.maxCpuUsageMicros)
|
||||
.writeLong(entry.maxLatencyMicros)
|
||||
.writeLong(entry.recordedDelayMessageCount)
|
||||
.writeLong(entry.delayMillis)
|
||||
.writeLong(entry.maxDelayMillis)
|
||||
.build();
|
||||
pulledData.add(e);
|
||||
}
|
||||
return StatsManager.PULL_SUCCESS;
|
||||
}
|
||||
|
||||
private void registerDiskStats() {
|
||||
|
||||
Reference in New Issue
Block a user