• 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 enum class RawEventType { WARNING, FREEZE, RECOVER };
141 
142 struct EventInfo {
143     std::string eventType;
144     int32_t errorType = 0;
145     std::string pageUrl;
146 };
147 
148 class ACE_FORCE_EXPORT EventReport {
149 public:
150     static void SendEvent(const EventInfo& eventInfo);
151     static void SendJsCardRenderTimeEvent(
152         const std::string& sessionID,
153         const std::string& timeType,
154         uint64_t timeDelay);
155 
156     static void SendAppStartException(AppStartExcepType type);
157     static void SendPageRouterException(PageRouterExcepType type, const std::string& pageUrl = "");
158     static void SendComponentException(ComponentExcepType type);
159     static void SendAPIChannelException(APIChannelExcepType type);
160     static void SendRenderException(RenderExcepType type);
161     static void SendJsException(JsExcepType type);
162     static void SendAnimationException(AnimationExcepType type);
163     static void SendEventException(EventExcepType type);
164     static void SendInternalException(InternalExcepType type);
165     static void SendAccessibilityException(AccessibilityExcepType type);
166     static void SendFormException(FormExcepType type);
167 
168     static void JsEventReport(int32_t eventType, const std::string& jsonStr);
169     static void JsErrReport(
170         const std::string& packageName, const std::string& reason, const std::string& summary);
171     static void ANRRawReport(RawEventType type, int32_t uid, const std::string& packageName,
172         const std::string& processName, const std::string& msg = " ");
173     static void ANRShowDialog(int32_t uid, const std::string& packageName,
174         const std::string& processName, const std::string& msg = "");
175     static void JankFrameReport(int64_t startTime, int64_t duration, const std::vector<uint16_t>& jank,
176         const std::string& pageUrl, uint32_t jankStatusVersion = 1);
177     static void ReportEventComplete(DataBase& data);
178     static void ReportEventJankFrame(DataBase& data);
179 
180 private:
181     static void SendEventInner(const EventInfo& eventInfo);
182 };
183 
184 } // namespace OHOS::Ace
185 
186 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_EVENT_REPORT_H
187