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 <aidl/android/os/BnStatsd.h>
20 #include <gtest/gtest_prod.h>
21 #include <stdio.h>
22 
23 #include <unordered_map>
24 
25 #include "config/ConfigListener.h"
26 #include "external/StatsPullerManager.h"
27 #include "logd/LogEvent.h"
28 #include "metrics/MetricsManager.h"
29 #include "packages/UidMap.h"
30 #include "socket/LogEventFilter.h"
31 #include "src/statsd_config.pb.h"
32 #include "src/statsd_metadata.pb.h"
33 
34 namespace android {
35 namespace os {
36 namespace statsd {
37 
38 class StatsLogProcessor : public ConfigListener, public virtual PackageInfoListener {
39 public:
40     StatsLogProcessor(
41             const sp<UidMap>& uidMap, const sp<StatsPullerManager>& pullerManager,
42             const sp<AlarmMonitor>& anomalyAlarmMonitor,
43             const sp<AlarmMonitor>& subscriberTriggerAlarmMonitor, int64_t timeBaseNs,
44             const std::function<bool(const ConfigKey&)>& sendBroadcast,
45             const std::function<bool(const int&, const vector<int64_t>&)>& sendActivationBroadcast,
46             const std::function<void(const ConfigKey&, const string&, const vector<int64_t>&)>&
47                     sendRestrictedMetricsBroadcast,
48             const std::shared_ptr<LogEventFilter>& logEventFilter);
49 
50     virtual ~StatsLogProcessor();
51 
52     void OnLogEvent(LogEvent* event);
53 
54     void OnConfigUpdated(const int64_t timestampNs, int64_t wallClockNs, const ConfigKey& key,
55                          const StatsdConfig& config, bool modularUpdate = true);
56     // For testing only.
57     void OnConfigUpdated(const int64_t timestampNs, const ConfigKey& key,
58                          const StatsdConfig& config, bool modularUpdate = true);
59     void OnConfigRemoved(const ConfigKey& key);
60 
61     size_t GetMetricsSize(const ConfigKey& key) const;
62 
63     void GetActiveConfigs(const int uid, vector<int64_t>& outActiveConfigs);
64 
65     void onDumpReport(const ConfigKey& key, int64_t dumpTimeNs, int64_t wallClockNs,
66                       const bool include_current_partial_bucket, const bool erase_data,
67                       const DumpReportReason dumpReportReason, const DumpLatency dumpLatency,
68                       vector<uint8_t>* outData);
69     void onDumpReport(const ConfigKey& key, int64_t dumpTimeNs, int64_t wallClockNs,
70                       const bool include_current_partial_bucket, const bool erase_data,
71                       const DumpReportReason dumpReportReason, const DumpLatency dumpLatency,
72                       ProtoOutputStream* proto);
73     // For testing only.
74     void onDumpReport(const ConfigKey& key, int64_t dumpTimeNs,
75                       const bool include_current_partial_bucket, const bool erase_data,
76                       const DumpReportReason dumpReportReason, const DumpLatency dumpLatency,
77                       vector<uint8_t>* outData);
78 
79     /* Tells MetricsManager that the alarms in alarmSet have fired. Modifies periodic alarmSet. */
80     void onPeriodicAlarmFired(
81             int64_t timestampNs,
82             unordered_set<sp<const InternalAlarm>, SpHash<InternalAlarm>>& alarmSet);
83 
84     /* Flushes data to disk. Data on memory will be gone after written to disk. */
85     void WriteDataToDisk(const DumpReportReason dumpReportReason, const DumpLatency dumpLatency,
86                          const int64_t elapsedRealtimeNs, int64_t wallClockNs);
87 
88     /* Persist configs containing metrics with active activations to disk. */
89     void SaveActiveConfigsToDisk(int64_t currentTimeNs);
90 
91     /* Writes the current active status/ttl for all configs and metrics to ProtoOutputStream. */
92     void WriteActiveConfigsToProtoOutputStream(
93             int64_t currentTimeNs, const DumpReportReason reason, ProtoOutputStream* proto);
94 
95     /* Load configs containing metrics with active activations from disk. */
96     void LoadActiveConfigsFromDisk();
97 
98     /* Persist metadata for configs and metrics to disk. */
99     void SaveMetadataToDisk(int64_t currentWallClockTimeNs, int64_t systemElapsedTimeNs);
100 
101     /* Writes the statsd metadata for all configs and metrics to StatsMetadataList. */
102     void WriteMetadataToProto(int64_t currentWallClockTimeNs,
103                               int64_t systemElapsedTimeNs,
104                               metadata::StatsMetadataList* metadataList);
105 
106     /* Load stats metadata for configs and metrics from disk. */
107     void LoadMetadataFromDisk(int64_t currentWallClockTimeNs,
108                               int64_t systemElapsedTimeNs);
109 
110     /* Sets the metadata for all configs and metrics */
111     void SetMetadataState(const metadata::StatsMetadataList& statsMetadataList,
112                           int64_t currentWallClockTimeNs,
113                           int64_t systemElapsedTimeNs);
114 
115     /* Enforces ttls for restricted metrics */
116     void EnforceDataTtls(const int64_t wallClockNs, int64_t elapsedRealtimeNs);
117 
118     /* Sets the active status/ttl for all configs and metrics to the status in ActiveConfigList. */
119     void SetConfigsActiveState(const ActiveConfigList& activeConfigList, int64_t currentTimeNs);
120 
121     /* Notify all MetricsManagers of app upgrades */
122     void notifyAppUpgrade(int64_t eventTimeNs, const string& apk, int uid,
123                           int64_t version) override;
124 
125     /* Notify all MetricsManagers of app removals */
126     void notifyAppRemoved(int64_t eventTimeNs, const string& apk, int uid) override;
127 
128     /* Notify all MetricsManagers of uid map snapshots received */
129     void onUidMapReceived(int64_t eventTimeNs) override;
130 
131     /* Notify all metrics managers of boot completed
132      * This will force a bucket split when the boot is finished.
133      */
134     void onStatsdInitCompleted(int64_t elapsedTimeNs);
135 
136     // Reset all configs.
137     void resetConfigs();
138 
getUidMap()139     inline sp<UidMap> getUidMap() {
140         return mUidMap;
141     }
142 
143     void dumpStates(int outFd, bool verbose) const;
144 
145     void informPullAlarmFired(const int64_t timestampNs);
146 
147     int64_t getLastReportTimeNs(const ConfigKey& key);
148 
setPrintLogs(bool enabled)149     inline void setPrintLogs(bool enabled) {
150         std::lock_guard<std::mutex> lock(mMetricsMutex);
151         mPrintAllLogs = enabled;
152         // Turning on print logs turns off pushed event filtering to enforce
153         // complete log event buffer parsing
154         mLogEventFilter->setFilteringEnabled(!enabled);
155     }
156 
157     // Add a specific config key to the possible configs to dump ASAP.
158     void noteOnDiskData(const ConfigKey& key);
159 
160     void setAnomalyAlarm(const int64_t timeMillis);
161 
162     void cancelAnomalyAlarm();
163 
164     void querySql(const string& sqlQuery, const int32_t minSqlClientVersion,
165                   const optional<vector<uint8_t>>& policyConfig,
166                   const shared_ptr<aidl::android::os::IStatsQueryCallback>& callback,
167                   const int64_t configId, const string& configPackage, const int32_t callingUid);
168 
169     void fillRestrictedMetrics(const int64_t configId, const string& configPackage,
170                                const int32_t delegateUid, vector<int64_t>* output);
171 
172     /* Returns pre-defined list of atoms to parse by LogEventFilter */
173     static LogEventFilter::AtomIdSet getDefaultAtomIdSet();
174 
175 private:
176     // For testing only.
getAnomalyAlarmMonitor()177     inline sp<AlarmMonitor> getAnomalyAlarmMonitor() const {
178         return mAnomalyAlarmMonitor;
179     }
180 
getPeriodicAlarmMonitor()181     inline sp<AlarmMonitor> getPeriodicAlarmMonitor() const {
182         return mPeriodicAlarmMonitor;
183     }
184 
185     mutable mutex mMetricsMutex;
186 
187     // Guards mNextAnomalyAlarmTime. A separate mutex is needed because alarms are set/cancelled
188     // in the onLogEvent code path, which is locked by mMetricsMutex.
189     // DO NOT acquire mMetricsMutex while holding mAnomalyAlarmMutex. This can lead to a deadlock.
190     mutable mutex mAnomalyAlarmMutex;
191 
192     std::unordered_map<ConfigKey, sp<MetricsManager>> mMetricsManagers;
193 
194     std::unordered_map<ConfigKey, int64_t> mLastBroadcastTimes;
195 
196     // Last time we sent a broadcast to this uid that the active configs had changed.
197     std::unordered_map<int, int64_t> mLastActivationBroadcastTimes;
198 
199     // Tracks when we last checked the bytes consumed for each config key.
200     std::unordered_map<ConfigKey, int64_t> mLastByteSizeTimes;
201 
202     // Tracks the number of times a config with a specified config key has been dumped.
203     std::unordered_map<ConfigKey, int32_t> mDumpReportNumbers;
204 
205     // Tracks when we last checked the ttl for restricted metrics.
206     int64_t mLastTtlTime;
207 
208     // Tracks when we last flushed restricted metrics.
209     int64_t mLastFlushRestrictedTime;
210 
211     // Tracks when we last checked db guardrails.
212     int64_t mLastDbGuardrailEnforcementTime;
213 
214     // Tracks which config keys has metric reports on disk
215     std::set<ConfigKey> mOnDiskDataConfigs;
216 
217     sp<UidMap> mUidMap;  // Reference to the UidMap to lookup app name and version for each uid.
218 
219     sp<StatsPullerManager> mPullerManager;  // Reference to StatsPullerManager
220 
221     sp<AlarmMonitor> mAnomalyAlarmMonitor;
222 
223     sp<AlarmMonitor> mPeriodicAlarmMonitor;
224 
225     std::shared_ptr<LogEventFilter> mLogEventFilter;
226 
227     void OnLogEvent(LogEvent* event, int64_t elapsedRealtimeNs);
228 
229     void resetIfConfigTtlExpiredLocked(const int64_t eventTimeNs);
230 
231     void OnConfigUpdatedLocked(const int64_t currentTimestampNs, const ConfigKey& key,
232                                const StatsdConfig& config, bool modularUpdate);
233 
234     void GetActiveConfigsLocked(const int uid, vector<int64_t>& outActiveConfigs);
235 
236     void WriteActiveConfigsToProtoOutputStreamLocked(
237             int64_t currentTimeNs, const DumpReportReason reason, ProtoOutputStream* proto);
238 
239     void SetConfigsActiveStateLocked(const ActiveConfigList& activeConfigList,
240                                      int64_t currentTimeNs);
241 
242     void SetMetadataStateLocked(const metadata::StatsMetadataList& statsMetadataList,
243                                 int64_t currentWallClockTimeNs,
244                                 int64_t systemElapsedTimeNs);
245 
246     void WriteMetadataToProtoLocked(int64_t currentWallClockTimeNs,
247                                     int64_t systemElapsedTimeNs,
248                                     metadata::StatsMetadataList* metadataList);
249 
250     void WriteDataToDiskLocked(const DumpReportReason dumpReportReason,
251                                const DumpLatency dumpLatency, int64_t elapsedRealtimeNs,
252                                const int64_t wallClockNs);
253 
254     void WriteDataToDiskLocked(const ConfigKey& key, int64_t timestampNs, const int64_t wallClockNs,
255                                const DumpReportReason dumpReportReason,
256                                const DumpLatency dumpLatency);
257 
258     void onConfigMetricsReportLocked(
259             const ConfigKey& key, int64_t dumpTimeStampNs, int64_t wallClockNs,
260             const bool include_current_partial_bucket, const bool erase_data,
261             const DumpReportReason dumpReportReason, const DumpLatency dumpLatency,
262             /*if dataSavedToDisk is true, it indicates the caller will write the data to disk
263              (e.g., before reboot). So no need to further persist local history.*/
264             const bool dataSavedToDisk, vector<uint8_t>* proto);
265 
266     /* Check if it is time enforce data ttls for restricted metrics, and if it is, enforce ttls
267      * on all restricted metrics. */
268     void enforceDataTtlsIfNecessaryLocked(const int64_t wallClockNs,
269                                           const int64_t elapsedRealtimeNs);
270 
271     // Enforces ttls on all restricted metrics.
272     void enforceDataTtlsLocked(const int64_t wallClockNs, int64_t elapsedRealtimeNs);
273 
274     // Enforces that dbs are within guardrail parameters.
275     void enforceDbGuardrailsIfNecessaryLocked(const int64_t wallClockNs,
276                                               const int64_t elapsedRealtimeNs);
277 
278     /* Check if we should send a broadcast if approaching memory limits and if we're over, we
279      * actually delete the data. */
280     void flushIfNecessaryLocked(const ConfigKey& key, MetricsManager& metricsManager);
281 
282     set<ConfigKey> getRestrictedConfigKeysToQueryLocked(int32_t callingUid, const int64_t configId,
283                                                         const set<int32_t>& configPackageUids,
284                                                         string& err,
285                                                         InvalidQueryReason& invalidQueryReason);
286 
287     // Maps the isolated uid in the log event to host uid if the log event contains uid fields.
288     void mapIsolatedUidToHostUidIfNecessaryLocked(LogEvent* event) const;
289 
290     // Handler over the isolated uid change event.
291     void onIsolatedUidChangedEventLocked(const LogEvent& event);
292 
293     // Handler over the binary push state changed event.
294     void onBinaryPushStateChangedEventLocked(LogEvent* event);
295 
296     // Handler over the watchdog rollback occurred event.
297     void onWatchdogRollbackOccurredLocked(LogEvent* event);
298 
299     // Updates train info on disk based on binary push state changed info and
300     // write disk info into parameters.
301     void getAndUpdateTrainInfoOnDisk(bool is_rollback, InstallTrainInfo* trainInfoIn);
302 
303     // Gets experiment ids on disk for associated train and updates them
304     // depending on rollback type. Then writes them back to disk and returns
305     // them.
306     std::vector<int64_t> processWatchdogRollbackOccurred(int32_t rollbackTypeIn,
307                                                          const string& packageName);
308 
309     // Reset all configs.
310     void resetConfigsLocked(const int64_t timestampNs);
311     // Reset the specified configs.
312     void resetConfigsLocked(const int64_t timestampNs, const std::vector<ConfigKey>& configs);
313 
314     // An anomaly alarm should have fired.
315     // Check with anomaly alarm manager to find the alarms and process the result.
316     void informAnomalyAlarmFiredLocked(const int64_t elapsedTimeMillis);
317 
318     /* Tells MetricsManager that the alarms in alarmSet have fired. Modifies anomaly alarmSet. */
319     void processFiredAnomalyAlarmsLocked(
320             int64_t timestampNs,
321             unordered_set<sp<const InternalAlarm>, SpHash<InternalAlarm>>& alarmSet);
322 
323     void flushRestrictedDataLocked(const int64_t elapsedRealtimeNs);
324 
325     void flushRestrictedDataIfNecessaryLocked(const int64_t elapsedRealtimeNs);
326 
327     /* Tells LogEventFilter about atom ids to parse */
328     void updateLogEventFilterLocked() const;
329 
330     bool validateAppBreadcrumbEvent(const LogEvent& event) const;
331 
332     // Function used to send a broadcast so that receiver for the config key can call getData
333     // to retrieve the stored data.
334     std::function<bool(const ConfigKey& key)> mSendBroadcast;
335 
336     // Function used to send a broadcast so that receiver can be notified of which configs
337     // are currently active.
338     std::function<bool(const int& uid, const vector<int64_t>& configIds)> mSendActivationBroadcast;
339 
340     // Function used to send a broadcast if necessary so the receiver can be notified of the
341     // restricted metrics for the given config.
342     std::function<void(const ConfigKey& key, const string& delegatePackage,
343                        const vector<int64_t>& restrictedMetricIds)>
344             mSendRestrictedMetricsBroadcast;
345 
346     const int64_t mTimeBaseNs;
347 
348     // Largest timestamp of the events that we have processed.
349     int64_t mLargestTimestampSeen = 0;
350 
351     int64_t mLastTimestampSeen = 0;
352 
353     int64_t mLastPullerCacheClearTimeSec = 0;
354 
355     // Last time we wrote data to disk.
356     int64_t mLastWriteTimeNs = 0;
357 
358     // Last time we wrote active metrics to disk.
359     int64_t mLastActiveMetricsWriteNs = 0;
360 
361     //Last time we wrote metadata to disk.
362     int64_t mLastMetadataWriteNs = 0;
363 
364     // The time for the next anomaly alarm for alerts.
365     int64_t mNextAnomalyAlarmTime = 0;
366 
367     bool mPrintAllLogs = false;
368 
369     friend class StatsLogProcessorTestRestricted;
370     FRIEND_TEST(StatsLogProcessorTest, TestOutOfOrderLogs);
371     FRIEND_TEST(StatsLogProcessorTest, TestRateLimitByteSize);
372     FRIEND_TEST(StatsLogProcessorTest, TestRateLimitBroadcast);
373     FRIEND_TEST(StatsLogProcessorTest, TestDropWhenByteSizeTooLarge);
374     FRIEND_TEST(StatsLogProcessorTest, InvalidConfigRemoved);
375     FRIEND_TEST(StatsLogProcessorTest, TestActiveConfigMetricDiskWriteRead);
376     FRIEND_TEST(StatsLogProcessorTest, TestActivationOnBoot);
377     FRIEND_TEST(StatsLogProcessorTest, TestActivationOnBootMultipleActivations);
378     FRIEND_TEST(StatsLogProcessorTest,
379             TestActivationOnBootMultipleActivationsDifferentActivationTypes);
380     FRIEND_TEST(StatsLogProcessorTest, TestActivationsPersistAcrossSystemServerRestart);
381     FRIEND_TEST(StatsLogProcessorTest, LogEventFilterOnSetPrintLogs);
382     FRIEND_TEST(StatsLogProcessorTest, TestUidMapHasSnapshot);
383     FRIEND_TEST(StatsLogProcessorTest, TestEmptyConfigHasNoUidMap);
384     FRIEND_TEST(StatsLogProcessorTest, TestReportIncludesSubConfig);
385     FRIEND_TEST(StatsLogProcessorTest, TestPullUidProviderSetOnConfigUpdate);
386     FRIEND_TEST(StatsLogProcessorTestRestricted, TestInconsistentRestrictedMetricsConfigUpdate);
387     FRIEND_TEST(StatsLogProcessorTestRestricted, TestRestrictedLogEventPassed);
388     FRIEND_TEST(StatsLogProcessorTestRestricted, TestRestrictedLogEventNotPassed);
389     FRIEND_TEST(StatsLogProcessorTestRestricted, RestrictedMetricsManagerOnDumpReportNotCalled);
390     FRIEND_TEST(StatsLogProcessorTestRestricted, NonRestrictedMetricsManagerOnDumpReportCalled);
391     FRIEND_TEST(StatsLogProcessorTestRestricted, RestrictedMetricOnDumpReportEmpty);
392     FRIEND_TEST(StatsLogProcessorTestRestricted, NonRestrictedMetricOnDumpReportNotEmpty);
393     FRIEND_TEST(StatsLogProcessorTestRestricted, RestrictedMetricNotWriteToDisk);
394     FRIEND_TEST(StatsLogProcessorTestRestricted, NonRestrictedMetricWriteToDisk);
395     FRIEND_TEST(StatsLogProcessorTestRestricted, RestrictedMetricFlushIfReachMemoryLimit);
396     FRIEND_TEST(StatsLogProcessorTestRestricted, RestrictedMetricNotFlushIfNotReachMemoryLimit);
397     FRIEND_TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForSumDuration1);
398     FRIEND_TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForSumDuration2);
399     FRIEND_TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForSumDuration3);
400     FRIEND_TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForMaxDuration1);
401     FRIEND_TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForMaxDuration2);
402     FRIEND_TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForMaxDuration3);
403     FRIEND_TEST(MetricConditionLinkE2eTest, TestMultiplePredicatesAndLinks1);
404     FRIEND_TEST(MetricConditionLinkE2eTest, TestMultiplePredicatesAndLinks2);
405     FRIEND_TEST(AttributionE2eTest, TestAttributionMatchAndSliceByFirstUid);
406     FRIEND_TEST(AttributionE2eTest, TestAttributionMatchAndSliceByChain);
407     FRIEND_TEST(GaugeMetricE2ePulledTest, TestFirstNSamplesPulledNoTrigger);
408     FRIEND_TEST(GaugeMetricE2ePulledTest, TestFirstNSamplesPulledNoTriggerWithActivation);
409     FRIEND_TEST(GaugeMetricE2ePushedTest, TestMultipleFieldsForPushedEvent);
410     FRIEND_TEST(GaugeMetricE2ePushedTest, TestRepeatedFieldsForPushedEvent);
411     FRIEND_TEST(GaugeMetricE2ePulledTest, TestRandomSamplePulledEvents);
412     FRIEND_TEST(GaugeMetricE2ePulledTest, TestRandomSamplePulledEvent_LateAlarm);
413     FRIEND_TEST(GaugeMetricE2ePulledTest, TestRandomSamplePulledEventsWithActivation);
414     FRIEND_TEST(GaugeMetricE2ePulledTest, TestRandomSamplePulledEventsNoCondition);
415     FRIEND_TEST(GaugeMetricE2ePulledTest, TestConditionChangeToTrueSamplePulledEvents);
416     FRIEND_TEST(RestrictedEventMetricE2eTest, TestEnforceTtlRemovesOldEvents);
417     FRIEND_TEST(RestrictedEventMetricE2eTest, TestFlagDisabled);
418     FRIEND_TEST(RestrictedEventMetricE2eTest, TestLogEventsEnforceTtls);
419     FRIEND_TEST(RestrictedEventMetricE2eTest, TestQueryEnforceTtls);
420     FRIEND_TEST(RestrictedEventMetricE2eTest, TestLogEventsDoesNotEnforceTtls);
421     FRIEND_TEST(RestrictedEventMetricE2eTest, TestNotFlushed);
422     FRIEND_TEST(RestrictedEventMetricE2eTest, TestFlushInWriteDataToDisk);
423     FRIEND_TEST(RestrictedEventMetricE2eTest, TestFlushPeriodically);
424     FRIEND_TEST(RestrictedEventMetricE2eTest, TestTTlsEnforceDbGuardrails);
425     FRIEND_TEST(RestrictedEventMetricE2eTest, TestOnLogEventMalformedDbNameDeleted);
426     FRIEND_TEST(RestrictedEventMetricE2eTest, TestEnforceDbGuardrails);
427     FRIEND_TEST(RestrictedEventMetricE2eTest, TestEnforceDbGuardrailsDoesNotDeleteBeforeGuardrail);
428     FRIEND_TEST(RestrictedEventMetricE2eTest, TestRestrictedMetricLoadsTtlFromDisk);
429 
430     FRIEND_TEST(AnomalyCountDetectionE2eTest, TestSlicedCountMetric_single_bucket);
431     FRIEND_TEST(AnomalyCountDetectionE2eTest, TestSlicedCountMetric_multiple_buckets);
432     FRIEND_TEST(AnomalyCountDetectionE2eTest,
433                 TestCountMetric_save_refractory_to_disk_no_data_written);
434     FRIEND_TEST(AnomalyCountDetectionE2eTest, TestCountMetric_save_refractory_to_disk);
435     FRIEND_TEST(AnomalyCountDetectionE2eTest, TestCountMetric_load_refractory_from_disk);
436     FRIEND_TEST(AnomalyDurationDetectionE2eTest, TestDurationMetric_SUM_single_bucket);
437     FRIEND_TEST(AnomalyDurationDetectionE2eTest, TestDurationMetric_SUM_partial_bucket);
438     FRIEND_TEST(AnomalyDurationDetectionE2eTest, TestDurationMetric_SUM_multiple_buckets);
439     FRIEND_TEST(AnomalyDurationDetectionE2eTest, TestDurationMetric_SUM_long_refractory_period);
440 
441     FRIEND_TEST(AlarmE2eTest, TestMultipleAlarms);
442     FRIEND_TEST(ConfigTtlE2eTest, TestCountMetric);
443     FRIEND_TEST(MetricActivationE2eTest, TestCountMetric);
444     FRIEND_TEST(MetricActivationE2eTest, TestCountMetricWithOneDeactivation);
445     FRIEND_TEST(MetricActivationE2eTest, TestCountMetricWithTwoDeactivations);
446     FRIEND_TEST(MetricActivationE2eTest, TestCountMetricWithSameDeactivation);
447     FRIEND_TEST(MetricActivationE2eTest, TestCountMetricWithTwoMetricsTwoDeactivations);
448 
449     FRIEND_TEST(ConfigUpdateE2eTest, TestAlarms);
450     FRIEND_TEST(ConfigUpdateE2eTest, TestGaugeMetric);
451     FRIEND_TEST(ConfigUpdateE2eTest, TestValueMetric);
452     FRIEND_TEST(ConfigUpdateE2eTest, TestAnomalyDurationMetric);
453     FRIEND_TEST(ConfigUpdateE2eAbTest, TestHashStrings);
454     FRIEND_TEST(ConfigUpdateE2eAbTest, TestUidMapVersionStringInstaller);
455     FRIEND_TEST(ConfigUpdateE2eAbTest, TestConfigTtl);
456 
457     FRIEND_TEST(CountMetricE2eTest, TestInitialConditionChanges);
458     FRIEND_TEST(CountMetricE2eTest, TestSlicedState);
459     FRIEND_TEST(CountMetricE2eTest, TestSlicedStateWithMap);
460     FRIEND_TEST(CountMetricE2eTest, TestMultipleSlicedStates);
461     FRIEND_TEST(CountMetricE2eTest, TestSlicedStateWithPrimaryFields);
462     FRIEND_TEST(CountMetricE2eTest, TestRepeatedFieldsAndEmptyArrays);
463 
464     FRIEND_TEST(DurationMetricE2eTest, TestOneBucket);
465     FRIEND_TEST(DurationMetricE2eTest, TestTwoBuckets);
466     FRIEND_TEST(DurationMetricE2eTest, TestWithActivation);
467     FRIEND_TEST(DurationMetricE2eTest, TestWithCondition);
468     FRIEND_TEST(DurationMetricE2eTest, TestWithSlicedCondition);
469     FRIEND_TEST(DurationMetricE2eTest, TestWithActivationAndSlicedCondition);
470     FRIEND_TEST(DurationMetricE2eTest, TestWithSlicedState);
471     FRIEND_TEST(DurationMetricE2eTest, TestWithConditionAndSlicedState);
472     FRIEND_TEST(DurationMetricE2eTest, TestWithSlicedStateMapped);
473     FRIEND_TEST(DurationMetricE2eTest, TestSlicedStatePrimaryFieldsNotSubsetDimInWhat);
474     FRIEND_TEST(DurationMetricE2eTest, TestWithSlicedStatePrimaryFieldsSubset);
475     FRIEND_TEST(DurationMetricE2eTest, TestUploadThreshold);
476     FRIEND_TEST(DurationMetricE2eTest, TestConditionOnRepeatedEnumField);
477 
478     FRIEND_TEST(ValueMetricE2eTest, TestInitialConditionChanges);
479     FRIEND_TEST(ValueMetricE2eTest, TestPulledEvents);
480     FRIEND_TEST(ValueMetricE2eTest, TestPulledEvents_LateAlarm);
481     FRIEND_TEST(ValueMetricE2eTest, TestPulledEvents_WithActivation);
482     FRIEND_TEST(ValueMetricE2eTest, TestInitWithSlicedState);
483     FRIEND_TEST(ValueMetricE2eTest, TestInitWithSlicedState_WithDimensions);
484     FRIEND_TEST(ValueMetricE2eTest, TestInitWithSlicedState_WithIncorrectDimensions);
485     FRIEND_TEST(ValueMetricE2eTest, TestInitWithValueFieldPositionALL);
486     FRIEND_TEST(ValueMetricE2eTest, TestInitWithMultipleAggTypes);
487     FRIEND_TEST(ValueMetricE2eTest, TestInitWithDefaultAggType);
488 
489     FRIEND_TEST(KllMetricE2eTest, TestInitWithKllFieldPositionALL);
490 
491     FRIEND_TEST(StatsServiceConfigTest, StatsServiceStatsdInitTest);
492 
493     FRIEND_TEST(StringReplaceE2eTest, TestPulledDimension);
494     FRIEND_TEST(StringReplaceE2eTest, TestPulledWhat);
495     FRIEND_TEST(StringReplaceE2eTest, TestMultipleMatchersForAtom);
496 };
497 
498 }  // namespace statsd
499 }  // namespace os
500 }  // namespace android
501