Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #ifndef STATS_LOG_PROCESSOR_H |
| 17 | #define STATS_LOG_PROCESSOR_H |
| 18 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame^] | 19 | #include "config/ConfigListener.h" |
| 20 | #include "logd/LogReader.h" |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 21 | #include "metrics/MetricsManager.h" |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame^] | 22 | #include "packages/UidMap.h" |
| 23 | #include "storage/DropboxWriter.h" |
| 24 | |
| 25 | #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 26 | |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 27 | #include <log/logprint.h> |
| 28 | #include <stdio.h> |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 29 | #include <unordered_map> |
| 30 | |
Bookatz | 906a35c | 2017-09-20 15:26:44 -0700 | [diff] [blame] | 31 | namespace android { |
| 32 | namespace os { |
| 33 | namespace statsd { |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 34 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame^] | 35 | class StatsLogProcessor : public ConfigListener { |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 36 | public: |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 37 | StatsLogProcessor(const sp<UidMap> &uidMap); |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 38 | virtual ~StatsLogProcessor(); |
| 39 | |
| 40 | virtual void OnLogEvent(const log_msg& msg); |
| 41 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame^] | 42 | void OnConfigUpdated(const ConfigKey& key, const StatsdConfig& config); |
| 43 | void OnConfigRemoved(const ConfigKey& key); |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 44 | |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 45 | private: |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 46 | // TODO: use EventMetrics to log the events. |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 47 | DropboxWriter m_dropbox_writer; |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 48 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame^] | 49 | std::unordered_map<ConfigKey, std::unique_ptr<MetricsManager>> mMetricsManagers; |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 50 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame^] | 51 | sp<UidMap> mUidMap; // Reference to the UidMap to lookup app name and version for each uid. |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 52 | }; |
Bookatz | 906a35c | 2017-09-20 15:26:44 -0700 | [diff] [blame] | 53 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 54 | } // namespace statsd |
| 55 | } // namespace os |
| 56 | } // namespace android |
Bookatz | 906a35c | 2017-09-20 15:26:44 -0700 | [diff] [blame] | 57 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 58 | #endif // STATS_LOG_PROCESSOR_H |