• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 OHOS_FORM_FWK_FORM_EVENT_REPORT_H
17 #define OHOS_FORM_FWK_FORM_EVENT_REPORT_H
18 
19 #include <string>
20 
21 #include "hisysevent.h"
22 #include "want.h"
23 
24 using HiSysEventType = OHOS::HiviewDFX::HiSysEvent::EventType;
25 using HiSysEvent = OHOS::HiviewDFX::HiSysEvent;
26 using Want = OHOS::AAFwk::Want;
27 
28 namespace OHOS {
29 namespace AppExecFwk {
30 struct FormEventInfo {
31     int64_t formId = -1;
32     std::string bundleName;
33     std::string moduleName;
34     std::string abilityName;
35     std::string hostBundleName = "";
36     int32_t formAppPid = -1;
37     int64_t timeStamp = 0;
38 };
39 
40 enum class CallDbFiledErrorType : int64_t {
41     LOAD_DATABASE_FAILED = 1,
42     DATABASE_RESET_CONNECT_FAILED,
43     DATABASE_SAVE_FORMID_FAILED,
44     DATABASE_DELETE_FORMID_FAILED,
45     DATABASE_QUERY_FORMID_FAILED,
46     DATABASE_EXIT_ABNORMA,
47 };
48 
49 enum class InitFmsFiledErrorType : int64_t {
50     LOAD_FORM_DB_FAILED = 1,
51     PUBLISH_SER_FAILED,
52 };
53 
54 enum class AddFormFiledErrorType : int64_t {
55     NUMBER_EXCEEDING_LIMIT = 1,
56 };
57 
58 struct NewFormEventInfo {
59     int64_t formId = -1;
60     std::string bundleName;
61     std::string moduleName;
62     std::string abilityName;
63     std::string hostBundleName = "";
64     int64_t sessionId;
65     int64_t bindDuration;
66     int64_t getDuration;
67     std::string formName;
68     int64_t formDimension;
69     int64_t acquireDuration;
70     int64_t duration;
71     int64_t durationType;
72     int32_t dailyRefreshTimes;
73     int32_t invisibleRefreshTimes;
74     int32_t hfRefreshBlockTimes;
75     int32_t invisibleRefreshBlockTimes;
76     int32_t highLoadRefreshBlockTimes;
77     int32_t activeRecoverRefreshTimes;
78     int32_t passiveRecoverRefreshTimes;
79     int32_t hfRecoverRefreshTimes;
80     int32_t offloadRecoverRefreshTimes;
81     std::string clientBundleName = "";
82     std::string formBundleName = "";
83     int32_t conditionType;
84     int32_t renderingMode;
85     std::string bundleAndFormName;
86 };
87 
88 enum class FormEventName {
89     // form behavior event
90     ADD_FORM,
91     REQUEST_FORM,
92     DELETE_FORM,
93     CASTTEMP_FORM,
94     ACQUIREFORMSTATE_FORM,
95     MESSAGE_EVENT_FORM,
96     ROUTE_EVENT_FORM,
97     BACKGROUND_EVENT_FORM,
98     RELEASE_FORM,
99     DELETE_INVALID_FORM,
100     SET_NEXT_REFRESH_TIME_FORM,
101     FORM_RENDER_BLOCK,
102     INIT_FMS_FAILED,
103     CALLEN_DB_FAILED,
104     ADD_FORM_FAILED,
105     FIRST_ADD_FORM_DURATION,
106     FIRST_UPDATE_FORM_DURATION,
107     UPDATE_FORM_REFRESH_TIMES,
108     PROXY_UPDATE_FORM,
109     INVALID_PUBLISH_FORM_TO_HOST,
110     LAUNCH_FORM_APP,
111     CONDITION_UPDATE_FORM,
112     UNBIND_FORM_APP,
113     LOAD_STAGE_FORM_CONFIG_INFO
114 };
115 
116 class FormEventReport {
117 public:
118     static void SendFormEvent(const FormEventName &eventName, HiSysEventType type, const FormEventInfo &eventInfo);
119     static void SendSecondFormEvent(const FormEventName &eventName, HiSysEventType type,
120         const FormEventInfo &eventInfo);
121     static void SendThirdFormEvent(const FormEventName &eventName, HiSysEventType type,
122         const FormEventInfo &eventInfo);
123     static void SendFormFailedEvent(const FormEventName &eventName, HiSysEventType type, int64_t errorType);
124     static void SendFirstAddFormEvent(const FormEventName &eventName, HiSysEventType type,
125         const NewFormEventInfo &eventInfo);
126     static void SendFirstUpdateFormEvent(const FormEventName &eventName, HiSysEventType type,
127         const NewFormEventInfo &eventInfo);
128     static void SendFourthFormEvent(const FormEventName &eventName, HiSysEventType type,
129         const NewFormEventInfo &eventInfo, const Want &want);
130     static void SendConditonUpdateFormEvent(const FormEventName &eventName, HiSysEventType type,
131         const NewFormEventInfo &eventInfo);
132     static void SendFormRefreshCountEvent(const FormEventName &eventName, HiSysEventType type,
133         const NewFormEventInfo &eventInfo);
134     static void SendLoadStageFormConfigInfoEvent(const FormEventName &eventName, HiSysEventType type,
135         const NewFormEventInfo &eventInfo);
136 private:
137     static std::string ConvertEventName(const FormEventName &eventName);
138 };
139 } // namespace AppExecFwk
140 } // namespace OHOS
141 #endif // OHOS_FORM_FWK_FORM_EVENT_REPORT_H
142