Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Yao Chen | 8a8d16c | 2018-02-08 14:50:40 -0800 | [diff] [blame] | 17 | #define DEBUG true // STOPSHIP if true |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 18 | #include "Log.h" |
David Chen | 2158296 | 2017-11-01 17:32:46 -0700 | [diff] [blame] | 19 | #include "statslog.h" |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 20 | |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 21 | #include <android-base/file.h> |
| 22 | #include <dirent.h> |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 23 | #include "StatsLogProcessor.h" |
Yangster-mac | 330af58 | 2018-02-08 15:24:38 -0800 | [diff] [blame] | 24 | #include "stats_log_util.h" |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 25 | #include "android-base/stringprintf.h" |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 26 | #include "guardrail/StatsdStats.h" |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 27 | #include "metrics/CountMetricProducer.h" |
Chenjie Yu | 85ed838 | 2017-12-14 16:48:54 -0800 | [diff] [blame] | 28 | #include "external/StatsPullerManager.h" |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 29 | #include "stats_util.h" |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 30 | #include "storage/StorageManager.h" |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 31 | |
yro | 00698da | 2017-09-15 10:06:40 -0700 | [diff] [blame] | 32 | #include <log/log_event_list.h> |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 33 | #include <utils/Errors.h> |
David Chen | 1604957 | 2018-02-01 18:27:51 -0800 | [diff] [blame] | 34 | #include <utils/SystemClock.h> |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 35 | |
| 36 | using namespace android; |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 37 | using android::base::StringPrintf; |
yro | b0378b0 | 2017-11-09 20:36:25 -0800 | [diff] [blame] | 38 | using android::util::FIELD_COUNT_REPEATED; |
yro | 17adac9 | 2017-11-08 23:16:29 -0800 | [diff] [blame] | 39 | using android::util::FIELD_TYPE_BOOL; |
| 40 | using android::util::FIELD_TYPE_FLOAT; |
| 41 | using android::util::FIELD_TYPE_INT32; |
| 42 | using android::util::FIELD_TYPE_INT64; |
| 43 | using android::util::FIELD_TYPE_MESSAGE; |
| 44 | using android::util::FIELD_TYPE_STRING; |
| 45 | using android::util::ProtoOutputStream; |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 46 | using std::make_unique; |
| 47 | using std::unique_ptr; |
| 48 | using std::vector; |
Bookatz | 906a35c | 2017-09-20 15:26:44 -0700 | [diff] [blame] | 49 | |
| 50 | namespace android { |
| 51 | namespace os { |
| 52 | namespace statsd { |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 53 | |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 54 | // for ConfigMetricsReportList |
yro | 17adac9 | 2017-11-08 23:16:29 -0800 | [diff] [blame] | 55 | const int FIELD_ID_CONFIG_KEY = 1; |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 56 | const int FIELD_ID_REPORTS = 2; |
yro | 17adac9 | 2017-11-08 23:16:29 -0800 | [diff] [blame] | 57 | // for ConfigKey |
| 58 | const int FIELD_ID_UID = 1; |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 59 | const int FIELD_ID_ID = 2; |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 60 | // for ConfigMetricsReport |
Yao Chen | 4c959cb | 2018-02-13 13:27:48 -0800 | [diff] [blame] | 61 | // const int FIELD_ID_METRICS = 1; // written in MetricsManager.cpp |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 62 | const int FIELD_ID_UID_MAP = 2; |
Yangster-mac | 330af58 | 2018-02-08 15:24:38 -0800 | [diff] [blame] | 63 | const int FIELD_ID_LAST_REPORT_ELAPSED_NANOS = 3; |
| 64 | const int FIELD_ID_CURRENT_REPORT_ELAPSED_NANOS = 4; |
Yangster-mac | 3fa5d7f | 2018-03-10 21:50:27 -0800 | [diff] [blame] | 65 | const int FIELD_ID_LAST_REPORT_WALL_CLOCK_NANOS = 5; |
| 66 | const int FIELD_ID_CURRENT_REPORT_WALL_CLOCK_NANOS = 6; |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 67 | const int FIELD_ID_DUMP_REPORT_REASON = 8; |
Yangster-mac | 9def8e3 | 2018-04-17 13:55:51 -0700 | [diff] [blame] | 68 | const int FIELD_ID_STRINGS = 9; |
Yangster-mac | 3fa5d7f | 2018-03-10 21:50:27 -0800 | [diff] [blame] | 69 | |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 70 | #define NS_PER_HOUR 3600 * NS_PER_SEC |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 71 | |
yro | 03faf09 | 2017-12-12 00:17:50 -0800 | [diff] [blame] | 72 | #define STATS_DATA_DIR "/data/misc/stats-data" |
yro | 17adac9 | 2017-11-08 23:16:29 -0800 | [diff] [blame] | 73 | |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 74 | StatsLogProcessor::StatsLogProcessor(const sp<UidMap>& uidMap, |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 75 | const sp<AlarmMonitor>& anomalyAlarmMonitor, |
| 76 | const sp<AlarmMonitor>& periodicAlarmMonitor, |
Yangster-mac | 15f6bbc | 2018-04-08 11:52:26 -0700 | [diff] [blame] | 77 | const int64_t timeBaseNs, |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 78 | const std::function<void(const ConfigKey&)>& sendBroadcast) |
Chenjie Yu | 85ed838 | 2017-12-14 16:48:54 -0800 | [diff] [blame] | 79 | : mUidMap(uidMap), |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 80 | mAnomalyAlarmMonitor(anomalyAlarmMonitor), |
| 81 | mPeriodicAlarmMonitor(periodicAlarmMonitor), |
Chenjie Yu | 85ed838 | 2017-12-14 16:48:54 -0800 | [diff] [blame] | 82 | mSendBroadcast(sendBroadcast), |
Yangster-mac | 15f6bbc | 2018-04-08 11:52:26 -0700 | [diff] [blame] | 83 | mTimeBaseNs(timeBaseNs), |
Yao Chen | 163d260 | 2018-04-10 10:39:53 -0700 | [diff] [blame] | 84 | mLargestTimestampSeen(0), |
| 85 | mLastTimestampSeen(0) { |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 88 | StatsLogProcessor::~StatsLogProcessor() { |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Yangster-mac | e2cd6d5 | 2017-11-09 20:38:30 -0800 | [diff] [blame] | 91 | void StatsLogProcessor::onAnomalyAlarmFired( |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 92 | const int64_t& timestampNs, |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 93 | unordered_set<sp<const InternalAlarm>, SpHash<InternalAlarm>> alarmSet) { |
Yangster-mac | b0d0628 | 2018-01-05 15:44:07 -0800 | [diff] [blame] | 94 | std::lock_guard<std::mutex> lock(mMetricsMutex); |
Bookatz | cc5adef | 2017-11-21 14:36:23 -0800 | [diff] [blame] | 95 | for (const auto& itr : mMetricsManagers) { |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 96 | itr.second->onAnomalyAlarmFired(timestampNs, alarmSet); |
| 97 | } |
| 98 | } |
| 99 | void StatsLogProcessor::onPeriodicAlarmFired( |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 100 | const int64_t& timestampNs, |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 101 | unordered_set<sp<const InternalAlarm>, SpHash<InternalAlarm>> alarmSet) { |
| 102 | |
| 103 | std::lock_guard<std::mutex> lock(mMetricsMutex); |
| 104 | for (const auto& itr : mMetricsManagers) { |
| 105 | itr.second->onPeriodicAlarmFired(timestampNs, alarmSet); |
Yangster-mac | e2cd6d5 | 2017-11-09 20:38:30 -0800 | [diff] [blame] | 106 | } |
| 107 | } |
| 108 | |
Yao Chen | 8a8d16c | 2018-02-08 14:50:40 -0800 | [diff] [blame] | 109 | void updateUid(Value* value, int hostUid) { |
| 110 | int uid = value->int_value; |
| 111 | if (uid != hostUid) { |
| 112 | value->setInt(hostUid); |
| 113 | } |
| 114 | } |
| 115 | |
Yangster-mac | d40053e | 2018-01-09 16:29:22 -0800 | [diff] [blame] | 116 | void StatsLogProcessor::mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event) const { |
Yao Chen | c40a19d | 2018-03-15 16:48:25 -0700 | [diff] [blame] | 117 | if (android::util::AtomsInfo::kAtomsWithAttributionChain.find(event->GetTagId()) != |
| 118 | android::util::AtomsInfo::kAtomsWithAttributionChain.end()) { |
Yao Chen | 8a8d16c | 2018-02-08 14:50:40 -0800 | [diff] [blame] | 119 | for (auto& value : *(event->getMutableValues())) { |
| 120 | if (value.mField.getPosAtDepth(0) > kAttributionField) { |
| 121 | break; |
| 122 | } |
| 123 | if (isAttributionUidField(value)) { |
| 124 | const int hostUid = mUidMap->getHostUidOrSelf(value.mValue.int_value); |
| 125 | updateUid(&value.mValue, hostUid); |
| 126 | } |
Yangster-mac | d40053e | 2018-01-09 16:29:22 -0800 | [diff] [blame] | 127 | } |
Yao Chen | c40a19d | 2018-03-15 16:48:25 -0700 | [diff] [blame] | 128 | } else { |
| 129 | auto it = android::util::AtomsInfo::kAtomsWithUidField.find(event->GetTagId()); |
| 130 | if (it != android::util::AtomsInfo::kAtomsWithUidField.end()) { |
| 131 | int uidField = it->second; // uidField is the field number in proto, |
| 132 | // starting from 1 |
| 133 | if (uidField > 0 && (int)event->getValues().size() >= uidField && |
| 134 | (event->getValues())[uidField - 1].mValue.getType() == INT) { |
| 135 | Value& value = (*event->getMutableValues())[uidField - 1].mValue; |
| 136 | const int hostUid = mUidMap->getHostUidOrSelf(value.int_value); |
| 137 | updateUid(&value, hostUid); |
| 138 | } else { |
| 139 | ALOGE("Malformed log, uid not found. %s", event->ToString().c_str()); |
| 140 | } |
| 141 | } |
Yao Chen | 312e898 | 2017-12-05 15:29:03 -0800 | [diff] [blame] | 142 | } |
Yangster-mac | d40053e | 2018-01-09 16:29:22 -0800 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | void StatsLogProcessor::onIsolatedUidChangedEventLocked(const LogEvent& event) { |
| 146 | status_t err = NO_ERROR, err2 = NO_ERROR, err3 = NO_ERROR; |
| 147 | bool is_create = event.GetBool(3, &err); |
| 148 | auto parent_uid = int(event.GetLong(1, &err2)); |
| 149 | auto isolated_uid = int(event.GetLong(2, &err3)); |
| 150 | if (err == NO_ERROR && err2 == NO_ERROR && err3 == NO_ERROR) { |
| 151 | if (is_create) { |
| 152 | mUidMap->assignIsolatedUid(isolated_uid, parent_uid); |
| 153 | } else { |
| 154 | mUidMap->removeIsolatedUid(isolated_uid, parent_uid); |
| 155 | } |
| 156 | } else { |
| 157 | ALOGE("Failed to parse uid in the isolated uid change event."); |
| 158 | } |
| 159 | } |
| 160 | |
Yangster-mac | d40053e | 2018-01-09 16:29:22 -0800 | [diff] [blame] | 161 | void StatsLogProcessor::OnLogEvent(LogEvent* event) { |
Yao Chen | 163d260 | 2018-04-10 10:39:53 -0700 | [diff] [blame] | 162 | OnLogEvent(event, false); |
| 163 | } |
| 164 | |
| 165 | void StatsLogProcessor::OnLogEvent(LogEvent* event, bool reconnected) { |
Yangster-mac | d40053e | 2018-01-09 16:29:22 -0800 | [diff] [blame] | 166 | std::lock_guard<std::mutex> lock(mMetricsMutex); |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 167 | const int64_t currentTimestampNs = event->GetElapsedTimestampNs(); |
Yangster-mac | b8382a1 | 2018-04-04 10:39:12 -0700 | [diff] [blame] | 168 | |
Yao Chen | 163d260 | 2018-04-10 10:39:53 -0700 | [diff] [blame] | 169 | if (reconnected && mLastTimestampSeen != 0) { |
| 170 | // LogReader tells us the connection has just been reset. Now we need |
| 171 | // to enter reconnection state to find the last CP. |
| 172 | mInReconnection = true; |
| 173 | } |
| 174 | |
| 175 | if (mInReconnection) { |
| 176 | // We see the checkpoint |
| 177 | if (currentTimestampNs == mLastTimestampSeen) { |
| 178 | mInReconnection = false; |
| 179 | // Found the CP. ignore this event, and we will start to read from next event. |
| 180 | return; |
| 181 | } |
| 182 | if (currentTimestampNs > mLargestTimestampSeen) { |
| 183 | // We see a new log but CP has not been found yet. Give up now. |
| 184 | mLogLossCount++; |
| 185 | mInReconnection = false; |
| 186 | StatsdStats::getInstance().noteLogLost(currentTimestampNs); |
| 187 | // Persist the data before we reset. Do we want this? |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 188 | WriteDataToDiskLocked(CONFIG_RESET); |
Yao Chen | 163d260 | 2018-04-10 10:39:53 -0700 | [diff] [blame] | 189 | // We see fresher event before we see the checkpoint. We might have lost data. |
| 190 | // The best we can do is to reset. |
| 191 | std::vector<ConfigKey> configKeys; |
| 192 | for (auto it = mMetricsManagers.begin(); it != mMetricsManagers.end(); it++) { |
| 193 | configKeys.push_back(it->first); |
| 194 | } |
| 195 | resetConfigsLocked(currentTimestampNs, configKeys); |
| 196 | } else { |
| 197 | // Still in search of the CP. Keep going. |
| 198 | return; |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | mLogCount++; |
| 203 | mLastTimestampSeen = currentTimestampNs; |
| 204 | if (mLargestTimestampSeen < currentTimestampNs) { |
| 205 | mLargestTimestampSeen = currentTimestampNs; |
Yao Chen | 8f42ba0 | 2018-02-27 15:17:07 -0800 | [diff] [blame] | 206 | } |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 207 | |
| 208 | resetIfConfigTtlExpiredLocked(currentTimestampNs); |
| 209 | |
Yangster-mac | d40053e | 2018-01-09 16:29:22 -0800 | [diff] [blame] | 210 | StatsdStats::getInstance().noteAtomLogged( |
Yangster-mac | 330af58 | 2018-02-08 15:24:38 -0800 | [diff] [blame] | 211 | event->GetTagId(), event->GetElapsedTimestampNs() / NS_PER_SEC); |
Yangster-mac | d40053e | 2018-01-09 16:29:22 -0800 | [diff] [blame] | 212 | |
David Chen | 2158296 | 2017-11-01 17:32:46 -0700 | [diff] [blame] | 213 | // Hard-coded logic to update the isolated uid's in the uid-map. |
Stefan Lafon | ae2df01 | 2017-11-14 09:17:21 -0800 | [diff] [blame] | 214 | // The field numbers need to be currently updated by hand with atoms.proto |
Yangster-mac | d40053e | 2018-01-09 16:29:22 -0800 | [diff] [blame] | 215 | if (event->GetTagId() == android::util::ISOLATED_UID_CHANGED) { |
| 216 | onIsolatedUidChangedEventLocked(*event); |
David Chen | cfc311d | 2018-01-23 17:55:54 -0800 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | if (mMetricsManagers.empty()) { |
| 220 | return; |
| 221 | } |
| 222 | |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 223 | int64_t curTimeSec = getElapsedRealtimeSec(); |
Yangster-mac | 330af58 | 2018-02-08 15:24:38 -0800 | [diff] [blame] | 224 | if (curTimeSec - mLastPullerCacheClearTimeSec > StatsdStats::kPullerCacheClearIntervalSec) { |
Chenjie Yu | 1a0a941 | 2018-03-28 10:07:22 -0700 | [diff] [blame] | 225 | mStatsPullerManager.ClearPullerCacheIfNecessary(curTimeSec * NS_PER_SEC); |
Yangster-mac | 330af58 | 2018-02-08 15:24:38 -0800 | [diff] [blame] | 226 | mLastPullerCacheClearTimeSec = curTimeSec; |
Chenjie Yu | fa22d65 | 2018-02-05 14:37:48 -0800 | [diff] [blame] | 227 | } |
| 228 | |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 229 | |
David Chen | cfc311d | 2018-01-23 17:55:54 -0800 | [diff] [blame] | 230 | if (event->GetTagId() != android::util::ISOLATED_UID_CHANGED) { |
Yangster-mac | d40053e | 2018-01-09 16:29:22 -0800 | [diff] [blame] | 231 | // Map the isolated uid to host uid if necessary. |
| 232 | mapIsolatedUidToHostUidIfNecessaryLocked(event); |
| 233 | } |
| 234 | |
| 235 | // pass the event to metrics managers. |
| 236 | for (auto& pair : mMetricsManagers) { |
| 237 | pair.second->onLogEvent(*event); |
Yangster-mac | 330af58 | 2018-02-08 15:24:38 -0800 | [diff] [blame] | 238 | flushIfNecessaryLocked(event->GetElapsedTimestampNs(), pair.first, *(pair.second)); |
David Chen | 2158296 | 2017-11-01 17:32:46 -0700 | [diff] [blame] | 239 | } |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Yangster-mac | c04feba | 2018-04-02 14:37:33 -0700 | [diff] [blame] | 242 | void StatsLogProcessor::OnConfigUpdated(const int64_t timestampNs, const ConfigKey& key, |
| 243 | const StatsdConfig& config) { |
Yangster-mac | b0d0628 | 2018-01-05 15:44:07 -0800 | [diff] [blame] | 244 | std::lock_guard<std::mutex> lock(mMetricsMutex); |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 245 | OnConfigUpdatedLocked(timestampNs, key, config); |
| 246 | } |
| 247 | |
| 248 | void StatsLogProcessor::OnConfigUpdatedLocked( |
| 249 | const int64_t timestampNs, const ConfigKey& key, const StatsdConfig& config) { |
Tej Singh | 484524a | 2018-02-01 15:10:05 -0800 | [diff] [blame] | 250 | VLOG("Updated configuration for key %s", key.ToString().c_str()); |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 251 | sp<MetricsManager> newMetricsManager = |
Yangster-mac | 15f6bbc | 2018-04-08 11:52:26 -0700 | [diff] [blame] | 252 | new MetricsManager(key, config, mTimeBaseNs, timestampNs, mUidMap, |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 253 | mAnomalyAlarmMonitor, mPeriodicAlarmMonitor); |
Yangster-mac | e68f3a5 | 2018-04-04 00:01:43 -0700 | [diff] [blame] | 254 | auto it = mMetricsManagers.find(key); |
| 255 | if (it != mMetricsManagers.end()) { |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 256 | WriteDataToDiskLocked(it->first, CONFIG_UPDATED); |
Yangster-mac | e68f3a5 | 2018-04-04 00:01:43 -0700 | [diff] [blame] | 257 | } |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 258 | if (newMetricsManager->isConfigValid()) { |
David Chen | d689689 | 2017-10-25 11:49:03 -0700 | [diff] [blame] | 259 | mUidMap->OnConfigUpdated(key); |
Yao Chen | 147ce60 | 2017-12-22 14:35:34 -0800 | [diff] [blame] | 260 | if (newMetricsManager->shouldAddUidMapListener()) { |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 261 | // We have to add listener after the MetricsManager is constructed because it's |
| 262 | // not safe to create wp or sp from this pointer inside its constructor. |
| 263 | mUidMap->addListener(newMetricsManager.get()); |
| 264 | } |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 265 | newMetricsManager->refreshTtl(timestampNs); |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 266 | mMetricsManagers[key] = newMetricsManager; |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 267 | VLOG("StatsdConfig valid"); |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 268 | } else { |
| 269 | // If there is any error in the config, don't use it. |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 270 | ALOGE("StatsdConfig NOT valid"); |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 271 | } |
yro | 00698da | 2017-09-15 10:06:40 -0700 | [diff] [blame] | 272 | } |
Bookatz | 906a35c | 2017-09-20 15:26:44 -0700 | [diff] [blame] | 273 | |
Yangster | 7c334a1 | 2017-11-22 14:24:24 -0800 | [diff] [blame] | 274 | size_t StatsLogProcessor::GetMetricsSize(const ConfigKey& key) const { |
Yangster-mac | b0d0628 | 2018-01-05 15:44:07 -0800 | [diff] [blame] | 275 | std::lock_guard<std::mutex> lock(mMetricsMutex); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 276 | auto it = mMetricsManagers.find(key); |
| 277 | if (it == mMetricsManagers.end()) { |
| 278 | ALOGW("Config source %s does not exist", key.ToString().c_str()); |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 279 | return 0; |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 280 | } |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 281 | return it->second->byteSize(); |
| 282 | } |
| 283 | |
Yao Chen | 884c8c1 | 2018-01-26 10:36:25 -0800 | [diff] [blame] | 284 | void StatsLogProcessor::dumpStates(FILE* out, bool verbose) { |
| 285 | std::lock_guard<std::mutex> lock(mMetricsMutex); |
| 286 | fprintf(out, "MetricsManager count: %lu\n", (unsigned long)mMetricsManagers.size()); |
| 287 | for (auto metricsManager : mMetricsManagers) { |
| 288 | metricsManager.second->dumpStates(out, verbose); |
| 289 | } |
| 290 | } |
| 291 | |
yro | 4beccbe | 2018-03-15 19:42:05 -0700 | [diff] [blame] | 292 | /* |
| 293 | * onDumpReport dumps serialized ConfigMetricsReportList into outData. |
| 294 | */ |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 295 | void StatsLogProcessor::onDumpReport(const ConfigKey& key, const int64_t dumpTimeStampNs, |
Yangster-mac | e68f3a5 | 2018-04-04 00:01:43 -0700 | [diff] [blame] | 296 | const bool include_current_partial_bucket, |
Yangster-mac | 9def8e3 | 2018-04-17 13:55:51 -0700 | [diff] [blame] | 297 | const bool include_string, |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 298 | const DumpReportReason dumpReportReason, |
Yao Chen | 8a8d16c | 2018-02-08 14:50:40 -0800 | [diff] [blame] | 299 | vector<uint8_t>* outData) { |
Yangster-mac | b0d0628 | 2018-01-05 15:44:07 -0800 | [diff] [blame] | 300 | std::lock_guard<std::mutex> lock(mMetricsMutex); |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 301 | |
yro | 17adac9 | 2017-11-08 23:16:29 -0800 | [diff] [blame] | 302 | ProtoOutputStream proto; |
| 303 | |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 304 | // Start of ConfigKey. |
Yi Jin | 5ee0787 | 2018-03-05 18:18:27 -0800 | [diff] [blame] | 305 | uint64_t configKeyToken = proto.start(FIELD_TYPE_MESSAGE | FIELD_ID_CONFIG_KEY); |
yro | 17adac9 | 2017-11-08 23:16:29 -0800 | [diff] [blame] | 306 | proto.write(FIELD_TYPE_INT32 | FIELD_ID_UID, key.GetUid()); |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 307 | proto.write(FIELD_TYPE_INT64 | FIELD_ID_ID, (long long)key.GetId()); |
yro | 17adac9 | 2017-11-08 23:16:29 -0800 | [diff] [blame] | 308 | proto.end(configKeyToken); |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 309 | // End of ConfigKey. |
yro | 17adac9 | 2017-11-08 23:16:29 -0800 | [diff] [blame] | 310 | |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 311 | // Then, check stats-data directory to see there's any file containing |
| 312 | // ConfigMetricsReport from previous shutdowns to concatenate to reports. |
yro | 4beccbe | 2018-03-15 19:42:05 -0700 | [diff] [blame] | 313 | StorageManager::appendConfigMetricsReport(key, &proto); |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 314 | |
Yangster-mac | e68f3a5 | 2018-04-04 00:01:43 -0700 | [diff] [blame] | 315 | auto it = mMetricsManagers.find(key); |
| 316 | if (it != mMetricsManagers.end()) { |
| 317 | // This allows another broadcast to be sent within the rate-limit period if we get close to |
| 318 | // filling the buffer again soon. |
| 319 | mLastBroadcastTimes.erase(key); |
| 320 | |
| 321 | // Start of ConfigMetricsReport (reports). |
| 322 | uint64_t reportsToken = |
| 323 | proto.start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_REPORTS); |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 324 | onConfigMetricsReportLocked(key, dumpTimeStampNs, include_current_partial_bucket, |
Yangster-mac | 9def8e3 | 2018-04-17 13:55:51 -0700 | [diff] [blame] | 325 | include_string, dumpReportReason, &proto); |
Yangster-mac | e68f3a5 | 2018-04-04 00:01:43 -0700 | [diff] [blame] | 326 | proto.end(reportsToken); |
| 327 | // End of ConfigMetricsReport (reports). |
| 328 | } else { |
| 329 | ALOGW("Config source %s does not exist", key.ToString().c_str()); |
| 330 | } |
| 331 | |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 332 | if (outData != nullptr) { |
| 333 | outData->clear(); |
| 334 | outData->resize(proto.size()); |
| 335 | size_t pos = 0; |
| 336 | auto iter = proto.data(); |
| 337 | while (iter.readBuffer() != NULL) { |
| 338 | size_t toRead = iter.currentToRead(); |
| 339 | std::memcpy(&((*outData)[pos]), iter.readBuffer(), toRead); |
| 340 | pos += toRead; |
| 341 | iter.rp()->move(toRead); |
| 342 | } |
yro | 17adac9 | 2017-11-08 23:16:29 -0800 | [diff] [blame] | 343 | } |
Yao Chen | 8a8d16c | 2018-02-08 14:50:40 -0800 | [diff] [blame] | 344 | |
Yangster-mac | e68f3a5 | 2018-04-04 00:01:43 -0700 | [diff] [blame] | 345 | StatsdStats::getInstance().noteMetricsReportSent(key, proto.size()); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 346 | } |
| 347 | |
yro | 4beccbe | 2018-03-15 19:42:05 -0700 | [diff] [blame] | 348 | /* |
| 349 | * onConfigMetricsReportLocked dumps serialized ConfigMetricsReport into outData. |
| 350 | */ |
| 351 | void StatsLogProcessor::onConfigMetricsReportLocked(const ConfigKey& key, |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 352 | const int64_t dumpTimeStampNs, |
Yangster-mac | e68f3a5 | 2018-04-04 00:01:43 -0700 | [diff] [blame] | 353 | const bool include_current_partial_bucket, |
Yangster-mac | 9def8e3 | 2018-04-17 13:55:51 -0700 | [diff] [blame] | 354 | const bool include_string, |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 355 | const DumpReportReason dumpReportReason, |
yro | 4beccbe | 2018-03-15 19:42:05 -0700 | [diff] [blame] | 356 | ProtoOutputStream* proto) { |
| 357 | // We already checked whether key exists in mMetricsManagers in |
| 358 | // WriteDataToDisk. |
| 359 | auto it = mMetricsManagers.find(key); |
Yangster-mac | e68f3a5 | 2018-04-04 00:01:43 -0700 | [diff] [blame] | 360 | if (it == mMetricsManagers.end()) { |
| 361 | return; |
| 362 | } |
yro | 4beccbe | 2018-03-15 19:42:05 -0700 | [diff] [blame] | 363 | int64_t lastReportTimeNs = it->second->getLastReportTimeNs(); |
| 364 | int64_t lastReportWallClockNs = it->second->getLastReportWallClockNs(); |
| 365 | |
Yangster-mac | 9def8e3 | 2018-04-17 13:55:51 -0700 | [diff] [blame] | 366 | std::set<string> str_set; |
| 367 | |
yro | 4beccbe | 2018-03-15 19:42:05 -0700 | [diff] [blame] | 368 | // First, fill in ConfigMetricsReport using current data on memory, which |
| 369 | // starts from filling in StatsLogReport's. |
Yangster-mac | 9def8e3 | 2018-04-17 13:55:51 -0700 | [diff] [blame] | 370 | it->second->onDumpReport(dumpTimeStampNs, include_current_partial_bucket, |
| 371 | &str_set, proto); |
yro | 4beccbe | 2018-03-15 19:42:05 -0700 | [diff] [blame] | 372 | |
| 373 | // Fill in UidMap. |
| 374 | uint64_t uidMapToken = proto->start(FIELD_TYPE_MESSAGE | FIELD_ID_UID_MAP); |
Yangster-mac | 9def8e3 | 2018-04-17 13:55:51 -0700 | [diff] [blame] | 375 | mUidMap->appendUidMap(dumpTimeStampNs, key, &str_set, proto); |
yro | 4beccbe | 2018-03-15 19:42:05 -0700 | [diff] [blame] | 376 | proto->end(uidMapToken); |
| 377 | |
| 378 | // Fill in the timestamps. |
| 379 | proto->write(FIELD_TYPE_INT64 | FIELD_ID_LAST_REPORT_ELAPSED_NANOS, |
| 380 | (long long)lastReportTimeNs); |
| 381 | proto->write(FIELD_TYPE_INT64 | FIELD_ID_CURRENT_REPORT_ELAPSED_NANOS, |
| 382 | (long long)dumpTimeStampNs); |
| 383 | proto->write(FIELD_TYPE_INT64 | FIELD_ID_LAST_REPORT_WALL_CLOCK_NANOS, |
| 384 | (long long)lastReportWallClockNs); |
| 385 | proto->write(FIELD_TYPE_INT64 | FIELD_ID_CURRENT_REPORT_WALL_CLOCK_NANOS, |
| 386 | (long long)getWallClockNs()); |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 387 | // Dump report reason |
| 388 | proto->write(FIELD_TYPE_INT32 | FIELD_ID_DUMP_REPORT_REASON, dumpReportReason); |
Yangster-mac | 9def8e3 | 2018-04-17 13:55:51 -0700 | [diff] [blame] | 389 | |
| 390 | if (include_string) { |
| 391 | for (const auto& str : str_set) { |
| 392 | proto->write(FIELD_TYPE_STRING | FIELD_COUNT_REPEATED | FIELD_ID_STRINGS, str); |
| 393 | } |
| 394 | } |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 395 | } |
yro | 4beccbe | 2018-03-15 19:42:05 -0700 | [diff] [blame] | 396 | |
Yao Chen | 163d260 | 2018-04-10 10:39:53 -0700 | [diff] [blame] | 397 | void StatsLogProcessor::resetConfigsLocked(const int64_t timestampNs, |
| 398 | const std::vector<ConfigKey>& configs) { |
| 399 | for (const auto& key : configs) { |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 400 | StatsdConfig config; |
| 401 | if (StorageManager::readConfigFromDisk(key, &config)) { |
| 402 | OnConfigUpdatedLocked(timestampNs, key, config); |
| 403 | StatsdStats::getInstance().noteConfigReset(key); |
| 404 | } else { |
| 405 | ALOGE("Failed to read backup config from disk for : %s", key.ToString().c_str()); |
| 406 | auto it = mMetricsManagers.find(key); |
| 407 | if (it != mMetricsManagers.end()) { |
| 408 | it->second->refreshTtl(timestampNs); |
| 409 | } |
| 410 | } |
| 411 | } |
yro | 4beccbe | 2018-03-15 19:42:05 -0700 | [diff] [blame] | 412 | } |
| 413 | |
Yao Chen | 163d260 | 2018-04-10 10:39:53 -0700 | [diff] [blame] | 414 | void StatsLogProcessor::resetIfConfigTtlExpiredLocked(const int64_t timestampNs) { |
| 415 | std::vector<ConfigKey> configKeysTtlExpired; |
| 416 | for (auto it = mMetricsManagers.begin(); it != mMetricsManagers.end(); it++) { |
| 417 | if (it->second != nullptr && !it->second->isInTtl(timestampNs)) { |
| 418 | configKeysTtlExpired.push_back(it->first); |
| 419 | } |
| 420 | } |
| 421 | if (configKeysTtlExpired.size() > 0) { |
| 422 | resetConfigsLocked(timestampNs, configKeysTtlExpired); |
| 423 | } |
| 424 | } |
| 425 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 426 | void StatsLogProcessor::OnConfigRemoved(const ConfigKey& key) { |
Yangster-mac | b0d0628 | 2018-01-05 15:44:07 -0800 | [diff] [blame] | 427 | std::lock_guard<std::mutex> lock(mMetricsMutex); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 428 | auto it = mMetricsManagers.find(key); |
| 429 | if (it != mMetricsManagers.end()) { |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 430 | WriteDataToDiskLocked(key, CONFIG_REMOVED); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 431 | mMetricsManagers.erase(it); |
David Chen | d689689 | 2017-10-25 11:49:03 -0700 | [diff] [blame] | 432 | mUidMap->OnConfigRemoved(key); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 433 | } |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 434 | StatsdStats::getInstance().noteConfigRemoved(key); |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 435 | |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 436 | mLastBroadcastTimes.erase(key); |
Chenjie Yu | fa22d65 | 2018-02-05 14:37:48 -0800 | [diff] [blame] | 437 | |
| 438 | if (mMetricsManagers.empty()) { |
| 439 | mStatsPullerManager.ForceClearPullerCache(); |
| 440 | } |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 441 | } |
| 442 | |
Yangster-mac | b0d0628 | 2018-01-05 15:44:07 -0800 | [diff] [blame] | 443 | void StatsLogProcessor::flushIfNecessaryLocked( |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 444 | int64_t timestampNs, const ConfigKey& key, MetricsManager& metricsManager) { |
David Chen | d9269e2 | 2017-12-05 13:43:51 -0800 | [diff] [blame] | 445 | auto lastCheckTime = mLastByteSizeTimes.find(key); |
| 446 | if (lastCheckTime != mLastByteSizeTimes.end()) { |
| 447 | if (timestampNs - lastCheckTime->second < StatsdStats::kMinByteSizeCheckPeriodNs) { |
| 448 | return; |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | // We suspect that the byteSize() computation is expensive, so we set a rate limit. |
| 453 | size_t totalBytes = metricsManager.byteSize(); |
| 454 | mLastByteSizeTimes[key] = timestampNs; |
| 455 | if (totalBytes > |
| 456 | StatsdStats::kMaxMetricsBytesPerConfig) { // Too late. We need to start clearing data. |
Yao Chen | 06dba5d | 2018-01-26 13:38:16 -0800 | [diff] [blame] | 457 | metricsManager.dropData(timestampNs); |
David Chen | 1294295 | 2017-12-04 14:28:43 -0800 | [diff] [blame] | 458 | StatsdStats::getInstance().noteDataDropped(key); |
| 459 | VLOG("StatsD had to toss out metrics for %s", key.ToString().c_str()); |
David Chen | 4c6d97a | 2018-03-22 16:31:40 -0700 | [diff] [blame] | 460 | } else if (totalBytes > StatsdStats::kBytesPerConfigTriggerGetData) { |
David Chen | d9269e2 | 2017-12-05 13:43:51 -0800 | [diff] [blame] | 461 | // Send broadcast so that receivers can pull data. |
| 462 | auto lastBroadcastTime = mLastBroadcastTimes.find(key); |
| 463 | if (lastBroadcastTime != mLastBroadcastTimes.end()) { |
| 464 | if (timestampNs - lastBroadcastTime->second < StatsdStats::kMinBroadcastPeriodNs) { |
| 465 | VLOG("StatsD would've sent a broadcast but the rate limit stopped us."); |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 466 | return; |
| 467 | } |
| 468 | } |
| 469 | mLastBroadcastTimes[key] = timestampNs; |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 470 | VLOG("StatsD requesting broadcast for %s", key.ToString().c_str()); |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 471 | mSendBroadcast(key); |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 472 | StatsdStats::getInstance().noteBroadcastSent(key); |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 473 | } |
| 474 | } |
| 475 | |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 476 | void StatsLogProcessor::WriteDataToDiskLocked(const ConfigKey& key, |
| 477 | const DumpReportReason dumpReportReason) { |
Yangster-mac | e68f3a5 | 2018-04-04 00:01:43 -0700 | [diff] [blame] | 478 | ProtoOutputStream proto; |
| 479 | onConfigMetricsReportLocked(key, getElapsedRealtimeNs(), |
Yangster-mac | 9def8e3 | 2018-04-17 13:55:51 -0700 | [diff] [blame] | 480 | true /* include_current_partial_bucket*/, |
| 481 | false /* include strings */, dumpReportReason, &proto); |
Yangster-mac | e68f3a5 | 2018-04-04 00:01:43 -0700 | [diff] [blame] | 482 | string file_name = StringPrintf("%s/%ld_%d_%lld", STATS_DATA_DIR, |
| 483 | (long)getWallClockSec(), key.GetUid(), (long long)key.GetId()); |
| 484 | android::base::unique_fd fd(open(file_name.c_str(), |
| 485 | O_WRONLY | O_CREAT | O_CLOEXEC, S_IRUSR | S_IWUSR)); |
| 486 | if (fd == -1) { |
| 487 | ALOGE("Attempt to write %s but failed", file_name.c_str()); |
| 488 | return; |
| 489 | } |
| 490 | proto.flush(fd.get()); |
| 491 | } |
| 492 | |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 493 | void StatsLogProcessor::WriteDataToDiskLocked(const DumpReportReason dumpReportReason) { |
Yangster-mac | e68f3a5 | 2018-04-04 00:01:43 -0700 | [diff] [blame] | 494 | for (auto& pair : mMetricsManagers) { |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 495 | WriteDataToDiskLocked(pair.first, dumpReportReason); |
Yangster-mac | e68f3a5 | 2018-04-04 00:01:43 -0700 | [diff] [blame] | 496 | } |
| 497 | } |
| 498 | |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 499 | void StatsLogProcessor::WriteDataToDisk(bool isShutdown) { |
Yangster-mac | b0d0628 | 2018-01-05 15:44:07 -0800 | [diff] [blame] | 500 | std::lock_guard<std::mutex> lock(mMetricsMutex); |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 501 | WriteDataToDiskLocked(DEVICE_SHUTDOWN); |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 502 | } |
| 503 | |
Yangster-mac | 15f6bbc | 2018-04-08 11:52:26 -0700 | [diff] [blame] | 504 | void StatsLogProcessor::informPullAlarmFired(const int64_t timestampNs) { |
Yangster | 6df5fcc | 2018-04-12 11:04:29 -0700 | [diff] [blame] | 505 | std::lock_guard<std::mutex> lock(mMetricsMutex); |
Yangster-mac | 15f6bbc | 2018-04-08 11:52:26 -0700 | [diff] [blame] | 506 | mStatsPullerManager.OnAlarmFired(timestampNs); |
| 507 | } |
| 508 | |
David Chen | d37bc23 | 2018-04-12 18:05:11 -0700 | [diff] [blame] | 509 | int64_t StatsLogProcessor::getLastReportTimeNs(const ConfigKey& key) { |
| 510 | auto it = mMetricsManagers.find(key); |
| 511 | if (it == mMetricsManagers.end()) { |
| 512 | return 0; |
| 513 | } else { |
| 514 | return it->second->getLastReportTimeNs(); |
| 515 | } |
| 516 | } |
| 517 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 518 | } // namespace statsd |
| 519 | } // namespace os |
| 520 | } // namespace android |