blob: 05e441caa4966eebb031ba960c2676cb0a17f637 [file] [log] [blame]
Yao Chenab273e22017-09-06 12:53:50 -07001/*
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 Chen44cf27c2017-09-14 22:32:50 -070019#include "DropboxWriter.h"
20#include "LogReader.h"
Yao Chencaf339d2017-10-06 16:01:10 -070021#include "frameworks/base/cmds/statsd/src/statsd_config.pb.h"
Yao Chen44cf27c2017-09-14 22:32:50 -070022#include "metrics/MetricsManager.h"
Yao Chencaf339d2017-10-06 16:01:10 -070023#include "stats_util.h"
David Chende701692017-10-05 13:16:02 -070024#include "UidMap.h"
Yao Chenab273e22017-09-06 12:53:50 -070025
Yao Chen44cf27c2017-09-14 22:32:50 -070026#include <log/logprint.h>
27#include <stdio.h>
David Chen0656b7a2017-09-13 15:53:39 -070028#include <unordered_map>
29
Bookatz906a35c2017-09-20 15:26:44 -070030namespace android {
31namespace os {
32namespace statsd {
Yao Chenab273e22017-09-06 12:53:50 -070033
Yao Chenef99c4f2017-09-22 16:26:54 -070034class StatsLogProcessor : public LogListener {
Yao Chenab273e22017-09-06 12:53:50 -070035public:
David Chende701692017-10-05 13:16:02 -070036 StatsLogProcessor(const sp<UidMap> &uidMap);
Yao Chenab273e22017-09-06 12:53:50 -070037 virtual ~StatsLogProcessor();
38
39 virtual void OnLogEvent(const log_msg& msg);
40
Yao Chen44cf27c2017-09-14 22:32:50 -070041 void UpdateConfig(const int config_source, const StatsdConfig& config);
David Chen0656b7a2017-09-13 15:53:39 -070042
Yao Chenab273e22017-09-06 12:53:50 -070043private:
Yao Chen44cf27c2017-09-14 22:32:50 -070044 // TODO: use EventMetrics to log the events.
Yao Chenab273e22017-09-06 12:53:50 -070045 DropboxWriter m_dropbox_writer;
David Chen0656b7a2017-09-13 15:53:39 -070046
Yao Chen44cf27c2017-09-14 22:32:50 -070047 std::unordered_map<int, std::unique_ptr<MetricsManager>> mMetricsManagers;
David Chende701692017-10-05 13:16:02 -070048
49 sp<UidMap> m_UidMap; // Reference to the UidMap to lookup app name and version for each uid.
Yao Chenab273e22017-09-06 12:53:50 -070050};
Bookatz906a35c2017-09-20 15:26:44 -070051
Yao Chenef99c4f2017-09-22 16:26:54 -070052} // namespace statsd
53} // namespace os
54} // namespace android
Bookatz906a35c2017-09-20 15:26:44 -070055
Yao Chenef99c4f2017-09-22 16:26:54 -070056#endif // STATS_LOG_PROCESSOR_H