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