diff options
Diffstat (limited to 'cmds/statsd/src/StatsService.cpp')
-rw-r--r-- | cmds/statsd/src/StatsService.cpp | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp index 10c04f67ca05..1119eb36c239 100644 --- a/cmds/statsd/src/StatsService.cpp +++ b/cmds/statsd/src/StatsService.cpp @@ -150,25 +150,26 @@ StatsService::StatsService(const sp<Looper>& handlerLooper) })) { mUidMap = new UidMap(); + mPullerManager = new StatsPullerManager(); StatsPuller::SetUidMap(mUidMap); mConfigManager = new ConfigManager(); - mProcessor = new StatsLogProcessor(mUidMap, mAnomalyAlarmMonitor, mPeriodicAlarmMonitor, - getElapsedRealtimeNs(), [this](const ConfigKey& key) { - sp<IStatsCompanionService> sc = getStatsCompanionService(); - auto receiver = mConfigManager->GetConfigReceiver(key); - if (sc == nullptr) { - VLOG("Could not find StatsCompanionService"); - return false; - } else if (receiver == nullptr) { - VLOG("Statscompanion could not find a broadcast receiver for %s", - key.ToString().c_str()); - return false; - } else { - sc->sendDataBroadcast(receiver, mProcessor->getLastReportTimeNs(key)); - return true; - } - } - ); + mProcessor = new StatsLogProcessor( + mUidMap, mPullerManager, mAnomalyAlarmMonitor, mPeriodicAlarmMonitor, + getElapsedRealtimeNs(), [this](const ConfigKey& key) { + sp<IStatsCompanionService> sc = getStatsCompanionService(); + auto receiver = mConfigManager->GetConfigReceiver(key); + if (sc == nullptr) { + VLOG("Could not find StatsCompanionService"); + return false; + } else if (receiver == nullptr) { + VLOG("Statscompanion could not find a broadcast receiver for %s", + key.ToString().c_str()); + return false; + } else { + sc->sendDataBroadcast(receiver, mProcessor->getLastReportTimeNs(key)); + return true; + } + }); mConfigManager->AddListener(mProcessor); @@ -439,7 +440,6 @@ status_t StatsService::cmd_trigger_broadcast(FILE* out, Vector<String8>& args) { if (argCount == 2) { // Automatically pick the UID uid = IPCThreadState::self()->getCallingUid(); - // TODO: What if this isn't a binder call? Should we fail? name.assign(args[1].c_str(), args[1].size()); good = true; } else if (argCount == 3) { @@ -492,7 +492,6 @@ status_t StatsService::cmd_config(FILE* in, FILE* out, FILE* err, Vector<String8 if (argCount == 3) { // Automatically pick the UID uid = IPCThreadState::self()->getCallingUid(); - // TODO: What if this isn't a binder call? Should we fail? name.assign(args[2].c_str(), args[2].size()); good = true; } else if (argCount == 4) { @@ -577,7 +576,6 @@ status_t StatsService::cmd_dump_report(FILE* out, FILE* err, const Vector<String if (argCount == 2) { // Automatically pick the UID uid = IPCThreadState::self()->getCallingUid(); - // TODO: What if this isn't a binder call? Should we fail? name.assign(args[1].c_str(), args[1].size()); good = true; } else if (argCount == 3) { @@ -603,7 +601,6 @@ status_t StatsService::cmd_dump_report(FILE* out, FILE* err, const Vector<String vector<uint8_t> data; mProcessor->onDumpReport(ConfigKey(uid, StrToInt64(name)), getElapsedRealtimeNs(), false /* include_current_bucket*/, ADB_DUMP, &data); - // TODO: print the returned StatsLogReport to file instead of printing to logcat. if (proto) { for (size_t i = 0; i < data.size(); i ++) { fprintf(out, "%c", data[i]); @@ -711,7 +708,7 @@ status_t StatsService::cmd_log_app_breadcrumb(FILE* out, const Vector<String8>& status_t StatsService::cmd_print_pulled_metrics(FILE* out, const Vector<String8>& args) { int s = atoi(args[1].c_str()); vector<shared_ptr<LogEvent> > stats; - if (mStatsPullerManager.Pull(s, getElapsedRealtimeNs(), &stats)) { + if (mPullerManager->Pull(s, getElapsedRealtimeNs(), &stats)) { for (const auto& it : stats) { fprintf(out, "Pull from %d: %s\n", s, it->ToString().c_str()); } @@ -739,7 +736,7 @@ status_t StatsService::cmd_clear_puller_cache(FILE* out) { VLOG("StatsService::cmd_clear_puller_cache with Pid %i, Uid %i", ipc->getCallingPid(), ipc->getCallingUid()); if (checkCallingPermission(String16(kPermissionDump))) { - int cleared = mStatsPullerManager.ForceClearPullerCache(); + int cleared = mPullerManager->ForceClearPullerCache(); fprintf(out, "Puller removed %d cached data!\n", cleared); return NO_ERROR; } else { @@ -870,7 +867,7 @@ Status StatsService::statsCompanionReady() { } VLOG("StatsService::statsCompanionReady linking to statsCompanion."); IInterface::asBinder(statsCompanion)->linkToDeath(this); - mStatsPullerManager.SetStatsCompanionService(statsCompanion); + mPullerManager->SetStatsCompanionService(statsCompanion); mAnomalyAlarmMonitor->setStatsCompanionService(statsCompanion); mPeriodicAlarmMonitor->setStatsCompanionService(statsCompanion); SubscriberReporter::getInstance().setStatsCompanionService(statsCompanion); @@ -1014,7 +1011,7 @@ void StatsService::binderDied(const wp <IBinder>& who) { mAnomalyAlarmMonitor->setStatsCompanionService(nullptr); mPeriodicAlarmMonitor->setStatsCompanionService(nullptr); SubscriberReporter::getInstance().setStatsCompanionService(nullptr); - mStatsPullerManager.SetStatsCompanionService(nullptr); + mPullerManager->SetStatsCompanionService(nullptr); } } // namespace statsd |