• 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  * 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_ACE_FRAMEWORKS_BASE_LOG_EVENT_REPORT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_EVENT_REPORT_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "base/perfmonitor/perf_monitor.h"
23 #include "base/utils/macros.h"
24 
25 namespace OHOS::Ace {
26 
27 const std::string EXCEPTION_FRAMEWORK_APP_START = "FRAMEWORK_APP_START_EXCEPTION";
28 const std::string EXCEPTION_FRAMEWORK_PAGE_ROUTER = "FRAMEWORK_PAGE_ROUTER_EXCEPTION";
29 const std::string EXCEPTION_COMPONENT = "COMPONENT_EXCEPTION";
30 const std::string EXCEPTION_API_CHANNEL = "API_CHANNEL_EXCEPTION";
31 const std::string EXCEPTION_RENDER = "RENDER_EXCEPTION";
32 const std::string EXCEPTION_JS = "JS_EXCEPTION";
33 const std::string EXCEPTION_ANIMATION = "ANIMATION_EXCEPTION";
34 const std::string EXCEPTION_EVENT = "EVENT_EXCEPTION";
35 const std::string EXCEPTION_INTERNATIONALIZATION = "INTERNATIONALIZATION_EXCEPTION";
36 const std::string EXCEPTION_ACCESSIBILITY = "ACCESSIBILITY_EXCEPTION";
37 const std::string EXCEPTION_FORM = "FORM_EXCEPTION";
38 
39 // EXCEPTION_FRAMEWORK_APP_START
40 enum class AppStartExcepType {
41     CREATE_CONTAINER_ERR = 1,
42     SET_VIEW_ERR,
43     VIEW_TYPE_ERR,
44     GET_PACKAGE_PATH_ERR,
45     JNI_CLASS_ERR,
46     JNI_INIT_ERR = 10,
47     FRONTEND_TYPE_ERR,
48     PIPELINE_CONTEXT_ERR,
49     VIEW_STATE_ERR,
50     RESOURCE_REGISTER_INIT_ERR,
51     JS_ENGINE_CREATE_ERR,
52     JAVA_EVENT_CALLBACK_INIT_ERR,
53 };
54 
55 // EXCEPTION_FRAMEWORK_PAGE_ROUTER
56 enum class PageRouterExcepType {
57     ROUTE_PARSE_ERR = 0,
58     PAGE_STACK_OVERFLOW_ERR,
59     RUN_PAGE_ERR,
60     UPDATE_PAGE_ERR,
61     LOAD_PAGE_ERR,
62     REPLACE_PAGE_ERR,
63 };
64 
65 // EXCEPTION_COMPONENT
66 enum class ComponentExcepType {
67     TEXT_INPUT_CONNECTION_CLOSE_ERR = 0,
68     GET_THEME_ERR,
69     BUTTON_COMPONENT_ERR,
70     DIALOG_EVENT_ERR,
71     DOM_NODE_NOT_FOUND,
72     SET_ROOT_DOM_NODE_ERR,
73     IMAGE_ANIMATOR_ERR,
74     LIST_COMPONENT_ERR,
75     LIST_ITEM_ERR,
76     MARQUEE_ERR,
77     NAVIGATION_BAR_ERR,
78 };
79 
80 // EXCEPTION_API_CHANNEL
81 enum class APIChannelExcepType {
82     JS_BRIDGE_INIT_ERR = 0,
83     SET_FUNCTION_ERR,
84 };
85 
86 // EXCEPTION_RENDER
87 enum class RenderExcepType {
88     VIEW_SCALE_ERR = 0,
89     RENDER_ANIMATION_ERR,
90     RENDER_COMPONENT_ERR,
91     CLIP_ERR,
92     UI_THREAD_STUCK,
93 };
94 
95 // EXCEPTION_JS
96 enum class JsExcepType {
97     GET_NODE_ERR = 0,
98     CREATE_NODE_ERR,
99     CREATE_DOM_BODY_ERR,
100     REMOVE_DOM_ELEMENT_ERR,
101     UPDATE_DOM_ELEMENT_ERR,
102     JS_ENGINE_INIT_ERR,
103     JS_RUNTIME_OBJ_ERR,
104     JS_CONTEXT_INIT_ERR,
105     JS_THREAD_STUCK,
106 };
107 
108 // EXCEPTION_ANIMATION
109 enum class AnimationExcepType {
110     ANIMATION_BRIDGE_ERR = 0,
111     ANIMATION_PAGE_ERR,
112 };
113 
114 // EXCEPTION_EVENT
115 enum class EventExcepType {
116     FIRE_EVENT_ERR = 1,
117 };
118 
119 // EXCEPTION_INTERNATIONALIZATION
120 enum class InternalExcepType {
121     CHANGE_LOCALE_ERR = 0,
122 };
123 
124 // EXCEPTION_ACCESSIBILITY
125 enum class AccessibilityExcepType {
126     CREATE_ACCESSIBILITY_NODE_ERR = 0,
127     GET_NODE_ERR,
128 };
129 
130 // EXCEPTION_FORM
131 enum class FormExcepType {
132     RUN_PAGE_ERR = 0,
133     LOAD_PAGE_ERR,
134     CREATE_NODE_ERR,
135     UPDATE_PAGE_ERR,
136     FIRE_FORM_EVENT_ERR,
137     ACTION_EVENT_CALLBACK_ERR,
138 };
139 
140 #ifdef VSYNC_TIMEOUT_CHECK
141 enum class VsyncExcepType {
142     UI_VSYNC_TIMEOUT
143 };
144 #endif
145 
146 enum class RawEventType { WARNING, FREEZE, RECOVER };
147 
148 struct EventInfo {
149     std::string eventType;
150     int32_t errorType = 0;
151     std::string pageUrl;
152 };
153 
154 class ACE_FORCE_EXPORT EventReport {
155 public:
156     static void SendEvent(const EventInfo& eventInfo);
157     static void SendJsCardRenderTimeEvent(
158         const std::string& sessionID,
159         const std::string& timeType,
160         uint64_t timeDelay);
161 
162     static void SendAppStartException(AppStartExcepType type);
163     static void SendPageRouterException(PageRouterExcepType type, const std::string& pageUrl = "");
164     static void SendComponentException(ComponentExcepType type);
165     static void SendAPIChannelException(APIChannelExcepType type);
166     static void SendRenderException(RenderExcepType type);
167     static void SendJsException(JsExcepType type);
168     static void SendAnimationException(AnimationExcepType type);
169     static void SendEventException(EventExcepType type);
170     static void SendInternalException(InternalExcepType type);
171     static void SendAccessibilityException(AccessibilityExcepType type);
172     static void SendFormException(FormExcepType type);
173 #ifdef VSYNC_TIMEOUT_CHECK
174     static void SendVsyncException(VsyncExcepType type, uint32_t windowId, int32_t instanceId, uint64_t timeStamp);
175 #endif
176 
177     static void JsEventReport(int32_t eventType, const std::string& jsonStr);
178     static void JsErrReport(
179         const std::string& packageName, const std::string& reason, const std::string& summary);
180     static void ANRRawReport(RawEventType type, int32_t uid, const std::string& packageName,
181         const std::string& processName, const std::string& msg = " ");
182     static void ANRShowDialog(int32_t uid, const std::string& packageName,
183         const std::string& processName, const std::string& msg = "");
184     static void JankFrameReport(int64_t startTime, int64_t duration, const std::vector<uint16_t>& jank,
185         const std::string& pageUrl, uint32_t jankStatusVersion = 1);
186     static void ReportEventComplete(DataBase& data);
187     static void ReportEventJankFrame(DataBase& data);
188     static void ReportJankFrameApp(JankInfo& info);
189     static void ReportJankFrameFiltered(JankInfo& info);
190     static void ReportJankFrameUnFiltered(JankInfo& info);
191     static void ReportDoubleClickTitle(int32_t stateChange);
192     static void ReportClickTitleMaximizeMenu(int32_t maxMenuItem, int32_t stateChange);
193     static void ReportPageNodeOverflow(const std::string& pageUrl, int32_t nodeCount, int32_t threshold);
194     static void ReportPageDepthOverflow(const std::string& pageUrl, int32_t depth, int32_t threshold);
195     static void ReportFunctionTimeout(const std::string& functionName, int64_t time, int32_t threshold);
196     static void ReportHoverStatusChange(int32_t foldStatus, int32_t time, bool isHoverMode,
197         int32_t appRotation, int32_t windowMode);
198     static void ReportPageShowMsg(const std::string& pageUrl, const std::string& bundleName,
199                                   const std::string& pageName);
200 
201 private:
202     static void SendEventInner(const EventInfo& eventInfo);
203 #ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE
204     static void ReportAppFrameDropToRss(const bool isInteractionJank, const std::string &bundleName,
205         const int64_t maxFrameTime = 0);
206 #endif // RESOURCE_SCHEDULE_SERVICE_ENABLE
207 };
208 
209 } // namespace OHOS::Ace
210 
211 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_EVENT_REPORT_H
212