• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef RESTRICTED_EVENT_METRIC_PRODUCER_H
2 #define RESTRICTED_EVENT_METRIC_PRODUCER_H
3 
4 #include <gtest/gtest_prod.h>
5 
6 #include "EventMetricProducer.h"
7 #include "utils/RestrictedPolicyManager.h"
8 
9 namespace android {
10 namespace os {
11 namespace statsd {
12 
13 class RestrictedEventMetricProducer : public EventMetricProducer {
14 public:
15     RestrictedEventMetricProducer(
16             const ConfigKey& key, const EventMetric& eventMetric, const int conditionIndex,
17             const vector<ConditionState>& initialConditionCache, const sp<ConditionWizard>& wizard,
18             const uint64_t protoHash, const int64_t startTimeNs,
19             const std::unordered_map<int, std::shared_ptr<Activation>>& eventActivationMap = {},
20             const std::unordered_map<int, std::vector<std::shared_ptr<Activation>>>&
21                     eventDeactivationMap = {},
22             const vector<int>& slicedStateAtoms = {},
23             const unordered_map<int, unordered_map<int, int64_t>>& stateGroupMap = {});
24 
25     void onMetricRemove() override;
26 
27     void enforceRestrictedDataTtl(sqlite3* db, const int64_t wallClockNs);
28 
29     void flushRestrictedData() override;
30 
31     bool writeMetricMetadataToProto(metadata::MetricMetadata* metricMetadata) override;
32 
33     void loadMetricMetadataFromProto(const metadata::MetricMetadata& metricMetadata) override;
34 
getRestrictionCategory()35     inline StatsdRestrictionCategory getRestrictionCategory() {
36         std::lock_guard<std::mutex> lock(mMutex);
37         return mRestrictedDataCategory;
38     }
39 
40 private:
41     void onMatchedLogEventInternalLocked(
42             const size_t matcherIndex, const MetricDimensionKey& eventKey,
43             const ConditionKey& conditionKey, bool condition, const LogEvent& event,
44             const std::map<int, HashableDimensionKey>& statePrimaryKeys) override;
45 
46     void onDumpReportLocked(const int64_t dumpTimeNs, const bool include_current_partial_bucket,
47                             const bool erase_data, const DumpLatency dumpLatency,
48                             std::set<string>* str_set,
49                             android::util::ProtoOutputStream* protoOutput) override;
50 
51     void clearPastBucketsLocked(const int64_t dumpTimeNs) override;
52 
53     void dropDataLocked(const int64_t dropTimeNs) override;
54 
55     void deleteMetricTable();
56 
57     bool mIsMetricTableCreated = false;
58 
59     StatsdRestrictionCategory mRestrictedDataCategory;
60 
61     vector<LogEvent> mLogEvents;
62 };
63 
64 }  // namespace statsd
65 }  // namespace os
66 }  // namespace android
67 #endif  // RESTRICTED_EVENT_METRIC_PRODUCER_H
68