Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -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 | |
Chenjie Yu | 80f9112 | 2018-01-31 20:24:50 -0800 | [diff] [blame] | 17 | #define DEBUG false |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 18 | #include "Log.h" |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 19 | |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 20 | #include <android/os/IStatsCompanionService.h> |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 21 | #include <cutils/log.h> |
| 22 | #include <algorithm> |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 23 | #include <climits> |
Chenjie Yu | aa5b201 | 2018-03-21 13:53:15 -0700 | [diff] [blame^] | 24 | #include "../logd/LogEvent.h" |
| 25 | #include "../stats_log_util.h" |
| 26 | #include "../statscompanion_util.h" |
Tej Singh | 4029831 | 2018-02-16 00:15:09 -0800 | [diff] [blame] | 27 | #include "ResourceHealthManagerPuller.h" |
| 28 | #include "ResourceThermalManagerPuller.h" |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 29 | #include "StatsCompanionServicePuller.h" |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 30 | #include "StatsService.h" |
Tej Singh | bf972d9 | 2018-01-10 20:51:13 -0800 | [diff] [blame] | 31 | #include "SubsystemSleepStatePuller.h" |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 32 | #include "statslog.h" |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 33 | |
| 34 | #include <iostream> |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 35 | |
Yao Chen | 93fe3a3 | 2017-11-02 13:52:59 -0700 | [diff] [blame] | 36 | using std::make_shared; |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 37 | using std::map; |
Yao Chen | 93fe3a3 | 2017-11-02 13:52:59 -0700 | [diff] [blame] | 38 | using std::shared_ptr; |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 39 | using std::string; |
| 40 | using std::vector; |
Chenjie Yu | 6736c89 | 2017-11-09 10:50:09 -0800 | [diff] [blame] | 41 | using std::list; |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 42 | |
| 43 | namespace android { |
| 44 | namespace os { |
| 45 | namespace statsd { |
| 46 | |
Chenjie Yu | 80f9112 | 2018-01-31 20:24:50 -0800 | [diff] [blame] | 47 | const std::map<int, PullAtomInfo> StatsPullerManagerImpl::kAllPullAtomInfo = { |
Chenjie Yu | feba309 | 2018-02-08 14:33:37 -0800 | [diff] [blame] | 48 | // wifi_bytes_transfer |
| 49 | {android::util::WIFI_BYTES_TRANSFER, |
Chenjie Yu | ec67661 | 2018-03-07 09:19:17 -0800 | [diff] [blame] | 50 | {{2, 3, 4, 5}, {}, 1, |
Chenjie Yu | feba309 | 2018-02-08 14:33:37 -0800 | [diff] [blame] | 51 | new StatsCompanionServicePuller(android::util::WIFI_BYTES_TRANSFER)}}, |
| 52 | // wifi_bytes_transfer_by_fg_bg |
| 53 | {android::util::WIFI_BYTES_TRANSFER_BY_FG_BG, |
Chenjie Yu | ec67661 | 2018-03-07 09:19:17 -0800 | [diff] [blame] | 54 | {{3, 4, 5, 6}, {2}, 1, |
Chenjie Yu | feba309 | 2018-02-08 14:33:37 -0800 | [diff] [blame] | 55 | new StatsCompanionServicePuller(android::util::WIFI_BYTES_TRANSFER_BY_FG_BG)}}, |
| 56 | // mobile_bytes_transfer |
| 57 | {android::util::MOBILE_BYTES_TRANSFER, |
Chenjie Yu | ec67661 | 2018-03-07 09:19:17 -0800 | [diff] [blame] | 58 | {{2, 3, 4, 5}, {}, 1, |
Chenjie Yu | feba309 | 2018-02-08 14:33:37 -0800 | [diff] [blame] | 59 | new StatsCompanionServicePuller(android::util::MOBILE_BYTES_TRANSFER)}}, |
| 60 | // mobile_bytes_transfer_by_fg_bg |
| 61 | {android::util::MOBILE_BYTES_TRANSFER_BY_FG_BG, |
Chenjie Yu | ec67661 | 2018-03-07 09:19:17 -0800 | [diff] [blame] | 62 | {{3, 4, 5, 6}, {2}, 1, |
Chenjie Yu | feba309 | 2018-02-08 14:33:37 -0800 | [diff] [blame] | 63 | new StatsCompanionServicePuller(android::util::MOBILE_BYTES_TRANSFER_BY_FG_BG)}}, |
| 64 | // bluetooth_bytes_transfer |
| 65 | {android::util::BLUETOOTH_BYTES_TRANSFER, |
| 66 | {{2, 3}, {}, 1, new StatsCompanionServicePuller(android::util::BLUETOOTH_BYTES_TRANSFER)}}, |
| 67 | // kernel_wakelock |
| 68 | {android::util::KERNEL_WAKELOCK, |
| 69 | {{}, {}, 1, new StatsCompanionServicePuller(android::util::KERNEL_WAKELOCK)}}, |
| 70 | // subsystem_sleep_state |
Chenjie Yu | ec67661 | 2018-03-07 09:19:17 -0800 | [diff] [blame] | 71 | {android::util::SUBSYSTEM_SLEEP_STATE, |
| 72 | {{}, {}, 1, new SubsystemSleepStatePuller()}}, |
Chenjie Yu | feba309 | 2018-02-08 14:33:37 -0800 | [diff] [blame] | 73 | // cpu_time_per_freq |
| 74 | {android::util::CPU_TIME_PER_FREQ, |
| 75 | {{3}, {2}, 1, new StatsCompanionServicePuller(android::util::CPU_TIME_PER_FREQ)}}, |
| 76 | // cpu_time_per_uid |
Chenjie Yu | ec67661 | 2018-03-07 09:19:17 -0800 | [diff] [blame] | 77 | {android::util::CPU_TIME_PER_UID, |
| 78 | {{2, 3}, {}, 1, new StatsCompanionServicePuller(android::util::CPU_TIME_PER_UID)}}, |
Chenjie Yu | feba309 | 2018-02-08 14:33:37 -0800 | [diff] [blame] | 79 | // cpu_time_per_uid_freq |
Chenjie Yu | ec67661 | 2018-03-07 09:19:17 -0800 | [diff] [blame] | 80 | // the throttling is 3sec, handled in frameworks/base/core/java/com/android/internal/os/KernelCpuProcReader |
| 81 | {android::util::CPU_TIME_PER_UID_FREQ, |
| 82 | {{4}, {2,3}, 0, new StatsCompanionServicePuller(android::util::CPU_TIME_PER_UID_FREQ)}}, |
| 83 | // cpu_active_time |
| 84 | // the throttling is 3sec, handled in frameworks/base/core/java/com/android/internal/os/KernelCpuProcReader |
| 85 | {android::util::CPU_ACTIVE_TIME, |
| 86 | {{2}, {}, 0, new StatsCompanionServicePuller(android::util::CPU_ACTIVE_TIME)}}, |
| 87 | // cpu_cluster_time |
| 88 | // the throttling is 3sec, handled in frameworks/base/core/java/com/android/internal/os/KernelCpuProcReader |
| 89 | {android::util::CPU_CLUSTER_TIME, |
| 90 | {{3}, {2}, 0, new StatsCompanionServicePuller(android::util::CPU_CLUSTER_TIME)}}, |
Chenjie Yu | feba309 | 2018-02-08 14:33:37 -0800 | [diff] [blame] | 91 | // wifi_activity_energy_info |
| 92 | {android::util::WIFI_ACTIVITY_ENERGY_INFO, |
| 93 | {{}, {}, 1, new StatsCompanionServicePuller(android::util::WIFI_ACTIVITY_ENERGY_INFO)}}, |
| 94 | // modem_activity_info |
| 95 | {android::util::MODEM_ACTIVITY_INFO, |
| 96 | {{}, {}, 1, new StatsCompanionServicePuller(android::util::MODEM_ACTIVITY_INFO)}}, |
| 97 | // bluetooth_activity_info |
| 98 | {android::util::BLUETOOTH_ACTIVITY_INFO, |
| 99 | {{}, {}, 1, new StatsCompanionServicePuller(android::util::BLUETOOTH_ACTIVITY_INFO)}}, |
| 100 | // system_elapsed_realtime |
| 101 | {android::util::SYSTEM_ELAPSED_REALTIME, |
| 102 | {{}, {}, 1, new StatsCompanionServicePuller(android::util::SYSTEM_ELAPSED_REALTIME)}}, |
| 103 | // system_uptime |
| 104 | {android::util::SYSTEM_UPTIME, |
| 105 | {{}, {}, 1, new StatsCompanionServicePuller(android::util::SYSTEM_UPTIME)}}, |
Chenjie Yu | feba309 | 2018-02-08 14:33:37 -0800 | [diff] [blame] | 106 | // disk_space |
| 107 | {android::util::DISK_SPACE, |
| 108 | {{}, {}, 1, new StatsCompanionServicePuller(android::util::DISK_SPACE)}}, |
| 109 | // remaining_battery_capacity |
| 110 | {android::util::REMAINING_BATTERY_CAPACITY, |
| 111 | {{}, {}, 1, new ResourceHealthManagerPuller(android::util::REMAINING_BATTERY_CAPACITY)}}, |
| 112 | // full_battery_capacity |
| 113 | {android::util::FULL_BATTERY_CAPACITY, |
Rajeev Kumar | 22d92b7 | 2018-02-07 18:38:36 -0800 | [diff] [blame] | 114 | {{}, {}, 1, new ResourceHealthManagerPuller(android::util::FULL_BATTERY_CAPACITY)}}, |
| 115 | // process_memory_state |
| 116 | {android::util::PROCESS_MEMORY_STATE, |
Chenjie Yu | ec67661 | 2018-03-07 09:19:17 -0800 | [diff] [blame] | 117 | {{4,5,6,7,8}, |
| 118 | {2,3}, |
| 119 | 0, |
| 120 | new StatsCompanionServicePuller(android::util::PROCESS_MEMORY_STATE)}}, |
Tej Singh | 4029831 | 2018-02-16 00:15:09 -0800 | [diff] [blame] | 121 | // temperature |
| 122 | {android::util::TEMPERATURE, {{}, {}, 1, new ResourceThermalManagerPuller()}}}; |
Chenjie Yu | 80f9112 | 2018-01-31 20:24:50 -0800 | [diff] [blame] | 123 | |
Chenjie Yu | 6736c89 | 2017-11-09 10:50:09 -0800 | [diff] [blame] | 124 | StatsPullerManagerImpl::StatsPullerManagerImpl() |
Chenjie Yu | 85ed838 | 2017-12-14 16:48:54 -0800 | [diff] [blame] | 125 | : mCurrentPullingInterval(LONG_MAX) { |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 126 | } |
| 127 | |
Chenjie Yu | 6736c89 | 2017-11-09 10:50:09 -0800 | [diff] [blame] | 128 | bool StatsPullerManagerImpl::Pull(int tagId, vector<shared_ptr<LogEvent>>* data) { |
Tej Singh | 484524a | 2018-02-01 15:10:05 -0800 | [diff] [blame] | 129 | VLOG("Initiating pulling %d", tagId); |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 130 | |
Chenjie Yu | 80f9112 | 2018-01-31 20:24:50 -0800 | [diff] [blame] | 131 | if (kAllPullAtomInfo.find(tagId) != kAllPullAtomInfo.end()) { |
Tej Singh | 484524a | 2018-02-01 15:10:05 -0800 | [diff] [blame] | 132 | bool ret = kAllPullAtomInfo.find(tagId)->second.puller->Pull(data); |
| 133 | VLOG("pulled %d items", (int)data->size()); |
| 134 | return ret; |
Yao Chen | 93fe3a3 | 2017-11-02 13:52:59 -0700 | [diff] [blame] | 135 | } else { |
Tej Singh | 484524a | 2018-02-01 15:10:05 -0800 | [diff] [blame] | 136 | VLOG("Unknown tagId %d", tagId); |
Yao Chen | 93fe3a3 | 2017-11-02 13:52:59 -0700 | [diff] [blame] | 137 | return false; // Return early since we don't know what to pull. |
| 138 | } |
| 139 | } |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 140 | |
Chenjie Yu | 6736c89 | 2017-11-09 10:50:09 -0800 | [diff] [blame] | 141 | StatsPullerManagerImpl& StatsPullerManagerImpl::GetInstance() { |
| 142 | static StatsPullerManagerImpl instance; |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 143 | return instance; |
| 144 | } |
| 145 | |
Yangster | 7c334a1 | 2017-11-22 14:24:24 -0800 | [diff] [blame] | 146 | bool StatsPullerManagerImpl::PullerForMatcherExists(int tagId) const { |
Chenjie Yu | feba309 | 2018-02-08 14:33:37 -0800 | [diff] [blame] | 147 | return kAllPullAtomInfo.find(tagId) != kAllPullAtomInfo.end(); |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Chenjie Yu | aa5b201 | 2018-03-21 13:53:15 -0700 | [diff] [blame^] | 150 | void StatsPullerManagerImpl::updateAlarmLocked() { |
| 151 | long currentTimeMs = getElapsedRealtimeMillis(); |
| 152 | long nextAlarmTimeMs = currentTimeMs + mCurrentPullingInterval - |
| 153 | (currentTimeMs - mTimeBaseSec * 1000) % mCurrentPullingInterval; |
| 154 | sp<IStatsCompanionService> statsCompanionServiceCopy = mStatsCompanionService; |
| 155 | if (statsCompanionServiceCopy != nullptr) { |
| 156 | statsCompanionServiceCopy->setPullingAlarms(nextAlarmTimeMs, mCurrentPullingInterval); |
| 157 | } else { |
| 158 | VLOG("StatsCompanionService not available. Alarm not set."); |
| 159 | } |
| 160 | return; |
| 161 | } |
| 162 | |
| 163 | void StatsPullerManagerImpl::SetStatsCompanionService( |
| 164 | sp<IStatsCompanionService> statsCompanionService) { |
| 165 | AutoMutex _l(mLock); |
| 166 | sp<IStatsCompanionService> tmpForLock = mStatsCompanionService; |
| 167 | mStatsCompanionService = statsCompanionService; |
| 168 | for (const auto& pulledAtom : kAllPullAtomInfo) { |
| 169 | pulledAtom.second.puller->SetStatsCompanionService(statsCompanionService); |
| 170 | } |
| 171 | if (mStatsCompanionService != nullptr) { |
| 172 | updateAlarmLocked(); |
| 173 | } |
| 174 | } |
| 175 | |
Chenjie Yu | 6736c89 | 2017-11-09 10:50:09 -0800 | [diff] [blame] | 176 | void StatsPullerManagerImpl::RegisterReceiver(int tagId, wp<PullDataReceiver> receiver, |
| 177 | long intervalMs) { |
Chenjie Yu | aa5b201 | 2018-03-21 13:53:15 -0700 | [diff] [blame^] | 178 | AutoMutex _l(mLock); |
Chenjie Yu | 6736c89 | 2017-11-09 10:50:09 -0800 | [diff] [blame] | 179 | auto& receivers = mReceivers[tagId]; |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 180 | for (auto it = receivers.begin(); it != receivers.end(); it++) { |
Chenjie Yu | 6736c89 | 2017-11-09 10:50:09 -0800 | [diff] [blame] | 181 | if (it->receiver == receiver) { |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 182 | VLOG("Receiver already registered of %d", (int)receivers.size()); |
| 183 | return; |
| 184 | } |
| 185 | } |
| 186 | ReceiverInfo receiverInfo; |
| 187 | receiverInfo.receiver = receiver; |
| 188 | receiverInfo.timeInfo.first = intervalMs; |
| 189 | receivers.push_back(receiverInfo); |
| 190 | |
Chenjie Yu | 85ed838 | 2017-12-14 16:48:54 -0800 | [diff] [blame] | 191 | // Round it to the nearest minutes. This is the limit of alarm manager. |
| 192 | // In practice, we should limit it higher. |
| 193 | long roundedIntervalMs = intervalMs/1000/60 * 1000 * 60; |
Chenjie Yu | 83baaa1 | 2018-03-19 10:41:35 -0700 | [diff] [blame] | 194 | // Scheduled pulling should be at least 1 min apart. |
| 195 | // This can be lower in cts tests, in which case we round it to 1 min. |
| 196 | if (roundedIntervalMs < 60 * 1000) { |
| 197 | roundedIntervalMs = 60 * 1000; |
| 198 | } |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 199 | // There is only one alarm for all pulled events. So only set it to the smallest denom. |
Chenjie Yu | 85ed838 | 2017-12-14 16:48:54 -0800 | [diff] [blame] | 200 | if (roundedIntervalMs < mCurrentPullingInterval) { |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 201 | VLOG("Updating pulling interval %ld", intervalMs); |
Chenjie Yu | 85ed838 | 2017-12-14 16:48:54 -0800 | [diff] [blame] | 202 | mCurrentPullingInterval = roundedIntervalMs; |
Chenjie Yu | aa5b201 | 2018-03-21 13:53:15 -0700 | [diff] [blame^] | 203 | updateAlarmLocked(); |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 204 | } |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 205 | VLOG("Puller for tagId %d registered of %d", tagId, (int)receivers.size()); |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Chenjie Yu | 6736c89 | 2017-11-09 10:50:09 -0800 | [diff] [blame] | 208 | void StatsPullerManagerImpl::UnRegisterReceiver(int tagId, wp<PullDataReceiver> receiver) { |
Chenjie Yu | aa5b201 | 2018-03-21 13:53:15 -0700 | [diff] [blame^] | 209 | AutoMutex _l(mLock); |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 210 | if (mReceivers.find(tagId) == mReceivers.end()) { |
| 211 | VLOG("Unknown pull code or no receivers: %d", tagId); |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 212 | return; |
| 213 | } |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 214 | auto& receivers = mReceivers.find(tagId)->second; |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 215 | for (auto it = receivers.begin(); it != receivers.end(); it++) { |
Chenjie Yu | 6736c89 | 2017-11-09 10:50:09 -0800 | [diff] [blame] | 216 | if (receiver == it->receiver) { |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 217 | receivers.erase(it); |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 218 | VLOG("Puller for tagId %d unregistered of %d", tagId, (int)receivers.size()); |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 219 | return; |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
Chenjie Yu | 6736c89 | 2017-11-09 10:50:09 -0800 | [diff] [blame] | 224 | void StatsPullerManagerImpl::OnAlarmFired() { |
Chenjie Yu | aa5b201 | 2018-03-21 13:53:15 -0700 | [diff] [blame^] | 225 | AutoMutex _l(mLock); |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 226 | |
Yangster-mac | 330af58 | 2018-02-08 15:24:38 -0800 | [diff] [blame] | 227 | uint64_t currentTimeMs = getElapsedRealtimeMillis(); |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 228 | |
| 229 | vector<pair<int, vector<ReceiverInfo*>>> needToPull = |
| 230 | vector<pair<int, vector<ReceiverInfo*>>>(); |
| 231 | for (auto& pair : mReceivers) { |
| 232 | vector<ReceiverInfo*> receivers = vector<ReceiverInfo*>(); |
Yao Chen | 93fe3a3 | 2017-11-02 13:52:59 -0700 | [diff] [blame] | 233 | if (pair.second.size() != 0) { |
| 234 | for (auto& receiverInfo : pair.second) { |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 235 | if (receiverInfo.timeInfo.first + receiverInfo.timeInfo.second > currentTimeMs) { |
| 236 | receivers.push_back(&receiverInfo); |
| 237 | } |
| 238 | } |
| 239 | if (receivers.size() > 0) { |
| 240 | needToPull.push_back(make_pair(pair.first, receivers)); |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | for (const auto& pullInfo : needToPull) { |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 246 | vector<shared_ptr<LogEvent>> data; |
| 247 | if (Pull(pullInfo.first, &data)) { |
| 248 | for (const auto& receiverInfo : pullInfo.second) { |
Chenjie Yu | 6736c89 | 2017-11-09 10:50:09 -0800 | [diff] [blame] | 249 | sp<PullDataReceiver> receiverPtr = receiverInfo->receiver.promote(); |
| 250 | if (receiverPtr != nullptr) { |
| 251 | receiverPtr->onDataPulled(data); |
| 252 | receiverInfo->timeInfo.second = currentTimeMs; |
| 253 | } else { |
| 254 | VLOG("receiver already gone."); |
| 255 | } |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 256 | } |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 257 | } |
| 258 | } |
| 259 | } |
| 260 | |
Chenjie Yu | fa22d65 | 2018-02-05 14:37:48 -0800 | [diff] [blame] | 261 | int StatsPullerManagerImpl::ForceClearPullerCache() { |
| 262 | int totalCleared = 0; |
Chenjie Yu | 80f9112 | 2018-01-31 20:24:50 -0800 | [diff] [blame] | 263 | for (const auto& pulledAtom : kAllPullAtomInfo) { |
| 264 | totalCleared += pulledAtom.second.puller->ForceClearCache(); |
Chenjie Yu | e72252b | 2018-02-01 13:19:35 -0800 | [diff] [blame] | 265 | } |
Chenjie Yu | fa22d65 | 2018-02-05 14:37:48 -0800 | [diff] [blame] | 266 | return totalCleared; |
| 267 | } |
| 268 | |
| 269 | int StatsPullerManagerImpl::ClearPullerCacheIfNecessary(long timestampSec) { |
| 270 | int totalCleared = 0; |
Chenjie Yu | 80f9112 | 2018-01-31 20:24:50 -0800 | [diff] [blame] | 271 | for (const auto& pulledAtom : kAllPullAtomInfo) { |
| 272 | totalCleared += pulledAtom.second.puller->ClearCacheIfNecessary(timestampSec); |
Chenjie Yu | fa22d65 | 2018-02-05 14:37:48 -0800 | [diff] [blame] | 273 | } |
| 274 | return totalCleared; |
Chenjie Yu | e72252b | 2018-02-01 13:19:35 -0800 | [diff] [blame] | 275 | } |
| 276 | |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 277 | } // namespace statsd |
| 278 | } // namespace os |
| 279 | } // namespace android |