From 032fefc3b547726e675a112baa8d1b6c550ac192 Mon Sep 17 00:00:00 2001 From: Chenjie Yu Date: Fri, 1 Dec 2017 23:30:59 -0800 Subject: [PATCH] bug fixes * add timestamp to those pull from StatsCompanionService * GaugeMetricProducer unregister from StatsPullerManager when dismissed Test: cts test Change-Id: I930179979c146a7407aec3df7e76833f51e9b346 --- cmds/statsd/src/external/StatsCompanionServicePuller.cpp | 6 ++++-- cmds/statsd/src/external/StatsPullerManagerImpl.cpp | 4 +++- cmds/statsd/src/metrics/GaugeMetricProducer.cpp | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmds/statsd/src/external/StatsCompanionServicePuller.cpp b/cmds/statsd/src/external/StatsCompanionServicePuller.cpp index 8e96399716794..e1c02d74d6018 100644 --- a/cmds/statsd/src/external/StatsCompanionServicePuller.cpp +++ b/cmds/statsd/src/external/StatsCompanionServicePuller.cpp @@ -45,10 +45,11 @@ bool StatsCompanionServicePuller::Pull(const int tagId, vectorpullData(tagId, &returned_value); if (!status.isOk()) { - ALOGW("error pulling kernel wakelock"); + ALOGW("error pulling for %d", tagId); return false; } data->clear(); + long timestamp = time(nullptr); for (const StatsLogEventWrapper& it : returned_value) { log_msg tmp; tmp.entry_v1.len = it.bytes.size(); @@ -56,9 +57,10 @@ bool StatsCompanionServicePuller::Pull(const int tagId, vectorpush_back(make_shared(tmp)); } - ALOGD("KernelWakelockPuller::pull succeeded!"); + ALOGD("StatsCompanionServicePuller::pull succeeded for %d", tagId); return true; } else { ALOGW("statsCompanion not found!"); diff --git a/cmds/statsd/src/external/StatsPullerManagerImpl.cpp b/cmds/statsd/src/external/StatsPullerManagerImpl.cpp index 3ffcd77bea445..c4688a2b1c3de 100644 --- a/cmds/statsd/src/external/StatsPullerManagerImpl.cpp +++ b/cmds/statsd/src/external/StatsPullerManagerImpl.cpp @@ -76,7 +76,9 @@ bool StatsPullerManagerImpl::Pull(int tagId, vector>* data) if (DEBUG) ALOGD("Initiating pulling %d", tagId); if (mPullers.find(tagId) != mPullers.end()) { - return mPullers.find(tagId)->second->Pull(tagId, data); + bool ret = mPullers.find(tagId)->second->Pull(tagId, data); + ALOGD("pulled %d items", (int)data->size()); + return ret; } else { ALOGD("Unknown tagId %d", tagId); return false; // Return early since we don't know what to pull. diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp index 1791654ba7ccc..2c26716b1fb00 100644 --- a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp +++ b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp @@ -99,6 +99,9 @@ GaugeMetricProducer::GaugeMetricProducer(const ConfigKey& key, const GaugeMetric GaugeMetricProducer::~GaugeMetricProducer() { VLOG("~GaugeMetricProducer() called"); + if (mPullTagId != -1) { + mStatsPullerManager.UnRegisterReceiver(mPullTagId, this); + } } void GaugeMetricProducer::startNewProtoOutputStream(long long startTime) {