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 
17 #pragma once
18 
19 #include <set>
20 #include <unordered_map>
21 #include <vector>
22 
23 #include "anomaly/AlarmTracker.h"
24 #include "condition/ConditionTracker.h"
25 #include "config/ConfigMetadataProvider.h"
26 #include "external/StatsPullerManager.h"
27 #include "matchers/AtomMatchingTracker.h"
28 #include "metrics/MetricProducer.h"
29 
30 namespace android {
31 namespace os {
32 namespace statsd {
33 
34 // Helper functions for creating, validating, and updating config components from StatsdConfig.
35 // Should only be called from metrics_manager_util and config_update_utils.
36 
37 // Create a AtomMatchingTracker.
38 // input:
39 // [logMatcher]: the input AtomMatcher from the StatsdConfig
40 // [invalidConfigReason]: logging ids if config is invalid
41 // output:
42 // new AtomMatchingTracker, or null if the tracker is unable to be created
43 sp<AtomMatchingTracker> createAtomMatchingTracker(
44         const AtomMatcher& logMatcher, const sp<UidMap>& uidMap,
45         optional<InvalidConfigReason>& invalidConfigReason);
46 
47 // Create a ConditionTracker.
48 // input:
49 // [predicate]: the input Predicate from the StatsdConfig
50 // [index]: the index of the condition tracker
51 // [atomMatchingTrackerMap]: map of atom matcher id to its index in allAtomMatchingTrackers
52 // [invalidConfigReason]: logging ids if config is invalid
53 // output:
54 // new ConditionTracker, or null if the tracker is unable to be created
55 sp<ConditionTracker> createConditionTracker(
56         const ConfigKey& key, const Predicate& predicate, int index,
57         const unordered_map<int64_t, int>& atomMatchingTrackerMap,
58         optional<InvalidConfigReason>& invalidConfigReason);
59 
60 // Get the hash of a metric, combining the activation if the metric has one.
61 optional<InvalidConfigReason> getMetricProtoHash(
62         const StatsdConfig& config, const google::protobuf::MessageLite& metric, int64_t id,
63         const std::unordered_map<int64_t, int>& metricToActivationMap, uint64_t& metricHash);
64 
65 // 1. Validates matcher existence
66 // 2. Enforces matchers with dimensions and those used for trigger_event are about one atom
67 // 3. Gets matcher index and updates tracker to metric map
68 optional<InvalidConfigReason> handleMetricWithAtomMatchingTrackers(
69         const int64_t matcherId, int64_t metricId, int metricIndex, const bool enforceOneAtom,
70         const std::vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers,
71         const std::unordered_map<int64_t, int>& atomMatchingTrackerMap,
72         std::unordered_map<int, std::vector<int>>& trackerToMetricMap, int& logTrackerIndex);
73 
74 // 1. Validates condition existence, including those in links
75 // 2. Gets condition index and updates condition to metric map
76 optional<InvalidConfigReason> handleMetricWithConditions(
77         const int64_t condition, int64_t metricId, int metricIndex,
78         const std::unordered_map<int64_t, int>& conditionTrackerMap,
79         const ::google::protobuf::RepeatedPtrField<MetricConditionLink>& links,
80         const std::vector<sp<ConditionTracker>>& allConditionTrackers, int& conditionIndex,
81         std::unordered_map<int, std::vector<int>>& conditionToMetricMap);
82 
83 // Validates a metricActivation and populates state.
84 // Fills the new event activation/deactivation maps, preserving the existing activations.
85 // Returns nullopt if successful and InvalidConfigReason if not.
86 optional<InvalidConfigReason> handleMetricActivationOnConfigUpdate(
87         const StatsdConfig& config, int64_t metricId, int metricIndex,
88         const std::unordered_map<int64_t, int>& metricToActivationMap,
89         const std::unordered_map<int64_t, int>& oldAtomMatchingTrackerMap,
90         const std::unordered_map<int64_t, int>& newAtomMatchingTrackerMap,
91         const std::unordered_map<int, shared_ptr<Activation>>& oldEventActivationMap,
92         std::unordered_map<int, std::vector<int>>& activationAtomTrackerToMetricMap,
93         std::unordered_map<int, std::vector<int>>& deactivationAtomTrackerToMetricMap,
94         std::vector<int>& metricsWithActivation,
95         std::unordered_map<int, shared_ptr<Activation>>& newEventActivationMap,
96         std::unordered_map<int, std::vector<shared_ptr<Activation>>>& newEventDeactivationMap);
97 
98 // Creates a CountMetricProducer and updates the vectors/maps used by MetricsManager with
99 // the appropriate indices. Returns an sp to the producer, or nullopt if there was an error.
100 optional<sp<MetricProducer>> createCountMetricProducerAndUpdateMetadata(
101         const ConfigKey& key, const StatsdConfig& config, int64_t timeBaseNs,
102         const int64_t currentTimeNs, const CountMetric& metric, int metricIndex,
103         const std::vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers,
104         const std::unordered_map<int64_t, int>& atomMatchingTrackerMap,
105         std::vector<sp<ConditionTracker>>& allConditionTrackers,
106         const std::unordered_map<int64_t, int>& conditionTrackerMap,
107         const std::vector<ConditionState>& initialConditionCache, const sp<ConditionWizard>& wizard,
108         const std::unordered_map<int64_t, int>& stateAtomIdMap,
109         const std::unordered_map<int64_t, std::unordered_map<int, int64_t>>& allStateGroupMaps,
110         const std::unordered_map<int64_t, int>& metricToActivationMap,
111         std::unordered_map<int, std::vector<int>>& trackerToMetricMap,
112         std::unordered_map<int, std::vector<int>>& conditionToMetricMap,
113         std::unordered_map<int, std::vector<int>>& activationAtomTrackerToMetricMap,
114         std::unordered_map<int, std::vector<int>>& deactivationAtomTrackerToMetricMap,
115         std::vector<int>& metricsWithActivation, optional<InvalidConfigReason>& invalidConfigReason,
116         const wp<ConfigMetadataProvider> configMetadataProvider);
117 
118 // Creates a DurationMetricProducer and updates the vectors/maps used by MetricsManager with
119 // the appropriate indices. Returns an sp to the producer, or nullopt if there was an error.
120 optional<sp<MetricProducer>> createDurationMetricProducerAndUpdateMetadata(
121         const ConfigKey& key, const StatsdConfig& config, int64_t timeBaseNs,
122         const int64_t currentTimeNs, const DurationMetric& metric, int metricIndex,
123         const std::vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers,
124         const std::unordered_map<int64_t, int>& atomMatchingTrackerMap,
125         std::vector<sp<ConditionTracker>>& allConditionTrackers,
126         const std::unordered_map<int64_t, int>& conditionTrackerMap,
127         const std::vector<ConditionState>& initialConditionCache, const sp<ConditionWizard>& wizard,
128         const std::unordered_map<int64_t, int>& stateAtomIdMap,
129         const std::unordered_map<int64_t, std::unordered_map<int, int64_t>>& allStateGroupMaps,
130         const std::unordered_map<int64_t, int>& metricToActivationMap,
131         std::unordered_map<int, std::vector<int>>& trackerToMetricMap,
132         std::unordered_map<int, std::vector<int>>& conditionToMetricMap,
133         std::unordered_map<int, std::vector<int>>& activationAtomTrackerToMetricMap,
134         std::unordered_map<int, std::vector<int>>& deactivationAtomTrackerToMetricMap,
135         std::vector<int>& metricsWithActivation, optional<InvalidConfigReason>& invalidConfigReason,
136         const wp<ConfigMetadataProvider> configMetadataProvider);
137 
138 // Creates an EventMetricProducer and updates the vectors/maps used by MetricsManager with
139 // the appropriate indices. Returns an sp to the producer, or nullopt if there was an error.
140 optional<sp<MetricProducer>> createEventMetricProducerAndUpdateMetadata(
141         const ConfigKey& key, const StatsdConfig& config, int64_t timeBaseNs,
142         const EventMetric& metric, int metricIndex,
143         const std::vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers,
144         const std::unordered_map<int64_t, int>& atomMatchingTrackerMap,
145         std::vector<sp<ConditionTracker>>& allConditionTrackers,
146         const std::unordered_map<int64_t, int>& conditionTrackerMap,
147         const std::vector<ConditionState>& initialConditionCache, const sp<ConditionWizard>& wizard,
148         const std::unordered_map<int64_t, int>& metricToActivationMap,
149         std::unordered_map<int, std::vector<int>>& trackerToMetricMap,
150         std::unordered_map<int, std::vector<int>>& conditionToMetricMap,
151         std::unordered_map<int, std::vector<int>>& activationAtomTrackerToMetricMap,
152         std::unordered_map<int, std::vector<int>>& deactivationAtomTrackerToMetricMap,
153         std::vector<int>& metricsWithActivation, optional<InvalidConfigReason>& invalidConfigReason,
154         const wp<ConfigMetadataProvider> configMetadataProvider);
155 
156 // Creates a NumericValueMetricProducer and updates the vectors/maps used by MetricsManager with
157 // the appropriate indices. Returns an sp to the producer, or nullopt if there was an error.
158 optional<sp<MetricProducer>> createNumericValueMetricProducerAndUpdateMetadata(
159         const ConfigKey& key, const StatsdConfig& config, int64_t timeBaseNs,
160         const int64_t currentTimeNs, const sp<StatsPullerManager>& pullerManager,
161         const ValueMetric& metric, int metricIndex,
162         const std::vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers,
163         const std::unordered_map<int64_t, int>& atomMatchingTrackerMap,
164         std::vector<sp<ConditionTracker>>& allConditionTrackers,
165         const std::unordered_map<int64_t, int>& conditionTrackerMap,
166         const std::vector<ConditionState>& initialConditionCache, const sp<ConditionWizard>& wizard,
167         const sp<EventMatcherWizard>& matcherWizard,
168         const std::unordered_map<int64_t, int>& stateAtomIdMap,
169         const std::unordered_map<int64_t, std::unordered_map<int, int64_t>>& allStateGroupMaps,
170         const std::unordered_map<int64_t, int>& metricToActivationMap,
171         std::unordered_map<int, std::vector<int>>& trackerToMetricMap,
172         std::unordered_map<int, std::vector<int>>& conditionToMetricMap,
173         std::unordered_map<int, std::vector<int>>& activationAtomTrackerToMetricMap,
174         std::unordered_map<int, std::vector<int>>& deactivationAtomTrackerToMetricMap,
175         std::vector<int>& metricsWithActivation, optional<InvalidConfigReason>& invalidConfigReason,
176         const wp<ConfigMetadataProvider> configMetadataProvider);
177 
178 // Creates a GaugeMetricProducer and updates the vectors/maps used by MetricsManager with
179 // the appropriate indices. Returns an sp to the producer, or nullopt if there was an error.
180 optional<sp<MetricProducer>> createGaugeMetricProducerAndUpdateMetadata(
181         const ConfigKey& key, const StatsdConfig& config, int64_t timeBaseNs,
182         const int64_t currentTimeNs, const sp<StatsPullerManager>& pullerManager,
183         const GaugeMetric& metric, int metricIndex,
184         const std::vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers,
185         const std::unordered_map<int64_t, int>& atomMatchingTrackerMap,
186         std::vector<sp<ConditionTracker>>& allConditionTrackers,
187         const std::unordered_map<int64_t, int>& conditionTrackerMap,
188         const std::vector<ConditionState>& initialConditionCache, const sp<ConditionWizard>& wizard,
189         const sp<EventMatcherWizard>& matcherWizard,
190         const std::unordered_map<int64_t, int>& metricToActivationMap,
191         std::unordered_map<int, std::vector<int>>& trackerToMetricMap,
192         std::unordered_map<int, std::vector<int>>& conditionToMetricMap,
193         std::unordered_map<int, std::vector<int>>& activationAtomTrackerToMetricMap,
194         std::unordered_map<int, std::vector<int>>& deactivationAtomTrackerToMetricMap,
195         std::vector<int>& metricsWithActivation, optional<InvalidConfigReason>& invalidConfigReason,
196         const wp<ConfigMetadataProvider> configMetadataProvider);
197 
198 // Creates a KllMetricProducer and updates the vectors/maps used by MetricsManager with
199 // the appropriate indices. Returns an sp to the producer, or nullopt if there was an error.
200 optional<sp<MetricProducer>> createKllMetricProducerAndUpdateMetadata(
201         const ConfigKey& key, const StatsdConfig& config, int64_t timeBaseNs,
202         const int64_t currentTimeNs, const sp<StatsPullerManager>& pullerManager,
203         const KllMetric& metric, int metricIndex,
204         const vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers,
205         const unordered_map<int64_t, int>& atomMatchingTrackerMap,
206         vector<sp<ConditionTracker>>& allConditionTrackers,
207         const unordered_map<int64_t, int>& conditionTrackerMap,
208         const vector<ConditionState>& initialConditionCache, const sp<ConditionWizard>& wizard,
209         const sp<EventMatcherWizard>& matcherWizard,
210         const unordered_map<int64_t, int>& stateAtomIdMap,
211         const unordered_map<int64_t, unordered_map<int, int64_t>>& allStateGroupMaps,
212         const unordered_map<int64_t, int>& metricToActivationMap,
213         unordered_map<int, vector<int>>& trackerToMetricMap,
214         unordered_map<int, vector<int>>& conditionToMetricMap,
215         unordered_map<int, vector<int>>& activationAtomTrackerToMetricMap,
216         unordered_map<int, vector<int>>& deactivationAtomTrackerToMetricMap,
217         vector<int>& metricsWithActivation, optional<InvalidConfigReason>& invalidConfigReason,
218         const wp<ConfigMetadataProvider> configMetadataProvider);
219 
220 // Creates an AnomalyTracker and adds it to the appropriate metric.
221 // Returns an sp to the AnomalyTracker, or nullopt if there was an error.
222 optional<sp<AnomalyTracker>> createAnomalyTracker(
223         const Alert& alert, const sp<AlarmMonitor>& anomalyAlarmMonitor,
224         const UpdateStatus& updateStatus, int64_t currentTimeNs,
225         const std::unordered_map<int64_t, int>& metricProducerMap,
226         std::vector<sp<MetricProducer>>& allMetricProducers,
227         optional<InvalidConfigReason>& invalidConfigReason);
228 
229 // Templated function for adding subscriptions to alarms or alerts. Returns nullopt if successful
230 // and InvalidConfigReason if not.
231 template <typename T>
initSubscribersForSubscriptionType(const StatsdConfig & config,const Subscription_RuleType ruleType,const std::unordered_map<int64_t,int> & ruleMap,std::vector<T> & allRules)232 optional<InvalidConfigReason> initSubscribersForSubscriptionType(
233         const StatsdConfig& config, const Subscription_RuleType ruleType,
234         const std::unordered_map<int64_t, int>& ruleMap, std::vector<T>& allRules) {
235     for (int i = 0; i < config.subscription_size(); ++i) {
236         const Subscription& subscription = config.subscription(i);
237         if (subscription.rule_type() != ruleType) {
238             continue;
239         }
240         if (subscription.subscriber_information_case() ==
241             Subscription::SubscriberInformationCase::SUBSCRIBER_INFORMATION_NOT_SET) {
242             ALOGW("subscription \"%lld\" has no subscriber info.\"", (long long)subscription.id());
243             return createInvalidConfigReasonWithSubscription(
244                     INVALID_CONFIG_REASON_SUBSCRIPTION_SUBSCRIBER_INFO_MISSING, subscription.id());
245         }
246         const auto& itr = ruleMap.find(subscription.rule_id());
247         if (itr == ruleMap.end()) {
248             ALOGW("subscription \"%lld\" has unknown rule id: \"%lld\"",
249                   (long long)subscription.id(), (long long)subscription.rule_id());
250             switch (subscription.rule_type()) {
251                 case Subscription::ALARM:
252                     return createInvalidConfigReasonWithSubscriptionAndAlarm(
253                             INVALID_CONFIG_REASON_SUBSCRIPTION_RULE_NOT_FOUND, subscription.id(),
254                             subscription.rule_id());
255                 case Subscription::ALERT:
256                     return createInvalidConfigReasonWithSubscriptionAndAlert(
257                             INVALID_CONFIG_REASON_SUBSCRIPTION_RULE_NOT_FOUND, subscription.id(),
258                             subscription.rule_id());
259                 case Subscription::RULE_TYPE_UNSPECIFIED:
260                     return createInvalidConfigReasonWithSubscription(
261                             INVALID_CONFIG_REASON_SUBSCRIPTION_RULE_NOT_FOUND, subscription.id());
262             }
263         }
264         const int ruleIndex = itr->second;
265         allRules[ruleIndex]->addSubscription(subscription);
266     }
267     return nullopt;
268 }
269 
270 // Helper functions for MetricsManager to initialize from StatsdConfig.
271 // *Note*: only initStatsdConfig() should be called from outside.
272 // All other functions are intermediate
273 // steps, created to make unit tests easier. And most of the parameters in these
274 // functions are temporary objects in the initialization phase.
275 
276 // Initialize the AtomMatchingTrackers.
277 // input:
278 // [key]: the config key that this config belongs to
279 // [config]: the input StatsdConfig
280 // output:
281 // [atomMatchingTrackerMap]: this map should contain matcher name to index mapping
282 // [allAtomMatchingTrackers]: should store the sp to all the AtomMatchingTracker
283 // [allTagIdsToMatchersMap]: maps of tag ids to atom matchers
284 // Returns nullopt if successful and InvalidConfigReason if not.
285 optional<InvalidConfigReason> initAtomMatchingTrackers(
286         const StatsdConfig& config, const sp<UidMap>& uidMap,
287         std::unordered_map<int64_t, int>& atomMatchingTrackerMap,
288         std::vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers,
289         std::unordered_map<int, std::vector<int>>& allTagIdsToMatchersMap);
290 
291 // Initialize ConditionTrackers
292 // input:
293 // [key]: the config key that this config belongs to
294 // [config]: the input config
295 // [atomMatchingTrackerMap]: AtomMatchingTracker name to index mapping from previous step.
296 // output:
297 // [conditionTrackerMap]: this map should contain condition name to index mapping
298 // [allConditionTrackers]: stores the sp to all the ConditionTrackers
299 // [trackerToConditionMap]: contain the mapping from index of
300 //                        log tracker to condition trackers that use the log tracker
301 // [initialConditionCache]: stores the initial conditions for each ConditionTracker
302 // Returns nullopt if successful and InvalidConfigReason if not.
303 optional<InvalidConfigReason> initConditions(
304         const ConfigKey& key, const StatsdConfig& config,
305         const std::unordered_map<int64_t, int>& atomMatchingTrackerMap,
306         std::unordered_map<int64_t, int>& conditionTrackerMap,
307         std::vector<sp<ConditionTracker>>& allConditionTrackers,
308         std::unordered_map<int, std::vector<int>>& trackerToConditionMap,
309         std::vector<ConditionState>& initialConditionCache);
310 
311 // Initialize State maps using State protos in the config. These maps will
312 // eventually be passed to MetricProducers to initialize their state info.
313 // input:
314 // [config]: the input config
315 // output:
316 // [stateAtomIdMap]: this map should contain the mapping from state ids to atom ids
317 // [allStateGroupMaps]: this map should contain the mapping from states ids and state
318 //                      values to state group ids for all states
319 // [stateProtoHashes]: contains a map of state id to the hash of the State proto from the config
320 // Returns nullopt if successful and InvalidConfigReason if not.
321 optional<InvalidConfigReason> initStates(
322         const StatsdConfig& config, unordered_map<int64_t, int>& stateAtomIdMap,
323         unordered_map<int64_t, unordered_map<int, int64_t>>& allStateGroupMaps,
324         std::map<int64_t, uint64_t>& stateProtoHashes);
325 
326 // Initialize MetricProducers.
327 // input:
328 // [key]: the config key that this config belongs to
329 // [config]: the input config
330 // [timeBaseSec]: start time base for all metrics
331 // [atomMatchingTrackerMap]: AtomMatchingTracker name to index mapping from previous step.
332 // [conditionTrackerMap]: condition name to index mapping
333 // [stateAtomIdMap]: contains the mapping from state ids to atom ids
334 // [allStateGroupMaps]: contains the mapping from atom ids and state values to
335 //                      state group ids for all states
336 // output:
337 // [allMetricProducers]: contains the list of sp to the MetricProducers created.
338 // [conditionToMetricMap]: contains the mapping from condition tracker index to
339 //                          the list of MetricProducer index
340 // [trackerToMetricMap]: contains the mapping from log tracker to MetricProducer index.
341 // Returns nullopt if successful and InvalidConfigReason if not.
342 optional<InvalidConfigReason> initMetrics(
343         const ConfigKey& key, const StatsdConfig& config, int64_t timeBaseTimeNs,
344         const int64_t currentTimeNs, const sp<StatsPullerManager>& pullerManager,
345         const std::unordered_map<int64_t, int>& atomMatchingTrackerMap,
346         const std::unordered_map<int64_t, int>& conditionTrackerMap,
347         const vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers,
348         const unordered_map<int64_t, int>& stateAtomIdMap,
349         const unordered_map<int64_t, unordered_map<int, int64_t>>& allStateGroupMaps,
350         vector<sp<ConditionTracker>>& allConditionTrackers,
351         const std::vector<ConditionState>& initialConditionCache,
352         std::vector<sp<MetricProducer>>& allMetricProducers,
353         std::unordered_map<int, std::vector<int>>& conditionToMetricMap,
354         std::unordered_map<int, std::vector<int>>& trackerToMetricMap,
355         std::set<int64_t>& noReportMetricIds,
356         std::unordered_map<int, std::vector<int>>& activationAtomTrackerToMetricMap,
357         std::unordered_map<int, std::vector<int>>& deactivationAtomTrackerToMetricMap,
358         std::vector<int>& metricsWithActivation,
359         const wp<ConfigMetadataProvider> configMetadataProvider);
360 
361 // Initialize alarms
362 // Is called both on initialize new configs and config updates since alarms do not have any state.
363 optional<InvalidConfigReason> initAlarms(const StatsdConfig& config, const ConfigKey& key,
364                                          const sp<AlarmMonitor>& periodicAlarmMonitor,
365                                          const int64_t timeBaseNs, int64_t currentTimeNs,
366                                          std::vector<sp<AlarmTracker>>& allAlarmTrackers);
367 
368 // Initialize MetricsManager from StatsdConfig.
369 // Parameters are the members of MetricsManager. See MetricsManager for declaration.
370 optional<InvalidConfigReason> initStatsdConfig(
371         const ConfigKey& key, const StatsdConfig& config, const sp<UidMap>& uidMap,
372         const sp<StatsPullerManager>& pullerManager, const sp<AlarmMonitor>& anomalyAlarmMonitor,
373         const sp<AlarmMonitor>& periodicAlarmMonitor, int64_t timeBaseNs,
374         const int64_t currentTimeNs, const wp<ConfigMetadataProvider> configMetadataProvider,
375         std::unordered_map<int, std::vector<int>>& allTagIdsToMatchersMap,
376         std::vector<sp<AtomMatchingTracker>>& allAtomMatchingTrackers,
377         std::unordered_map<int64_t, int>& atomMatchingTrackerMap,
378         std::vector<sp<ConditionTracker>>& allConditionTrackers,
379         std::unordered_map<int64_t, int>& conditionTrackerMap,
380         std::vector<sp<MetricProducer>>& allMetricProducers,
381         std::unordered_map<int64_t, int>& metricProducerMap,
382         vector<sp<AnomalyTracker>>& allAnomalyTrackers,
383         vector<sp<AlarmTracker>>& allPeriodicAlarmTrackers,
384         std::unordered_map<int, std::vector<int>>& conditionToMetricMap,
385         std::unordered_map<int, std::vector<int>>& trackerToMetricMap,
386         std::unordered_map<int, std::vector<int>>& trackerToConditionMap,
387         std::unordered_map<int, std::vector<int>>& activationAtomTrackerToMetricMap,
388         std::unordered_map<int, std::vector<int>>& deactivationAtomTrackerToMetricMap,
389         std::unordered_map<int64_t, int>& alertTrackerMap, std::vector<int>& metricsWithActivation,
390         std::map<int64_t, uint64_t>& stateProtoHashes, std::set<int64_t>& noReportMetricIds);
391 
392 }  // namespace statsd
393 }  // namespace os
394 }  // namespace android
395