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 | |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 19 | #include "DropboxWriter.h" |
| 20 | #include "LogReader.h" |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 21 | #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 22 | #include "metrics/MetricsManager.h" |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 23 | #include "stats_util.h" |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 24 | #include "UidMap.h" |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 25 | |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 26 | #include <log/logprint.h> |
| 27 | #include <stdio.h> |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 28 | #include <unordered_map> |
| 29 | |
Bookatz | 906a35c | 2017-09-20 15:26:44 -0700 | [diff] [blame] | 30 | namespace android { |
| 31 | namespace os { |
| 32 | namespace statsd { |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 33 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 34 | class StatsLogProcessor : public LogListener { |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 35 | public: |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 36 | StatsLogProcessor(const sp<UidMap> &uidMap); |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 37 | virtual ~StatsLogProcessor(); |
| 38 | |
| 39 | virtual void OnLogEvent(const log_msg& msg); |
| 40 | |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 41 | void UpdateConfig(const int config_source, const StatsdConfig& config); |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 42 | |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 43 | private: |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 44 | // TODO: use EventMetrics to log the events. |
Yao Chen | ab273e2 | 2017-09-06 12:53:50 -0700 | [diff] [blame] | 45 | DropboxWriter m_dropbox_writer; |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 46 | |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 47 | std::unordered_map<int, std::unique_ptr<MetricsManager>> mMetricsManagers; |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 48 | |
| 49 | sp<UidMap> m_UidMap; // 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] | 50 | }; |
Bookatz | 906a35c | 2017-09-20 15:26:44 -0700 | [diff] [blame] | 51 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 52 | } // namespace statsd |
| 53 | } // namespace os |
| 54 | } // namespace android |
Bookatz | 906a35c | 2017-09-20 15:26:44 -0700 | [diff] [blame] | 55 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 56 | #endif // STATS_LOG_PROCESSOR_H |