• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 IMSA_HISYSEVENT_REPORTER_H
17 #define IMSA_HISYSEVENT_REPORTER_H
18 
19 #include <cstdint>
20 #include <map>
21 #include <unordered_set>
22 #include <utility>
23 #include <vector>
24 
25 #include "global.h"
26 #include "imf_hisysevent_reporter.h"
27 namespace OHOS {
28 namespace MiscServices {
29 struct ClientAttachAllInfo {
ClientAttachAllInfoClientAttachAllInfo30     ClientAttachAllInfo(uint32_t succeedIntervalNum, uint32_t failedIntervalNum)
31         : succeedRateInfo(SuccessRateStatistics(succeedIntervalNum, failedIntervalNum))
32     {
33     }
34     std::vector<std::string> appNames;
35     std::vector<std::string> imeNames;
36     SuccessRateStatistics succeedRateInfo;
37 };
38 
39 struct ClientShowAllInfo {
ClientShowAllInfoClientShowAllInfo40     ClientShowAllInfo(uint32_t succeedIntervalNum, uint32_t failedIntervalNum)
41         : succeedRateInfo(SuccessRateStatistics(succeedIntervalNum, failedIntervalNum))
42     {
43     }
44     std::vector<std::string> appNames;
45     std::vector<std::string> imeNames;
46     SuccessRateStatistics succeedRateInfo;
47 };
48 
49 class ImsaHiSysEventReporter : public ImfHiSysEventReporter {
50 public:
51     static ImsaHiSysEventReporter &GetInstance();
52 
53 private:
54     ImsaHiSysEventReporter();
55     ~ImsaHiSysEventReporter();
56     bool IsValidErrCode(int32_t errCode) override;
57     bool IsFault(int32_t errCode) override;
58     void RecordStatisticsEvent(ImfStatisticsEvent event, const HiSysOriginalInfo &info) override;
59     void ReportStatisticsEvent() override;
60     void RecordClientAttachStatistics(const HiSysOriginalInfo &info);
61     void RecordClientShowStatistics(const HiSysOriginalInfo &info);
62     std::mutex statisticsEventLock_;
63     ClientAttachAllInfo clientAttachInfo_;
64     ClientShowAllInfo clientShowInfo_;
65 };
66 } // namespace MiscServices
67 } // namespace OHOS
68 
69 #endif // IMSA_HISYSEVENT_REPORTER_H