diff --git a/accessibility_manager_service.gni b/accessibility_manager_service.gni index 58fb5713..3a4fb6b1 100644 --- a/accessibility_manager_service.gni +++ b/accessibility_manager_service.gni @@ -19,6 +19,8 @@ declare_args() { accessibility_feature_data_share = true accessibility_use_rosen_drawing = false accessibility_watch_feature = false + accessibility_feature_hiviewdfx_hitrace = true + accessibility_feature_hiviewdfx_hisysevent = true if (defined(global_parts_info) && !defined(global_parts_info.powermgr_display_manager)) { accessibility_feature_display_manager = false @@ -37,6 +39,15 @@ declare_args() { !defined(global_parts_info.distributeddatamgr_data_share)) { distributeddatamgr_data_share = false } + if (defined(global_parts_info) && + !defined(global_parts_info.hiviewdfx_hitrace)) { + accessibility_feature_hiviewdfx_hitrace = false + } + + if (defined(global_parts_info) && + !defined(global_parts_info.hiviewdfx_hisysevent)) { + accessibility_feature_hiviewdfx_hisysevent = false + } } print( @@ -45,6 +56,10 @@ print( "accessibility_feature_power_manager = ${accessibility_feature_power_manager}") print("accessibility_use_rosen_drawing = ${accessibility_use_rosen_drawing}") print("accessibility_feature_data_share = ${accessibility_feature_data_share}") +print( + "accessibility_feature_hiviewdfx_hitrace = ${accessibility_feature_hiviewdfx_hitrace}") +print( + "accessibility_feature_hiviewdfx_hisysevent = ${accessibility_feature_hiviewdfx_hisysevent}") accessibility_default_defines = [] @@ -67,3 +82,11 @@ if (accessibility_feature_data_share) { if (defined(accessibility_watch_feature) && accessibility_watch_feature) { accessibility_default_defines += [ "ACCESSIBILITY_WATCH_FEATURE" ] } + +if (accessibility_feature_hiviewdfx_hitrace) { + accessibility_default_defines += [ "OHOS_BUILD_ENABLE_HITRACE" ] +} + +if (accessibility_feature_hiviewdfx_hisysevent) { + accessibility_default_defines += [ "OHOS_BUILD_ENABLE_HISYSEVENT" ] +} diff --git a/frameworks/aafwk/src/accessible_ability_channel_client.cpp b/frameworks/aafwk/src/accessible_ability_channel_client.cpp index eba8658b..bda221f7 100644 --- a/frameworks/aafwk/src/accessible_ability_channel_client.cpp +++ b/frameworks/aafwk/src/accessible_ability_channel_client.cpp @@ -16,7 +16,9 @@ #include "accessible_ability_channel_client.h" #include +#ifdef OHOS_BUILD_ENABLE_HITRACE #include +#endif // OHOS_BUILD_ENABLE_HITRACE #include "accessibility_element_operator_callback_impl.h" #include "hilog_wrapper.h" @@ -54,7 +56,9 @@ RetError AccessibleAbilityChannelClient::FindFocusedElementInfo(int32_t accessib int64_t elementId, int32_t focusType, AccessibilityElementInfo &elementInfo) { HILOG_DEBUG("[channelId:%{public}d]", channelId_); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "FindFocusedElement"); +#endif // OHOS_BUILD_ENABLE_HITRACE if (proxy_ == nullptr) { HILOG_ERROR("FindFocusedElementInfo Failed to connect to aams [channelId:%{public}d]", channelId_); @@ -118,7 +122,9 @@ RetError AccessibleAbilityChannelClient::SendSimulateGesture( RetError AccessibleAbilityChannelClient::GetCursorPosition( int32_t accessibilityWindowId, int64_t elementId, int32_t &position) { +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "GetCursorPosition"); +#endif // OHOS_BUILD_ENABLE_HITRACE if (proxy_ == nullptr) { HILOG_ERROR("GetCursorPosition Failed to connect to aams [channelId:%{public}d]", channelId_); @@ -155,7 +161,9 @@ RetError AccessibleAbilityChannelClient::ExecuteAction(int32_t accessibilityWind int64_t elementId, int32_t action, const std::map &actionArguments) { HILOG_DEBUG("execute action:%{public}d, elementId:%{public}" PRId64 "", action, elementId); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "ExecuteAction"); +#endif // OHOS_BUILD_ENABLE_HITRACE if (proxy_ == nullptr) { HILOG_ERROR("ExecuteAction Failed to connect to aams [channelId:%{public}d]", channelId_); return RET_ERR_SAMGR; @@ -223,7 +231,9 @@ RetError AccessibleAbilityChannelClient::SearchElementInfosByAccessibilityId(int int32_t requestId = GenerateRequestId(); HILOG_DEBUG("channelId:%{public}d, elementId:%{public}" PRId64 ", windowId:%{public}d, requestId:%{public}d", channelId_, elementId, accessibilityWindowId, requestId); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SearchElementById"); +#endif // OHOS_BUILD_ENABLE_HITRACE if (proxy_ == nullptr) { HILOG_ERROR("SearchElementInfosByAccessibilityId Failed to connect to aams [channelId:%{public}d]", channelId_); @@ -270,7 +280,9 @@ RetError AccessibleAbilityChannelClient::SearchElementInfosByAccessibilityId(int RetError AccessibleAbilityChannelClient::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) { HILOG_DEBUG("[channelId:%{public}d] [windowId:%{public}d]", channelId_, windowId); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER(HITRACE_TAG_ACCESSIBILITY_MANAGER); +#endif // OHOS_BUILD_ENABLE_HITRACE if (proxy_ == nullptr) { HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_); return RET_ERR_SAMGR; @@ -281,7 +293,9 @@ RetError AccessibleAbilityChannelClient::GetWindow(const int32_t windowId, Acces RetError AccessibleAbilityChannelClient::GetWindows(std::vector &windows) { HILOG_DEBUG("[channelId:%{public}d]", channelId_); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER(HITRACE_TAG_ACCESSIBILITY_MANAGER); +#endif // OHOS_BUILD_ENABLE_HITRACE if (proxy_) { return proxy_->GetWindows(windows); } else { @@ -294,7 +308,9 @@ RetError AccessibleAbilityChannelClient::GetWindows(const uint64_t displayId, std::vector &windows) const { HILOG_DEBUG("[channelId:%{public}d] [displayId:%{public}" PRIu64 "]", channelId_, displayId); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "GetWindowsByDisplayId"); +#endif // OHOS_BUILD_ENABLE_HITRACE if (proxy_) { return proxy_->GetWindowsByDisplayId(displayId, windows); } else { @@ -307,7 +323,9 @@ RetError AccessibleAbilityChannelClient::SearchElementInfosByText(int32_t access int64_t elementId, const std::string &text, std::vector &elementInfos) { HILOG_DEBUG("[channelId:%{public}d]", channelId_); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SearchElementByText"); +#endif // OHOS_BUILD_ENABLE_HITRACE if (proxy_ == nullptr) { HILOG_ERROR("SearchElementInfosByText Failed to connect to aams [channelId:%{public}d]", channelId_); diff --git a/interfaces/innerkits/aafwk/BUILD.gn b/interfaces/innerkits/aafwk/BUILD.gn index 134d50c3..46f7f7cb 100644 --- a/interfaces/innerkits/aafwk/BUILD.gn +++ b/interfaces/innerkits/aafwk/BUILD.gn @@ -76,7 +76,6 @@ ohos_shared_library("accessibleability") { "c_utils:utils", "ffrt:libffrt", "hilog:libhilog", - "hitrace:hitrace_meter", "init:libbeget_proxy", "init:libbegetutil", "input:libmmi-client", @@ -84,6 +83,10 @@ ohos_shared_library("accessibleability") { "samgr:samgr_proxy", ] + if (accessibility_feature_hiviewdfx_hitrace) { + external_deps += [ "hitrace:hitrace_meter" ] + } + install_enable = true subsystem_name = "barrierfree" diff --git a/services/aams/BUILD.gn b/services/aams/BUILD.gn old mode 100755 new mode 100644 index 17dd78c4..ee803c4a --- a/services/aams/BUILD.gn +++ b/services/aams/BUILD.gn @@ -122,8 +122,6 @@ ohos_shared_library("accessibleabilityms") { "graphic_2d:librender_service_client", "hicollie:libhicollie", "hilog:libhilog", - "hisysevent:libhisysevent", - "hitrace:hitrace_meter", "init:libbegetutil", "input:libmmi-client", "ipc:ipc_single", @@ -147,6 +145,14 @@ ohos_shared_library("accessibleabilityms") { external_deps += [ "data_share:datashare_consumer" ] } + if (accessibility_feature_hiviewdfx_hitrace) { + external_deps += [ "hitrace:hitrace_meter" ] + } + + if (accessibility_feature_hiviewdfx_hisysevent) { + external_deps += [ "hisysevent:libhisysevent" ] + } + install_enable = true subsystem_name = "barrierfree" diff --git a/services/aams/include/accessible_ability_connection.h b/services/aams/include/accessible_ability_connection.h index 9738403b..af047b70 100644 --- a/services/aams/include/accessible_ability_connection.h +++ b/services/aams/include/accessible_ability_connection.h @@ -35,6 +35,8 @@ public: virtual ~AccessibleAbilityConnection(); + void HandleNoEventHandler(const AppExecFwk::ElementName &element); + virtual void OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr &remoteObject, int32_t resultCode) override; diff --git a/services/aams/src/accessibility_account_data.cpp b/services/aams/src/accessibility_account_data.cpp index 5ca3a52b..8c59f041 100644 --- a/services/aams/src/accessibility_account_data.cpp +++ b/services/aams/src/accessibility_account_data.cpp @@ -16,7 +16,9 @@ #include "accessibility_account_data.h" #include +#ifdef OHOS_BUILD_ENABLE_HITRACE #include +#endif // OHOS_BUILD_ENABLE_HITRACE #ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER #include "accessibility_display_manager.h" #endif @@ -631,7 +633,9 @@ RetError AccessibilityAccountData::EnableAbility(const std::string &name, const HILOG_ERROR("The ability[%{public}s] is already enabled", name.c_str()); return RET_ERR_CONNECTION_EXIST; } +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "EnableAbility:" + name); +#endif // OHOS_BUILD_ENABLE_HITRACE enabledAbilities_.push_back(name); SetAbilityAutoStartState(name, true); @@ -646,7 +650,9 @@ RetError AccessibilityAccountData::EnableAbility(const std::string &name, const bool AccessibilityAccountData::GetInstalledAbilitiesFromBMS() { HILOG_DEBUG("start."); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "QueryInstalledAbilityInfo"); +#endif // OHOS_BUILD_ENABLE_HITRACE std::vector extensionInfos; sptr bms = Singleton::GetInstance().GetBundleMgrProxy(); if (!bms) { diff --git a/services/aams/src/accessibility_settings.cpp b/services/aams/src/accessibility_settings.cpp index 8175c84e..3539cbfd 100644 --- a/services/aams/src/accessibility_settings.cpp +++ b/services/aams/src/accessibility_settings.cpp @@ -14,7 +14,9 @@ */ #include +#ifdef OHOS_BUILD_ENABLE_HITRACE #include +#endif // OHOS_BUILD_ENABLE_HITRACE #include "accessibility_account_data.h" #include "accessible_ability_manager_service.h" #include "accessibility_settings.h" @@ -43,7 +45,9 @@ void AccessibilitySettings::RegisterSettingsHandler(const std::shared_ptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -60,7 +64,9 @@ RetError AccessibilitySettings::SetScreenMagnificationState(const bool state) RetError AccessibilitySettings::SetShortKeyState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetShortKeyState:" + std::to_string(state)); +#endif // OHOS_BUILD_ENABLE_HITRACE if (!handler_) { HILOG_ERROR("handler_ is nullptr."); @@ -130,7 +136,9 @@ RetError AccessibilitySettings::SetMouseAutoClick(const int32_t time) RetError AccessibilitySettings::SetShortkeyTarget(const std::string &name) { HILOG_INFO("name = [%{public}s]", name.c_str()); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetShortkeyTarget:" + name); +#endif // OHOS_BUILD_ENABLE_HITRACE if (!handler_) { HILOG_ERROR("handler_ is nullptr."); @@ -156,7 +164,9 @@ RetError AccessibilitySettings::SetShortkeyTarget(const std::string &name) RetError AccessibilitySettings::SetShortkeyMultiTarget(const std::vector &name) { HILOG_DEBUG(); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetShortkeyMultiTarget"); +#endif // OHOS_BUILD_ENABLE_HITRACE if (!handler_) { HILOG_ERROR("handler_ is nullptr."); @@ -182,7 +192,9 @@ RetError AccessibilitySettings::SetShortkeyMultiTarget(const std::vector accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -198,7 +210,9 @@ RetError AccessibilitySettings::SetHighContrastTextState(const bool state) RetError AccessibilitySettings::SetDaltonizationState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetDaltonizationState:" + std::to_string(state)); +#endif // OHOS_BUILD_ENABLE_HITRACE sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -214,7 +228,9 @@ RetError AccessibilitySettings::SetDaltonizationState(const bool state) RetError AccessibilitySettings::SetInvertColorState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetInvertColorState:" + std::to_string(state)); +#endif // OHOS_BUILD_ENABLE_HITRACE sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -255,7 +271,9 @@ RetError AccessibilitySettings::SetAnimationOffState(const bool state) RetError AccessibilitySettings::SetAudioMonoState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetAudioMonoState:" + std::to_string(state)); +#endif // OHOS_BUILD_ENABLE_HITRACE sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -271,7 +289,9 @@ RetError AccessibilitySettings::SetAudioMonoState(const bool state) RetError AccessibilitySettings::SetDaltonizationColorFilter(const uint32_t filter) { HILOG_INFO("filter = [%{public}u]", filter); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetDaltonizationColorFilter:" + std::to_string(filter)); +#endif // OHOS_BUILD_ENABLE_HITRACE if (!handler_) { HILOG_ERROR("handler_ is nullptr."); return RET_ERR_NULLPTR; @@ -353,7 +373,9 @@ RetError AccessibilitySettings::SetBrightnessDiscount(const float discount) RetError AccessibilitySettings::SetAudioBalance(const float balance) { HILOG_INFO("balance = [%{public}f]", balance); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetAudioBalance:" + std::to_string(balance)); +#endif // OHOS_BUILD_ENABLE_HITRACE if (!handler_) { HILOG_ERROR("handler_ is nullptr."); @@ -380,7 +402,9 @@ RetError AccessibilitySettings::SetAudioBalance(const float balance) RetError AccessibilitySettings::SetClickResponseTime(const uint32_t time) { HILOG_INFO("click response time = [%{public}u]", time); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetClickResponseTime:" + std::to_string(time)); +#endif // OHOS_BUILD_ENABLE_HITRACE if (!handler_) { HILOG_ERROR("handler_ is nullptr."); @@ -408,7 +432,9 @@ RetError AccessibilitySettings::SetClickResponseTime(const uint32_t time) RetError AccessibilitySettings::SetIgnoreRepeatClickState(const bool state) { HILOG_INFO("ignore repeat click state = [%{public}s]", state ? "True" : "False"); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetIgnoreRepeatClickState:" + std::to_string(state)); +#endif // OHOS_BUILD_ENABLE_HITRACE if (!handler_) { HILOG_ERROR("handler_ is nullptr."); @@ -436,7 +462,9 @@ RetError AccessibilitySettings::SetIgnoreRepeatClickState(const bool state) RetError AccessibilitySettings::SetIgnoreRepeatClickTime(const uint32_t time) { HILOG_INFO("click response time = [%{public}u]", time); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetIgnoreRepeatClickTime:" + std::to_string(time)); +#endif // OHOS_BUILD_ENABLE_HITRACE if (!handler_) { HILOG_ERROR("handler_ is nullptr."); diff --git a/services/aams/src/accessibility_window_manager.cpp b/services/aams/src/accessibility_window_manager.cpp index a7fa3b30..f04cdf7b 100644 --- a/services/aams/src/accessibility_window_manager.cpp +++ b/services/aams/src/accessibility_window_manager.cpp @@ -15,7 +15,9 @@ #include "accessibility_window_manager.h" +#ifdef OHOS_BUILD_ENABLE_HITRACE #include +#endif // OHOS_BUILD_ENABLE_HITRACE #include "accessible_ability_manager_service.h" #include "hilog_wrapper.h" @@ -31,7 +33,9 @@ bool AccessibilityWindowManager::Init() { DeInit(); HILOG_DEBUG("deinit before start"); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "QueryWindowInfo"); +#endif // OHOS_BUILD_ENABLE_HITRACE std::vector> windowInfos; Rosen::WMError err = OHOS::Rosen::WindowManager::GetInstance().GetAccessibilityWindowInfo(windowInfos); if (err != Rosen::WMError::WM_OK) { @@ -996,7 +1000,9 @@ std::map AccessibilityWindowManager::SceneBoardElementIdMap::G RetError AccessibilityWindowManager::GetFocusedWindowId(int32_t &focusedWindowId) { HILOG_DEBUG(); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "QueryFocusedWindowInfo"); +#endif // OHOS_BUILD_ENABLE_HITRACE Rosen::FocusChangeInfo focusedWindowInfo; OHOS::Rosen::WindowManager::GetInstance().GetFocusWindowInfo(focusedWindowInfo); if (focusedWindowInfo.windowId_ == INVALID_WINDOW_ID) { diff --git a/services/aams/src/accessible_ability_connection.cpp b/services/aams/src/accessible_ability_connection.cpp index 546a7c63..d703c4a2 100644 --- a/services/aams/src/accessible_ability_connection.cpp +++ b/services/aams/src/accessible_ability_connection.cpp @@ -15,7 +15,9 @@ #include "accessible_ability_connection.h" +#ifdef OHOS_BUILD_ENABLE_HITRACE #include +#endif // OHOS_BUILD_ENABLE_HITRACE #include "ability_manager_client.h" #include "accessible_ability_manager_service.h" @@ -41,24 +43,30 @@ AccessibleAbilityConnection::~AccessibleAbilityConnection() } } +void AccessibleAbilityConnection::HandleNoEventHandler(const AppExecFwk::ElementName &element) +{ + HILOG_ERROR("eventHandler_ is nullptr."); + auto accountData = Singleton::GetInstance().GetAccountData(accountId_); + if (accountData != nullptr) { + accountData->RemoveConnectingA11yAbility(Utils::GetUri(element)); + } +} + void AccessibleAbilityConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr &remoteObject, int32_t resultCode) { HILOG_INFO("ResultCode is %{public}d", resultCode); if (!eventHandler_) { - HILOG_ERROR("eventHandler_ is nullptr."); - auto accountData = Singleton::GetInstance().GetAccountData(accountId_); - if (accountData != nullptr) { - accountData->RemoveConnectingA11yAbility(Utils::GetUri(element)); - return; - } + HandleNoEventHandler(element); return; } int32_t accountId = accountId_; eventHandler_->PostTask([accountId, element, remoteObject, resultCode]() { +#ifdef OHOS_BUILD_ENABLE_HITRACE FinishAsyncTrace(HITRACE_TAG_ACCESSIBILITY_MANAGER, "AccessibleAbilityConnect", static_cast(TraceTaskId::ACCESSIBLE_ABILITY_CONNECT)); +#endif // OHOS_BUILD_ENABLE_HITRACE std::string bundleName = element.GetBundleName(); std::string abilityName = element.GetAbilityName(); auto accountData = Singleton::GetInstance().GetAccountData(accountId); @@ -190,8 +198,10 @@ void AccessibleAbilityConnection::Disconnect() bool AccessibleAbilityConnection::Connect(const AppExecFwk::ElementName &element) { HILOG_DEBUG(); +#ifdef OHOS_BUILD_ENABLE_HITRACE StartAsyncTrace(HITRACE_TAG_ACCESSIBILITY_MANAGER, "AccessibleAbilityConnect", static_cast(TraceTaskId::ACCESSIBLE_ABILITY_CONNECT)); +#endif // OHOS_BUILD_ENABLE_HITRACE std::string bundleName = element.GetBundleName(); std::string abilityName = element.GetAbilityName(); diff --git a/services/aams/src/accessible_ability_manager_service.cpp b/services/aams/src/accessible_ability_manager_service.cpp index f614b747..eea9034a 100644 --- a/services/aams/src/accessible_ability_manager_service.cpp +++ b/services/aams/src/accessible_ability_manager_service.cpp @@ -20,7 +20,9 @@ #include #include #include +#ifdef OHOS_BUILD_ENABLE_HITRACE #include +#endif // OHOS_BUILD_ENABLE_HITRACE #include "ability_info.h" #include "accessibility_event_info.h" @@ -770,7 +772,9 @@ RetError AccessibleAbilityManagerService::RegisterElementOperator( } handler_->PostTask([=]() { HILOG_INFO("Register windowId[%{public}d]", windowId); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "RegisterElementOperator"); +#endif // OHOS_BUILD_ENABLE_HITRACE sptr accountData = GetCurrentAccountData(); if (!accountData) { Utils::RecordUnavailableEvent(A11yUnavailableEvent::CONNECT_EVENT, @@ -898,7 +902,9 @@ RetError AccessibleAbilityManagerService::RegisterElementOperator(Registration p } handler_->PostTask([=]() { HILOG_INFO("Register windowId[%{public}d]", parameter.windowId); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "RegisterElementOperator"); +#endif // OHOS_BUILD_ENABLE_HITRACE if (RET_OK != RegisterElementOperatorChildWork(parameter, treeIdSingle, nodeId, operation, tokenId, isApp)) { return; } @@ -1304,7 +1310,9 @@ RetError AccessibleAbilityManagerService::DisableAbility(const std::string &name RetError AccessibleAbilityManagerService::InnerDisableAbility(const std::string &name) { HILOG_INFO(); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "InnerDisableAbility:" + name); +#endif // OHOS_BUILD_ENABLE_HITRACE sptr accountData = GetCurrentAccountData(); if (!accountData) { @@ -2340,7 +2348,9 @@ bool AccessibleAbilityManagerService::EnableShortKeyTargetAbility(const std::str { HILOG_DEBUG(); HILOG_INFO("EnableShortKeyTargetAbility name = %{public}s", name.c_str()); +#ifdef OHOS_BUILD_ENABLE_HITRACE HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "EnableShortKeyTargetAbility"); +#endif // OHOS_BUILD_ENABLE_HITRACE sptr accountData = GetCurrentAccountData(); if (!accountData) { diff --git a/services/aams/src/utils.cpp b/services/aams/src/utils.cpp index 552aeced..5cf99e65 100644 --- a/services/aams/src/utils.cpp +++ b/services/aams/src/utils.cpp @@ -15,7 +15,9 @@ #include "utils.h" +#ifdef OHOS_BUILD_ENABLE_HISYSEVENT #include +#endif //OHOS_BUILD_ENABLE_HISYSEVENT #include "bundle_mgr_client.h" #include "hilog_wrapper.h" @@ -297,6 +299,7 @@ void Utils::RecordUnavailableEvent(A11yUnavailableEvent event, A11yError errCode << ", bundleName: " << bundleName << ", abilityName: " << abilityName << ";"; std::string info = oss.str(); HILOG_DEBUG("accessibility function is unavailable: %{public}s", info.c_str()); +#ifdef OHOS_BUILD_ENABLE_HISYSEVENT int32_t ret = HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::ACCESSIBILITY, "UNAVAILABLE", @@ -305,6 +308,7 @@ void Utils::RecordUnavailableEvent(A11yUnavailableEvent event, A11yError errCode if (ret != 0) { HILOG_ERROR("Write HiSysEvent error, ret:%{public}d", ret); } +#endif //OHOS_BUILD_ENABLE_HISYSEVENT } std::string Utils::TransferUnavailableEventToString(A11yUnavailableEvent type) @@ -332,6 +336,7 @@ void Utils::RecordStartingA11yEvent(uint32_t flag) std::ostringstream oss; oss << "starting accessibility: " << "event: " << "system" << ", id: " << flag << ";"; HILOG_DEBUG("starting accessibility: %{public}s", oss.str().c_str()); +#ifdef OHOS_BUILD_ENABLE_HISYSEVENT int32_t ret = HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::ACCESSIBILITY, "STARTING_FUNCTION", @@ -340,6 +345,7 @@ void Utils::RecordStartingA11yEvent(uint32_t flag) if (ret != 0) { HILOG_ERROR("Write HiSysEvent error, ret:%{public}d", ret); } +#endif //OHOS_BUILD_ENABLE_HISYSEVENT } void Utils::RecordStartingA11yEvent(const std::string &name) @@ -347,6 +353,7 @@ void Utils::RecordStartingA11yEvent(const std::string &name) std::ostringstream oss; oss << "starting accessibility: " << "event: " << "extension" << ", name: " << name << ";"; HILOG_DEBUG("starting accessibility: %{public}s", oss.str().c_str()); +#ifdef OHOS_BUILD_ENABLE_HISYSEVENT int32_t ret = HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::ACCESSIBILITY, "STARTING_FUNCTION", @@ -355,6 +362,7 @@ void Utils::RecordStartingA11yEvent(const std::string &name) if (ret != 0) { HILOG_ERROR("Write HiSysEvent error, ret:%{public}d", ret); } +#endif //OHOS_BUILD_ENABLE_HISYSEVENT } void Utils::VectorToString(const std::vector &vectorVal, std::string &stringOut)