1 /*
2  * Copyright (c) 2022-2024 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 FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_EVENT_REPORT_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_EVENT_REPORT_H
18 
19 #include <unordered_map>
20 
21 #include "event_report.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 #define HISYSEVENT_PERIOD 5
26 #define HISYSEVENT_THRESHOLD 500
27 class InnerEventReport {
28 public:
29     /**
30      * @brief Send system events.
31      * @param eventType Indicates the bms eventInfo.
32      * @param eventInfo Indicates the eventInfo.
33      */
34     static void SendSystemEvent(BMSEventType eventType, const EventInfo& eventInfo);
35 
36 private:
37     // fault event
38     static void InnerSendBundleInstallExceptionEvent(const EventInfo& eventInfo);
39     static void InnerSendBundleUninstallExceptionEvent(const EventInfo& eventInfo);
40     static void InnerSendBundleUpdateExceptionEvent(const EventInfo& eventInfo);
41     static void InnerSendPreBundleRecoverExceptionEvent(const EventInfo& eventInfo);
42     static void InnerSendBundleStateChangeExceptionEvent(const EventInfo& eventInfo);
43     static void InnerSendBundleCleanCacheExceptionEvent(const EventInfo& eventInfo);
44 
45     // behavior event
46     static void InnerSendBootScanStartEvent(const EventInfo& eventInfo);
47     static void InnerSendBootScanEndEvent(const EventInfo& eventInfo);
48     static void InnerSendBundleInstallEvent(const EventInfo& eventInfo);
49     static void InnerSendBundleUninstallEvent(const EventInfo& eventInfo);
50     static void InnerSendBundleUpdateEvent(const EventInfo& eventInfo);
51     static void InnerSendPreBundleRecoverEvent(const EventInfo& eventInfo);
52     static void InnerSendBundleStateChangeEvent(const EventInfo& eventInfo);
53     static void InnerSendBundleCleanCacheEvent(const EventInfo& eventInfo);
54     static void InnerSendUserEvent(const EventInfo& eventInfo);
55     static void InnerSendQuickFixEvent(const EventInfo& eventInfo);
56     static void InnerSendCpuSceneEvent(const EventInfo& eventInfo);
57     static void InnerSendAOTSummaryEvent(const EventInfo& eventInfo);
58     static void InnerSendAOTRecordEvent(const EventInfo& eventInfo);
59     static void InnerSendQueryOfContinueTypeEvent(const EventInfo& eventInfo);
60     static void InnerSendFreeInstallEvent(const EventInfo& eventInfo);
61     static void InnerSendBmsDiskSpaceEvent(const EventInfo& eventInfo);
62 
63     template<typename... Types>
64     static void InnerEventWrite(const std::string &eventName,
65         HiSysEventType type, Types... keyValues);
66 
67     static std::unordered_map<BMSEventType, void (*)(const EventInfo& eventInfo)> bmsSysEventMap_;
68 };
69 }  // namespace AppExecFwk
70 }  // namespace OHOS
71 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_EVENT_REPORT_H
72