1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef HIVIEW_PLUGINS_USAGE_EVENT_REPORT_SERVICE_USAGE_EVENT_REPORT_SERVICE_H
17 #define HIVIEW_PLUGINS_USAGE_EVENT_REPORT_SERVICE_USAGE_EVENT_REPORT_SERVICE_H
18 
19 #include <string>
20 
21 #include "logger_event.h"
22 #include "usage_event_cacher.h"
23 
24 namespace OHOS {
25 namespace HiviewDFX {
26 class UsageEventReportService {
27 public:
28     UsageEventReportService();
~UsageEventReportService()29     ~UsageEventReportService() {}
30     bool ProcessArgsRequest(int argc, char* argv[]);
31 
32 private:
33     void InitWorkPath(const char* path);
34     void ReportAppUsage();
35     void ReportSysUsage();
36     void SaveSysUsage();
37     void UpdateCacheSysUsage(std::shared_ptr<LoggerEvent>& cacheUsage, const UsageEventCacher& cacher);
38     void UpdateLastSysUsage(std::shared_ptr<LoggerEvent>& nowUsage, const UsageEventCacher& cacher);
39 
40 private:
41     std::string workPath_;
42     uint64_t lastReportTime_;
43     uint64_t lastSysReportTime_;
44 }; // UsageEventReportService
45 } // namespace HiviewDFX
46 } // namespace OHOS
47 #endif // HIVIEW_PLUGINS_USAGE_EVENT_REPORT_SERVICE_USAGE_EVENT_REPORT_SERVICE_H
48