Migrate pullSystemElapsedRealtime

Test: atest ValueMetricTests
Test: No cts test. Ran adb shell cmd pull-source 10014
Change-Id: I89c673cb2337405dbe1aa4e3a5756bdf9410927a
This commit is contained in:
Jeffrey Huang
2020-01-14 14:33:52 -08:00
parent 7f9fe5024f
commit 882f99a836
3 changed files with 20 additions and 23 deletions

View File

@@ -714,14 +714,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
}
}
private void pullSystemElapsedRealtime(
int tagId, long elapsedNanos, long wallClockNanos,
List<StatsLogEventWrapper> pulledData) {
StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
e.writeLong(SystemClock.elapsedRealtime());
pulledData.add(e);
}
// read high watermark for section
private long readProcStatsHighWaterMark(int section) {
try {
@@ -1158,11 +1150,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
long wallClockNanos = SystemClock.currentTimeMicro() * 1000L;
switch (tagId) {
case StatsLog.SYSTEM_ELAPSED_REALTIME: {
pullSystemElapsedRealtime(tagId, elapsedNanos, wallClockNanos, ret);
break;
}
case StatsLog.PROC_STATS: {
pullProcessStats(ProcessStats.REPORT_ALL, tagId, elapsedNanos, wallClockNanos, ret);
break;

View File

@@ -68,13 +68,6 @@ std::map<PullerKey, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
{{.atomTag = android::util::ON_DEVICE_POWER_MEASUREMENT},
{.puller = new PowerStatsPuller()}},
// system_elapsed_realtime
{{.atomTag = android::util::SYSTEM_ELAPSED_REALTIME},
{.coolDownNs = NS_PER_SEC,
.puller = new StatsCompanionServicePuller(android::util::SYSTEM_ELAPSED_REALTIME),
.pullTimeoutNs = NS_PER_SEC / 2,
}},
// remaining_battery_capacity
{{.atomTag = android::util::REMAINING_BATTERY_CAPACITY},
{.puller = new ResourceHealthManagerPuller(android::util::REMAINING_BATTERY_CAPACITY)}},

View File

@@ -989,12 +989,29 @@ public class StatsPullAtomService extends SystemService {
return StatsManager.PULL_SUCCESS;
}
private static final long NS_PER_SEC = 1000000000;
private void registerSystemElapsedRealtime() {
// No op.
int tagId = StatsLog.SYSTEM_ELAPSED_REALTIME;
PullAtomMetadata metadata = PullAtomMetadata.newBuilder()
.setCoolDownNs(NS_PER_SEC)
.setTimeoutNs(NS_PER_SEC / 2)
.build();
mStatsManager.registerPullAtomCallback(
tagId,
metadata,
(atomTag, data) -> pullSystemElapsedRealtime(atomTag, data),
BackgroundThread.getExecutor()
);
}
private void pullSystemElapsedRealtime() {
// No op.
private int pullSystemElapsedRealtime(int atomTag, List<StatsEvent> pulledData) {
StatsEvent e = StatsEvent.newBuilder()
.setAtomId(atomTag)
.writeLong(SystemClock.elapsedRealtime())
.build();
pulledData.add(e);
return StatsManager.PULL_SUCCESS;
}
private void registerSystemUptime() {