• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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  * miscservices under the License is miscservices 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 MISCSERVICES_STATISTIC_REPORTER_H
17 #define MISCSERVICES_STATISTIC_REPORTER_H
18 #include <map>
19 #include <mutex>
20 
21 #include "dfx_types.h"
22 namespace OHOS {
23 namespace MiscServices {
24 // 统计报告
25 class StatisticReporter {
26 public:
27     static void ReportUsageTimeStatistic(int userId, const UsageTimeStat &stat);
28     static void StartTimerThread();
29     static ReportStatus InvokeUsageTime(time_t curTime);
30 
31 private:
32     static std::mutex usageTimeMutex_;
33     static std::map<int, std::vector<UsageTimeStat>> usageTimeStat_;
34 
35     static std::mutex runMutex_;
36     static bool running_;
37     static const inline int ONE_DAY_IN_HOURS = 24;
38     static const inline int ONE_MINUTE_IN_SECONDS = 60;
39     static const inline int ONE_HOUR_IN_SECONDS = 1 * 60 * 60; // 1 hours
40 
41     static const inline int EXEC_HOUR_TIME = 23;
42     static const inline int EXEC_MIN_TIME = 60;
43 };
44 } // namespace MiscServices
45 } // namespace OHOS
46 #endif // MISCSERVICES_STATISTIC_REPORTER_H
47