123b3eb3cSopenharmony_ci/* 223b3eb3cSopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 323b3eb3cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 423b3eb3cSopenharmony_ci * you may not use this file except in compliance with the License. 523b3eb3cSopenharmony_ci * You may obtain a copy of the License at 623b3eb3cSopenharmony_ci * 723b3eb3cSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 823b3eb3cSopenharmony_ci * 923b3eb3cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1023b3eb3cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1123b3eb3cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1223b3eb3cSopenharmony_ci * See the License for the specific language governing permissions and 1323b3eb3cSopenharmony_ci * limitations under the License. 1423b3eb3cSopenharmony_ci */ 1523b3eb3cSopenharmony_ci 1623b3eb3cSopenharmony_ci#include "base/log/event_report.h" 1723b3eb3cSopenharmony_ci 1823b3eb3cSopenharmony_ci#include <unistd.h> 1923b3eb3cSopenharmony_ci 2023b3eb3cSopenharmony_ci#include "hisysevent.h" 2123b3eb3cSopenharmony_ci 2223b3eb3cSopenharmony_ci#include "core/common/ace_engine.h" 2323b3eb3cSopenharmony_ci#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE 2423b3eb3cSopenharmony_ci#include "res_sched_client.h" 2523b3eb3cSopenharmony_ci#include "res_type.h" 2623b3eb3cSopenharmony_ci#endif // RESOURCE_SCHEDULE_SERVICE_ENABLE 2723b3eb3cSopenharmony_ci 2823b3eb3cSopenharmony_cinamespace OHOS::Ace { 2923b3eb3cSopenharmony_cinamespace { 3023b3eb3cSopenharmony_ci 3123b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_ERROR_TYPE[] = "ERROR_TYPE"; 3223b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_UID[] = "UID"; 3323b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_PID[] = "PID"; 3423b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_SESSIONID[] = "SESSION_ID"; 3523b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_PACKAGE_NAME[] = "PACKAGE_NAME"; 3623b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_PROCESS_NAME[] = "PROCESS_NAME"; 3723b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_MESSAGE[] = "MSG"; 3823b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_CMD[] = "CMD"; 3923b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_REASON[] = "REASON"; 4023b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_SUMMARY[] = "SUMMARY"; 4123b3eb3cSopenharmony_ciconstexpr char EVENT_NAME_JS_ERROR[] = "JS_ERROR"; 4223b3eb3cSopenharmony_ciconstexpr char STATISTIC_DURATION[] = "DURATION"; 4323b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_STARTTIME[] = "STARTTIME"; 4423b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_VERSION_CODE[] = "VERSION_CODE"; 4523b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_VERSION_NAME[] = "VERSION_NAME"; 4623b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_BUNDLE_NAME[] = "BUNDLE_NAME"; 4723b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_ABILITY_NAME[] = "ABILITY_NAME"; 4823b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_PAGE_URL[] = "PAGE_URL"; 4923b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_JANK_STATS[] = "JANK_STATS"; 5023b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_JANK_STATS_VER[] = "JANK_STATS_VER"; 5123b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_APP_PID[] = "APP_PID"; 5223b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_SCENE_ID[] = "SCENE_ID"; 5323b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_INPUT_TIME[] = "INPUT_TIME"; 5423b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_ANIMATION_START_LATENCY[] = "ANIMATION_START_LATENCY"; 5523b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_ANIMATION_END_LATENCY[] = "ANIMATION_END_LATENCY"; 5623b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_E2E_LATENCY[] = "E2E_LATENCY"; 5723b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_UNIQUE_ID[] = "UNIQUE_ID"; 5823b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_MODULE_NAME[] = "MODULE_NAME"; 5923b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_DURITION[] = "DURITION"; 6023b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_TOTAL_FRAMES[] = "TOTAL_FRAMES"; 6123b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_TOTAL_MISSED_FRAMES[] = "TOTAL_MISSED_FRAMES"; 6223b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_MAX_FRAMETIME[] = "MAX_FRAMETIME"; 6323b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_MAX_FRAMETIME_SINCE_START[] = "MAX_FRAMETIME_SINCE_START"; 6423b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_MAX_HITCH_TIME[] = "MAX_HITCH_TIME"; 6523b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_MAX_HITCH_TIME_SINCE_START[] = "MAX_HITCH_TIME_SINCE_START"; 6623b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_MAX_SEQ_MISSED_FRAMES[] = "MAX_SEQ_MISSED_FRAMES"; 6723b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_SOURCE_TYPE[] = "SOURCE_TYPE"; 6823b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_NOTE[] = "NOTE"; 6923b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_DISPLAY_ANIMATOR[] = "DISPLAY_ANIMATOR"; 7023b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_SKIPPED_FRAME_TIME[] = "SKIPPED_FRAME_TIME"; 7123b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_PAGE_NODE_COUNT[] = "PAGE_NODE_COUNT"; 7223b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_PAGE_NODE_THRESHOLD[] = "PAGE_NODE_THRESHOLD"; 7323b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_PAGE_DEPTH[] = "PAGE_DEPTH"; 7423b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_PAGE_DEPTH_THRESHOLD[] = "PAGE_DEPTH_THRESHOLD"; 7523b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_FUNCTION_NAME[] = "FUNCTION_NAME"; 7623b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_FUNCTION_EXECUTE_TIME[] = "FUNCTION_EXECUTE_TIME"; 7723b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_FUNCTION_TIME_THRESHOLD[] = "FUNCTION_TIME_THRESHOLD"; 7823b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_NOTIFY_HOVER_STATUS_CHANGE[] = "NOTIFY_HOVER_STATUS_CHANGE"; 7923b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_FOLDER_STATUS[] = "FOLDER_STATUS"; 8023b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_HOVER_TIME[] = "HOVER_TIME"; 8123b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_IS_HOVER_MODE[] = "IS_HOVER_MODE"; 8223b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_APP_ROTATION[] = "APP_ROTATION"; 8323b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_WINDOW_MODE[] = "WINDOW_MODE"; 8423b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_NON_MANUAL_POSTCARD_ACTION[] = "NON_MANUAL_POSTCARD_ACTION"; 8523b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_PAGE_NAME[] = "PAGE_NAME"; 8623b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_FILTER_TYPE[] = "FILTER_TYPE"; 8723b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_FORM_NAME[] = "FORM_NAME"; 8823b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_DIMENSION[] = "DIMENSION"; 8923b3eb3cSopenharmony_ci 9023b3eb3cSopenharmony_ciconstexpr int32_t MAX_PACKAGE_NAME_LENGTH = 128; 9123b3eb3cSopenharmony_ci#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE 9223b3eb3cSopenharmony_ciconstexpr int32_t MAX_JANK_FRAME_TIME = 32; 9323b3eb3cSopenharmony_ci#endif // RESOURCE_SCHEDULE_SERVICE_ENABLE 9423b3eb3cSopenharmony_ci 9523b3eb3cSopenharmony_ciconstexpr char DUMP_LOG_COMMAND[] = "B"; 9623b3eb3cSopenharmony_ci 9723b3eb3cSopenharmony_ciconstexpr char CLICK_TITLE_MAXIMIZE_MENU[] = "CLICK_TITLE_MAXIMIZE_MENU"; 9823b3eb3cSopenharmony_ciconstexpr char DOUBLE_CLICK_TITLE[] = "DOUBLE_CLICK_TITLE"; 9923b3eb3cSopenharmony_ciconstexpr char CURRENTPKG[] = "CURRENTPKG"; 10023b3eb3cSopenharmony_ciconstexpr char STATECHANGE[] = "STATECHANGE"; 10123b3eb3cSopenharmony_ciconstexpr char MAXMENUITEM[] = "MAXMENUITEM"; 10223b3eb3cSopenharmony_ciconstexpr char SCENE_BOARD_UE_DOMAIN[] = "SCENE_BOARD_UE"; 10323b3eb3cSopenharmony_ci#ifdef VSYNC_TIMEOUT_CHECK 10423b3eb3cSopenharmony_ciconstexpr char UI_VSYNC_TIMEOUT[] = "UI_VSYNC_TIMEOUT"; 10523b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_WINDOW_ID[] = "WINDOW_ID"; 10623b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_INSTANCE_ID[] = "INSTANCE_ID"; 10723b3eb3cSopenharmony_ciconstexpr char EVENT_KEY_VSYNC_TIMESTAMP[] = "VSYNC_TIMESTAMP"; 10823b3eb3cSopenharmony_ci#endif 10923b3eb3cSopenharmony_ciconstexpr char PAGE_NODE_OVERFLOW[] = "PAGE_NODE_OVERFLOW"; 11023b3eb3cSopenharmony_ciconstexpr char PAGE_DEPTH_OVERFLOW[] = "PAGE_DEPTH_OVERFLOW"; 11123b3eb3cSopenharmony_ciconstexpr char UI_LIFECIRCLE_FUNCTION_TIMEOUT[] = "UI_LIFECIRCLE_FUNCTION_TIMEOUT"; 11223b3eb3cSopenharmony_ciconstexpr char UIEXTENSION_TRANSPARENT_DETECTED[] = "UIEXTENSION_TRANSPARENT_DETECTED"; 11323b3eb3cSopenharmony_ci 11423b3eb3cSopenharmony_civoid StrTrim(std::string& str) 11523b3eb3cSopenharmony_ci{ 11623b3eb3cSopenharmony_ci if (str.size() > MAX_PACKAGE_NAME_LENGTH) { 11723b3eb3cSopenharmony_ci str = str.substr(0, MAX_PACKAGE_NAME_LENGTH); 11823b3eb3cSopenharmony_ci } 11923b3eb3cSopenharmony_ci} 12023b3eb3cSopenharmony_ci 12123b3eb3cSopenharmony_ci} // namespace 12223b3eb3cSopenharmony_ci 12323b3eb3cSopenharmony_civoid EventReport::SendEvent(const EventInfo& eventInfo) 12423b3eb3cSopenharmony_ci{ 12523b3eb3cSopenharmony_ci auto packageName = AceApplicationInfo::GetInstance().GetPackageName(); 12623b3eb3cSopenharmony_ci if (packageName.size() > MAX_PACKAGE_NAME_LENGTH) { 12723b3eb3cSopenharmony_ci StrTrim(packageName); 12823b3eb3cSopenharmony_ci } 12923b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, eventInfo.eventType, 13023b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, 13123b3eb3cSopenharmony_ci EVENT_KEY_ERROR_TYPE, eventInfo.errorType, 13223b3eb3cSopenharmony_ci EVENT_KEY_PACKAGE_NAME, packageName); 13323b3eb3cSopenharmony_ci} 13423b3eb3cSopenharmony_ci 13523b3eb3cSopenharmony_civoid EventReport::SendJsCardRenderTimeEvent( 13623b3eb3cSopenharmony_ci const std::string& sessionID, 13723b3eb3cSopenharmony_ci const std::string& timeType, 13823b3eb3cSopenharmony_ci uint64_t timeDelay) 13923b3eb3cSopenharmony_ci{ 14023b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, timeType, 14123b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, 14223b3eb3cSopenharmony_ci EVENT_KEY_SESSIONID, sessionID, 14323b3eb3cSopenharmony_ci STATISTIC_DURATION, timeDelay); 14423b3eb3cSopenharmony_ci} 14523b3eb3cSopenharmony_ci 14623b3eb3cSopenharmony_civoid EventReport::SendAppStartException(AppStartExcepType type) 14723b3eb3cSopenharmony_ci{ 14823b3eb3cSopenharmony_ci EventInfo eventInfo = { 14923b3eb3cSopenharmony_ci .eventType = EXCEPTION_FRAMEWORK_APP_START, 15023b3eb3cSopenharmony_ci .errorType = static_cast<int32_t>(type), 15123b3eb3cSopenharmony_ci }; 15223b3eb3cSopenharmony_ci 15323b3eb3cSopenharmony_ci SendEventInner(eventInfo); 15423b3eb3cSopenharmony_ci} 15523b3eb3cSopenharmony_ci 15623b3eb3cSopenharmony_civoid EventReport::SendPageRouterException(PageRouterExcepType type, const std::string& pageUrl) 15723b3eb3cSopenharmony_ci{ 15823b3eb3cSopenharmony_ci EventInfo eventInfo = { 15923b3eb3cSopenharmony_ci .eventType = EXCEPTION_FRAMEWORK_PAGE_ROUTER, 16023b3eb3cSopenharmony_ci .errorType = static_cast<int32_t>(type), 16123b3eb3cSopenharmony_ci .pageUrl = pageUrl, 16223b3eb3cSopenharmony_ci }; 16323b3eb3cSopenharmony_ci 16423b3eb3cSopenharmony_ci SendEventInner(eventInfo); 16523b3eb3cSopenharmony_ci} 16623b3eb3cSopenharmony_ci 16723b3eb3cSopenharmony_civoid EventReport::SendComponentException(ComponentExcepType type) 16823b3eb3cSopenharmony_ci{ 16923b3eb3cSopenharmony_ci EventInfo eventInfo = { 17023b3eb3cSopenharmony_ci .eventType = EXCEPTION_COMPONENT, 17123b3eb3cSopenharmony_ci .errorType = static_cast<int32_t>(type), 17223b3eb3cSopenharmony_ci }; 17323b3eb3cSopenharmony_ci 17423b3eb3cSopenharmony_ci SendEventInner(eventInfo); 17523b3eb3cSopenharmony_ci} 17623b3eb3cSopenharmony_ci 17723b3eb3cSopenharmony_civoid EventReport::SendAPIChannelException(APIChannelExcepType type) 17823b3eb3cSopenharmony_ci{ 17923b3eb3cSopenharmony_ci EventInfo eventInfo = { 18023b3eb3cSopenharmony_ci .eventType = EXCEPTION_API_CHANNEL, 18123b3eb3cSopenharmony_ci .errorType = static_cast<int32_t>(type), 18223b3eb3cSopenharmony_ci }; 18323b3eb3cSopenharmony_ci 18423b3eb3cSopenharmony_ci SendEventInner(eventInfo); 18523b3eb3cSopenharmony_ci} 18623b3eb3cSopenharmony_ci 18723b3eb3cSopenharmony_civoid EventReport::SendRenderException(RenderExcepType type) 18823b3eb3cSopenharmony_ci{ 18923b3eb3cSopenharmony_ci EventInfo eventInfo = { 19023b3eb3cSopenharmony_ci .eventType = EXCEPTION_RENDER, 19123b3eb3cSopenharmony_ci .errorType = static_cast<int32_t>(type), 19223b3eb3cSopenharmony_ci }; 19323b3eb3cSopenharmony_ci 19423b3eb3cSopenharmony_ci SendEventInner(eventInfo); 19523b3eb3cSopenharmony_ci} 19623b3eb3cSopenharmony_ci 19723b3eb3cSopenharmony_civoid EventReport::SendJsException(JsExcepType type) 19823b3eb3cSopenharmony_ci{ 19923b3eb3cSopenharmony_ci EventInfo eventInfo = { 20023b3eb3cSopenharmony_ci .eventType = EXCEPTION_JS, 20123b3eb3cSopenharmony_ci .errorType = static_cast<int32_t>(type), 20223b3eb3cSopenharmony_ci }; 20323b3eb3cSopenharmony_ci 20423b3eb3cSopenharmony_ci SendEventInner(eventInfo); 20523b3eb3cSopenharmony_ci} 20623b3eb3cSopenharmony_ci 20723b3eb3cSopenharmony_civoid EventReport::SendAnimationException(AnimationExcepType type) 20823b3eb3cSopenharmony_ci{ 20923b3eb3cSopenharmony_ci EventInfo eventInfo = { 21023b3eb3cSopenharmony_ci .eventType = EXCEPTION_ANIMATION, 21123b3eb3cSopenharmony_ci .errorType = static_cast<int32_t>(type), 21223b3eb3cSopenharmony_ci }; 21323b3eb3cSopenharmony_ci 21423b3eb3cSopenharmony_ci SendEventInner(eventInfo); 21523b3eb3cSopenharmony_ci} 21623b3eb3cSopenharmony_ci 21723b3eb3cSopenharmony_civoid EventReport::SendEventException(EventExcepType type) 21823b3eb3cSopenharmony_ci{ 21923b3eb3cSopenharmony_ci EventInfo eventInfo = { 22023b3eb3cSopenharmony_ci .eventType = EXCEPTION_EVENT, 22123b3eb3cSopenharmony_ci .errorType = static_cast<int32_t>(type), 22223b3eb3cSopenharmony_ci }; 22323b3eb3cSopenharmony_ci 22423b3eb3cSopenharmony_ci SendEventInner(eventInfo); 22523b3eb3cSopenharmony_ci} 22623b3eb3cSopenharmony_ci 22723b3eb3cSopenharmony_civoid EventReport::SendInternalException(InternalExcepType type) 22823b3eb3cSopenharmony_ci{ 22923b3eb3cSopenharmony_ci EventInfo eventInfo = { 23023b3eb3cSopenharmony_ci .eventType = EXCEPTION_INTERNATIONALIZATION, 23123b3eb3cSopenharmony_ci .errorType = static_cast<int32_t>(type), 23223b3eb3cSopenharmony_ci }; 23323b3eb3cSopenharmony_ci 23423b3eb3cSopenharmony_ci SendEventInner(eventInfo); 23523b3eb3cSopenharmony_ci} 23623b3eb3cSopenharmony_ci 23723b3eb3cSopenharmony_civoid EventReport::SendAccessibilityException(AccessibilityExcepType type) 23823b3eb3cSopenharmony_ci{ 23923b3eb3cSopenharmony_ci EventInfo eventInfo = { 24023b3eb3cSopenharmony_ci .eventType = EXCEPTION_ACCESSIBILITY, 24123b3eb3cSopenharmony_ci .errorType = static_cast<int32_t>(type), 24223b3eb3cSopenharmony_ci }; 24323b3eb3cSopenharmony_ci 24423b3eb3cSopenharmony_ci SendEventInner(eventInfo); 24523b3eb3cSopenharmony_ci} 24623b3eb3cSopenharmony_ci 24723b3eb3cSopenharmony_civoid EventReport::SendFormException(FormExcepType type) 24823b3eb3cSopenharmony_ci{ 24923b3eb3cSopenharmony_ci EventInfo eventInfo = { 25023b3eb3cSopenharmony_ci .eventType = EXCEPTION_FORM, 25123b3eb3cSopenharmony_ci .errorType = static_cast<int32_t>(type), 25223b3eb3cSopenharmony_ci }; 25323b3eb3cSopenharmony_ci 25423b3eb3cSopenharmony_ci SendEventInner(eventInfo); 25523b3eb3cSopenharmony_ci} 25623b3eb3cSopenharmony_ci 25723b3eb3cSopenharmony_ci#ifdef VSYNC_TIMEOUT_CHECK 25823b3eb3cSopenharmony_civoid EventReport::SendVsyncException(VsyncExcepType type, uint32_t windowId, int32_t instanceId, uint64_t timeStamp) 25923b3eb3cSopenharmony_ci{ 26023b3eb3cSopenharmony_ci auto packageName = AceApplicationInfo::GetInstance().GetPackageName(); 26123b3eb3cSopenharmony_ci StrTrim(packageName); 26223b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, UI_VSYNC_TIMEOUT, 26323b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, 26423b3eb3cSopenharmony_ci EVENT_KEY_ERROR_TYPE, static_cast<int32_t>(type), 26523b3eb3cSopenharmony_ci EVENT_KEY_PACKAGE_NAME, packageName, 26623b3eb3cSopenharmony_ci EVENT_KEY_WINDOW_ID, windowId, 26723b3eb3cSopenharmony_ci EVENT_KEY_INSTANCE_ID, instanceId, 26823b3eb3cSopenharmony_ci EVENT_KEY_VSYNC_TIMESTAMP, timeStamp); 26923b3eb3cSopenharmony_ci} 27023b3eb3cSopenharmony_ci#endif 27123b3eb3cSopenharmony_ci 27223b3eb3cSopenharmony_civoid EventReport::JsEventReport(int32_t eventType, const std::string& jsonStr) 27323b3eb3cSopenharmony_ci{ 27423b3eb3cSopenharmony_ci if (!JsonUtil::ParseJsonString(jsonStr)) { 27523b3eb3cSopenharmony_ci LOGE("jsonStr is not a JsonArray."); 27623b3eb3cSopenharmony_ci return; 27723b3eb3cSopenharmony_ci } 27823b3eb3cSopenharmony_ci} 27923b3eb3cSopenharmony_ci 28023b3eb3cSopenharmony_civoid EventReport::JsErrReport( 28123b3eb3cSopenharmony_ci const std::string& packageName, const std::string& reason, const std::string& summary) 28223b3eb3cSopenharmony_ci{ 28323b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, EVENT_NAME_JS_ERROR, 28423b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, 28523b3eb3cSopenharmony_ci EVENT_KEY_PACKAGE_NAME, packageName, 28623b3eb3cSopenharmony_ci EVENT_KEY_REASON, reason, 28723b3eb3cSopenharmony_ci EVENT_KEY_SUMMARY, summary); 28823b3eb3cSopenharmony_ci} 28923b3eb3cSopenharmony_ci 29023b3eb3cSopenharmony_civoid EventReport::ANRRawReport(RawEventType type, int32_t uid, const std::string& packageName, 29123b3eb3cSopenharmony_ci const std::string& processName, const std::string& msg) 29223b3eb3cSopenharmony_ci{ 29323b3eb3cSopenharmony_ci int32_t pid = getpid(); 29423b3eb3cSopenharmony_ci std::string cmd = " "; 29523b3eb3cSopenharmony_ci std::string eventName = ""; 29623b3eb3cSopenharmony_ci if (type == RawEventType::WARNING) { 29723b3eb3cSopenharmony_ci eventName = "UI_BLOCK_3S"; 29823b3eb3cSopenharmony_ci cmd = "p=" + std::to_string(pid); 29923b3eb3cSopenharmony_ci } else if (type == RawEventType::FREEZE) { 30023b3eb3cSopenharmony_ci eventName = "UI_BLOCK_6S"; 30123b3eb3cSopenharmony_ci cmd = DUMP_LOG_COMMAND; 30223b3eb3cSopenharmony_ci } else { 30323b3eb3cSopenharmony_ci eventName = "UI_BLOCK_RECOVERED"; 30423b3eb3cSopenharmony_ci } 30523b3eb3cSopenharmony_ci std::string uidStr = std::to_string(uid); 30623b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, eventName, 30723b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, 30823b3eb3cSopenharmony_ci EVENT_KEY_UID, uidStr, 30923b3eb3cSopenharmony_ci EVENT_KEY_PACKAGE_NAME, packageName, 31023b3eb3cSopenharmony_ci EVENT_KEY_PROCESS_NAME, processName, 31123b3eb3cSopenharmony_ci EVENT_KEY_MESSAGE, msg, 31223b3eb3cSopenharmony_ci EVENT_KEY_CMD, cmd); 31323b3eb3cSopenharmony_ci} 31423b3eb3cSopenharmony_ci 31523b3eb3cSopenharmony_civoid EventReport::ANRShowDialog(int32_t uid, const std::string& packageName, 31623b3eb3cSopenharmony_ci const std::string& processName, const std::string& msg) 31723b3eb3cSopenharmony_ci{ 31823b3eb3cSopenharmony_ci int32_t pid = getpid(); 31923b3eb3cSopenharmony_ci std::string eventName = "UI_BLOCK_DIALOG"; 32023b3eb3cSopenharmony_ci std::string uidStr = std::to_string(uid); 32123b3eb3cSopenharmony_ci std::string pidStr = std::to_string(pid); 32223b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, eventName, 32323b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, 32423b3eb3cSopenharmony_ci EVENT_KEY_UID, uidStr, 32523b3eb3cSopenharmony_ci EVENT_KEY_PID, pidStr, 32623b3eb3cSopenharmony_ci EVENT_KEY_PACKAGE_NAME, packageName, 32723b3eb3cSopenharmony_ci EVENT_KEY_PROCESS_NAME, processName, 32823b3eb3cSopenharmony_ci EVENT_KEY_MESSAGE, msg); 32923b3eb3cSopenharmony_ci} 33023b3eb3cSopenharmony_ci 33123b3eb3cSopenharmony_civoid EventReport::JankFrameReport(int64_t startTime, int64_t duration, const std::vector<uint16_t>& jank, 33223b3eb3cSopenharmony_ci const std::string& pageUrl, uint32_t jankStatusVersion) 33323b3eb3cSopenharmony_ci{ 33423b3eb3cSopenharmony_ci std::string eventName = "JANK_STATS_APP"; 33523b3eb3cSopenharmony_ci auto app_version_code = AceApplicationInfo::GetInstance().GetAppVersionCode(); 33623b3eb3cSopenharmony_ci auto app_version_name = AceApplicationInfo::GetInstance().GetAppVersionName(); 33723b3eb3cSopenharmony_ci auto packageName = AceApplicationInfo::GetInstance().GetPackageName(); 33823b3eb3cSopenharmony_ci auto abilityName = AceApplicationInfo::GetInstance().GetAbilityName(); 33923b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, eventName, 34023b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, 34123b3eb3cSopenharmony_ci EVENT_KEY_STARTTIME, startTime, 34223b3eb3cSopenharmony_ci STATISTIC_DURATION, duration, 34323b3eb3cSopenharmony_ci EVENT_KEY_VERSION_CODE, app_version_code, 34423b3eb3cSopenharmony_ci EVENT_KEY_VERSION_NAME, app_version_name, 34523b3eb3cSopenharmony_ci EVENT_KEY_BUNDLE_NAME, packageName, 34623b3eb3cSopenharmony_ci EVENT_KEY_ABILITY_NAME, abilityName, 34723b3eb3cSopenharmony_ci EVENT_KEY_PAGE_URL, pageUrl, 34823b3eb3cSopenharmony_ci EVENT_KEY_JANK_STATS, jank, 34923b3eb3cSopenharmony_ci EVENT_KEY_JANK_STATS_VER, jankStatusVersion); 35023b3eb3cSopenharmony_ci} 35123b3eb3cSopenharmony_ci 35223b3eb3cSopenharmony_civoid EventReport::SendEventInner(const EventInfo& eventInfo) 35323b3eb3cSopenharmony_ci{ 35423b3eb3cSopenharmony_ci auto packageName = AceApplicationInfo::GetInstance().GetPackageName(); 35523b3eb3cSopenharmony_ci StrTrim(packageName); 35623b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, eventInfo.eventType, 35723b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, 35823b3eb3cSopenharmony_ci EVENT_KEY_ERROR_TYPE, eventInfo.errorType, 35923b3eb3cSopenharmony_ci EVENT_KEY_PACKAGE_NAME, packageName); 36023b3eb3cSopenharmony_ci} 36123b3eb3cSopenharmony_ci 36223b3eb3cSopenharmony_civoid EventReport::ReportEventComplete(DataBase& data) 36323b3eb3cSopenharmony_ci{ 36423b3eb3cSopenharmony_ci std::string eventName = "INTERACTION_COMPLETED_LATENCY"; 36523b3eb3cSopenharmony_ci const auto& appPid = data.baseInfo.pid; 36623b3eb3cSopenharmony_ci const auto& bundleName = data.baseInfo.bundleName; 36723b3eb3cSopenharmony_ci const auto& processName = data.baseInfo.processName; 36823b3eb3cSopenharmony_ci const auto& abilityName = data.baseInfo.abilityName; 36923b3eb3cSopenharmony_ci const auto& pageUrl = data.baseInfo.pageUrl; 37023b3eb3cSopenharmony_ci const auto& versionCode = data.baseInfo.versionCode; 37123b3eb3cSopenharmony_ci const auto& versionName = data.baseInfo.versionName; 37223b3eb3cSopenharmony_ci const auto& pageName = data.baseInfo.pageName; 37323b3eb3cSopenharmony_ci const auto& sceneId = data.sceneId; 37423b3eb3cSopenharmony_ci const auto& sourceType = GetSourceTypeName(data.sourceType); 37523b3eb3cSopenharmony_ci auto inputTime = data.inputTime; 37623b3eb3cSopenharmony_ci ConvertRealtimeToSystime(data.inputTime, inputTime); 37723b3eb3cSopenharmony_ci const auto& animationStartLantency = (data.beginVsyncTime - data.inputTime) / NS_TO_MS; 37823b3eb3cSopenharmony_ci const auto& animationEndLantency = (data.endVsyncTime - data.beginVsyncTime) / NS_TO_MS; 37923b3eb3cSopenharmony_ci const auto& e2eLatency = animationStartLantency + animationEndLantency; 38023b3eb3cSopenharmony_ci const auto& note = data.baseInfo.note; 38123b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, eventName, 38223b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, 38323b3eb3cSopenharmony_ci EVENT_KEY_APP_PID, appPid, 38423b3eb3cSopenharmony_ci EVENT_KEY_BUNDLE_NAME, bundleName, 38523b3eb3cSopenharmony_ci EVENT_KEY_PROCESS_NAME, processName, 38623b3eb3cSopenharmony_ci EVENT_KEY_ABILITY_NAME, abilityName, 38723b3eb3cSopenharmony_ci EVENT_KEY_PAGE_URL, pageUrl, 38823b3eb3cSopenharmony_ci EVENT_KEY_VERSION_CODE, versionCode, 38923b3eb3cSopenharmony_ci EVENT_KEY_VERSION_NAME, versionName, 39023b3eb3cSopenharmony_ci EVENT_KEY_PAGE_NAME, pageName, 39123b3eb3cSopenharmony_ci EVENT_KEY_SCENE_ID, sceneId, 39223b3eb3cSopenharmony_ci EVENT_KEY_SOURCE_TYPE, sourceType, 39323b3eb3cSopenharmony_ci EVENT_KEY_INPUT_TIME, static_cast<uint64_t>(inputTime), 39423b3eb3cSopenharmony_ci EVENT_KEY_ANIMATION_START_LATENCY, static_cast<uint64_t>(animationStartLantency), 39523b3eb3cSopenharmony_ci EVENT_KEY_ANIMATION_END_LATENCY, static_cast<uint64_t>(animationEndLantency), 39623b3eb3cSopenharmony_ci EVENT_KEY_E2E_LATENCY, static_cast<uint64_t>(e2eLatency), 39723b3eb3cSopenharmony_ci EVENT_KEY_NOTE, note); 39823b3eb3cSopenharmony_ci ACE_SCOPED_TRACE("INTERACTION_COMPLETED_LATENCY: sceneId =%s, inputTime=%lld(ms)," 39923b3eb3cSopenharmony_ci "e2eLatency=%lld(ms)", sceneId.c_str(), 40023b3eb3cSopenharmony_ci static_cast<long long>(inputTime), static_cast<long long>(e2eLatency)); 40123b3eb3cSopenharmony_ci} 40223b3eb3cSopenharmony_ci 40323b3eb3cSopenharmony_ci#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE 40423b3eb3cSopenharmony_civoid EventReport::ReportAppFrameDropToRss(const bool isInteractionJank, const std::string &bundleName, 40523b3eb3cSopenharmony_ci const int64_t maxFrameTime) 40623b3eb3cSopenharmony_ci{ 40723b3eb3cSopenharmony_ci uint32_t eventType = ResourceSchedule::ResType::RES_TYPE_APP_FRAME_DROP; 40823b3eb3cSopenharmony_ci int32_t subType = isInteractionJank ? ResourceSchedule::ResType::AppFrameDropType::INTERACTION_APP_JANK 40923b3eb3cSopenharmony_ci : ResourceSchedule::ResType::AppFrameDropType::JANK_FRAME_APP; 41023b3eb3cSopenharmony_ci std::unordered_map<std::string, std::string> payload = { 41123b3eb3cSopenharmony_ci { "bundleName", bundleName }, 41223b3eb3cSopenharmony_ci { "maxFrameTime", std::to_string(maxFrameTime) }, 41323b3eb3cSopenharmony_ci }; 41423b3eb3cSopenharmony_ci ResourceSchedule::ResSchedClient::GetInstance().ReportData(eventType, subType, payload); 41523b3eb3cSopenharmony_ci} 41623b3eb3cSopenharmony_ci#endif // RESOURCE_SCHEDULE_SERVICE_ENABLE 41723b3eb3cSopenharmony_ci 41823b3eb3cSopenharmony_civoid EventReport::ReportEventJankFrame(DataBase& data) 41923b3eb3cSopenharmony_ci{ 42023b3eb3cSopenharmony_ci std::string eventName = "INTERACTION_APP_JANK"; 42123b3eb3cSopenharmony_ci const auto& uniqueId = data.beginVsyncTime / NS_TO_MS; 42223b3eb3cSopenharmony_ci const auto& sceneId = data.sceneId; 42323b3eb3cSopenharmony_ci const auto& bundleName = data.baseInfo.bundleName; 42423b3eb3cSopenharmony_ci const auto& processName = data.baseInfo.processName; 42523b3eb3cSopenharmony_ci const auto& abilityName = data.baseInfo.abilityName; 42623b3eb3cSopenharmony_ci auto startTime = data.beginVsyncTime; 42723b3eb3cSopenharmony_ci ConvertRealtimeToSystime(data.beginVsyncTime, startTime); 42823b3eb3cSopenharmony_ci const auto& durition = (data.endVsyncTime - data.beginVsyncTime) / NS_TO_MS; 42923b3eb3cSopenharmony_ci const auto& totalFrames = data.totalFrames; 43023b3eb3cSopenharmony_ci const auto& totalMissedFrames = data.totalMissed; 43123b3eb3cSopenharmony_ci const auto& maxFrameTime = data.maxFrameTime / NS_TO_MS; 43223b3eb3cSopenharmony_ci const auto& maxFrameTimeSinceStart = data.maxFrameTimeSinceStart; 43323b3eb3cSopenharmony_ci const auto& maxHitchTime = data.maxHitchTime; 43423b3eb3cSopenharmony_ci const auto& maxHitchTimeSinceStart = data.maxHitchTimeSinceStart; 43523b3eb3cSopenharmony_ci const auto& maxSeqMissedFrames = data.maxSuccessiveFrames; 43623b3eb3cSopenharmony_ci const auto& note = data.baseInfo.note; 43723b3eb3cSopenharmony_ci const auto& isDisplayAnimator = data.isDisplayAnimator; 43823b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, eventName, 43923b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, 44023b3eb3cSopenharmony_ci EVENT_KEY_UNIQUE_ID, static_cast<int32_t>(uniqueId), 44123b3eb3cSopenharmony_ci EVENT_KEY_SCENE_ID, sceneId, 44223b3eb3cSopenharmony_ci EVENT_KEY_PROCESS_NAME, processName, 44323b3eb3cSopenharmony_ci EVENT_KEY_MODULE_NAME, bundleName, 44423b3eb3cSopenharmony_ci EVENT_KEY_ABILITY_NAME, abilityName, 44523b3eb3cSopenharmony_ci EVENT_KEY_PAGE_URL, data.baseInfo.pageUrl, 44623b3eb3cSopenharmony_ci EVENT_KEY_VERSION_CODE, data.baseInfo.versionCode, 44723b3eb3cSopenharmony_ci EVENT_KEY_VERSION_NAME, data.baseInfo.versionName, 44823b3eb3cSopenharmony_ci EVENT_KEY_PAGE_NAME, data.baseInfo.pageName, 44923b3eb3cSopenharmony_ci EVENT_KEY_STARTTIME, static_cast<uint64_t>(startTime), 45023b3eb3cSopenharmony_ci EVENT_KEY_DURITION, static_cast<uint64_t>(durition), 45123b3eb3cSopenharmony_ci EVENT_KEY_TOTAL_FRAMES, totalFrames, 45223b3eb3cSopenharmony_ci EVENT_KEY_TOTAL_MISSED_FRAMES, totalMissedFrames, 45323b3eb3cSopenharmony_ci EVENT_KEY_MAX_FRAMETIME, static_cast<uint64_t>(maxFrameTime), 45423b3eb3cSopenharmony_ci EVENT_KEY_MAX_FRAMETIME_SINCE_START, static_cast<uint64_t>(maxFrameTimeSinceStart), 45523b3eb3cSopenharmony_ci EVENT_KEY_MAX_HITCH_TIME, static_cast<uint64_t>(maxHitchTime), 45623b3eb3cSopenharmony_ci EVENT_KEY_MAX_HITCH_TIME_SINCE_START, static_cast<uint64_t>(maxHitchTimeSinceStart), 45723b3eb3cSopenharmony_ci EVENT_KEY_MAX_SEQ_MISSED_FRAMES, maxSeqMissedFrames, 45823b3eb3cSopenharmony_ci EVENT_KEY_NOTE, note, 45923b3eb3cSopenharmony_ci EVENT_KEY_DISPLAY_ANIMATOR, isDisplayAnimator); 46023b3eb3cSopenharmony_ci ACE_SCOPED_TRACE("INTERACTION_APP_JANK: sceneId =%s, startTime=%lld(ms)," 46123b3eb3cSopenharmony_ci "maxFrameTime=%lld(ms)", sceneId.c_str(), 46223b3eb3cSopenharmony_ci static_cast<long long>(startTime), static_cast<long long>(maxFrameTime)); 46323b3eb3cSopenharmony_ci#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE 46423b3eb3cSopenharmony_ci if (isDisplayAnimator && maxFrameTime > MAX_JANK_FRAME_TIME) { 46523b3eb3cSopenharmony_ci ReportAppFrameDropToRss(true, bundleName, maxFrameTime); 46623b3eb3cSopenharmony_ci } 46723b3eb3cSopenharmony_ci#endif // RESOURCE_SCHEDULE_SERVICE_ENABLE 46823b3eb3cSopenharmony_ci} 46923b3eb3cSopenharmony_ci 47023b3eb3cSopenharmony_civoid EventReport::ReportJankFrameApp(JankInfo& info) 47123b3eb3cSopenharmony_ci{ 47223b3eb3cSopenharmony_ci std::string eventName = "JANK_FRAME_APP"; 47323b3eb3cSopenharmony_ci const auto& bundleName = info.baseInfo.bundleName; 47423b3eb3cSopenharmony_ci const auto& processName = info.baseInfo.processName; 47523b3eb3cSopenharmony_ci const auto& abilityName = info.baseInfo.abilityName; 47623b3eb3cSopenharmony_ci const auto& pageUrl = info.baseInfo.pageUrl; 47723b3eb3cSopenharmony_ci const auto& versionCode = info.baseInfo.versionCode; 47823b3eb3cSopenharmony_ci const auto& versionName = info.baseInfo.versionName; 47923b3eb3cSopenharmony_ci const auto& pageName = info.baseInfo.pageName; 48023b3eb3cSopenharmony_ci const auto& skippedFrameTime = info.skippedFrameTime; 48123b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, eventName, 48223b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, 48323b3eb3cSopenharmony_ci EVENT_KEY_PROCESS_NAME, processName, 48423b3eb3cSopenharmony_ci EVENT_KEY_MODULE_NAME, bundleName, 48523b3eb3cSopenharmony_ci EVENT_KEY_ABILITY_NAME, abilityName, 48623b3eb3cSopenharmony_ci EVENT_KEY_PAGE_URL, pageUrl, 48723b3eb3cSopenharmony_ci EVENT_KEY_VERSION_CODE, versionCode, 48823b3eb3cSopenharmony_ci EVENT_KEY_VERSION_NAME, versionName, 48923b3eb3cSopenharmony_ci EVENT_KEY_PAGE_NAME, pageName, 49023b3eb3cSopenharmony_ci EVENT_KEY_SKIPPED_FRAME_TIME, static_cast<uint64_t>(skippedFrameTime)); 49123b3eb3cSopenharmony_ci ACE_SCOPED_TRACE("JANK_FRAME_APP: skipppedFrameTime=%lld(ms)", static_cast<long long>(skippedFrameTime / NS_TO_MS)); 49223b3eb3cSopenharmony_ci#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE 49323b3eb3cSopenharmony_ci ReportAppFrameDropToRss(false, bundleName); 49423b3eb3cSopenharmony_ci#endif // RESOURCE_SCHEDULE_SERVICE_ENABLE 49523b3eb3cSopenharmony_ci} 49623b3eb3cSopenharmony_ci 49723b3eb3cSopenharmony_civoid EventReport::ReportJankFrameFiltered(JankInfo& info) 49823b3eb3cSopenharmony_ci{ 49923b3eb3cSopenharmony_ci std::string eventName = "JANK_FRAME_FILTERED"; 50023b3eb3cSopenharmony_ci const auto& bundleName = info.baseInfo.bundleName; 50123b3eb3cSopenharmony_ci const auto& processName = info.baseInfo.processName; 50223b3eb3cSopenharmony_ci const auto& abilityName = info.baseInfo.abilityName; 50323b3eb3cSopenharmony_ci const auto& pageUrl = info.baseInfo.pageUrl; 50423b3eb3cSopenharmony_ci const auto& versionCode = info.baseInfo.versionCode; 50523b3eb3cSopenharmony_ci const auto& versionName = info.baseInfo.versionName; 50623b3eb3cSopenharmony_ci const auto& pageName = info.baseInfo.pageName; 50723b3eb3cSopenharmony_ci const auto& skippedFrameTime = info.skippedFrameTime; 50823b3eb3cSopenharmony_ci const auto& windowName = info.windowName; 50923b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, eventName, 51023b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, 51123b3eb3cSopenharmony_ci EVENT_KEY_PROCESS_NAME, processName, 51223b3eb3cSopenharmony_ci EVENT_KEY_MODULE_NAME, bundleName, 51323b3eb3cSopenharmony_ci EVENT_KEY_ABILITY_NAME, abilityName, 51423b3eb3cSopenharmony_ci EVENT_KEY_PAGE_URL, pageUrl, 51523b3eb3cSopenharmony_ci EVENT_KEY_VERSION_CODE, versionCode, 51623b3eb3cSopenharmony_ci EVENT_KEY_VERSION_NAME, versionName, 51723b3eb3cSopenharmony_ci EVENT_KEY_PAGE_NAME, pageName, 51823b3eb3cSopenharmony_ci EVENT_KEY_SKIPPED_FRAME_TIME, static_cast<uint64_t>(skippedFrameTime)); 51923b3eb3cSopenharmony_ci ACE_SCOPED_TRACE("JANK_FRAME_FILTERED: skipppedFrameTime=%lld(ms), windowName=%s", 52023b3eb3cSopenharmony_ci static_cast<long long>(skippedFrameTime / NS_TO_MS), windowName.c_str()); 52123b3eb3cSopenharmony_ci} 52223b3eb3cSopenharmony_ci 52323b3eb3cSopenharmony_civoid EventReport::ReportJankFrameUnFiltered(JankInfo& info) 52423b3eb3cSopenharmony_ci{ 52523b3eb3cSopenharmony_ci std::string eventName = "JANK_FRAME_UNFILTERED"; 52623b3eb3cSopenharmony_ci const auto& bundleName = info.baseInfo.bundleName; 52723b3eb3cSopenharmony_ci const auto& processName = info.baseInfo.processName; 52823b3eb3cSopenharmony_ci const auto& abilityName = info.baseInfo.abilityName; 52923b3eb3cSopenharmony_ci const auto& pageUrl = info.baseInfo.pageUrl; 53023b3eb3cSopenharmony_ci const auto& versionCode = info.baseInfo.versionCode; 53123b3eb3cSopenharmony_ci const auto& versionName = info.baseInfo.versionName; 53223b3eb3cSopenharmony_ci const auto& pageName = info.baseInfo.pageName; 53323b3eb3cSopenharmony_ci const auto& skippedFrameTime = info.skippedFrameTime; 53423b3eb3cSopenharmony_ci const auto& windowName = info.windowName; 53523b3eb3cSopenharmony_ci const auto& filterType = info.filterType; 53623b3eb3cSopenharmony_ci const auto& sceneId = info.sceneId; 53723b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, eventName, 53823b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, 53923b3eb3cSopenharmony_ci EVENT_KEY_PROCESS_NAME, processName, 54023b3eb3cSopenharmony_ci EVENT_KEY_MODULE_NAME, bundleName, 54123b3eb3cSopenharmony_ci EVENT_KEY_ABILITY_NAME, abilityName, 54223b3eb3cSopenharmony_ci EVENT_KEY_PAGE_URL, pageUrl, 54323b3eb3cSopenharmony_ci EVENT_KEY_VERSION_CODE, versionCode, 54423b3eb3cSopenharmony_ci EVENT_KEY_VERSION_NAME, versionName, 54523b3eb3cSopenharmony_ci EVENT_KEY_PAGE_NAME, pageName, 54623b3eb3cSopenharmony_ci EVENT_KEY_FILTER_TYPE, filterType, 54723b3eb3cSopenharmony_ci EVENT_KEY_SCENE_ID, sceneId, 54823b3eb3cSopenharmony_ci EVENT_KEY_SKIPPED_FRAME_TIME, static_cast<uint64_t>(skippedFrameTime)); 54923b3eb3cSopenharmony_ci ACE_SCOPED_TRACE("JANK_FRAME_UNFILTERED: skipppedFrameTime=%lld(ms), windowName=%s, filterType=%d", 55023b3eb3cSopenharmony_ci static_cast<long long>(skippedFrameTime / NS_TO_MS), windowName.c_str(), filterType); 55123b3eb3cSopenharmony_ci} 55223b3eb3cSopenharmony_ci 55323b3eb3cSopenharmony_civoid EventReport::ReportPageShowMsg(const std::string& pageUrl, const std::string& bundleName, 55423b3eb3cSopenharmony_ci const std::string& pageName) 55523b3eb3cSopenharmony_ci{ 55623b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, "APP_PAGE_INFO_UPDATE", 55723b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, 55823b3eb3cSopenharmony_ci EVENT_KEY_PAGE_URL, pageUrl, EVENT_KEY_BUNDLE_NAME, bundleName, 55923b3eb3cSopenharmony_ci EVENT_KEY_PAGE_NAME, pageName); 56023b3eb3cSopenharmony_ci} 56123b3eb3cSopenharmony_ci 56223b3eb3cSopenharmony_civoid EventReport::ReportDoubleClickTitle(int32_t stateChange) 56323b3eb3cSopenharmony_ci{ 56423b3eb3cSopenharmony_ci auto packageName = AceApplicationInfo::GetInstance().GetPackageName(); 56523b3eb3cSopenharmony_ci StrTrim(packageName); 56623b3eb3cSopenharmony_ci HiSysEventWrite(SCENE_BOARD_UE_DOMAIN, DOUBLE_CLICK_TITLE, 56723b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, 56823b3eb3cSopenharmony_ci CURRENTPKG, packageName, 56923b3eb3cSopenharmony_ci STATECHANGE, stateChange); 57023b3eb3cSopenharmony_ci} 57123b3eb3cSopenharmony_ci 57223b3eb3cSopenharmony_civoid EventReport::ReportClickTitleMaximizeMenu(int32_t maxMenuItem, int32_t stateChange) 57323b3eb3cSopenharmony_ci{ 57423b3eb3cSopenharmony_ci auto packageName = AceApplicationInfo::GetInstance().GetPackageName(); 57523b3eb3cSopenharmony_ci StrTrim(packageName); 57623b3eb3cSopenharmony_ci HiSysEventWrite(SCENE_BOARD_UE_DOMAIN, CLICK_TITLE_MAXIMIZE_MENU, 57723b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, 57823b3eb3cSopenharmony_ci CURRENTPKG, packageName, 57923b3eb3cSopenharmony_ci MAXMENUITEM, maxMenuItem, 58023b3eb3cSopenharmony_ci STATECHANGE, stateChange); 58123b3eb3cSopenharmony_ci} 58223b3eb3cSopenharmony_ci 58323b3eb3cSopenharmony_civoid EventReport::ReportPageNodeOverflow(const std::string& pageUrl, int32_t nodeCount, int32_t threshold) 58423b3eb3cSopenharmony_ci{ 58523b3eb3cSopenharmony_ci auto packageName = AceApplicationInfo::GetInstance().GetPackageName(); 58623b3eb3cSopenharmony_ci StrTrim(packageName); 58723b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, PAGE_NODE_OVERFLOW, 58823b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, 58923b3eb3cSopenharmony_ci EVENT_KEY_PACKAGE_NAME, packageName, 59023b3eb3cSopenharmony_ci EVENT_KEY_PAGE_URL, pageUrl, 59123b3eb3cSopenharmony_ci EVENT_KEY_PAGE_NODE_COUNT, nodeCount, 59223b3eb3cSopenharmony_ci EVENT_KEY_PAGE_NODE_THRESHOLD, threshold); 59323b3eb3cSopenharmony_ci} 59423b3eb3cSopenharmony_ci 59523b3eb3cSopenharmony_civoid EventReport::ReportPageDepthOverflow(const std::string& pageUrl, int32_t depth, int32_t threshold) 59623b3eb3cSopenharmony_ci{ 59723b3eb3cSopenharmony_ci auto packageName = AceApplicationInfo::GetInstance().GetPackageName(); 59823b3eb3cSopenharmony_ci StrTrim(packageName); 59923b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, PAGE_DEPTH_OVERFLOW, 60023b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, 60123b3eb3cSopenharmony_ci EVENT_KEY_PACKAGE_NAME, packageName, 60223b3eb3cSopenharmony_ci EVENT_KEY_PAGE_URL, pageUrl, 60323b3eb3cSopenharmony_ci EVENT_KEY_PAGE_DEPTH, depth, 60423b3eb3cSopenharmony_ci EVENT_KEY_PAGE_DEPTH_THRESHOLD, threshold); 60523b3eb3cSopenharmony_ci} 60623b3eb3cSopenharmony_ci 60723b3eb3cSopenharmony_civoid EventReport::ReportFunctionTimeout(const std::string& functionName, int64_t time, int32_t threshold) 60823b3eb3cSopenharmony_ci{ 60923b3eb3cSopenharmony_ci auto packageName = AceApplicationInfo::GetInstance().GetPackageName(); 61023b3eb3cSopenharmony_ci StrTrim(packageName); 61123b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, UI_LIFECIRCLE_FUNCTION_TIMEOUT, 61223b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, 61323b3eb3cSopenharmony_ci EVENT_KEY_PACKAGE_NAME, packageName, 61423b3eb3cSopenharmony_ci EVENT_KEY_FUNCTION_NAME, functionName, 61523b3eb3cSopenharmony_ci EVENT_KEY_FUNCTION_EXECUTE_TIME, time, 61623b3eb3cSopenharmony_ci EVENT_KEY_FUNCTION_TIME_THRESHOLD, threshold); 61723b3eb3cSopenharmony_ci} 61823b3eb3cSopenharmony_ci 61923b3eb3cSopenharmony_civoid EventReport::ReportHoverStatusChange( 62023b3eb3cSopenharmony_ci int32_t foldStatus, int32_t time, bool isHoverMode, int32_t appRotation, int32_t windowMode) 62123b3eb3cSopenharmony_ci{ 62223b3eb3cSopenharmony_ci auto packageName = AceApplicationInfo::GetInstance().GetPackageName(); 62323b3eb3cSopenharmony_ci auto abilityName = AceApplicationInfo::GetInstance().GetAbilityName(); 62423b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, EVENT_KEY_NOTIFY_HOVER_STATUS_CHANGE, 62523b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, 62623b3eb3cSopenharmony_ci EVENT_KEY_BUNDLE_NAME, packageName, 62723b3eb3cSopenharmony_ci EVENT_KEY_ABILITY_NAME, abilityName, 62823b3eb3cSopenharmony_ci EVENT_KEY_FOLDER_STATUS, foldStatus, 62923b3eb3cSopenharmony_ci EVENT_KEY_HOVER_TIME, time, 63023b3eb3cSopenharmony_ci EVENT_KEY_IS_HOVER_MODE, isHoverMode, 63123b3eb3cSopenharmony_ci EVENT_KEY_WINDOW_MODE, windowMode, 63223b3eb3cSopenharmony_ci EVENT_KEY_APP_ROTATION, appRotation); 63323b3eb3cSopenharmony_ci} 63423b3eb3cSopenharmony_ci 63523b3eb3cSopenharmony_civoid EventReport::ReportNonManualPostCardActionInfo(const std::string& formName, const std::string& bundleName, 63623b3eb3cSopenharmony_ci const std::string& abilityName, const std::string& moduleName, int32_t dimension) 63723b3eb3cSopenharmony_ci{ 63823b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, EVENT_KEY_NON_MANUAL_POSTCARD_ACTION, 63923b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, 64023b3eb3cSopenharmony_ci EVENT_KEY_FORM_NAME, formName, 64123b3eb3cSopenharmony_ci EVENT_KEY_BUNDLE_NAME, bundleName, 64223b3eb3cSopenharmony_ci EVENT_KEY_ABILITY_NAME, abilityName, 64323b3eb3cSopenharmony_ci EVENT_KEY_MODULE_NAME, moduleName, 64423b3eb3cSopenharmony_ci EVENT_KEY_DIMENSION, dimension); 64523b3eb3cSopenharmony_ci} 64623b3eb3cSopenharmony_ci 64723b3eb3cSopenharmony_civoid EventReport::ReportUiExtensionTransparentEvent(const std::string& pageUrl, const std::string& bundleName, 64823b3eb3cSopenharmony_ci const std::string& moduleName) 64923b3eb3cSopenharmony_ci{ 65023b3eb3cSopenharmony_ci auto app_version_code = AceApplicationInfo::GetInstance().GetAppVersionCode(); 65123b3eb3cSopenharmony_ci auto app_version_name = AceApplicationInfo::GetInstance().GetAppVersionName(); 65223b3eb3cSopenharmony_ci HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, UIEXTENSION_TRANSPARENT_DETECTED, 65323b3eb3cSopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, 65423b3eb3cSopenharmony_ci EVENT_KEY_PAGE_NAME, pageUrl, 65523b3eb3cSopenharmony_ci EVENT_KEY_VERSION_CODE, app_version_code, 65623b3eb3cSopenharmony_ci EVENT_KEY_VERSION_NAME, app_version_name, 65723b3eb3cSopenharmony_ci EVENT_KEY_BUNDLE_NAME, bundleName, 65823b3eb3cSopenharmony_ci EVENT_KEY_MODULE_NAME, moduleName); 65923b3eb3cSopenharmony_ci} 66023b3eb3cSopenharmony_ci} // namespace OHOS::Ace 661