• 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 
21 #include "base/utils/macros.h"
22 
23 namespace OHOS::Ace {
24 
25 const std::string EXCEPTION_FRAMEWORK_APP_START = "FRAMEWORK_APP_START_EXCEPTION";
26 const std::string EXCEPTION_FRAMEWORK_PAGE_ROUTER = "FRAMEWORK_PAGE_ROUTER_EXCEPTION";
27 const std::string EXCEPTION_COMPONENT = "COMPONENT_EXCEPTION";
28 const std::string EXCEPTION_API_CHANNEL = "API_CHANNEL_EXCEPTION";
29 const std::string EXCEPTION_RENDER = "RENDER_EXCEPTION";
30 const std::string EXCEPTION_JS = "JS_EXCEPTION";
31 const std::string EXCEPTION_ANIMATION = "ANIMATION_EXCEPTION";
32 const std::string EXCEPTION_EVENT = "EVENT_EXCEPTION";
33 const std::string EXCEPTION_INTERNATIONALIZATION = "INTERNATIONALIZATION_EXCEPTION";
34 const std::string EXCEPTION_ACCESSIBILITY = "ACCESSIBILITY_EXCEPTION";
35 const std::string EXCEPTION_FORM = "FORM_EXCEPTION";
36 
37 // EXCEPTION_FRAMEWORK_APP_START
38 enum class AppStartExcepType {
39     CREATE_CONTAINER_ERR = 1,
40     SET_VIEW_ERR,
41     VIEW_TYPE_ERR,
42     GET_PACKAGE_PATH_ERR,
43     JNI_CLASS_ERR,
44     JNI_INIT_ERR = 10,
45     FRONTEND_TYPE_ERR,
46     PIPELINE_CONTEXT_ERR,
47     VIEW_STATE_ERR,
48     RESOURCE_REGISTER_INIT_ERR,
49     JS_ENGINE_CREATE_ERR,
50     JAVA_EVENT_CALLBACK_INIT_ERR,
51 };
52 
53 // EXCEPTION_FRAMEWORK_PAGE_ROUTER
54 enum class PageRouterExcepType {
55     ROUTE_PARSE_ERR = 0,
56     PAGE_STACK_OVERFLOW_ERR,
57     RUN_PAGE_ERR,
58     UPDATE_PAGE_ERR,
59     LOAD_PAGE_ERR,
60     REPLACE_PAGE_ERR,
61 };
62 
63 // EXCEPTION_COMPONENT
64 enum class ComponentExcepType {
65     TEXT_INPUT_CONNECTION_CLOSE_ERR = 0,
66     GET_THEME_ERR,
67     BUTTON_COMPONENT_ERR,
68     DIALOG_EVENT_ERR,
69     DOM_NODE_NOT_FOUND,
70     SET_ROOT_DOM_NODE_ERR,
71     IMAGE_ANIMATOR_ERR,
72     LIST_COMPONENT_ERR,
73     LIST_ITEM_ERR,
74     MARQUEE_ERR,
75     NAVIGATION_BAR_ERR,
76 };
77 
78 // EXCEPTION_API_CHANNEL
79 enum class APIChannelExcepType {
80     JS_BRIDGE_INIT_ERR = 0,
81     SET_FUNCTION_ERR,
82 };
83 
84 // EXCEPTION_RENDER
85 enum class RenderExcepType {
86     VIEW_SCALE_ERR = 0,
87     RENDER_ANIMATION_ERR,
88     RENDER_COMPONENT_ERR,
89     CLIP_ERR,
90     UI_THREAD_STUCK,
91 };
92 
93 // EXCEPTION_JS
94 enum class JsExcepType {
95     GET_NODE_ERR = 0,
96     CREATE_NODE_ERR,
97     CREATE_DOM_BODY_ERR,
98     REMOVE_DOM_ELEMENT_ERR,
99     UPDATE_DOM_ELEMENT_ERR,
100     JS_ENGINE_INIT_ERR,
101     JS_RUNTIME_OBJ_ERR,
102     JS_CONTEXT_INIT_ERR,
103     JS_THREAD_STUCK,
104 };
105 
106 // EXCEPTION_ANIMATION
107 enum class AnimationExcepType {
108     ANIMATION_BRIDGE_ERR = 0,
109     ANIMATION_PAGE_ERR,
110 };
111 
112 // EXCEPTION_EVENT
113 enum class EventExcepType {
114     FIRE_EVENT_ERR = 1,
115 };
116 
117 // EXCEPTION_INTERNATIONALIZATION
118 enum class InternalExcepType {
119     CHANGE_LOCALE_ERR = 0,
120 };
121 
122 // EXCEPTION_ACCESSIBILITY
123 enum class AccessibilityExcepType {
124     CREATE_ACCESSIBILITY_NODE_ERR = 0,
125     GET_NODE_ERR,
126 };
127 
128 // EXCEPTION_FORM
129 enum class FormExcepType {
130     RUN_PAGE_ERR = 0,
131     LOAD_PAGE_ERR,
132     CREATE_NODE_ERR,
133     UPDATE_PAGE_ERR,
134     FIRE_FORM_EVENT_ERR,
135     ACTION_EVENT_CALLBACK_ERR,
136 };
137 
138 enum class RawEventType { WARNING, FREEZE, RECOVER };
139 
140 struct EventInfo {
141     std::string eventType;
142     int32_t errorType = 0;
143     std::string pageUrl;
144 };
145 
146 class ACE_EXPORT EventReport {
147 public:
148     static void SendEvent(const EventInfo& eventInfo);
149     static void SendJsCardRenderTimeEvent(
150         const std::string& sessionID,
151         const std::string& timeType,
152         uint64_t timeDelay);
153 
154     static void SendAppStartException(AppStartExcepType type);
155     static void SendPageRouterException(PageRouterExcepType type, const std::string& pageUrl = "");
156     static void SendComponentException(ComponentExcepType type);
157     static void SendAPIChannelException(APIChannelExcepType type);
158     static void SendRenderException(RenderExcepType type);
159     static void SendJsException(JsExcepType type);
160     static void SendAnimationException(AnimationExcepType type);
161     static void SendEventException(EventExcepType type);
162     static void SendInternalException(InternalExcepType type);
163     static void SendAccessibilityException(AccessibilityExcepType type);
164     static void SendFormException(FormExcepType type);
165 
166     static void JsEventReport(int32_t eventType, const std::string& jsonStr);
167     static void JsErrReport(
168         const std::string& packageName, const std::string& reason, const std::string& summary);
169     static void ANRRawReport(RawEventType type, int32_t uid, const std::string& packageName,
170         const std::string& processName, const std::string& msg = " ");
171     static void ANRShowDialog(int32_t uid, const std::string& packageName,
172         const std::string& processName, const std::string& msg = "");
173 
174 private:
175     static void SendEventInner(const EventInfo& eventInfo);
176 };
177 
178 } // namespace OHOS::Ace
179 
180 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_EVENT_REPORT_H
181