From 96cecdced3811be737a8f516f5765eab6d7d862c Mon Sep 17 00:00:00 2001 From: ZhangYu Date: Fri, 12 Jan 2024 08:01:58 +0000 Subject: [PATCH] Add timeout protection for accessibility related interfaces of UIExtensionComponent. Signed-off-by: ZhangYu Change-Id: Ia877f7584b29ea3a6693eac5fb1391a9dcb8fd50 --- adapter/ohos/entrance/ace_container.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/adapter/ohos/entrance/ace_container.cpp b/adapter/ohos/entrance/ace_container.cpp index c1c9164ff61..ce9f5f6d1ee 100644 --- a/adapter/ohos/entrance/ace_container.cpp +++ b/adapter/ohos/entrance/ace_container.cpp @@ -2306,7 +2306,7 @@ void AceContainer::SearchElementInfoByAccessibilityIdNG( std::list& output) { CHECK_NULL_VOID(taskExecutor_); - taskExecutor_->PostSyncTask( + taskExecutor_->PostSyncTaskTimeout( [weak = WeakClaim(this), elementId, mode, baseParent, &output]() { auto container = weak.Upgrade(); CHECK_NULL_VOID(container); @@ -2320,7 +2320,7 @@ void AceContainer::SearchElementInfoByAccessibilityIdNG( accessibilityManager->SearchElementInfoByAccessibilityIdNG( elementId, mode, output, ngPipeline, baseParent); }, - TaskExecutor::TaskType::UI); + TaskExecutor::TaskType::UI, 1500); } void AceContainer::SearchElementInfosByTextNG( @@ -2328,7 +2328,7 @@ void AceContainer::SearchElementInfosByTextNG( std::list& output) { CHECK_NULL_VOID(taskExecutor_); - taskExecutor_->PostSyncTask( + taskExecutor_->PostSyncTaskTimeout( [weak = WeakClaim(this), elementId, &text, baseParent, &output]() { auto container = weak.Upgrade(); CHECK_NULL_VOID(container); @@ -2342,7 +2342,7 @@ void AceContainer::SearchElementInfosByTextNG( accessibilityManager->SearchElementInfosByTextNG( elementId, text, output, ngPipeline, baseParent); }, - TaskExecutor::TaskType::UI); + TaskExecutor::TaskType::UI, 1500); } void AceContainer::FindFocusedElementInfoNG( @@ -2350,7 +2350,7 @@ void AceContainer::FindFocusedElementInfoNG( Accessibility::AccessibilityElementInfo& output) { CHECK_NULL_VOID(taskExecutor_); - taskExecutor_->PostSyncTask( + taskExecutor_->PostSyncTaskTimeout( [weak = WeakClaim(this), elementId, focusType, baseParent, &output]() { auto container = weak.Upgrade(); CHECK_NULL_VOID(container); @@ -2364,7 +2364,7 @@ void AceContainer::FindFocusedElementInfoNG( accessibilityManager->FindFocusedElementInfoNG( elementId, focusType, output, ngPipeline, baseParent); }, - TaskExecutor::TaskType::UI); + TaskExecutor::TaskType::UI, 1500); } void AceContainer::FocusMoveSearchNG( @@ -2372,7 +2372,7 @@ void AceContainer::FocusMoveSearchNG( Accessibility::AccessibilityElementInfo& output) { CHECK_NULL_VOID(taskExecutor_); - taskExecutor_->PostSyncTask( + taskExecutor_->PostSyncTaskTimeout( [weak = WeakClaim(this), elementId, direction, baseParent, &output]() { auto container = weak.Upgrade(); CHECK_NULL_VOID(container); @@ -2385,7 +2385,7 @@ void AceContainer::FocusMoveSearchNG( CHECK_NULL_VOID(accessibilityManager); accessibilityManager->FocusMoveSearchNG(elementId, direction, output, ngPipeline, baseParent); }, - TaskExecutor::TaskType::UI); + TaskExecutor::TaskType::UI, 1500); } bool AceContainer::NotifyExecuteAction( @@ -2394,7 +2394,7 @@ bool AceContainer::NotifyExecuteAction( { bool IsExecuted = false; CHECK_NULL_RETURN(taskExecutor_, IsExecuted); - taskExecutor_->PostSyncTask( + taskExecutor_->PostSyncTaskTimeout( [weak = WeakClaim(this), elementId, &actionArguments, action, offset, &IsExecuted]() { auto container = weak.Upgrade(); CHECK_NULL_VOID(container); @@ -2408,7 +2408,7 @@ bool AceContainer::NotifyExecuteAction( IsExecuted = accessibilityManager->ExecuteExtensionActionNG( elementId, actionArguments, action, ngPipeline, offset); }, - TaskExecutor::TaskType::UI); + TaskExecutor::TaskType::UI, 1500); return IsExecuted; } -- Gitee