summaryrefslogtreecommitdiff
path: root/cmds/statsd/src/external/StatsPullerManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/statsd/src/external/StatsPullerManager.cpp')
-rw-r--r--cmds/statsd/src/external/StatsPullerManager.cpp87
1 files changed, 21 insertions, 66 deletions
diff --git a/cmds/statsd/src/external/StatsPullerManager.cpp b/cmds/statsd/src/external/StatsPullerManager.cpp
index 8d67b5c169f5..988a53f5d028 100644
--- a/cmds/statsd/src/external/StatsPullerManager.cpp
+++ b/cmds/statsd/src/external/StatsPullerManager.cpp
@@ -32,21 +32,13 @@
#include "../logd/LogEvent.h"
#include "../stats_log_util.h"
#include "../statscompanion_util.h"
-#include "CarStatsPuller.h"
#include "GpuStatsPuller.h"
-#include "PowerStatsPuller.h"
-#include "ResourceHealthManagerPuller.h"
#include "StatsCallbackPuller.h"
-#include "SubsystemSleepStatePuller.h"
#include "TrainInfoPuller.h"
#include "statslog.h"
-using std::make_shared;
-using std::map;
using std::shared_ptr;
-using std::string;
using std::vector;
-using std::list;
namespace android {
namespace os {
@@ -55,54 +47,21 @@ namespace statsd {
// Values smaller than this may require to update the alarm.
const int64_t NO_ALARM_UPDATE = INT64_MAX;
-std::map<PullerKey, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
+StatsPullerManager::StatsPullerManager()
+ : kAllPullAtomInfo({
+ // TrainInfo.
+ {{.atomTag = android::util::TRAIN_INFO}, new TrainInfoPuller()},
- // subsystem_sleep_state
- {{.atomTag = android::util::SUBSYSTEM_SLEEP_STATE},
- {.puller = new SubsystemSleepStatePuller()}},
+ // GpuStatsGlobalInfo
+ {{.atomTag = android::util::GPU_STATS_GLOBAL_INFO},
+ new GpuStatsPuller(android::util::GPU_STATS_GLOBAL_INFO)},
- // on_device_power_measurement
- {{.atomTag = android::util::ON_DEVICE_POWER_MEASUREMENT},
- {.puller = new PowerStatsPuller()}},
+ // GpuStatsAppInfo
+ {{.atomTag = android::util::GPU_STATS_APP_INFO},
+ new GpuStatsPuller(android::util::GPU_STATS_APP_INFO)},
- // remaining_battery_capacity
- {{.atomTag = android::util::REMAINING_BATTERY_CAPACITY},
- {.puller = new ResourceHealthManagerPuller(android::util::REMAINING_BATTERY_CAPACITY)}},
-
- // full_battery_capacity
- {{.atomTag = android::util::FULL_BATTERY_CAPACITY},
- {.puller = new ResourceHealthManagerPuller(android::util::FULL_BATTERY_CAPACITY)}},
-
- // battery_voltage
- {{.atomTag = android::util::BATTERY_VOLTAGE},
- {.puller = new ResourceHealthManagerPuller(android::util::BATTERY_VOLTAGE)}},
-
- // battery_level
- {{.atomTag = android::util::BATTERY_LEVEL},
- {.puller = new ResourceHealthManagerPuller(android::util::BATTERY_LEVEL)}},
-
- // battery_cycle_count
- {{.atomTag = android::util::BATTERY_CYCLE_COUNT},
- {.puller = new ResourceHealthManagerPuller(android::util::BATTERY_CYCLE_COUNT)}},
-
- // TrainInfo.
- {{.atomTag = android::util::TRAIN_INFO}, {.puller = new TrainInfoPuller()}},
-
- // GpuStatsGlobalInfo
- {{.atomTag = android::util::GPU_STATS_GLOBAL_INFO},
- {.puller = new GpuStatsPuller(android::util::GPU_STATS_GLOBAL_INFO)}},
-
- // GpuStatsAppInfo
- {{.atomTag = android::util::GPU_STATS_APP_INFO},
- {.puller = new GpuStatsPuller(android::util::GPU_STATS_APP_INFO)}},
-
- // VmsClientStats
- {{.atomTag = android::util::VMS_CLIENT_STATS},
- {.additiveFields = {5, 6, 7, 8, 9, 10},
- .puller = new CarStatsPuller(android::util::VMS_CLIENT_STATS)}},
-};
-
-StatsPullerManager::StatsPullerManager() : mNextPullTimeNs(NO_ALARM_UPDATE) {
+ }),
+ mNextPullTimeNs(NO_ALARM_UPDATE) {
}
bool StatsPullerManager::Pull(int tagId, vector<shared_ptr<LogEvent>>* data) {
@@ -114,7 +73,7 @@ bool StatsPullerManager::PullLocked(int tagId, vector<shared_ptr<LogEvent>>* dat
VLOG("Initiating pulling %d", tagId);
if (kAllPullAtomInfo.find({.atomTag = tagId}) != kAllPullAtomInfo.end()) {
- bool ret = kAllPullAtomInfo.find({.atomTag = tagId})->second.puller->Pull(data);
+ bool ret = kAllPullAtomInfo.find({.atomTag = tagId})->second->Pull(data);
VLOG("pulled %d items", (int)data->size());
if (!ret) {
StatsdStats::getInstance().notePullFailed(tagId);
@@ -127,9 +86,9 @@ bool StatsPullerManager::PullLocked(int tagId, vector<shared_ptr<LogEvent>>* dat
}
bool StatsPullerManager::PullerForMatcherExists(int tagId) const {
- // Vendor pulled atoms might be registered after we parse the config.
- return isVendorPulledAtom(tagId) ||
- kAllPullAtomInfo.find({.atomTag = tagId}) != kAllPullAtomInfo.end();
+ // Pulled atoms might be registered after we parse the config, so just make sure the id is in
+ // an appropriate range.
+ return isVendorPulledAtom(tagId) || isPulledAtom(tagId);
}
void StatsPullerManager::updateAlarmLocked() {
@@ -153,7 +112,7 @@ void StatsPullerManager::SetStatsCompanionService(
sp<IStatsCompanionService> tmpForLock = mStatsCompanionService;
mStatsCompanionService = statsCompanionService;
for (const auto& pulledAtom : kAllPullAtomInfo) {
- pulledAtom.second.puller->SetStatsCompanionService(statsCompanionService);
+ pulledAtom.second->SetStatsCompanionService(statsCompanionService);
}
if (mStatsCompanionService != nullptr) {
updateAlarmLocked();
@@ -285,7 +244,7 @@ void StatsPullerManager::OnAlarmFired(int64_t elapsedTimeNs) {
int StatsPullerManager::ForceClearPullerCache() {
int totalCleared = 0;
for (const auto& pulledAtom : kAllPullAtomInfo) {
- totalCleared += pulledAtom.second.puller->ForceClearCache();
+ totalCleared += pulledAtom.second->ForceClearCache();
}
return totalCleared;
}
@@ -293,7 +252,7 @@ int StatsPullerManager::ForceClearPullerCache() {
int StatsPullerManager::ClearPullerCacheIfNecessary(int64_t timestampNs) {
int totalCleared = 0;
for (const auto& pulledAtom : kAllPullAtomInfo) {
- totalCleared += pulledAtom.second.puller->ClearCacheIfNecessary(timestampNs);
+ totalCleared += pulledAtom.second->ClearCacheIfNecessary(timestampNs);
}
return totalCleared;
}
@@ -306,12 +265,8 @@ void StatsPullerManager::RegisterPullAtomCallback(const int uid, const int32_t a
VLOG("RegisterPullerCallback: adding puller for tag %d", atomTag);
// TODO: linkToDeath with the callback so that we can remove it and delete the puller.
StatsdStats::getInstance().notePullerCallbackRegistrationChanged(atomTag, /*registered=*/true);
- kAllPullAtomInfo[{.atomTag = atomTag}] = {
- .additiveFields = additiveFields,
- .coolDownNs = coolDownNs,
- .puller = new StatsCallbackPuller(atomTag, callback, timeoutNs),
- .pullTimeoutNs = timeoutNs,
- };
+ kAllPullAtomInfo[{.atomTag = atomTag}] =
+ new StatsCallbackPuller(atomTag, callback, coolDownNs, timeoutNs, additiveFields);
}
void StatsPullerManager::UnregisterPullAtomCallback(const int uid, const int32_t atomTag) {