From 40797535cc4a042f44d38b5c093f4c9e893c8a71 Mon Sep 17 00:00:00 2001 From: w00524930 Date: Wed, 14 Jun 2023 22:13:27 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=88=E5=AF=B9=E6=9F=A5=E8=AF=A2=E5=92=8C?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E6=93=8D=E4=BD=9C=E5=A2=9E=E5=8A=A0=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E6=8A=A5=E9=94=99=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangxinqiang007 --- .../acfwk/src/accessibility_config_impl.cpp | 12 +++- .../aams/src/accessible_ability_channel.cpp | 58 +++++++++++++++++++ .../accessible_ability_manager_service.cpp | 19 ++++++ 3 files changed, 87 insertions(+), 2 deletions(-) diff --git a/frameworks/acfwk/src/accessibility_config_impl.cpp b/frameworks/acfwk/src/accessibility_config_impl.cpp index 1aba96d3..ce512c7e 100644 --- a/frameworks/acfwk/src/accessibility_config_impl.cpp +++ b/frameworks/acfwk/src/accessibility_config_impl.cpp @@ -125,7 +125,11 @@ bool AccessibilityConfig::Impl::RegisterToService() HILOG_ERROR("Create captionObserver_ failed."); return false; } - serviceProxy_->RegisterCaptionObserver(captionObserver_); + uint32_t ret = serviceProxy_->RegisterCaptionObserver(captionObserver_); + if (ret != 0) { + HILOG_ERROR("Register captionObserver failed."); + return false; + } } if (!enableAbilityListsObserver_) { @@ -143,7 +147,11 @@ bool AccessibilityConfig::Impl::RegisterToService() HILOG_ERROR("Create configObserver_ failed."); return false; } - serviceProxy_->RegisterConfigObserver(configObserver_); + uint32_t ret = serviceProxy_->RegisterConfigObserver(configObserver_); + if (ret != 0) { + HILOG_ERROR("Register configObserver failed."); + return false; + } } HILOG_DEBUG("RegisterToService succeaddss"); diff --git a/services/aams/src/accessible_ability_channel.cpp b/services/aams/src/accessible_ability_channel.cpp index eb716f61..fb6d5af4 100644 --- a/services/aams/src/accessible_ability_channel.cpp +++ b/services/aams/src/accessible_ability_channel.cpp @@ -22,6 +22,10 @@ namespace OHOS { namespace Accessibility { +namespace { + constexpr uint32_t TIME_OUT_OPERATOR = 5000; +} // namespace + AccessibleAbilityChannel::AccessibleAbilityChannel(const int32_t accountId, const std::string &clientName) : clientName_(clientName), accountId_(accountId) { @@ -56,6 +60,12 @@ RetError AccessibleAbilityChannel::SearchElementInfoByAccessibilityId(const int3 HILOG_DEBUG("AccessibleAbilityChannel::SearchElementInfoByAccessibilityId successfully"); syncPromise.set_value(RET_OK); }, accountId_, clientName_), "SearchElementInfoByAccessibilityId"); + + std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != std::future_status::ready) { + HILOG_ERROR("Failed to wait SearchElementInfoByAccessibilityId result"); + return RET_ERR_TIME_OUT; + } return syncFuture.get(); } @@ -85,6 +95,12 @@ RetError AccessibleAbilityChannel::SearchElementInfosByText(const int32_t access elementOperator->SearchElementInfosByText(elementId, text, requestId, callback); syncPromise.set_value(RET_OK); }, accountId_, clientName_), "SearchElementInfosByText"); + + std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != std::future_status::ready) { + HILOG_ERROR("Failed to wait SearchElementInfosByText result"); + return RET_ERR_TIME_OUT; + } return syncFuture.get(); } @@ -114,6 +130,12 @@ RetError AccessibleAbilityChannel::FindFocusedElementInfo(const int32_t accessib elementOperator->FindFocusedElementInfo(elementId, focusType, requestId, callback); syncPromise.set_value(RET_OK); }, accountId_, clientName_), "FindFocusedElementInfo"); + + std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != std::future_status::ready) { + HILOG_ERROR("Failed to wait FindFocusedElementInfo result"); + return RET_ERR_TIME_OUT; + } return syncFuture.get(); } @@ -142,6 +164,12 @@ RetError AccessibleAbilityChannel::FocusMoveSearch(const int32_t accessibilityWi elementOperator->FocusMoveSearch(elementId, direction, requestId, callback); syncPromise.set_value(RET_OK); }, accountId_, clientName_), "FocusMoveSearch"); + + std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != std::future_status::ready) { + HILOG_ERROR("Failed to wait FocusMoveSearch result"); + return RET_ERR_TIME_OUT; + } return syncFuture.get(); } @@ -171,6 +199,12 @@ RetError AccessibleAbilityChannel::ExecuteAction(const int32_t accessibilityWind elementOperator->ExecuteAction(elementId, action, actionArguments, requestId, callback); syncPromise.set_value(RET_OK); }, accountId_, clientName_), "ExecuteAction"); + + std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != std::future_status::ready) { + HILOG_ERROR("Failed to wait ExecuteAction result"); + return RET_ERR_TIME_OUT; + } return syncFuture.get(); } @@ -206,6 +240,12 @@ RetError AccessibleAbilityChannel::GetWindow(const int32_t windowId, Accessibili syncPromise.set_value(RET_ERR_NO_WINDOW_CONNECTION); } }, accountId_, clientName_), "GetWindow"); + + std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != std::future_status::ready) { + HILOG_ERROR("Failed to wait GetWindow result"); + return RET_ERR_TIME_OUT; + } return syncFuture.get(); } @@ -258,6 +298,12 @@ RetError AccessibleAbilityChannel::GetWindows(uint64_t displayId, std::vectorInjectEvents(gesturePath); syncPromise.set_value(RET_OK); }, accountId_, clientName_), "SendSimulateGesture"); + + std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != std::future_status::ready) { + HILOG_ERROR("Failed to wait SendSimulateGesture result"); + return RET_ERR_TIME_OUT; + } return syncFuture.get(); } @@ -348,6 +400,12 @@ RetError AccessibleAbilityChannel::SetTargetBundleName(const std::vectorSetAbilityInfoTargetBundleName(targetBundleNames); syncPromise.set_value(RET_OK); }, accountId_, clientName_), "SetTargetBundleName"); + + std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != std::future_status::ready) { + HILOG_ERROR("Failed to wait SetTargetBundleName result"); + return RET_ERR_TIME_OUT; + } return syncFuture.get(); } diff --git a/services/aams/src/accessible_ability_manager_service.cpp b/services/aams/src/accessible_ability_manager_service.cpp index 0d68b220..39945882 100644 --- a/services/aams/src/accessible_ability_manager_service.cpp +++ b/services/aams/src/accessible_ability_manager_service.cpp @@ -45,6 +45,7 @@ namespace { const std::string ARKUI_ANIMATION_SCALE_NAME = "persist.sys.arkui.animationscale"; constexpr int32_t QUERY_USER_ID_RETRY_COUNT = 600; constexpr int32_t QUERY_USER_ID_SLEEP_TIME = 50; + constexpr uint32_t TIME_OUT_OPERATOR = 5000; } // namespace const bool REGISTER_RESULT = @@ -349,6 +350,12 @@ uint32_t AccessibleAbilityManagerService::RegisterCaptionObserver( accountData->GetCaptionPropertyCallbacks().size()); syncPromise.set_value(NO_ERROR); }), "TASK_REGISTER_CAPTION_OBSERVER"); + + std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != std::future_status::ready) { + HILOG_ERROR("Failed to wait RegisterCaptionObserver result"); + return RET_ERR_TIME_OUT; + } return syncFuture.get(); } @@ -388,6 +395,12 @@ void AccessibleAbilityManagerService::RegisterEnableAbilityListsObserver( accountData->AddEnableAbilityListsObserver(observer); syncPromise.set_value(); }), "TASK_REGISTER_ENABLE_ABILITY_LISTS_OBSERVER"); + + std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != std::future_status::ready) { + HILOG_ERROR("Failed to wait RegisterEnableAbilityListsObserver result"); + return; + } return syncFuture.get(); } @@ -1985,6 +1998,12 @@ uint32_t AccessibleAbilityManagerService::RegisterConfigObserver( accountData->GetConfigCallbacks().size()); syncPromise.set_value(NO_ERROR); }), "TASK_REGISTER_CONFIG_OBSERVER"); + + std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != std::future_status::ready) { + HILOG_ERROR("Failed to wait RegisterConfigObserver result"); + return RET_ERR_TIME_OUT; + } return syncFuture.get(); } -- Gitee