accessible解耦hitrace和hisysevent,以及超大函数修改

Signed-off-by: tu-xinxin <xxtud@isoftstone.com>
This commit is contained in:
tu-xinxin 2024-09-03 10:22:22 +08:00
parent 01da47d722
commit d6017bcdf4
11 changed files with 129 additions and 9 deletions

View File

@ -19,6 +19,8 @@ declare_args() {
accessibility_feature_data_share = true accessibility_feature_data_share = true
accessibility_use_rosen_drawing = false accessibility_use_rosen_drawing = false
accessibility_watch_feature = false accessibility_watch_feature = false
accessibility_feature_hiviewdfx_hitrace = true
accessibility_feature_hiviewdfx_hisysevent = true
if (defined(global_parts_info) && if (defined(global_parts_info) &&
!defined(global_parts_info.powermgr_display_manager)) { !defined(global_parts_info.powermgr_display_manager)) {
accessibility_feature_display_manager = false accessibility_feature_display_manager = false
@ -37,6 +39,15 @@ declare_args() {
!defined(global_parts_info.distributeddatamgr_data_share)) { !defined(global_parts_info.distributeddatamgr_data_share)) {
distributeddatamgr_data_share = false 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( print(
@ -45,6 +56,10 @@ print(
"accessibility_feature_power_manager = ${accessibility_feature_power_manager}") "accessibility_feature_power_manager = ${accessibility_feature_power_manager}")
print("accessibility_use_rosen_drawing = ${accessibility_use_rosen_drawing}") print("accessibility_use_rosen_drawing = ${accessibility_use_rosen_drawing}")
print("accessibility_feature_data_share = ${accessibility_feature_data_share}") 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 = [] accessibility_default_defines = []
@ -67,3 +82,11 @@ if (accessibility_feature_data_share) {
if (defined(accessibility_watch_feature) && accessibility_watch_feature) { if (defined(accessibility_watch_feature) && accessibility_watch_feature) {
accessibility_default_defines += [ "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" ]
}

View File

@ -16,7 +16,9 @@
#include "accessible_ability_channel_client.h" #include "accessible_ability_channel_client.h"
#include <cinttypes> #include <cinttypes>
#ifdef OHOS_BUILD_ENABLE_HITRACE
#include <hitrace_meter.h> #include <hitrace_meter.h>
#endif // OHOS_BUILD_ENABLE_HITRACE
#include "accessibility_element_operator_callback_impl.h" #include "accessibility_element_operator_callback_impl.h"
#include "hilog_wrapper.h" #include "hilog_wrapper.h"
@ -54,7 +56,9 @@ RetError AccessibleAbilityChannelClient::FindFocusedElementInfo(int32_t accessib
int64_t elementId, int32_t focusType, AccessibilityElementInfo &elementInfo) int64_t elementId, int32_t focusType, AccessibilityElementInfo &elementInfo)
{ {
HILOG_DEBUG("[channelId:%{public}d]", channelId_); HILOG_DEBUG("[channelId:%{public}d]", channelId_);
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "FindFocusedElement"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "FindFocusedElement");
#endif // OHOS_BUILD_ENABLE_HITRACE
if (proxy_ == nullptr) { if (proxy_ == nullptr) {
HILOG_ERROR("FindFocusedElementInfo Failed to connect to aams [channelId:%{public}d]", HILOG_ERROR("FindFocusedElementInfo Failed to connect to aams [channelId:%{public}d]",
channelId_); channelId_);
@ -118,7 +122,9 @@ RetError AccessibleAbilityChannelClient::SendSimulateGesture(
RetError AccessibleAbilityChannelClient::GetCursorPosition( RetError AccessibleAbilityChannelClient::GetCursorPosition(
int32_t accessibilityWindowId, int64_t elementId, int32_t &position) int32_t accessibilityWindowId, int64_t elementId, int32_t &position)
{ {
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "GetCursorPosition"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "GetCursorPosition");
#endif // OHOS_BUILD_ENABLE_HITRACE
if (proxy_ == nullptr) { if (proxy_ == nullptr) {
HILOG_ERROR("GetCursorPosition Failed to connect to aams [channelId:%{public}d]", HILOG_ERROR("GetCursorPosition Failed to connect to aams [channelId:%{public}d]",
channelId_); channelId_);
@ -155,7 +161,9 @@ RetError AccessibleAbilityChannelClient::ExecuteAction(int32_t accessibilityWind
int64_t elementId, int32_t action, const std::map<std::string, std::string> &actionArguments) int64_t elementId, int32_t action, const std::map<std::string, std::string> &actionArguments)
{ {
HILOG_DEBUG("execute action:%{public}d, elementId:%{public}" PRId64 "", action, elementId); HILOG_DEBUG("execute action:%{public}d, elementId:%{public}" PRId64 "", action, elementId);
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "ExecuteAction"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "ExecuteAction");
#endif // OHOS_BUILD_ENABLE_HITRACE
if (proxy_ == nullptr) { if (proxy_ == nullptr) {
HILOG_ERROR("ExecuteAction Failed to connect to aams [channelId:%{public}d]", channelId_); HILOG_ERROR("ExecuteAction Failed to connect to aams [channelId:%{public}d]", channelId_);
return RET_ERR_SAMGR; return RET_ERR_SAMGR;
@ -223,7 +231,9 @@ RetError AccessibleAbilityChannelClient::SearchElementInfosByAccessibilityId(int
int32_t requestId = GenerateRequestId(); int32_t requestId = GenerateRequestId();
HILOG_DEBUG("channelId:%{public}d, elementId:%{public}" PRId64 ", windowId:%{public}d, requestId:%{public}d", HILOG_DEBUG("channelId:%{public}d, elementId:%{public}" PRId64 ", windowId:%{public}d, requestId:%{public}d",
channelId_, elementId, accessibilityWindowId, requestId); channelId_, elementId, accessibilityWindowId, requestId);
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SearchElementById"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SearchElementById");
#endif // OHOS_BUILD_ENABLE_HITRACE
if (proxy_ == nullptr) { if (proxy_ == nullptr) {
HILOG_ERROR("SearchElementInfosByAccessibilityId Failed to connect to aams [channelId:%{public}d]", HILOG_ERROR("SearchElementInfosByAccessibilityId Failed to connect to aams [channelId:%{public}d]",
channelId_); channelId_);
@ -270,7 +280,9 @@ RetError AccessibleAbilityChannelClient::SearchElementInfosByAccessibilityId(int
RetError AccessibleAbilityChannelClient::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) RetError AccessibleAbilityChannelClient::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
{ {
HILOG_DEBUG("[channelId:%{public}d] [windowId:%{public}d]", channelId_, windowId); HILOG_DEBUG("[channelId:%{public}d] [windowId:%{public}d]", channelId_, windowId);
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER(HITRACE_TAG_ACCESSIBILITY_MANAGER); HITRACE_METER(HITRACE_TAG_ACCESSIBILITY_MANAGER);
#endif // OHOS_BUILD_ENABLE_HITRACE
if (proxy_ == nullptr) { if (proxy_ == nullptr) {
HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_); HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_);
return RET_ERR_SAMGR; return RET_ERR_SAMGR;
@ -281,7 +293,9 @@ RetError AccessibleAbilityChannelClient::GetWindow(const int32_t windowId, Acces
RetError AccessibleAbilityChannelClient::GetWindows(std::vector<AccessibilityWindowInfo> &windows) RetError AccessibleAbilityChannelClient::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
{ {
HILOG_DEBUG("[channelId:%{public}d]", channelId_); HILOG_DEBUG("[channelId:%{public}d]", channelId_);
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER(HITRACE_TAG_ACCESSIBILITY_MANAGER); HITRACE_METER(HITRACE_TAG_ACCESSIBILITY_MANAGER);
#endif // OHOS_BUILD_ENABLE_HITRACE
if (proxy_) { if (proxy_) {
return proxy_->GetWindows(windows); return proxy_->GetWindows(windows);
} else { } else {
@ -294,7 +308,9 @@ RetError AccessibleAbilityChannelClient::GetWindows(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows) const std::vector<AccessibilityWindowInfo> &windows) const
{ {
HILOG_DEBUG("[channelId:%{public}d] [displayId:%{public}" PRIu64 "]", channelId_, displayId); HILOG_DEBUG("[channelId:%{public}d] [displayId:%{public}" PRIu64 "]", channelId_, displayId);
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "GetWindowsByDisplayId"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "GetWindowsByDisplayId");
#endif // OHOS_BUILD_ENABLE_HITRACE
if (proxy_) { if (proxy_) {
return proxy_->GetWindowsByDisplayId(displayId, windows); return proxy_->GetWindowsByDisplayId(displayId, windows);
} else { } else {
@ -307,7 +323,9 @@ RetError AccessibleAbilityChannelClient::SearchElementInfosByText(int32_t access
int64_t elementId, const std::string &text, std::vector<AccessibilityElementInfo> &elementInfos) int64_t elementId, const std::string &text, std::vector<AccessibilityElementInfo> &elementInfos)
{ {
HILOG_DEBUG("[channelId:%{public}d]", channelId_); HILOG_DEBUG("[channelId:%{public}d]", channelId_);
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SearchElementByText"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SearchElementByText");
#endif // OHOS_BUILD_ENABLE_HITRACE
if (proxy_ == nullptr) { if (proxy_ == nullptr) {
HILOG_ERROR("SearchElementInfosByText Failed to connect to aams [channelId:%{public}d]", HILOG_ERROR("SearchElementInfosByText Failed to connect to aams [channelId:%{public}d]",
channelId_); channelId_);

View File

@ -76,7 +76,6 @@ ohos_shared_library("accessibleability") {
"c_utils:utils", "c_utils:utils",
"ffrt:libffrt", "ffrt:libffrt",
"hilog:libhilog", "hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbeget_proxy", "init:libbeget_proxy",
"init:libbegetutil", "init:libbegetutil",
"input:libmmi-client", "input:libmmi-client",
@ -84,6 +83,10 @@ ohos_shared_library("accessibleability") {
"samgr:samgr_proxy", "samgr:samgr_proxy",
] ]
if (accessibility_feature_hiviewdfx_hitrace) {
external_deps += [ "hitrace:hitrace_meter" ]
}
install_enable = true install_enable = true
subsystem_name = "barrierfree" subsystem_name = "barrierfree"

10
services/aams/BUILD.gn Executable file → Normal file
View File

@ -122,8 +122,6 @@ ohos_shared_library("accessibleabilityms") {
"graphic_2d:librender_service_client", "graphic_2d:librender_service_client",
"hicollie:libhicollie", "hicollie:libhicollie",
"hilog:libhilog", "hilog:libhilog",
"hisysevent:libhisysevent",
"hitrace:hitrace_meter",
"init:libbegetutil", "init:libbegetutil",
"input:libmmi-client", "input:libmmi-client",
"ipc:ipc_single", "ipc:ipc_single",
@ -147,6 +145,14 @@ ohos_shared_library("accessibleabilityms") {
external_deps += [ "data_share:datashare_consumer" ] 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 install_enable = true
subsystem_name = "barrierfree" subsystem_name = "barrierfree"

View File

@ -35,6 +35,8 @@ public:
virtual ~AccessibleAbilityConnection(); virtual ~AccessibleAbilityConnection();
void HandleNoEventHandler(const AppExecFwk::ElementName &element);
virtual void OnAbilityConnectDone(const AppExecFwk::ElementName &element, virtual void OnAbilityConnectDone(const AppExecFwk::ElementName &element,
const sptr<IRemoteObject> &remoteObject, const sptr<IRemoteObject> &remoteObject,
int32_t resultCode) override; int32_t resultCode) override;

View File

@ -16,7 +16,9 @@
#include "accessibility_account_data.h" #include "accessibility_account_data.h"
#include <any> #include <any>
#ifdef OHOS_BUILD_ENABLE_HITRACE
#include <hitrace_meter.h> #include <hitrace_meter.h>
#endif // OHOS_BUILD_ENABLE_HITRACE
#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER #ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER
#include "accessibility_display_manager.h" #include "accessibility_display_manager.h"
#endif #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()); HILOG_ERROR("The ability[%{public}s] is already enabled", name.c_str());
return RET_ERR_CONNECTION_EXIST; return RET_ERR_CONNECTION_EXIST;
} }
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "EnableAbility:" + name); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "EnableAbility:" + name);
#endif // OHOS_BUILD_ENABLE_HITRACE
enabledAbilities_.push_back(name); enabledAbilities_.push_back(name);
SetAbilityAutoStartState(name, true); SetAbilityAutoStartState(name, true);
@ -646,7 +650,9 @@ RetError AccessibilityAccountData::EnableAbility(const std::string &name, const
bool AccessibilityAccountData::GetInstalledAbilitiesFromBMS() bool AccessibilityAccountData::GetInstalledAbilitiesFromBMS()
{ {
HILOG_DEBUG("start."); HILOG_DEBUG("start.");
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "QueryInstalledAbilityInfo"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "QueryInstalledAbilityInfo");
#endif // OHOS_BUILD_ENABLE_HITRACE
std::vector<AppExecFwk::ExtensionAbilityInfo> extensionInfos; std::vector<AppExecFwk::ExtensionAbilityInfo> extensionInfos;
sptr<AppExecFwk::IBundleMgr> bms = Singleton<AccessibleAbilityManagerService>::GetInstance().GetBundleMgrProxy(); sptr<AppExecFwk::IBundleMgr> bms = Singleton<AccessibleAbilityManagerService>::GetInstance().GetBundleMgrProxy();
if (!bms) { if (!bms) {

View File

@ -14,7 +14,9 @@
*/ */
#include <string> #include <string>
#ifdef OHOS_BUILD_ENABLE_HITRACE
#include <hitrace_meter.h> #include <hitrace_meter.h>
#endif // OHOS_BUILD_ENABLE_HITRACE
#include "accessibility_account_data.h" #include "accessibility_account_data.h"
#include "accessible_ability_manager_service.h" #include "accessible_ability_manager_service.h"
#include "accessibility_settings.h" #include "accessibility_settings.h"
@ -43,7 +45,9 @@ void AccessibilitySettings::RegisterSettingsHandler(const std::shared_ptr<AppExe
RetError AccessibilitySettings::SetScreenMagnificationState(const bool state) RetError AccessibilitySettings::SetScreenMagnificationState(const bool state)
{ {
HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); HILOG_INFO("state = [%{public}s]", state ? "True" : "False");
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetScreenMagnificationState:" + std::to_string(state)); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetScreenMagnificationState:" + std::to_string(state));
#endif // OHOS_BUILD_ENABLE_HITRACE
sptr<AccessibilityAccountData> accountData = sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -60,7 +64,9 @@ RetError AccessibilitySettings::SetScreenMagnificationState(const bool state)
RetError AccessibilitySettings::SetShortKeyState(const bool state) RetError AccessibilitySettings::SetShortKeyState(const bool state)
{ {
HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); 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)); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetShortKeyState:" + std::to_string(state));
#endif // OHOS_BUILD_ENABLE_HITRACE
if (!handler_) { if (!handler_) {
HILOG_ERROR("handler_ is nullptr."); HILOG_ERROR("handler_ is nullptr.");
@ -130,7 +136,9 @@ RetError AccessibilitySettings::SetMouseAutoClick(const int32_t time)
RetError AccessibilitySettings::SetShortkeyTarget(const std::string &name) RetError AccessibilitySettings::SetShortkeyTarget(const std::string &name)
{ {
HILOG_INFO("name = [%{public}s]", name.c_str()); HILOG_INFO("name = [%{public}s]", name.c_str());
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetShortkeyTarget:" + name); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetShortkeyTarget:" + name);
#endif // OHOS_BUILD_ENABLE_HITRACE
if (!handler_) { if (!handler_) {
HILOG_ERROR("handler_ is nullptr."); HILOG_ERROR("handler_ is nullptr.");
@ -156,7 +164,9 @@ RetError AccessibilitySettings::SetShortkeyTarget(const std::string &name)
RetError AccessibilitySettings::SetShortkeyMultiTarget(const std::vector<std::string> &name) RetError AccessibilitySettings::SetShortkeyMultiTarget(const std::vector<std::string> &name)
{ {
HILOG_DEBUG(); HILOG_DEBUG();
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetShortkeyMultiTarget"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetShortkeyMultiTarget");
#endif // OHOS_BUILD_ENABLE_HITRACE
if (!handler_) { if (!handler_) {
HILOG_ERROR("handler_ is nullptr."); HILOG_ERROR("handler_ is nullptr.");
@ -182,7 +192,9 @@ RetError AccessibilitySettings::SetShortkeyMultiTarget(const std::vector<std::st
RetError AccessibilitySettings::SetHighContrastTextState(const bool state) RetError AccessibilitySettings::SetHighContrastTextState(const bool state)
{ {
HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); HILOG_INFO("state = [%{public}s]", state ? "True" : "False");
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetHighContrastTextState:" + std::to_string(state)); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetHighContrastTextState:" + std::to_string(state));
#endif // OHOS_BUILD_ENABLE_HITRACE
sptr<AccessibilityAccountData> accountData = sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -198,7 +210,9 @@ RetError AccessibilitySettings::SetHighContrastTextState(const bool state)
RetError AccessibilitySettings::SetDaltonizationState(const bool state) RetError AccessibilitySettings::SetDaltonizationState(const bool state)
{ {
HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); 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)); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetDaltonizationState:" + std::to_string(state));
#endif // OHOS_BUILD_ENABLE_HITRACE
sptr<AccessibilityAccountData> accountData = sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -214,7 +228,9 @@ RetError AccessibilitySettings::SetDaltonizationState(const bool state)
RetError AccessibilitySettings::SetInvertColorState(const bool state) RetError AccessibilitySettings::SetInvertColorState(const bool state)
{ {
HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); 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)); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetInvertColorState:" + std::to_string(state));
#endif // OHOS_BUILD_ENABLE_HITRACE
sptr<AccessibilityAccountData> accountData = sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -255,7 +271,9 @@ RetError AccessibilitySettings::SetAnimationOffState(const bool state)
RetError AccessibilitySettings::SetAudioMonoState(const bool state) RetError AccessibilitySettings::SetAudioMonoState(const bool state)
{ {
HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); 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)); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetAudioMonoState:" + std::to_string(state));
#endif // OHOS_BUILD_ENABLE_HITRACE
sptr<AccessibilityAccountData> accountData = sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -271,7 +289,9 @@ RetError AccessibilitySettings::SetAudioMonoState(const bool state)
RetError AccessibilitySettings::SetDaltonizationColorFilter(const uint32_t filter) RetError AccessibilitySettings::SetDaltonizationColorFilter(const uint32_t filter)
{ {
HILOG_INFO("filter = [%{public}u]", filter); HILOG_INFO("filter = [%{public}u]", filter);
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetDaltonizationColorFilter:" + std::to_string(filter)); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetDaltonizationColorFilter:" + std::to_string(filter));
#endif // OHOS_BUILD_ENABLE_HITRACE
if (!handler_) { if (!handler_) {
HILOG_ERROR("handler_ is nullptr."); HILOG_ERROR("handler_ is nullptr.");
return RET_ERR_NULLPTR; return RET_ERR_NULLPTR;
@ -353,7 +373,9 @@ RetError AccessibilitySettings::SetBrightnessDiscount(const float discount)
RetError AccessibilitySettings::SetAudioBalance(const float balance) RetError AccessibilitySettings::SetAudioBalance(const float balance)
{ {
HILOG_INFO("balance = [%{public}f]", balance); HILOG_INFO("balance = [%{public}f]", balance);
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetAudioBalance:" + std::to_string(balance)); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetAudioBalance:" + std::to_string(balance));
#endif // OHOS_BUILD_ENABLE_HITRACE
if (!handler_) { if (!handler_) {
HILOG_ERROR("handler_ is nullptr."); HILOG_ERROR("handler_ is nullptr.");
@ -380,7 +402,9 @@ RetError AccessibilitySettings::SetAudioBalance(const float balance)
RetError AccessibilitySettings::SetClickResponseTime(const uint32_t time) RetError AccessibilitySettings::SetClickResponseTime(const uint32_t time)
{ {
HILOG_INFO("click response time = [%{public}u]", 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)); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetClickResponseTime:" + std::to_string(time));
#endif // OHOS_BUILD_ENABLE_HITRACE
if (!handler_) { if (!handler_) {
HILOG_ERROR("handler_ is nullptr."); HILOG_ERROR("handler_ is nullptr.");
@ -408,7 +432,9 @@ RetError AccessibilitySettings::SetClickResponseTime(const uint32_t time)
RetError AccessibilitySettings::SetIgnoreRepeatClickState(const bool state) RetError AccessibilitySettings::SetIgnoreRepeatClickState(const bool state)
{ {
HILOG_INFO("ignore repeat click state = [%{public}s]", state ? "True" : "False"); 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)); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetIgnoreRepeatClickState:" + std::to_string(state));
#endif // OHOS_BUILD_ENABLE_HITRACE
if (!handler_) { if (!handler_) {
HILOG_ERROR("handler_ is nullptr."); HILOG_ERROR("handler_ is nullptr.");
@ -436,7 +462,9 @@ RetError AccessibilitySettings::SetIgnoreRepeatClickState(const bool state)
RetError AccessibilitySettings::SetIgnoreRepeatClickTime(const uint32_t time) RetError AccessibilitySettings::SetIgnoreRepeatClickTime(const uint32_t time)
{ {
HILOG_INFO("click response time = [%{public}u]", 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)); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetIgnoreRepeatClickTime:" + std::to_string(time));
#endif // OHOS_BUILD_ENABLE_HITRACE
if (!handler_) { if (!handler_) {
HILOG_ERROR("handler_ is nullptr."); HILOG_ERROR("handler_ is nullptr.");

View File

@ -15,7 +15,9 @@
#include "accessibility_window_manager.h" #include "accessibility_window_manager.h"
#ifdef OHOS_BUILD_ENABLE_HITRACE
#include <hitrace_meter.h> #include <hitrace_meter.h>
#endif // OHOS_BUILD_ENABLE_HITRACE
#include "accessible_ability_manager_service.h" #include "accessible_ability_manager_service.h"
#include "hilog_wrapper.h" #include "hilog_wrapper.h"
@ -31,7 +33,9 @@ bool AccessibilityWindowManager::Init()
{ {
DeInit(); DeInit();
HILOG_DEBUG("deinit before start"); HILOG_DEBUG("deinit before start");
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "QueryWindowInfo"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "QueryWindowInfo");
#endif // OHOS_BUILD_ENABLE_HITRACE
std::vector<sptr<Rosen::AccessibilityWindowInfo>> windowInfos; std::vector<sptr<Rosen::AccessibilityWindowInfo>> windowInfos;
Rosen::WMError err = OHOS::Rosen::WindowManager::GetInstance().GetAccessibilityWindowInfo(windowInfos); Rosen::WMError err = OHOS::Rosen::WindowManager::GetInstance().GetAccessibilityWindowInfo(windowInfos);
if (err != Rosen::WMError::WM_OK) { if (err != Rosen::WMError::WM_OK) {
@ -989,7 +993,9 @@ std::map<int32_t, int64_t> AccessibilityWindowManager::SceneBoardElementIdMap::G
RetError AccessibilityWindowManager::GetFocusedWindowId(int32_t &focusedWindowId) RetError AccessibilityWindowManager::GetFocusedWindowId(int32_t &focusedWindowId)
{ {
HILOG_DEBUG(); HILOG_DEBUG();
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "QueryFocusedWindowInfo"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "QueryFocusedWindowInfo");
#endif // OHOS_BUILD_ENABLE_HITRACE
Rosen::FocusChangeInfo focusedWindowInfo; Rosen::FocusChangeInfo focusedWindowInfo;
OHOS::Rosen::WindowManager::GetInstance().GetFocusWindowInfo(focusedWindowInfo); OHOS::Rosen::WindowManager::GetInstance().GetFocusWindowInfo(focusedWindowInfo);
if (focusedWindowInfo.windowId_ == INVALID_WINDOW_ID) { if (focusedWindowInfo.windowId_ == INVALID_WINDOW_ID) {

View File

@ -15,7 +15,9 @@
#include "accessible_ability_connection.h" #include "accessible_ability_connection.h"
#ifdef OHOS_BUILD_ENABLE_HITRACE
#include <hitrace_meter.h> #include <hitrace_meter.h>
#endif // OHOS_BUILD_ENABLE_HITRACE
#include "ability_manager_client.h" #include "ability_manager_client.h"
#include "accessible_ability_manager_service.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<AccessibleAbilityManagerService>::GetInstance().GetAccountData(accountId_);
if (accountData != nullptr) {
accountData->RemoveConnectingA11yAbility(Utils::GetUri(element));
}
}
void AccessibleAbilityConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &element, void AccessibleAbilityConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &element,
const sptr<IRemoteObject> &remoteObject, int32_t resultCode) const sptr<IRemoteObject> &remoteObject, int32_t resultCode)
{ {
HILOG_INFO("ResultCode is %{public}d", resultCode); HILOG_INFO("ResultCode is %{public}d", resultCode);
if (!eventHandler_) { if (!eventHandler_) {
HILOG_ERROR("eventHandler_ is nullptr."); HandleNoEventHandler(element);
auto accountData = Singleton<AccessibleAbilityManagerService>::GetInstance().GetAccountData(accountId_);
if (accountData != nullptr) {
accountData->RemoveConnectingA11yAbility(Utils::GetUri(element));
return;
}
return; return;
} }
int32_t accountId = accountId_; int32_t accountId = accountId_;
eventHandler_->PostTask([accountId, element, remoteObject, resultCode]() { eventHandler_->PostTask([accountId, element, remoteObject, resultCode]() {
#ifdef OHOS_BUILD_ENABLE_HITRACE
FinishAsyncTrace(HITRACE_TAG_ACCESSIBILITY_MANAGER, "AccessibleAbilityConnect", FinishAsyncTrace(HITRACE_TAG_ACCESSIBILITY_MANAGER, "AccessibleAbilityConnect",
static_cast<int32_t>(TraceTaskId::ACCESSIBLE_ABILITY_CONNECT)); static_cast<int32_t>(TraceTaskId::ACCESSIBLE_ABILITY_CONNECT));
#endif // OHOS_BUILD_ENABLE_HITRACE
std::string bundleName = element.GetBundleName(); std::string bundleName = element.GetBundleName();
std::string abilityName = element.GetAbilityName(); std::string abilityName = element.GetAbilityName();
auto accountData = Singleton<AccessibleAbilityManagerService>::GetInstance().GetAccountData(accountId); auto accountData = Singleton<AccessibleAbilityManagerService>::GetInstance().GetAccountData(accountId);
@ -190,8 +198,10 @@ void AccessibleAbilityConnection::Disconnect()
bool AccessibleAbilityConnection::Connect(const AppExecFwk::ElementName &element) bool AccessibleAbilityConnection::Connect(const AppExecFwk::ElementName &element)
{ {
HILOG_DEBUG(); HILOG_DEBUG();
#ifdef OHOS_BUILD_ENABLE_HITRACE
StartAsyncTrace(HITRACE_TAG_ACCESSIBILITY_MANAGER, "AccessibleAbilityConnect", StartAsyncTrace(HITRACE_TAG_ACCESSIBILITY_MANAGER, "AccessibleAbilityConnect",
static_cast<int32_t>(TraceTaskId::ACCESSIBLE_ABILITY_CONNECT)); static_cast<int32_t>(TraceTaskId::ACCESSIBLE_ABILITY_CONNECT));
#endif // OHOS_BUILD_ENABLE_HITRACE
std::string bundleName = element.GetBundleName(); std::string bundleName = element.GetBundleName();
std::string abilityName = element.GetAbilityName(); std::string abilityName = element.GetAbilityName();

View File

@ -20,7 +20,9 @@
#include <string> #include <string>
#include <unistd.h> #include <unistd.h>
#include <functional> #include <functional>
#ifdef OHOS_BUILD_ENABLE_HITRACE
#include <hitrace_meter.h> #include <hitrace_meter.h>
#endif // OHOS_BUILD_ENABLE_HITRACE
#include "ability_info.h" #include "ability_info.h"
#include "accessibility_event_info.h" #include "accessibility_event_info.h"
@ -770,7 +772,9 @@ RetError AccessibleAbilityManagerService::RegisterElementOperator(
} }
handler_->PostTask([=]() { handler_->PostTask([=]() {
HILOG_INFO("Register windowId[%{public}d]", windowId); HILOG_INFO("Register windowId[%{public}d]", windowId);
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "RegisterElementOperator"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "RegisterElementOperator");
#endif // OHOS_BUILD_ENABLE_HITRACE
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData(); sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (!accountData) { if (!accountData) {
Utils::RecordUnavailableEvent(A11yUnavailableEvent::CONNECT_EVENT, Utils::RecordUnavailableEvent(A11yUnavailableEvent::CONNECT_EVENT,
@ -898,7 +902,9 @@ RetError AccessibleAbilityManagerService::RegisterElementOperator(Registration p
} }
handler_->PostTask([=]() { handler_->PostTask([=]() {
HILOG_INFO("Register windowId[%{public}d]", parameter.windowId); HILOG_INFO("Register windowId[%{public}d]", parameter.windowId);
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "RegisterElementOperator"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "RegisterElementOperator");
#endif // OHOS_BUILD_ENABLE_HITRACE
if (RET_OK != RegisterElementOperatorChildWork(parameter, treeIdSingle, nodeId, operation, tokenId, isApp)) { if (RET_OK != RegisterElementOperatorChildWork(parameter, treeIdSingle, nodeId, operation, tokenId, isApp)) {
return; return;
} }
@ -1304,7 +1310,9 @@ RetError AccessibleAbilityManagerService::DisableAbility(const std::string &name
RetError AccessibleAbilityManagerService::InnerDisableAbility(const std::string &name) RetError AccessibleAbilityManagerService::InnerDisableAbility(const std::string &name)
{ {
HILOG_INFO(); HILOG_INFO();
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "InnerDisableAbility:" + name); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "InnerDisableAbility:" + name);
#endif // OHOS_BUILD_ENABLE_HITRACE
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData(); sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (!accountData) { if (!accountData) {
@ -2340,7 +2348,9 @@ bool AccessibleAbilityManagerService::EnableShortKeyTargetAbility(const std::str
{ {
HILOG_DEBUG(); HILOG_DEBUG();
HILOG_INFO("EnableShortKeyTargetAbility name = %{public}s", name.c_str()); HILOG_INFO("EnableShortKeyTargetAbility name = %{public}s", name.c_str());
#ifdef OHOS_BUILD_ENABLE_HITRACE
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "EnableShortKeyTargetAbility"); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "EnableShortKeyTargetAbility");
#endif // OHOS_BUILD_ENABLE_HITRACE
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData(); sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (!accountData) { if (!accountData) {

View File

@ -15,7 +15,9 @@
#include "utils.h" #include "utils.h"
#ifdef OHOS_BUILD_ENABLE_HISYSEVENT
#include <hisysevent.h> #include <hisysevent.h>
#endif //OHOS_BUILD_ENABLE_HISYSEVENT
#include "bundle_mgr_client.h" #include "bundle_mgr_client.h"
#include "hilog_wrapper.h" #include "hilog_wrapper.h"
@ -297,6 +299,7 @@ void Utils::RecordUnavailableEvent(A11yUnavailableEvent event, A11yError errCode
<< ", bundleName: " << bundleName << ", abilityName: " << abilityName << ";"; << ", bundleName: " << bundleName << ", abilityName: " << abilityName << ";";
std::string info = oss.str(); std::string info = oss.str();
HILOG_DEBUG("accessibility function is unavailable: %{public}s", info.c_str()); HILOG_DEBUG("accessibility function is unavailable: %{public}s", info.c_str());
#ifdef OHOS_BUILD_ENABLE_HISYSEVENT
int32_t ret = HiSysEventWrite( int32_t ret = HiSysEventWrite(
OHOS::HiviewDFX::HiSysEvent::Domain::ACCESSIBILITY, OHOS::HiviewDFX::HiSysEvent::Domain::ACCESSIBILITY,
"UNAVAILABLE", "UNAVAILABLE",
@ -305,6 +308,7 @@ void Utils::RecordUnavailableEvent(A11yUnavailableEvent event, A11yError errCode
if (ret != 0) { if (ret != 0) {
HILOG_ERROR("Write HiSysEvent error, ret:%{public}d", ret); HILOG_ERROR("Write HiSysEvent error, ret:%{public}d", ret);
} }
#endif //OHOS_BUILD_ENABLE_HISYSEVENT
} }
std::string Utils::TransferUnavailableEventToString(A11yUnavailableEvent type) std::string Utils::TransferUnavailableEventToString(A11yUnavailableEvent type)
@ -332,6 +336,7 @@ void Utils::RecordStartingA11yEvent(uint32_t flag)
std::ostringstream oss; std::ostringstream oss;
oss << "starting accessibility: " << "event: " << "system" << ", id: " << flag << ";"; oss << "starting accessibility: " << "event: " << "system" << ", id: " << flag << ";";
HILOG_DEBUG("starting accessibility: %{public}s", oss.str().c_str()); HILOG_DEBUG("starting accessibility: %{public}s", oss.str().c_str());
#ifdef OHOS_BUILD_ENABLE_HISYSEVENT
int32_t ret = HiSysEventWrite( int32_t ret = HiSysEventWrite(
OHOS::HiviewDFX::HiSysEvent::Domain::ACCESSIBILITY, OHOS::HiviewDFX::HiSysEvent::Domain::ACCESSIBILITY,
"STARTING_FUNCTION", "STARTING_FUNCTION",
@ -340,6 +345,7 @@ void Utils::RecordStartingA11yEvent(uint32_t flag)
if (ret != 0) { if (ret != 0) {
HILOG_ERROR("Write HiSysEvent error, ret:%{public}d", ret); HILOG_ERROR("Write HiSysEvent error, ret:%{public}d", ret);
} }
#endif //OHOS_BUILD_ENABLE_HISYSEVENT
} }
void Utils::RecordStartingA11yEvent(const std::string &name) void Utils::RecordStartingA11yEvent(const std::string &name)
@ -347,6 +353,7 @@ void Utils::RecordStartingA11yEvent(const std::string &name)
std::ostringstream oss; std::ostringstream oss;
oss << "starting accessibility: " << "event: " << "extension" << ", name: " << name << ";"; oss << "starting accessibility: " << "event: " << "extension" << ", name: " << name << ";";
HILOG_DEBUG("starting accessibility: %{public}s", oss.str().c_str()); HILOG_DEBUG("starting accessibility: %{public}s", oss.str().c_str());
#ifdef OHOS_BUILD_ENABLE_HISYSEVENT
int32_t ret = HiSysEventWrite( int32_t ret = HiSysEventWrite(
OHOS::HiviewDFX::HiSysEvent::Domain::ACCESSIBILITY, OHOS::HiviewDFX::HiSysEvent::Domain::ACCESSIBILITY,
"STARTING_FUNCTION", "STARTING_FUNCTION",
@ -355,6 +362,7 @@ void Utils::RecordStartingA11yEvent(const std::string &name)
if (ret != 0) { if (ret != 0) {
HILOG_ERROR("Write HiSysEvent error, ret:%{public}d", ret); HILOG_ERROR("Write HiSysEvent error, ret:%{public}d", ret);
} }
#endif //OHOS_BUILD_ENABLE_HISYSEVENT
} }
void Utils::VectorToString(const std::vector<std::string> &vectorVal, std::string &stringOut) void Utils::VectorToString(const std::vector<std::string> &vectorVal, std::string &stringOut)