blob: 615af89e3186f3e12fd5236c3b46b1add40bbc0f [file] [log] [blame]
Chenjie Yu1a317ba2017-10-05 16:05:32 -07001/*
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 Yu80f91122018-01-31 20:24:50 -080017#define DEBUG false
Joe Onorato9fc9edf2017-10-15 20:08:52 -070018#include "Log.h"
Chenjie Yu1a317ba2017-10-05 16:05:32 -070019
Alec Mouri1dc5f1e2019-09-18 21:13:01 -070020#include "StatsPullerManager.h"
21
Tej Singh6a5c9432019-10-11 11:07:06 -070022#include <android/os/IPullAtomCallback.h>
Chenjie Yu1a317ba2017-10-05 16:05:32 -070023#include <android/os/IStatsCompanionService.h>
Tej Singha0c89dd2019-01-25 16:39:18 -080024#include <android/os/IStatsPullerCallback.h>
David Chen1481fe12017-10-16 13:16:34 -070025#include <cutils/log.h>
Chenjie Yu1a0a9412018-03-28 10:07:22 -070026#include <math.h>
Chenjie Yu3b3adcd2018-04-18 16:25:36 -070027#include <stdint.h>
Alec Mouri1dc5f1e2019-09-18 21:13:01 -070028
David Chen1481fe12017-10-16 13:16:34 -070029#include <algorithm>
Alec Mouri1dc5f1e2019-09-18 21:13:01 -070030#include <iostream>
31
Chenjie Yu1a0a9412018-03-28 10:07:22 -070032#include "../StatsService.h"
Chenjie Yuaa5b2012018-03-21 13:53:15 -070033#include "../logd/LogEvent.h"
34#include "../stats_log_util.h"
35#include "../statscompanion_util.h"
Mark Tabry9dc13572019-11-06 13:42:30 -080036#include "CarStatsPuller.h"
Yiwei Zhang7e633032019-03-01 17:25:27 -080037#include "GpuStatsPuller.h"
Bookatz92da2832018-11-01 18:10:03 -070038#include "PowerStatsPuller.h"
Tej Singh40298312018-02-16 00:15:09 -080039#include "ResourceHealthManagerPuller.h"
Tej Singha0c89dd2019-01-25 16:39:18 -080040#include "StatsCallbackPuller.h"
Tej Singh6a5c9432019-10-11 11:07:06 -070041#include "StatsCallbackPullerDeprecated.h"
Chenjie Yu97dbb202019-02-13 16:42:04 -080042#include "StatsCompanionServicePuller.h"
Tej Singhbf972d92018-01-10 20:51:13 -080043#include "SubsystemSleepStatePuller.h"
Alec Mouri1dc5f1e2019-09-18 21:13:01 -070044#include "SurfaceflingerStatsPuller.h"
Chenjie Yu97dbb202019-02-13 16:42:04 -080045#include "TrainInfoPuller.h"
Chenjie Yu5305e1d2017-10-31 13:49:36 -070046#include "statslog.h"
David Chen1481fe12017-10-16 13:16:34 -070047
Yao Chen93fe3a32017-11-02 13:52:59 -070048using std::make_shared;
Chenjie Yu5305e1d2017-10-31 13:49:36 -070049using std::map;
Yao Chen93fe3a32017-11-02 13:52:59 -070050using std::shared_ptr;
Chenjie Yub3dda412017-10-24 13:41:59 -070051using std::string;
52using std::vector;
Chenjie Yu6736c892017-11-09 10:50:09 -080053using std::list;
Chenjie Yu1a317ba2017-10-05 16:05:32 -070054
55namespace android {
56namespace os {
57namespace statsd {
58
Chenjie Yu3b3adcd2018-04-18 16:25:36 -070059// Values smaller than this may require to update the alarm.
60const int64_t NO_ALARM_UPDATE = INT64_MAX;
61
Tej Singh6a5c9432019-10-11 11:07:06 -070062std::map<PullerKey, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
Chenjie Yufeba3092018-02-08 14:33:37 -080063 // wifi_bytes_transfer
Tej Singh6a5c9432019-10-11 11:07:06 -070064 {{.atomTag = android::util::WIFI_BYTES_TRANSFER},
Chenjie Yu0bd73db2018-12-16 07:37:04 -080065 {.additiveFields = {2, 3, 4, 5},
66 .puller = new StatsCompanionServicePuller(android::util::WIFI_BYTES_TRANSFER)}},
Chenjie Yufeba3092018-02-08 14:33:37 -080067 // wifi_bytes_transfer_by_fg_bg
Tej Singh6a5c9432019-10-11 11:07:06 -070068 {{.atomTag = android::util::WIFI_BYTES_TRANSFER_BY_FG_BG},
Chenjie Yu0bd73db2018-12-16 07:37:04 -080069 {.additiveFields = {3, 4, 5, 6},
70 .puller = new StatsCompanionServicePuller(android::util::WIFI_BYTES_TRANSFER_BY_FG_BG)}},
Chenjie Yufeba3092018-02-08 14:33:37 -080071 // mobile_bytes_transfer
Tej Singh6a5c9432019-10-11 11:07:06 -070072 {{.atomTag = android::util::MOBILE_BYTES_TRANSFER},
Chenjie Yu0bd73db2018-12-16 07:37:04 -080073 {.additiveFields = {2, 3, 4, 5},
74 .puller = new StatsCompanionServicePuller(android::util::MOBILE_BYTES_TRANSFER)}},
Chenjie Yufeba3092018-02-08 14:33:37 -080075 // mobile_bytes_transfer_by_fg_bg
Tej Singh6a5c9432019-10-11 11:07:06 -070076 {{.atomTag = android::util::MOBILE_BYTES_TRANSFER_BY_FG_BG},
Chenjie Yu0bd73db2018-12-16 07:37:04 -080077 {.additiveFields = {3, 4, 5, 6},
78 .puller =
79 new StatsCompanionServicePuller(android::util::MOBILE_BYTES_TRANSFER_BY_FG_BG)}},
Chenjie Yufeba3092018-02-08 14:33:37 -080080 // bluetooth_bytes_transfer
Tej Singh6a5c9432019-10-11 11:07:06 -070081 {{.atomTag = android::util::BLUETOOTH_BYTES_TRANSFER},
Chenjie Yu0bd73db2018-12-16 07:37:04 -080082 {.additiveFields = {2, 3},
83 .puller = new StatsCompanionServicePuller(android::util::BLUETOOTH_BYTES_TRANSFER)}},
Chenjie Yufeba3092018-02-08 14:33:37 -080084 // kernel_wakelock
Tej Singh6a5c9432019-10-11 11:07:06 -070085 {{.atomTag = android::util::KERNEL_WAKELOCK},
Chenjie Yu0bd73db2018-12-16 07:37:04 -080086 {.puller = new StatsCompanionServicePuller(android::util::KERNEL_WAKELOCK)}},
Chenjie Yufeba3092018-02-08 14:33:37 -080087 // subsystem_sleep_state
Tej Singh6a5c9432019-10-11 11:07:06 -070088 {{.atomTag = android::util::SUBSYSTEM_SLEEP_STATE},
89 {.puller = new SubsystemSleepStatePuller()}},
Bookatz92da2832018-11-01 18:10:03 -070090 // on_device_power_measurement
Tej Singh6a5c9432019-10-11 11:07:06 -070091 {{.atomTag = android::util::ON_DEVICE_POWER_MEASUREMENT},
92 {.puller = new PowerStatsPuller()}},
Chenjie Yufeba3092018-02-08 14:33:37 -080093 // cpu_time_per_freq
Tej Singh6a5c9432019-10-11 11:07:06 -070094 {{.atomTag = android::util::CPU_TIME_PER_FREQ},
Chenjie Yu0bd73db2018-12-16 07:37:04 -080095 {.additiveFields = {3},
96 .puller = new StatsCompanionServicePuller(android::util::CPU_TIME_PER_FREQ)}},
Chenjie Yufeba3092018-02-08 14:33:37 -080097 // cpu_time_per_uid
Tej Singh6a5c9432019-10-11 11:07:06 -070098 {{.atomTag = android::util::CPU_TIME_PER_UID},
Chenjie Yu0bd73db2018-12-16 07:37:04 -080099 {.additiveFields = {2, 3},
100 .puller = new StatsCompanionServicePuller(android::util::CPU_TIME_PER_UID)}},
Chenjie Yufeba3092018-02-08 14:33:37 -0800101 // cpu_time_per_uid_freq
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700102 // the throttling is 3sec, handled in
103 // frameworks/base/core/java/com/android/internal/os/KernelCpuProcReader
Tej Singh6a5c9432019-10-11 11:07:06 -0700104 {{.atomTag = android::util::CPU_TIME_PER_UID_FREQ},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800105 {.additiveFields = {4},
106 .puller = new StatsCompanionServicePuller(android::util::CPU_TIME_PER_UID_FREQ)}},
Chenjie Yuec676612018-03-07 09:19:17 -0800107 // cpu_active_time
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700108 // the throttling is 3sec, handled in
109 // frameworks/base/core/java/com/android/internal/os/KernelCpuProcReader
Tej Singh6a5c9432019-10-11 11:07:06 -0700110 {{.atomTag = android::util::CPU_ACTIVE_TIME},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800111 {.additiveFields = {2},
112 .puller = new StatsCompanionServicePuller(android::util::CPU_ACTIVE_TIME)}},
Chenjie Yuec676612018-03-07 09:19:17 -0800113 // cpu_cluster_time
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700114 // the throttling is 3sec, handled in
115 // frameworks/base/core/java/com/android/internal/os/KernelCpuProcReader
Tej Singh6a5c9432019-10-11 11:07:06 -0700116 {{.atomTag = android::util::CPU_CLUSTER_TIME},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800117 {.additiveFields = {3},
118 .puller = new StatsCompanionServicePuller(android::util::CPU_CLUSTER_TIME)}},
Chenjie Yufeba3092018-02-08 14:33:37 -0800119 // wifi_activity_energy_info
Tej Singh6a5c9432019-10-11 11:07:06 -0700120 {{.atomTag = android::util::WIFI_ACTIVITY_INFO},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800121 {.puller = new StatsCompanionServicePuller(android::util::WIFI_ACTIVITY_INFO)}},
Chenjie Yufeba3092018-02-08 14:33:37 -0800122 // modem_activity_info
Tej Singh6a5c9432019-10-11 11:07:06 -0700123 {{.atomTag = android::util::MODEM_ACTIVITY_INFO},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800124 {.puller = new StatsCompanionServicePuller(android::util::MODEM_ACTIVITY_INFO)}},
Chenjie Yufeba3092018-02-08 14:33:37 -0800125 // bluetooth_activity_info
Tej Singh6a5c9432019-10-11 11:07:06 -0700126 {{.atomTag = android::util::BLUETOOTH_ACTIVITY_INFO},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800127 {.puller = new StatsCompanionServicePuller(android::util::BLUETOOTH_ACTIVITY_INFO)}},
Chenjie Yufeba3092018-02-08 14:33:37 -0800128 // system_elapsed_realtime
Tej Singh6a5c9432019-10-11 11:07:06 -0700129 {{.atomTag = android::util::SYSTEM_ELAPSED_REALTIME},
Nick Desaulniers691e1a02019-10-10 13:08:34 -0700130 {.coolDownNs = NS_PER_SEC,
131 .puller = new StatsCompanionServicePuller(android::util::SYSTEM_ELAPSED_REALTIME),
132 .pullTimeoutNs = NS_PER_SEC / 2,
133 }},
Chenjie Yufeba3092018-02-08 14:33:37 -0800134 // system_uptime
Tej Singh6a5c9432019-10-11 11:07:06 -0700135 {{.atomTag = android::util::SYSTEM_UPTIME},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800136 {.puller = new StatsCompanionServicePuller(android::util::SYSTEM_UPTIME)}},
Chenjie Yufeba3092018-02-08 14:33:37 -0800137 // remaining_battery_capacity
Tej Singh6a5c9432019-10-11 11:07:06 -0700138 {{.atomTag = android::util::REMAINING_BATTERY_CAPACITY},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800139 {.puller = new ResourceHealthManagerPuller(android::util::REMAINING_BATTERY_CAPACITY)}},
Chenjie Yufeba3092018-02-08 14:33:37 -0800140 // full_battery_capacity
Tej Singh6a5c9432019-10-11 11:07:06 -0700141 {{.atomTag = android::util::FULL_BATTERY_CAPACITY},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800142 {.puller = new ResourceHealthManagerPuller(android::util::FULL_BATTERY_CAPACITY)}},
Bookatz17f0d8a2018-09-13 12:56:32 -0700143 // battery_voltage
Tej Singh6a5c9432019-10-11 11:07:06 -0700144 {{.atomTag = android::util::BATTERY_VOLTAGE},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800145 {.puller = new ResourceHealthManagerPuller(android::util::BATTERY_VOLTAGE)}},
Maggie White8735b852019-01-18 11:40:49 -0800146 // battery_level
Tej Singh6a5c9432019-10-11 11:07:06 -0700147 {{.atomTag = android::util::BATTERY_LEVEL},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800148 {.puller = new ResourceHealthManagerPuller(android::util::BATTERY_LEVEL)}},
Maggie White8735b852019-01-18 11:40:49 -0800149 // battery_cycle_count
Tej Singh6a5c9432019-10-11 11:07:06 -0700150 {{.atomTag = android::util::BATTERY_CYCLE_COUNT},
Maggie White8735b852019-01-18 11:40:49 -0800151 {.puller = new ResourceHealthManagerPuller(android::util::BATTERY_CYCLE_COUNT)}},
Rajeev Kumar22d92b72018-02-07 18:38:36 -0800152 // process_memory_state
Tej Singh6a5c9432019-10-11 11:07:06 -0700153 {{.atomTag = android::util::PROCESS_MEMORY_STATE},
Rafal Slawik203c3db2019-09-25 19:53:01 +0100154 {.additiveFields = {4, 5, 6, 7, 8},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800155 .puller = new StatsCompanionServicePuller(android::util::PROCESS_MEMORY_STATE)}},
Rafal Slawikd4e87572019-03-12 13:08:38 +0000156 // process_memory_high_water_mark
Tej Singh6a5c9432019-10-11 11:07:06 -0700157 {{.atomTag = android::util::PROCESS_MEMORY_HIGH_WATER_MARK},
Rafal Slawik203c3db2019-09-25 19:53:01 +0100158 {.puller =
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800159 new StatsCompanionServicePuller(android::util::PROCESS_MEMORY_HIGH_WATER_MARK)}},
Rafal Slawik7efcefb2019-09-20 11:16:20 +0100160 // process_memory_snapshot
Tej Singh6a5c9432019-10-11 11:07:06 -0700161 {{.atomTag = android::util::PROCESS_MEMORY_SNAPSHOT},
Rafal Slawik7efcefb2019-09-20 11:16:20 +0100162 {.puller = new StatsCompanionServicePuller(android::util::PROCESS_MEMORY_SNAPSHOT)}},
Rafal Slawikd4e87572019-03-12 13:08:38 +0000163 // system_ion_heap_size
Tej Singh6a5c9432019-10-11 11:07:06 -0700164 {{.atomTag = android::util::SYSTEM_ION_HEAP_SIZE},
Rafal Slawikd4e87572019-03-12 13:08:38 +0000165 {.puller = new StatsCompanionServicePuller(android::util::SYSTEM_ION_HEAP_SIZE)}},
Rafal Slawik77987ed2019-06-17 12:28:23 +0100166 // process_system_ion_heap_size
Tej Singh6a5c9432019-10-11 11:07:06 -0700167 {{.atomTag = android::util::PROCESS_SYSTEM_ION_HEAP_SIZE},
Rafal Slawik77987ed2019-06-17 12:28:23 +0100168 {.puller = new StatsCompanionServicePuller(android::util::PROCESS_SYSTEM_ION_HEAP_SIZE)}},
Tej Singh40298312018-02-16 00:15:09 -0800169 // temperature
Tej Singh6a5c9432019-10-11 11:07:06 -0700170 {{.atomTag = android::util::TEMPERATURE},
Chenjie Yu97dbb202019-02-13 16:42:04 -0800171 {.puller = new StatsCompanionServicePuller(android::util::TEMPERATURE)}},
Maggie White442b6312019-04-05 16:26:44 -0700172 // cooling_device
Tej Singh6a5c9432019-10-11 11:07:06 -0700173 {{.atomTag = android::util::COOLING_DEVICE},
Maggie White442b6312019-04-05 16:26:44 -0700174 {.puller = new StatsCompanionServicePuller(android::util::COOLING_DEVICE)}},
Olivier Gaillard00bfb1b2018-07-10 11:25:09 +0100175 // binder_calls
Tej Singh6a5c9432019-10-11 11:07:06 -0700176 {{.atomTag = android::util::BINDER_CALLS},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800177 {.additiveFields = {4, 5, 6, 8, 12},
178 .puller = new StatsCompanionServicePuller(android::util::BINDER_CALLS)}},
Olivier Gaillard6f52d152018-07-25 12:13:12 +0100179 // binder_calls_exceptions
Tej Singh6a5c9432019-10-11 11:07:06 -0700180 {{.atomTag = android::util::BINDER_CALLS_EXCEPTIONS},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800181 {.puller = new StatsCompanionServicePuller(android::util::BINDER_CALLS_EXCEPTIONS)}},
Marcin Oczeretkod8cc8592018-08-22 16:07:36 +0100182 // looper_stats
Tej Singh6a5c9432019-10-11 11:07:06 -0700183 {{.atomTag = android::util::LOOPER_STATS},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800184 {.additiveFields = {5, 6, 7, 8, 9},
185 .puller = new StatsCompanionServicePuller(android::util::LOOPER_STATS)}},
Tej Singh86dc9db2018-09-06 00:39:57 +0000186 // Disk Stats
Tej Singh6a5c9432019-10-11 11:07:06 -0700187 {{.atomTag = android::util::DISK_STATS},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800188 {.puller = new StatsCompanionServicePuller(android::util::DISK_STATS)}},
Tej Singh86dc9db2018-09-06 00:39:57 +0000189 // Directory usage
Tej Singh6a5c9432019-10-11 11:07:06 -0700190 {{.atomTag = android::util::DIRECTORY_USAGE},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800191 {.puller = new StatsCompanionServicePuller(android::util::DIRECTORY_USAGE)}},
Tej Singh86dc9db2018-09-06 00:39:57 +0000192 // Size of app's code, data, and cache
Tej Singh6a5c9432019-10-11 11:07:06 -0700193 {{.atomTag = android::util::APP_SIZE},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800194 {.puller = new StatsCompanionServicePuller(android::util::APP_SIZE)}},
Tej Singh86dc9db2018-09-06 00:39:57 +0000195 // Size of specific categories of files. Eg. Music.
Tej Singh6a5c9432019-10-11 11:07:06 -0700196 {{.atomTag = android::util::CATEGORY_SIZE},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800197 {.puller = new StatsCompanionServicePuller(android::util::CATEGORY_SIZE)}},
Kevin Chyn6ecc5702019-01-28 12:00:37 -0800198 // Number of fingerprints enrolled for each user.
Tej Singh6a5c9432019-10-11 11:07:06 -0700199 {{.atomTag = android::util::NUM_FINGERPRINTS_ENROLLED},
Kevin Chyn1741a072019-01-17 11:54:40 -0800200 {.puller = new StatsCompanionServicePuller(android::util::NUM_FINGERPRINTS_ENROLLED)}},
Kevin Chyn6ecc5702019-01-28 12:00:37 -0800201 // Number of faces enrolled for each user.
Tej Singh6a5c9432019-10-11 11:07:06 -0700202 {{.atomTag = android::util::NUM_FACES_ENROLLED},
Kevin Chyn6ecc5702019-01-28 12:00:37 -0800203 {.puller = new StatsCompanionServicePuller(android::util::NUM_FACES_ENROLLED)}},
Chenjie Yu2c0d83d2018-09-02 06:37:08 -0700204 // ProcStats.
Tej Singh6a5c9432019-10-11 11:07:06 -0700205 {{.atomTag = android::util::PROC_STATS},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800206 {.puller = new StatsCompanionServicePuller(android::util::PROC_STATS)}},
Chenjie Yub52779e2018-10-05 12:03:36 -0700207 // ProcStatsPkgProc.
Tej Singh6a5c9432019-10-11 11:07:06 -0700208 {{.atomTag = android::util::PROC_STATS_PKG_PROC},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800209 {.puller = new StatsCompanionServicePuller(android::util::PROC_STATS_PKG_PROC)}},
Tej Singhe7726dc2018-09-21 11:42:12 -0700210 // Disk I/O stats per uid.
Tej Singh6a5c9432019-10-11 11:07:06 -0700211 {{.atomTag = android::util::DISK_IO},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800212 {.additiveFields = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
213 .coolDownNs = 3 * NS_PER_SEC,
214 .puller = new StatsCompanionServicePuller(android::util::DISK_IO)}},
Chenjie Yuab530202018-09-26 12:39:20 -0700215 // PowerProfile constants for power model calculations.
Tej Singh6a5c9432019-10-11 11:07:06 -0700216 {{.atomTag = android::util::POWER_PROFILE},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800217 {.puller = new StatsCompanionServicePuller(android::util::POWER_PROFILE)}},
Yangster-mac308ea0c2018-10-22 13:10:25 -0700218 // Process cpu stats. Min cool-down is 5 sec, inline with what AcitivityManagerService uses.
Tej Singh6a5c9432019-10-11 11:07:06 -0700219 {{.atomTag = android::util::PROCESS_CPU_TIME},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800220 {.coolDownNs = 5 * NS_PER_SEC /* min cool-down in seconds*/,
221 .puller = new StatsCompanionServicePuller(android::util::PROCESS_CPU_TIME)}},
Tej Singh6a5c9432019-10-11 11:07:06 -0700222 {{.atomTag = android::util::CPU_TIME_PER_THREAD_FREQ},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800223 {.additiveFields = {7, 9, 11, 13, 15, 17, 19, 21},
224 .puller = new StatsCompanionServicePuller(android::util::CPU_TIME_PER_THREAD_FREQ)}},
Bookatz75ee6042018-11-09 12:27:37 -0800225 // DeviceCalculatedPowerUse.
Tej Singh6a5c9432019-10-11 11:07:06 -0700226 {{.atomTag = android::util::DEVICE_CALCULATED_POWER_USE},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800227 {.puller = new StatsCompanionServicePuller(android::util::DEVICE_CALCULATED_POWER_USE)}},
Bookatz75ee6042018-11-09 12:27:37 -0800228 // DeviceCalculatedPowerBlameUid.
Tej Singh6a5c9432019-10-11 11:07:06 -0700229 {{.atomTag = android::util::DEVICE_CALCULATED_POWER_BLAME_UID},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800230 {.puller = new StatsCompanionServicePuller(
231 android::util::DEVICE_CALCULATED_POWER_BLAME_UID)}},
Bookatz75ee6042018-11-09 12:27:37 -0800232 // DeviceCalculatedPowerBlameOther.
Tej Singh6a5c9432019-10-11 11:07:06 -0700233 {{.atomTag = android::util::DEVICE_CALCULATED_POWER_BLAME_OTHER},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800234 {.puller = new StatsCompanionServicePuller(
235 android::util::DEVICE_CALCULATED_POWER_BLAME_OTHER)}},
Olivier Gaillard18d452202019-01-22 15:03:41 +0000236 // DebugElapsedClock.
Tej Singh6a5c9432019-10-11 11:07:06 -0700237 {{.atomTag = android::util::DEBUG_ELAPSED_CLOCK},
Olivier Gaillard18d452202019-01-22 15:03:41 +0000238 {.additiveFields = {1, 2, 3, 4},
239 .puller = new StatsCompanionServicePuller(android::util::DEBUG_ELAPSED_CLOCK)}},
240 // DebugFailingElapsedClock.
Tej Singh6a5c9432019-10-11 11:07:06 -0700241 {{.atomTag = android::util::DEBUG_FAILING_ELAPSED_CLOCK},
Olivier Gaillard18d452202019-01-22 15:03:41 +0000242 {.additiveFields = {1, 2, 3, 4},
243 .puller = new StatsCompanionServicePuller(android::util::DEBUG_FAILING_ELAPSED_CLOCK)}},
Bookatz366a4432018-11-20 09:42:33 -0800244 // BuildInformation.
Tej Singh6a5c9432019-10-11 11:07:06 -0700245 {{.atomTag = android::util::BUILD_INFORMATION},
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800246 {.puller = new StatsCompanionServicePuller(android::util::BUILD_INFORMATION)}},
Philip P. Moltmann70b42ae2019-01-29 16:24:19 -0800247 // RoleHolder.
Tej Singh6a5c9432019-10-11 11:07:06 -0700248 {{.atomTag = android::util::ROLE_HOLDER},
Philip P. Moltmann70b42ae2019-01-29 16:24:19 -0800249 {.puller = new StatsCompanionServicePuller(android::util::ROLE_HOLDER)}},
Philip P. Moltmannf21a3502019-01-30 09:53:04 -0800250 // PermissionState.
Tej Singh6a5c9432019-10-11 11:07:06 -0700251 {{.atomTag = android::util::DANGEROUS_PERMISSION_STATE},
Philip P. Moltmannf21a3502019-01-30 09:53:04 -0800252 {.puller = new StatsCompanionServicePuller(android::util::DANGEROUS_PERMISSION_STATE)}},
Chenjie Yu97dbb202019-02-13 16:42:04 -0800253 // TrainInfo.
Tej Singh6a5c9432019-10-11 11:07:06 -0700254 {{.atomTag = android::util::TRAIN_INFO}, {.puller = new TrainInfoPuller()}},
Neil Fullerdb14b482019-02-05 19:44:44 +0000255 // TimeZoneDataInfo.
Tej Singh6a5c9432019-10-11 11:07:06 -0700256 {{.atomTag = android::util::TIME_ZONE_DATA_INFO},
Neil Fullerdb14b482019-02-05 19:44:44 +0000257 {.puller = new StatsCompanionServicePuller(android::util::TIME_ZONE_DATA_INFO)}},
Carmen Agimof12dec122019-03-06 16:14:38 +0000258 // ExternalStorageInfo
Tej Singh6a5c9432019-10-11 11:07:06 -0700259 {{.atomTag = android::util::EXTERNAL_STORAGE_INFO},
Carmen Agimof12dec122019-03-06 16:14:38 +0000260 {.puller = new StatsCompanionServicePuller(android::util::EXTERNAL_STORAGE_INFO)}},
Yiwei Zhang7e633032019-03-01 17:25:27 -0800261 // GpuStatsGlobalInfo
Tej Singh6a5c9432019-10-11 11:07:06 -0700262 {{.atomTag = android::util::GPU_STATS_GLOBAL_INFO},
Yiwei Zhang7e633032019-03-01 17:25:27 -0800263 {.puller = new GpuStatsPuller(android::util::GPU_STATS_GLOBAL_INFO)}},
Yiwei Zhang4fb92892019-03-04 14:29:25 -0800264 // GpuStatsAppInfo
Tej Singh6a5c9432019-10-11 11:07:06 -0700265 {{.atomTag = android::util::GPU_STATS_APP_INFO},
Yiwei Zhang4fb92892019-03-04 14:29:25 -0800266 {.puller = new GpuStatsPuller(android::util::GPU_STATS_APP_INFO)}},
Carmen Agimofa769c152019-03-04 14:39:14 +0000267 // AppsOnExternalStorageInfo
Tej Singh6a5c9432019-10-11 11:07:06 -0700268 {{.atomTag = android::util::APPS_ON_EXTERNAL_STORAGE_INFO},
Carmen Agimofa769c152019-03-04 14:39:14 +0000269 {.puller = new StatsCompanionServicePuller(android::util::APPS_ON_EXTERNAL_STORAGE_INFO)}},
joshmccloskey34c1f8e2019-04-11 14:06:43 -0700270 // Face Settings
Tej Singh6a5c9432019-10-11 11:07:06 -0700271 {{.atomTag = android::util::FACE_SETTINGS},
joshmccloskey34c1f8e2019-04-11 14:06:43 -0700272 {.puller = new StatsCompanionServicePuller(android::util::FACE_SETTINGS)}},
Martijn Coenencd95d462019-04-25 17:09:45 +0200273 // App ops
Tej Singh6a5c9432019-10-11 11:07:06 -0700274 {{.atomTag = android::util::APP_OPS},
Martijn Coenencd95d462019-04-25 17:09:45 +0200275 {.puller = new StatsCompanionServicePuller(android::util::APP_OPS)}},
Alec Mouri1dc5f1e2019-09-18 21:13:01 -0700276 // SurfaceflingerStatsGlobalInfo
Tej Singh6a5c9432019-10-11 11:07:06 -0700277 {{.atomTag = android::util::SURFACEFLINGER_STATS_GLOBAL_INFO},
Alec Mouri1dc5f1e2019-09-18 21:13:01 -0700278 {.puller =
279 new SurfaceflingerStatsPuller(android::util::SURFACEFLINGER_STATS_GLOBAL_INFO)}},
Mark Tabry9dc13572019-11-06 13:42:30 -0800280 // VmsClientStats
Tej Singh6a5c9432019-10-11 11:07:06 -0700281 {{.atomTag = android::util::VMS_CLIENT_STATS},
Mark Tabry9dc13572019-11-06 13:42:30 -0800282 {.additiveFields = {5, 6, 7, 8, 9, 10},
283 .puller = new CarStatsPuller(android::util::VMS_CLIENT_STATS)}},
Chris Wrencdea3b72019-11-22 16:58:17 -0500284 // NotiifcationRemoteViews.
285 {{.atomTag = android::util::NOTIFICATION_REMOTE_VIEWS},
286 {.puller = new StatsCompanionServicePuller(android::util::NOTIFICATION_REMOTE_VIEWS)}},
Chenjie Yu2c0d83d2018-09-02 06:37:08 -0700287};
Chenjie Yu80f91122018-01-31 20:24:50 -0800288
Chenjie Yue2219202018-06-08 10:07:51 -0700289StatsPullerManager::StatsPullerManager() : mNextPullTimeNs(NO_ALARM_UPDATE) {
Chenjie Yu1a317ba2017-10-05 16:05:32 -0700290}
291
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800292bool StatsPullerManager::Pull(int tagId, vector<shared_ptr<LogEvent>>* data) {
Tej Singh484524a2018-02-01 15:10:05 -0800293 VLOG("Initiating pulling %d", tagId);
Chenjie Yub3dda412017-10-24 13:41:59 -0700294
Tej Singh6a5c9432019-10-11 11:07:06 -0700295 if (kAllPullAtomInfo.find({.atomTag = tagId}) != kAllPullAtomInfo.end()) {
296 bool ret = kAllPullAtomInfo.find({.atomTag = tagId})->second.puller->Pull(data);
Tej Singh484524a2018-02-01 15:10:05 -0800297 VLOG("pulled %d items", (int)data->size());
Misha Wagner1eee2212019-01-22 11:47:11 +0000298 if (!ret) {
299 StatsdStats::getInstance().notePullFailed(tagId);
300 }
Tej Singh484524a2018-02-01 15:10:05 -0800301 return ret;
Yao Chen93fe3a32017-11-02 13:52:59 -0700302 } else {
Tej Singh484524a2018-02-01 15:10:05 -0800303 VLOG("Unknown tagId %d", tagId);
Yao Chen93fe3a32017-11-02 13:52:59 -0700304 return false; // Return early since we don't know what to pull.
305 }
306}
Chenjie Yub3dda412017-10-24 13:41:59 -0700307
Chenjie Yue2219202018-06-08 10:07:51 -0700308bool StatsPullerManager::PullerForMatcherExists(int tagId) const {
Tej Singhde473b52019-04-10 19:25:03 -0700309 // Vendor pulled atoms might be registered after we parse the config.
Tej Singh6a5c9432019-10-11 11:07:06 -0700310 return isVendorPulledAtom(tagId) ||
311 kAllPullAtomInfo.find({.atomTag = tagId}) != kAllPullAtomInfo.end();
Chenjie Yub3dda412017-10-24 13:41:59 -0700312}
313
Chenjie Yue2219202018-06-08 10:07:51 -0700314void StatsPullerManager::updateAlarmLocked() {
Chenjie Yu3b3adcd2018-04-18 16:25:36 -0700315 if (mNextPullTimeNs == NO_ALARM_UPDATE) {
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700316 VLOG("No need to set alarms. Skipping");
317 return;
318 }
319
Chenjie Yuaa5b2012018-03-21 13:53:15 -0700320 sp<IStatsCompanionService> statsCompanionServiceCopy = mStatsCompanionService;
321 if (statsCompanionServiceCopy != nullptr) {
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700322 statsCompanionServiceCopy->setPullingAlarm(mNextPullTimeNs / 1000000);
Chenjie Yuaa5b2012018-03-21 13:53:15 -0700323 } else {
324 VLOG("StatsCompanionService not available. Alarm not set.");
325 }
326 return;
327}
328
Chenjie Yue2219202018-06-08 10:07:51 -0700329void StatsPullerManager::SetStatsCompanionService(
Chenjie Yuaa5b2012018-03-21 13:53:15 -0700330 sp<IStatsCompanionService> statsCompanionService) {
331 AutoMutex _l(mLock);
332 sp<IStatsCompanionService> tmpForLock = mStatsCompanionService;
333 mStatsCompanionService = statsCompanionService;
334 for (const auto& pulledAtom : kAllPullAtomInfo) {
335 pulledAtom.second.puller->SetStatsCompanionService(statsCompanionService);
336 }
337 if (mStatsCompanionService != nullptr) {
338 updateAlarmLocked();
339 }
340}
341
Chenjie Yue2219202018-06-08 10:07:51 -0700342void StatsPullerManager::RegisterReceiver(int tagId, wp<PullDataReceiver> receiver,
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700343 int64_t nextPullTimeNs, int64_t intervalNs) {
Chenjie Yuaa5b2012018-03-21 13:53:15 -0700344 AutoMutex _l(mLock);
Chenjie Yu6736c892017-11-09 10:50:09 -0800345 auto& receivers = mReceivers[tagId];
Chenjie Yub3dda412017-10-24 13:41:59 -0700346 for (auto it = receivers.begin(); it != receivers.end(); it++) {
Chenjie Yu6736c892017-11-09 10:50:09 -0800347 if (it->receiver == receiver) {
Chenjie Yub3dda412017-10-24 13:41:59 -0700348 VLOG("Receiver already registered of %d", (int)receivers.size());
349 return;
350 }
351 }
352 ReceiverInfo receiverInfo;
353 receiverInfo.receiver = receiver;
Chenjie Yub3dda412017-10-24 13:41:59 -0700354
Chenjie Yu85ed8382017-12-14 16:48:54 -0800355 // Round it to the nearest minutes. This is the limit of alarm manager.
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700356 // In practice, we should always have larger buckets.
357 int64_t roundedIntervalNs = intervalNs / NS_PER_SEC / 60 * NS_PER_SEC * 60;
Chenjie Yu83baaa12018-03-19 10:41:35 -0700358 // Scheduled pulling should be at least 1 min apart.
359 // This can be lower in cts tests, in which case we round it to 1 min.
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700360 if (roundedIntervalNs < 60 * (int64_t)NS_PER_SEC) {
361 roundedIntervalNs = 60 * (int64_t)NS_PER_SEC;
Chenjie Yu83baaa12018-03-19 10:41:35 -0700362 }
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700363
364 receiverInfo.intervalNs = roundedIntervalNs;
365 receiverInfo.nextPullTimeNs = nextPullTimeNs;
366 receivers.push_back(receiverInfo);
367
Chenjie Yub3dda412017-10-24 13:41:59 -0700368 // There is only one alarm for all pulled events. So only set it to the smallest denom.
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700369 if (nextPullTimeNs < mNextPullTimeNs) {
370 VLOG("Updating next pull time %lld", (long long)mNextPullTimeNs);
371 mNextPullTimeNs = nextPullTimeNs;
Chenjie Yuaa5b2012018-03-21 13:53:15 -0700372 updateAlarmLocked();
Chenjie Yub3dda412017-10-24 13:41:59 -0700373 }
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700374 VLOG("Puller for tagId %d registered of %d", tagId, (int)receivers.size());
Chenjie Yub3dda412017-10-24 13:41:59 -0700375}
376
Chenjie Yue2219202018-06-08 10:07:51 -0700377void StatsPullerManager::UnRegisterReceiver(int tagId, wp<PullDataReceiver> receiver) {
Chenjie Yuaa5b2012018-03-21 13:53:15 -0700378 AutoMutex _l(mLock);
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700379 if (mReceivers.find(tagId) == mReceivers.end()) {
380 VLOG("Unknown pull code or no receivers: %d", tagId);
Chenjie Yub3dda412017-10-24 13:41:59 -0700381 return;
382 }
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700383 auto& receivers = mReceivers.find(tagId)->second;
Chenjie Yub3dda412017-10-24 13:41:59 -0700384 for (auto it = receivers.begin(); it != receivers.end(); it++) {
Chenjie Yu6736c892017-11-09 10:50:09 -0800385 if (receiver == it->receiver) {
Chenjie Yub3dda412017-10-24 13:41:59 -0700386 receivers.erase(it);
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700387 VLOG("Puller for tagId %d unregistered of %d", tagId, (int)receivers.size());
Chenjie Yub3dda412017-10-24 13:41:59 -0700388 return;
389 }
390 }
391}
392
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800393void StatsPullerManager::OnAlarmFired(int64_t elapsedTimeNs) {
Chenjie Yuaa5b2012018-03-21 13:53:15 -0700394 AutoMutex _l(mLock);
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800395 int64_t wallClockNs = getWallClockNs();
Chenjie Yub3dda412017-10-24 13:41:59 -0700396
Chenjie Yu3b3adcd2018-04-18 16:25:36 -0700397 int64_t minNextPullTimeNs = NO_ALARM_UPDATE;
Chenjie Yub3dda412017-10-24 13:41:59 -0700398
399 vector<pair<int, vector<ReceiverInfo*>>> needToPull =
400 vector<pair<int, vector<ReceiverInfo*>>>();
401 for (auto& pair : mReceivers) {
402 vector<ReceiverInfo*> receivers = vector<ReceiverInfo*>();
Yao Chen93fe3a32017-11-02 13:52:59 -0700403 if (pair.second.size() != 0) {
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700404 for (ReceiverInfo& receiverInfo : pair.second) {
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800405 if (receiverInfo.nextPullTimeNs <= elapsedTimeNs) {
Chenjie Yub3dda412017-10-24 13:41:59 -0700406 receivers.push_back(&receiverInfo);
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700407 } else {
408 if (receiverInfo.nextPullTimeNs < minNextPullTimeNs) {
409 minNextPullTimeNs = receiverInfo.nextPullTimeNs;
410 }
Chenjie Yub3dda412017-10-24 13:41:59 -0700411 }
412 }
413 if (receivers.size() > 0) {
414 needToPull.push_back(make_pair(pair.first, receivers));
415 }
416 }
417 }
418
419 for (const auto& pullInfo : needToPull) {
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700420 vector<shared_ptr<LogEvent>> data;
Olivier Gaillardc5f11c42019-02-05 12:44:58 +0000421 bool pullSuccess = Pull(pullInfo.first, &data);
422 if (pullSuccess) {
423 StatsdStats::getInstance().notePullDelay(
424 pullInfo.first, getElapsedRealtimeNs() - elapsedTimeNs);
425 } else {
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800426 VLOG("pull failed at %lld, will try again later", (long long)elapsedTimeNs);
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800427 }
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800428
429 // Convention is to mark pull atom timestamp at request time.
430 // If we pull at t0, puller starts at t1, finishes at t2, and send back
431 // at t3, we mark t0 as its timestamp, which should correspond to its
432 // triggering event, such as condition change at t0.
433 // Here the triggering event is alarm fired from AlarmManager.
434 // In ValueMetricProducer and GaugeMetricProducer we do same thing
435 // when pull on condition change, etc.
436 for (auto& event : data) {
437 event->setElapsedTimestampNs(elapsedTimeNs);
438 event->setLogdWallClockTimestampNs(wallClockNs);
439 }
440
441 for (const auto& receiverInfo : pullInfo.second) {
442 sp<PullDataReceiver> receiverPtr = receiverInfo->receiver.promote();
443 if (receiverPtr != nullptr) {
Olivier Gaillard11203df2019-02-06 13:18:09 +0000444 receiverPtr->onDataPulled(data, pullSuccess, elapsedTimeNs);
Olivier Gaillardc5f11c42019-02-05 12:44:58 +0000445 // We may have just come out of a coma, compute next pull time.
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800446 int numBucketsAhead =
447 (elapsedTimeNs - receiverInfo->nextPullTimeNs) / receiverInfo->intervalNs;
448 receiverInfo->nextPullTimeNs += (numBucketsAhead + 1) * receiverInfo->intervalNs;
449 if (receiverInfo->nextPullTimeNs < minNextPullTimeNs) {
450 minNextPullTimeNs = receiverInfo->nextPullTimeNs;
Chenjie Yu6736c892017-11-09 10:50:09 -0800451 }
Chenjie Yu0bd73db2018-12-16 07:37:04 -0800452 } else {
453 VLOG("receiver already gone.");
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700454 }
Chenjie Yub3dda412017-10-24 13:41:59 -0700455 }
456 }
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700457
Chenjie Yu3b3adcd2018-04-18 16:25:36 -0700458 VLOG("mNextPullTimeNs: %lld updated to %lld", (long long)mNextPullTimeNs,
459 (long long)minNextPullTimeNs);
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700460 mNextPullTimeNs = minNextPullTimeNs;
461 updateAlarmLocked();
Chenjie Yub3dda412017-10-24 13:41:59 -0700462}
463
Chenjie Yue2219202018-06-08 10:07:51 -0700464int StatsPullerManager::ForceClearPullerCache() {
Chenjie Yufa22d652018-02-05 14:37:48 -0800465 int totalCleared = 0;
Chenjie Yu80f91122018-01-31 20:24:50 -0800466 for (const auto& pulledAtom : kAllPullAtomInfo) {
467 totalCleared += pulledAtom.second.puller->ForceClearCache();
Chenjie Yue72252b2018-02-01 13:19:35 -0800468 }
Chenjie Yufa22d652018-02-05 14:37:48 -0800469 return totalCleared;
470}
471
Chenjie Yue2219202018-06-08 10:07:51 -0700472int StatsPullerManager::ClearPullerCacheIfNecessary(int64_t timestampNs) {
Chenjie Yufa22d652018-02-05 14:37:48 -0800473 int totalCleared = 0;
Chenjie Yu80f91122018-01-31 20:24:50 -0800474 for (const auto& pulledAtom : kAllPullAtomInfo) {
Chenjie Yu1a0a9412018-03-28 10:07:22 -0700475 totalCleared += pulledAtom.second.puller->ClearCacheIfNecessary(timestampNs);
Chenjie Yufa22d652018-02-05 14:37:48 -0800476 }
477 return totalCleared;
Chenjie Yue72252b2018-02-01 13:19:35 -0800478}
479
Tej Singh6a5c9432019-10-11 11:07:06 -0700480// Deprecated, remove after puller API is complete.
Tej Singha0c89dd2019-01-25 16:39:18 -0800481void StatsPullerManager::RegisterPullerCallback(int32_t atomTag,
482 const sp<IStatsPullerCallback>& callback) {
483 AutoMutex _l(mLock);
484 // Platform pullers cannot be changed.
Tej Singhde473b52019-04-10 19:25:03 -0700485 if (!isVendorPulledAtom(atomTag)) {
486 VLOG("RegisterPullerCallback: atom tag %d is not vendor pulled", atomTag);
Tej Singha0c89dd2019-01-25 16:39:18 -0800487 return;
488 }
489 VLOG("RegisterPullerCallback: adding puller for tag %d", atomTag);
490 StatsdStats::getInstance().notePullerCallbackRegistrationChanged(atomTag, /*registered=*/true);
Tej Singh6a5c9432019-10-11 11:07:06 -0700491 kAllPullAtomInfo[{.atomTag = atomTag}] = {
492 .puller = new StatsCallbackPullerDeprecated(atomTag, callback)};
493}
494
495void StatsPullerManager::RegisterPullAtomCallback(const int uid, const int32_t atomTag,
496 const int64_t coolDownNs, const int64_t timeoutNs,
497 const vector<int32_t>& additiveFields,
498 const sp<IPullAtomCallback>& callback) {
499 AutoMutex _l(mLock);
500 VLOG("RegisterPullerCallback: adding puller for tag %d", atomTag);
501 // TODO: linkToDeath with the callback so that we can remove it and delete the puller.
502 StatsdStats::getInstance().notePullerCallbackRegistrationChanged(atomTag, /*registered=*/true);
503 kAllPullAtomInfo[{.atomTag = atomTag}] = {.additiveFields = additiveFields,
504 .coolDownNs = coolDownNs,
Nick Desaulniersfceda702019-11-21 12:23:57 -0800505 .puller = new StatsCallbackPuller(atomTag, callback),
Tej Singh6a5c9432019-10-11 11:07:06 -0700506 .pullTimeoutNs = timeoutNs,
Nick Desaulniersfceda702019-11-21 12:23:57 -0800507 };
Tej Singha0c89dd2019-01-25 16:39:18 -0800508}
509
510void StatsPullerManager::UnregisterPullerCallback(int32_t atomTag) {
511 AutoMutex _l(mLock);
512 // Platform pullers cannot be changed.
Tej Singhde473b52019-04-10 19:25:03 -0700513 if (!isVendorPulledAtom(atomTag)) {
Tej Singha0c89dd2019-01-25 16:39:18 -0800514 return;
515 }
516 StatsdStats::getInstance().notePullerCallbackRegistrationChanged(atomTag, /*registered=*/false);
Tej Singh6a5c9432019-10-11 11:07:06 -0700517 kAllPullAtomInfo.erase({.atomTag = atomTag});
Tej Singha0c89dd2019-01-25 16:39:18 -0800518}
519
Chenjie Yu1a317ba2017-10-05 16:05:32 -0700520} // namespace statsd
521} // namespace os
522} // namespace android