1020a203aSopenharmony_ci/*
2020a203aSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
3020a203aSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4020a203aSopenharmony_ci * you may not use this file except in compliance with the License.
5020a203aSopenharmony_ci * You may obtain a copy of the License at
6020a203aSopenharmony_ci *
7020a203aSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8020a203aSopenharmony_ci *
9020a203aSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10020a203aSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11020a203aSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12020a203aSopenharmony_ci * See the License for the specific language governing permissions and
13020a203aSopenharmony_ci * limitations under the License.
14020a203aSopenharmony_ci */
15020a203aSopenharmony_ci#ifndef EVT_PARSER_H
16020a203aSopenharmony_ci#define EVT_PARSER_H
17020a203aSopenharmony_ci
18020a203aSopenharmony_ci#include "XperfEvt.h"
19020a203aSopenharmony_ci#include "plugin.h"
20020a203aSopenharmony_ci#include "sys_event.h"
21020a203aSopenharmony_ci
22020a203aSopenharmony_cinamespace OHOS {
23020a203aSopenharmony_cinamespace HiviewDFX {
24020a203aSopenharmony_ciconst std::string KEY_PNAME = "PROCESS_NAME";
25020a203aSopenharmony_ciconst std::string KEY_MESSAGE = "MSG";
26020a203aSopenharmony_ciconst std::string KEY_PID = "PID";
27020a203aSopenharmony_ciconst std::string KEY_UID = "UID";
28020a203aSopenharmony_ciconst std::string KEY_APP_PID = "APP_PID";
29020a203aSopenharmony_ciconst std::string KEY_APP_VERSION = "VERSION_NAME";
30020a203aSopenharmony_ciconst std::string KEY_ABILITY_NAME = "ABILITY_NAME";
31020a203aSopenharmony_ciconst std::string KEY_BUNDLE_NAME = "BUNDLE_NAME";
32020a203aSopenharmony_ciconst std::string KEY_ABILITY_TYPE = "ABILITY_TYPE";
33020a203aSopenharmony_ci
34020a203aSopenharmony_ciconst std::string START_ABILITY = "START_ABILITY";
35020a203aSopenharmony_ciconst std::string APP_ATTACH = "APP_ATTACH";
36020a203aSopenharmony_ciconst std::string ABILITY_ONFOREGROUND = "ABILITY_ONFOREGROUND";
37020a203aSopenharmony_ciconst std::string APP_FOREGROUND = "APP_FOREGROUND";
38020a203aSopenharmony_ciconst std::string APP_BACKGROUND = "APP_BACKGROUND";
39020a203aSopenharmony_ciconst std::string APP_TERMINATE = "APP_TERMINATE";
40020a203aSopenharmony_ciconst std::string JANK_FRAME_SKIP = "JANK_FRAME_SKIP";
41020a203aSopenharmony_ciconst std::string ABILITY_ONBACKGROUND = "ABILITY_ONBACKGROUND";
42020a203aSopenharmony_ciconst std::string RS_COMPOSITION_TIMEOUT = "RS_COMPOSITION_TIMEOUT";
43020a203aSopenharmony_ciconst std::string ABILITY_ONACTIVE = "ABILITY_ONACTIVE";
44020a203aSopenharmony_ciconst std::string KERNEL_AWAKE = "KERNEL_AWAKE";
45020a203aSopenharmony_ciconst std::string SCREENON_EVENT = "SCREENON_EVENT";
46020a203aSopenharmony_ciconst std::string LCD_POWER_ON = "LCD_POWER_ON";
47020a203aSopenharmony_ciconst std::string LCD_BACKLIGHT_ON = "LCD_BACKLIGHT_ON";
48020a203aSopenharmony_ciconst std::string KEY_STARTUP_TIME = "STARTUP_TIME";
49020a203aSopenharmony_ci
50020a203aSopenharmony_ciconst std::string KEY_VERSION_CODE = "VERSION_CODE";
51020a203aSopenharmony_ciconst std::string KEY_SOURCE_TYPE = "SOURCE_TYPE";
52020a203aSopenharmony_ciconst std::string PAGE_URL = "PAGE_URL";
53020a203aSopenharmony_ciconst std::string SCENE_ID = "SCENE_ID";
54020a203aSopenharmony_ciconst std::string INPUT_TIME = "INPUT_TIME";
55020a203aSopenharmony_ciconst std::string ANIMATION_START_TIME = "ANIMATION_START_TIME";
56020a203aSopenharmony_ciconst std::string RENDER_TIME = "RENDER_TIME";
57020a203aSopenharmony_ciconst std::string RESPONSE_LATENCY = "RESPONSE_LATENCY";
58020a203aSopenharmony_ciconst std::string TIMER = "time_";
59020a203aSopenharmony_ciconst std::string ANIMATION_END_LATENCY = "ANIMATION_END_LATENCY";
60020a203aSopenharmony_ciconst std::string E2E_LATENCY = "E2E_LATENCY";
61020a203aSopenharmony_ci
62020a203aSopenharmony_ci// for boot
63020a203aSopenharmony_ciconst std::string REASON = "REASON";
64020a203aSopenharmony_ciconst std::string ISFIRST = "ISFIRST";
65020a203aSopenharmony_ciconst std::string DETAILED_TIME = "DETAILED_TIME";
66020a203aSopenharmony_ciconst std::string TOTAL_TIME = "TOTAL_TIME";
67020a203aSopenharmony_ci
68020a203aSopenharmony_ci//for app startup
69020a203aSopenharmony_ciconst std::string KEY_BUNDLE_TYPE = "BUNDLE_TYPE";
70020a203aSopenharmony_ciconst std::string KEY_MODULE_NAME = "MODULE_NAME";
71020a203aSopenharmony_ciconst std::string KEY_STARTUP_ABILITY_TYPE = "STARTUP_ABILITY_TYPE";
72020a203aSopenharmony_ciconst std::string KEY_STARTUP_EXTENSION_TYPE = "STARTUP_EXTENSION_TYPE";
73020a203aSopenharmony_ciconst std::string KEY_CALLER_BUNDLE_NAME = "CALLER_BUNDLE_NAME";
74020a203aSopenharmony_ciconst std::string KEY_CALLER_UID = "CALLER_UID";
75020a203aSopenharmony_ciconst std::string KEY_CALLER_PROCESS_NAME = "CALLER_PROCESS_NAME";
76020a203aSopenharmony_ciconst std::string KEY_WINDOW_NAME = "WINDOW_NAME";
77020a203aSopenharmony_ciconst std::string KEY_ANIMATION_START_LATENCY = "ANIMATION_START_LATENCY";
78020a203aSopenharmony_ciconst std::string KEY_E2E_LATENCY = "ANIMATION_E2E_LATENCY";
79020a203aSopenharmony_ciconst std::string KEY_START_TYPE = "START_TYPE";
80020a203aSopenharmony_ciconst std::string KEY_APP_UID = "APP_UID";
81020a203aSopenharmony_ci
82020a203aSopenharmony_ci// for app associated start
83020a203aSopenharmony_ciconst std::string KEY_CALLEE_PROCESS_NAME = "CALLEE_PROCESS_NAME";
84020a203aSopenharmony_ciconst std::string KEY_CALLEE_BUNDLE_NAME = "CALLEE_BUNDLE_NAME";
85020a203aSopenharmony_ci
86020a203aSopenharmony_ci// animator jank frame
87020a203aSopenharmony_ciconst std::string UNIQUE_ID = "UNIQUE_ID";
88020a203aSopenharmony_ciconst std::string STARTTIME = "STARTTIME";
89020a203aSopenharmony_ciconst std::string DURITION = "DURITION";
90020a203aSopenharmony_ciconst std::string TOTAL_FRAMES = "TOTAL_FRAMES";
91020a203aSopenharmony_ciconst std::string TOTAL_MISSED_FRAMES = "TOTAL_MISSED_FRAMES";
92020a203aSopenharmony_ciconst std::string MAX_SEQ_MISSED_FRAMES = "MAX_SEQ_MISSED_FRAMES";
93020a203aSopenharmony_ciconst std::string MAX_FRAMETIME = "MAX_FRAMETIME";
94020a203aSopenharmony_ciconst std::string AVERAGE_FRAMETIME = "AVERAGE_FRAMETIME";
95020a203aSopenharmony_ciconst std::string IS_FOLD_DISP = "IS_FOLD_DISP";
96020a203aSopenharmony_ciconst std::string IS_DISPLAY_ANIMATOR = "DISPLAY_ANIMATOR";
97020a203aSopenharmony_ci// for screen switch
98020a203aSopenharmony_ciconst std::string KEY_SCREEN_ID = "SCREEN_ID";
99020a203aSopenharmony_ciconst std::string KEY_SCENE_PANEL_NAME = "SCENE_PANEL_NAME";
100020a203aSopenharmony_ciconst std::string KEY_ROTATION_START_TIME = "ROTATION_START_TIME";
101020a203aSopenharmony_ciconst std::string KEY_ROTATION_DURATION = "ROTATION_DURATION";
102020a203aSopenharmony_ci//for app exit
103020a203aSopenharmony_ciconst std::string KEY_EXIT_TIME = "EXIT_TIME";
104020a203aSopenharmony_ciconst std::string KEY_EXIT_RESULT = "EXIT_RESULT";
105020a203aSopenharmony_ciconst std::string KEY_EXIT_PID = "EXIT_PID";
106020a203aSopenharmony_ciconst std::string KEY_NOTE = "NOTE";
107020a203aSopenharmony_ci
108020a203aSopenharmony_ci// for power on
109020a203aSopenharmony_ciconst std::string POWER_STATE = "STATE";
110020a203aSopenharmony_ci
111020a203aSopenharmony_ci// for screen unlock
112020a203aSopenharmony_ciconst std::string KEY_PACKAGE_NAME = "PACKAGE_NAME";
113020a203aSopenharmony_ciconst std::string KEY_VERIFYSUCESS = "VERIFYSUCESS";
114020a203aSopenharmony_ciconst std::string KEY_VERIFY_COSTTIME = "VERIFY_COSTTIME";
115020a203aSopenharmony_ci
116020a203aSopenharmony_ci// for for PC quick wake
117020a203aSopenharmony_ciconst std::string KEY_KERNEL_START_TIME = "KERNEL_START_TIME";
118020a203aSopenharmony_ciconst std::string KEY_KERNEL_END_TIME = "KERNEL_END_TIME";
119020a203aSopenharmony_ciconst std::string KEY_ANIM_BEGIN_TIME = "BEGIN_TIME";
120020a203aSopenharmony_ciconst std::string KEY_ANIM_END_TIME = "END_TIME";
121020a203aSopenharmony_ci
122020a203aSopenharmony_ci// for general skip frame
123020a203aSopenharmony_ciconst std::string KEY_SKIPPED_FRAME_TIME = "SKIPPED_FRAME_TIME";
124020a203aSopenharmony_ci
125020a203aSopenharmony_ci// for DH jank frame
126020a203aSopenharmony_ciconst std::string DH_JANK_FRAME_HAPPEN_TIME = "HAPPEN_TIME";
127020a203aSopenharmony_ciconst std::string DH_JANK_FRAME_TOTAL_TIME_SPENT = "TOTAL_TIME_SPENT";
128020a203aSopenharmony_ciconst std::string DH_JANK_FRAME_PACKAGE_NAME = "PACKAGE_NAME";
129020a203aSopenharmony_ciconst std::string DH_JANK_FRAME_VERSION = "VERSION";
130020a203aSopenharmony_ci
131020a203aSopenharmony_ci// for DH compose jank frame
132020a203aSopenharmony_ciconst std::string DH_COMPOSE_JANK_FRAME_START_TIME = "START_TIME";
133020a203aSopenharmony_ciconst std::string DH_COMPOSE_JANK_FRAME_END_TIME = "END_TIME";
134020a203aSopenharmony_ciconst std::string DH_COMPOSE_JANK_FRAME_SKIP_FRAME = "SKIP_FRAME";
135020a203aSopenharmony_ciconst std::string DH_COMPOSE_JANK_FRAME_VSYNC_INTERVAL = "VSYNC_INTERVAL";
136020a203aSopenharmony_ci
137020a203aSopenharmony_ci// for DH app start
138020a203aSopenharmony_ciconst std::string DH_APP_START_MISSION_ID = "MISSION_ID";
139020a203aSopenharmony_ciconst std::string DH_APP_START_TASK_ID = "TASK_ID";
140020a203aSopenharmony_ciconst std::string DH_APP_START_TIMESTAMP = "TIMESTAMP";
141020a203aSopenharmony_ci// for screen Fold open and close
142020a203aSopenharmony_ciconst std::string KEY_POWER_OFF_SCREEN = "POWER_OFF_SCREEN";
143020a203aSopenharmony_ciconst std::string KEY_POWER_ON_SCREEN = "POWER_ON_SCREEN";
144020a203aSopenharmony_ci
145020a203aSopenharmony_ciconst std::string KEY_HAPPEN_TIME = "HAPPEN_TIME";
146020a203aSopenharmony_ci
147020a203aSopenharmony_ci// for perf factory test mode
148020a203aSopenharmony_ciconst std::string PERF_FACTORY_TEST_TITLE = "TEST_TITLE";
149020a203aSopenharmony_ci
150020a203aSopenharmony_ci// for frequency limit
151020a203aSopenharmony_ciconst std::string KEY_CLIENT_ID = "CLIENT_ID";
152020a203aSopenharmony_ciconst std::string KEY_RES_ID = "RES_ID";
153020a203aSopenharmony_ciconst std::string KEY_CONFIG = "CONFIG";
154020a203aSopenharmony_ci// for boost limit
155020a203aSopenharmony_ciconst std::string KEY_ON_OFF_TAG = "ON_OFF_TAG";
156020a203aSopenharmony_ci// for shader malfunction
157020a203aSopenharmony_ciconst std::string KEY_SHADER_MALFUNCTION_PID = "PID";
158020a203aSopenharmony_ciconst std::string KEY_SHADER_MALFUNCTION_PROCESS_NAME = "PROCESS_NAME";
159020a203aSopenharmony_ciconst std::string KEY_SHADER_MALFUNCTION_HASH_CODE = "HASH_CODE";
160020a203aSopenharmony_ciconst std::string KEY_SHADER_MALFUNCTION_COMPILE_TIME = "COMPILE_TIME";
161020a203aSopenharmony_ciconst std::string KEY_SHADER_MALFUNCTION_TIME_STAMP = "TIME_STAMP";
162020a203aSopenharmony_ciconst std::string KEY_SHADER_MALFUNCTION_PART_FLAG = "PART_FLAG";
163020a203aSopenharmony_ci// for shader stats
164020a203aSopenharmony_ciconst std::string KEY_SHADER_STATS_PID = "PID";
165020a203aSopenharmony_ciconst std::string KEY_SHADER_STATS_PROCESS_NAME = "PROCESS_NAME";
166020a203aSopenharmony_ciconst std::string KEY_SHADER_STATS_TIME_STAMP = "TIME_STAMP";
167020a203aSopenharmony_ciconst std::string KEY_SHADER_STATS_PART_FLAG = "PART_FLAG";
168020a203aSopenharmony_ci// for webview page load
169020a203aSopenharmony_ciconst std::string NAVIGATION_ID = "NAVIGATION_ID";
170020a203aSopenharmony_ciconst std::string NAVIGATION_START = "NAVIGATION_START";
171020a203aSopenharmony_ciconst std::string REDIRECT_COUNT = "REDIRECT_COUNT";
172020a203aSopenharmony_ciconst std::string REDIRECT_START = "REDIRECT_START";
173020a203aSopenharmony_ciconst std::string REDIRECT_END = "REDIRECT_END";
174020a203aSopenharmony_ciconst std::string FETCH_START = "FETCH_START";
175020a203aSopenharmony_ciconst std::string WORKER_START = "WORKER_START";
176020a203aSopenharmony_ciconst std::string DOMAIN_LOOKUP_START = "DOMAIN_LOOKUP_START";
177020a203aSopenharmony_ciconst std::string DOMAIN_LOOKUP_END = "DOMAIN_LOOKUP_END";
178020a203aSopenharmony_ciconst std::string CONNECT_START = "CONNECT_START";
179020a203aSopenharmony_ciconst std::string SECURE_CONNECT_START = "SECURE_CONNECT_START";
180020a203aSopenharmony_ciconst std::string CONNECT_END = "CONNECT_END";
181020a203aSopenharmony_ciconst std::string REQUEST_START = "REQUEST_START";
182020a203aSopenharmony_ciconst std::string RESPONSE_START = "RESPONSE_START";
183020a203aSopenharmony_ciconst std::string RESPONSE_END = "RESPONSE_END";
184020a203aSopenharmony_ciconst std::string DOM_INTERACTIVE = "DOM_INTERACTIVE";
185020a203aSopenharmony_ciconst std::string DOM_CONTENT_LOADED_EVENT_START = "DOM_CONTENT_LOADED_EVENT_START";
186020a203aSopenharmony_ciconst std::string DOM_CONTENT_LOADED_EVENT_END = "DOM_CONTENT_LOADED_EVENT_END";
187020a203aSopenharmony_ciconst std::string LOAD_EVENT_START = "LOAD_EVENT_START";
188020a203aSopenharmony_ciconst std::string LOAD_EVENT_END = "LOAD_EVENT_END";
189020a203aSopenharmony_ciconst std::string FIRST_PAINT = "FIRST_PAINT";
190020a203aSopenharmony_ciconst std::string FIRST_CONTENTFUL_PAINT = "FIRST_CONTENTFUL_PAINT";
191020a203aSopenharmony_ciconst std::string LARGEST_CONTENTFUL_PAINT = "LARGEST_CONTENTFUL_PAINT";
192020a203aSopenharmony_ci// for webview dynamic frame drop
193020a203aSopenharmony_ciconst std::string DURATION = "DURATION";
194020a203aSopenharmony_ciconst std::string TOTAL_APP_FRAMES = "TOTAL_APP_FRAMES";
195020a203aSopenharmony_ciconst std::string TOTAL_APP_MISSED_FRAMES = "TOTAL_APP_MISSED_FRAMES";
196020a203aSopenharmony_ciconst std::string MAX_APP_FRAMETIME = "MAX_APP_FRAMETIME";
197020a203aSopenharmony_ci// for webview audio frame drop
198020a203aSopenharmony_ciconst std::string AUDIO_BLANK_FRAME_COUNT = "AUDIO_BLANK_FRAME_COUNT";
199020a203aSopenharmony_ci// for webview video frame drop
200020a203aSopenharmony_ciconst std::string VIDEO_FRAME_DROPPED_COUNT = "VIDEO_FRAME_DROPPED_COUNT";
201020a203aSopenharmony_ciconst std::string VIDEO_FRAME_DROPPED_DURATION = "VIDEO_FRAME_DROPPED_DURATION";
202020a203aSopenharmony_ci// for hitch time ratio
203020a203aSopenharmony_ciconst std::string UI_START_TIME = "UI_START_TIME";
204020a203aSopenharmony_ciconst std::string RS_START_TIME = "RS_START_TIME";
205020a203aSopenharmony_ciconst std::string HITCH_TIME = "HITCH_TIME";
206020a203aSopenharmony_ciconst std::string KEY_HITCH_TIME_RATIO = "HITCH_TIME_RATIO";
207020a203aSopenharmony_ci
208020a203aSopenharmony_ci#define US_TO_S 1000000
209020a203aSopenharmony_ci
210020a203aSopenharmony_ciclass EvtParser {
211020a203aSopenharmony_ci    using Event = OHOS::HiviewDFX::Event;
212020a203aSopenharmony_ci    using SysEvent = OHOS::HiviewDFX::SysEvent;
213020a203aSopenharmony_ci
214020a203aSopenharmony_cipublic:
215020a203aSopenharmony_ci    static const std::string separator;
216020a203aSopenharmony_ci    static const std::map<std::string, unsigned int> logIdMap;
217020a203aSopenharmony_ci
218020a203aSopenharmony_ci    static unsigned int ExtractLogIdFromEvt(const SysEvent &sysEvent)
219020a203aSopenharmony_ci    {
220020a203aSopenharmony_ci        std::string logIdStr = std::string(sysEvent.domain_ + separator + sysEvent.eventName_);
221020a203aSopenharmony_ci        unsigned int logId = logIdMap.at(logIdStr); // this might throw std::out_of_range
222020a203aSopenharmony_ci        return logId;
223020a203aSopenharmony_ci    }
224020a203aSopenharmony_ci
225020a203aSopenharmony_ci    static std::shared_ptr <XperfEvt> FromHivewEvt(const SysEvent &e)
226020a203aSopenharmony_ci    {
227020a203aSopenharmony_ci        Validate(e);
228020a203aSopenharmony_ci        XperfEvt evt = ConvertToXperfEvent(e);
229020a203aSopenharmony_ci        std::shared_ptr <XperfEvt> ret = std::make_shared<XperfEvt>(evt);
230020a203aSopenharmony_ci        return ret;
231020a203aSopenharmony_ci    }
232020a203aSopenharmony_ci
233020a203aSopenharmony_ciprivate:
234020a203aSopenharmony_ci    static XperfEvt ConvertToXperfEvent(const SysEvent &event)
235020a203aSopenharmony_ci    {
236020a203aSopenharmony_ci        SysEvent &sysEvent = (SysEvent &) event;
237020a203aSopenharmony_ci        XperfEvt evt;
238020a203aSopenharmony_ci        evt.logId = ExtractLogIdFromEvt(sysEvent);
239020a203aSopenharmony_ci        evt.domain = sysEvent.domain_;
240020a203aSopenharmony_ci        evt.eventName = std::string(sysEvent.eventName_);
241020a203aSopenharmony_ci        evt.pid = sysEvent.GetPid();
242020a203aSopenharmony_ci        evt.versionCode = static_cast<int32_t>(sysEvent.GetEventIntValue(KEY_VERSION_CODE));
243020a203aSopenharmony_ci        evt.appPid = static_cast<int32_t>(sysEvent.GetEventIntValue(KEY_APP_PID));
244020a203aSopenharmony_ci        evt.sourceType = sysEvent.GetEventValue(KEY_SOURCE_TYPE);
245020a203aSopenharmony_ci        evt.pageUrl = sysEvent.GetEventValue(PAGE_URL);
246020a203aSopenharmony_ci        evt.sceneId = sysEvent.GetEventValue(SCENE_ID);
247020a203aSopenharmony_ci        evt.eventTime = static_cast<uint64_t>(sysEvent.GetEventIntValue(TIMER));
248020a203aSopenharmony_ci        evt.inputTime = static_cast<uint64_t>(sysEvent.GetEventIntValue(INPUT_TIME));
249020a203aSopenharmony_ci        evt.renderTime = static_cast<uint64_t>(sysEvent.GetEventIntValue(RENDER_TIME));
250020a203aSopenharmony_ci        evt.responseLatency = static_cast<uint64_t>(sysEvent.GetEventIntValue(RESPONSE_LATENCY));
251020a203aSopenharmony_ci        evt.e2eLatency = static_cast<uint64_t>(sysEvent.GetEventIntValue(E2E_LATENCY));
252020a203aSopenharmony_ci        evt.bundleName = sysEvent.GetEventValue(KEY_BUNDLE_NAME);
253020a203aSopenharmony_ci        evt.bundleType = static_cast<int32_t>(sysEvent.GetEventIntValue(KEY_BUNDLE_TYPE));
254020a203aSopenharmony_ci        evt.abilityName = sysEvent.GetEventValue(KEY_ABILITY_NAME);
255020a203aSopenharmony_ci        evt.processName = sysEvent.GetEventValue(KEY_PNAME);
256020a203aSopenharmony_ci        evt.moduleName = sysEvent.GetEventValue(KEY_MODULE_NAME);
257020a203aSopenharmony_ci        evt.versionName = sysEvent.GetEventValue(KEY_APP_VERSION);
258020a203aSopenharmony_ci        evt.startType = static_cast<int32_t>(sysEvent.GetEventIntValue(KEY_START_TYPE));
259020a203aSopenharmony_ci        evt.startupTime = static_cast<uint64_t>(sysEvent.GetEventIntValue(KEY_STARTUP_TIME));
260020a203aSopenharmony_ci        evt.startupAbilityType = static_cast<int32_t>(sysEvent.GetEventIntValue(KEY_STARTUP_ABILITY_TYPE));
261020a203aSopenharmony_ci        evt.startupExtensionType = static_cast<int32_t>(sysEvent.GetEventIntValue(KEY_STARTUP_EXTENSION_TYPE));
262020a203aSopenharmony_ci        evt.callerBundleName = sysEvent.GetEventValue(KEY_CALLER_BUNDLE_NAME);
263020a203aSopenharmony_ci        evt.callerUid = static_cast<int32_t>(sysEvent.GetEventIntValue(KEY_CALLER_UID));
264020a203aSopenharmony_ci        evt.callerProcessName = sysEvent.GetEventValue(KEY_CALLER_PROCESS_NAME);
265020a203aSopenharmony_ci        evt.windowName = sysEvent.GetEventValue(KEY_WINDOW_NAME);
266020a203aSopenharmony_ci        evt.time = evt.eventTime;
267020a203aSopenharmony_ci        evt.animationStartTime = evt.animStartTime;
268020a203aSopenharmony_ci        evt.animationStartLatency = static_cast<uint64_t>(sysEvent.GetEventIntValue(KEY_ANIMATION_START_LATENCY));
269020a203aSopenharmony_ci        evt.animationEndLatency = evt.animationLatency;
270020a203aSopenharmony_ci        evt.appUid = static_cast<int32_t>(sysEvent.GetEventIntValue(KEY_APP_UID));
271020a203aSopenharmony_ci        ConvertToXperfAnimatorEvent(evt, sysEvent);
272020a203aSopenharmony_ci        evt.exitTime = static_cast<uint64_t>(sysEvent.GetEventIntValue(KEY_EXIT_TIME));
273020a203aSopenharmony_ci        evt.exitResult = static_cast<int32_t>(sysEvent.GetEventIntValue(KEY_EXIT_RESULT));
274020a203aSopenharmony_ci        evt.exitPid = static_cast<int32_t>(sysEvent.GetEventIntValue(KEY_EXIT_PID));
275020a203aSopenharmony_ci        evt.note = sysEvent.GetEventValue(KEY_NOTE);
276020a203aSopenharmony_ci        return evt;
277020a203aSopenharmony_ci    }
278020a203aSopenharmony_ci
279020a203aSopenharmony_ci    static void ConvertToXperfAnimatorEvent(XperfEvt &evt, SysEvent &sysEvent)
280020a203aSopenharmony_ci    {
281020a203aSopenharmony_ci        evt.animatorInfo.basicInfo.uniqueId = static_cast<int32_t>(sysEvent.GetEventIntValue(UNIQUE_ID));
282020a203aSopenharmony_ci        evt.animatorInfo.basicInfo.sceneId = sysEvent.GetEventValue(SCENE_ID);
283020a203aSopenharmony_ci        evt.animatorInfo.basicInfo.moduleName = sysEvent.GetEventValue(KEY_MODULE_NAME);
284020a203aSopenharmony_ci        evt.animatorInfo.basicInfo.processName = sysEvent.GetEventValue(KEY_PNAME);
285020a203aSopenharmony_ci        evt.animatorInfo.basicInfo.abilityName = sysEvent.GetEventValue(KEY_ABILITY_NAME);
286020a203aSopenharmony_ci        evt.animatorInfo.basicInfo.pageUrl = sysEvent.GetEventValue(PAGE_URL);
287020a203aSopenharmony_ci        evt.animatorInfo.basicInfo.sourceType = sysEvent.GetEventValue(KEY_SOURCE_TYPE);
288020a203aSopenharmony_ci        evt.animatorInfo.basicInfo.versionCode = static_cast<int32_t>(sysEvent.GetEventIntValue(KEY_VERSION_CODE));
289020a203aSopenharmony_ci        evt.animatorInfo.basicInfo.versionName = sysEvent.GetEventValue(KEY_APP_VERSION);
290020a203aSopenharmony_ci        evt.animatorInfo.basicInfo.bundleNameEx = sysEvent.GetEventValue(KEY_NOTE);
291020a203aSopenharmony_ci        evt.animatorInfo.commonInfo.appPid = sysEvent.GetPid();
292020a203aSopenharmony_ci        evt.animatorInfo.commonInfo.durition = static_cast<uint64_t>(sysEvent.GetEventIntValue(DURITION));
293020a203aSopenharmony_ci        evt.animatorInfo.commonInfo.startTime = static_cast<uint64_t>(sysEvent.GetEventIntValue(STARTTIME));
294020a203aSopenharmony_ci        evt.animatorInfo.commonInfo.totalFrames = static_cast<int32_t>(sysEvent.GetEventIntValue(TOTAL_FRAMES));
295020a203aSopenharmony_ci        evt.animatorInfo.commonInfo.totalMissedFrames
296020a203aSopenharmony_ci            = static_cast<int32_t>(sysEvent.GetEventIntValue(TOTAL_MISSED_FRAMES));
297020a203aSopenharmony_ci        evt.animatorInfo.commonInfo.maxSeqMissedFrames
298020a203aSopenharmony_ci            = static_cast<int32_t>(sysEvent.GetEventIntValue(MAX_SEQ_MISSED_FRAMES));
299020a203aSopenharmony_ci        evt.animatorInfo.commonInfo.maxFrameTime = static_cast<uint64_t>(sysEvent.GetEventIntValue(MAX_FRAMETIME));
300020a203aSopenharmony_ci        evt.animatorInfo.commonInfo.averageFrameTime
301020a203aSopenharmony_ci            = static_cast<int32_t>(sysEvent.GetEventIntValue(AVERAGE_FRAMETIME));
302020a203aSopenharmony_ci        evt.animatorInfo.commonInfo.isFoldDisp = static_cast<bool>(sysEvent.GetEventIntValue(IS_FOLD_DISP));
303020a203aSopenharmony_ci        evt.animatorInfo.commonInfo.isDisplayAnimator
304020a203aSopenharmony_ci            = static_cast<bool>(sysEvent.GetEventIntValue(IS_DISPLAY_ANIMATOR));
305020a203aSopenharmony_ci        evt.animatorInfo.commonInfo.happenTime = static_cast<uint64_t>(sysEvent.GetEventIntValue(TIMER));
306020a203aSopenharmony_ci    }
307020a203aSopenharmony_ci
308020a203aSopenharmony_ci    static void Validate(const SysEvent &event)
309020a203aSopenharmony_ci    {
310020a203aSopenharmony_ci        SysEvent &sysEvent = (SysEvent &) event;
311020a203aSopenharmony_ci        if (sysEvent.eventName_ == JANK_FRAME_SKIP) {
312020a203aSopenharmony_ci            std::string appName = sysEvent.GetEventValue(KEY_ABILITY_NAME);
313020a203aSopenharmony_ci            if (appName == "") {
314020a203aSopenharmony_ci                throw std::invalid_argument("invalid sysEvent JANK_FRAME_SKIP");
315020a203aSopenharmony_ci            }
316020a203aSopenharmony_ci        }
317020a203aSopenharmony_ci        if (sysEvent.eventName_ == ABILITY_ONACTIVE) {
318020a203aSopenharmony_ci            int32_t type = static_cast<int32_t>(sysEvent.GetEventIntValue(KEY_ABILITY_TYPE));
319020a203aSopenharmony_ci            if (type != 1) {
320020a203aSopenharmony_ci                throw std::invalid_argument("invalid sysEvent ABILITY_ONACTIVE");
321020a203aSopenharmony_ci            }
322020a203aSopenharmony_ci        }
323020a203aSopenharmony_ci        if (sysEvent.eventName_ == KEY_STARTUP_TIME) {
324020a203aSopenharmony_ci            std::string detailedTime = sysEvent.GetEventValue(DETAILED_TIME);
325020a203aSopenharmony_ci            if (detailedTime == "") {
326020a203aSopenharmony_ci                throw std::invalid_argument("invalid sysEvent STARTUP_TIME");
327020a203aSopenharmony_ci            }
328020a203aSopenharmony_ci        }
329020a203aSopenharmony_ci        // what follows cannot be understood
330020a203aSopenharmony_ci    }
331020a203aSopenharmony_ci};
332020a203aSopenharmony_ci} // HiviewDFX
333020a203aSopenharmony_ci} // OHOS
334020a203aSopenharmony_ci#endif
335