diff --git a/accessibility_manager_service.gni b/accessibility_manager_service.gni index a4a1cbff..e6b46deb 100644 --- a/accessibility_manager_service.gni +++ b/accessibility_manager_service.gni @@ -16,6 +16,7 @@ import("//build/ohos.gni") declare_args() { accessibility_feature_power_manager = true accessibility_feature_display_manager = true + accessibility_feature_data_share = true accessibility_use_rosen_drawing = false if (defined(global_parts_info) && !defined(global_parts_info.powermgr_display_manager)) { @@ -30,6 +31,11 @@ declare_args() { if (defined(use_rosen_drawing) && use_rosen_drawing) { accessibility_use_rosen_drawing = true } + + if (defined(global_parts_info) && + !defined(global_parts_info.distributeddatamgr_data_share)) { + distributeddatamgr_data_share = false + } } print( @@ -37,6 +43,7 @@ print( 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}") accessibility_default_defines = [] @@ -51,3 +58,7 @@ if (accessibility_feature_display_manager) { if (accessibility_use_rosen_drawing) { accessibility_default_defines += [ "USE_ROSEN_DRAWING" ] } + +if (accessibility_feature_data_share) { + accessibility_default_defines += [ "OHOS_BUILD_ENABLE_DATA_SHARE" ] +} diff --git a/bundle.json b/bundle.json index 9fa1860b..cf0b27d7 100644 --- a/bundle.json +++ b/bundle.json @@ -40,6 +40,7 @@ "ability_base", "safwk", "bundle_framework", + "ffrt", "hitrace", "hilog", "ipc", diff --git a/common/interface/BUILD.gn b/common/interface/BUILD.gn index 2689f392..856950c6 100644 --- a/common/interface/BUILD.gn +++ b/common/interface/BUILD.gn @@ -91,6 +91,7 @@ ohos_shared_library("accessibility_interface") { "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "c_utils:utils", + "ffrt:libffrt", "hilog:libhilog", "input:libmmi-client", "ipc:ipc_single", diff --git a/common/interface/include/accessibility_element_operator_callback_stub.h b/common/interface/include/accessibility_element_operator_callback_stub.h index 26281b98..a3515009 100644 --- a/common/interface/include/accessibility_element_operator_callback_stub.h +++ b/common/interface/include/accessibility_element_operator_callback_stub.h @@ -17,9 +17,9 @@ #define ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_STUB_H #include -#include #include "i_accessibility_element_operator_callback.h" #include "iremote_stub.h" +#include "ffrt.h" namespace OHOS { namespace Accessibility { @@ -33,7 +33,7 @@ public: size_t Size(); void Clear(); std::vector storeData_ = {}; - std::mutex mutex_; + ffrt::mutex mutex_; }; /* diff --git a/common/interface/src/accessibility_element_operator_callback_stub.cpp b/common/interface/src/accessibility_element_operator_callback_stub.cpp index ffd99cb6..8e0e01a6 100644 --- a/common/interface/src/accessibility_element_operator_callback_stub.cpp +++ b/common/interface/src/accessibility_element_operator_callback_stub.cpp @@ -52,28 +52,28 @@ constexpr int32_t ERR_CODE_DEFAULT = -1000; void StoreElementData::WriteData(std::vector &infos) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); storeData_.insert(storeData_.end(), infos.begin(), infos.end()); } void StoreElementData::Clear() { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); storeData_.clear(); } std::vector StoreElementData::ReadData() { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return storeData_; } size_t StoreElementData::Size() { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return storeData_.size(); } @@ -101,8 +101,6 @@ StoreElementData AccessibilityElementOperatorCallbackStub::storeElementData; AccessibilityElementOperatorCallbackStub::~AccessibilityElementOperatorCallbackStub() { - HILOG_DEBUG(); - memberFuncMap_.clear(); } int AccessibilityElementOperatorCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, diff --git a/common/interface/src/accessibility_element_operator_stub.cpp b/common/interface/src/accessibility_element_operator_stub.cpp index 8e6a18e0..9846892f 100644 --- a/common/interface/src/accessibility_element_operator_stub.cpp +++ b/common/interface/src/accessibility_element_operator_stub.cpp @@ -77,8 +77,6 @@ AccessibilityElementOperatorStub::AccessibilityElementOperatorStub() AccessibilityElementOperatorStub::~AccessibilityElementOperatorStub() { - HILOG_DEBUG(); - memberFuncMap_.clear(); } int AccessibilityElementOperatorStub::OnRemoteRequest(uint32_t code, MessageParcel &data, diff --git a/common/interface/src/accessible_ability_channel_stub.cpp b/common/interface/src/accessible_ability_channel_stub.cpp index 46f8b244..5c409a00 100644 --- a/common/interface/src/accessible_ability_channel_stub.cpp +++ b/common/interface/src/accessible_ability_channel_stub.cpp @@ -90,8 +90,6 @@ AccessibleAbilityChannelStub::AccessibleAbilityChannelStub() AccessibleAbilityChannelStub::~AccessibleAbilityChannelStub() { - HILOG_DEBUG(); - memberFuncMap_.clear(); } int AccessibleAbilityChannelStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, diff --git a/common/interface/src/accessible_ability_client_stub.cpp b/common/interface/src/accessible_ability_client_stub.cpp index 27bb8005..f35d02aa 100644 --- a/common/interface/src/accessible_ability_client_stub.cpp +++ b/common/interface/src/accessible_ability_client_stub.cpp @@ -59,8 +59,6 @@ AccessibleAbilityClientStub::AccessibleAbilityClientStub() AccessibleAbilityClientStub::~AccessibleAbilityClientStub() { - HILOG_DEBUG(); - memberFuncMap_.clear(); } int AccessibleAbilityClientStub::OnRemoteRequest(uint32_t code, @@ -90,13 +88,13 @@ ErrCode AccessibleAbilityClientStub::HandleInit(MessageParcel &data, MessageParc { HILOG_DEBUG(); sptr remote = data.ReadRemoteObject(); - if (!remote) { + if (remote == nullptr) { HILOG_ERROR("object is nullptr."); return ERR_INVALID_VALUE; } sptr channel = iface_cast(remote); - if (!channel) { + if (channel == nullptr) { HILOG_ERROR("channel is nullptr."); return ERR_INVALID_VALUE; } @@ -133,6 +131,11 @@ ErrCode AccessibleAbilityClientStub::HandleOnKeyPressEvent(MessageParcel &data, int32_t sequence = data.ReadInt32(); std::shared_ptr keyEvent = MMI::KeyEvent::Create(); + if (keyEvent == nullptr) { + HILOG_ERROR("keyEvent is nullptr"); + return ERR_INVALID_VALUE; + } + if (!keyEvent->ReadFromParcel(data)) { HILOG_ERROR("keyEvent ReadFromParcel failed"); return ERR_INVALID_VALUE; diff --git a/common/interface/src/accessible_ability_manager_service_stub.cpp b/common/interface/src/accessible_ability_manager_service_stub.cpp index 2f98cc58..6fb62699 100644 --- a/common/interface/src/accessible_ability_manager_service_stub.cpp +++ b/common/interface/src/accessible_ability_manager_service_stub.cpp @@ -104,6 +104,8 @@ SWITCH_CASE(AccessibilityInterfaceCode::REGISTER_ENABLE_ABILITY_LISTS_OBSERVER, HandleRegisterEnableAbilityListsObserver)\ SWITCH_CASE(AccessibilityInterfaceCode::GET_FOCUSED_WINDOW_ID, HandleGetFocusedWindowId)\ SWITCH_CASE(AccessibilityInterfaceCode::REMOVE_REQUEST_ID, HandleRemoveRequestId)\ + SWITCH_CASE(AccessibilityInterfaceCode::GET_ROOT_PARENT_ID, HandleGetRootParentId) \ + SWITCH_CASE(AccessibilityInterfaceCode::GET_ALL_TREE_ID, HandleGetAllTreeId) \ namespace OHOS { namespace Accessibility { @@ -272,8 +274,6 @@ AccessibleAbilityManagerServiceStub::AccessibleAbilityManagerServiceStub() AccessibleAbilityManagerServiceStub::~AccessibleAbilityManagerServiceStub() { - HILOG_DEBUG("start."); - memberFuncMap_.clear(); } int AccessibleAbilityManagerServiceStub::OnRemoteRequest( diff --git a/common/interface/src/parcel/accessibility_element_info_parcel.cpp b/common/interface/src/parcel/accessibility_element_info_parcel.cpp index 48a0b3d6..2d2c743b 100644 --- a/common/interface/src/parcel/accessibility_element_info_parcel.cpp +++ b/common/interface/src/parcel/accessibility_element_info_parcel.cpp @@ -357,18 +357,18 @@ RangeInfoParcel::RangeInfoParcel(const RangeInfo &rangeInfo) bool RangeInfoParcel::ReadFromParcel(Parcel &parcel) { - READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, min_); - READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, max_); - READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, current_); + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Double, parcel, min_); + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Double, parcel, max_); + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Double, parcel, current_); return true; } bool RangeInfoParcel::Marshalling(Parcel &parcel) const { - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, min_); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, max_); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, current_); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Double, parcel, min_); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Double, parcel, max_); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Double, parcel, current_); return true; } diff --git a/common/interface/test/fuzztest/accessibilityelementoperatorcallbackstub_fuzzer/BUILD.gn b/common/interface/test/fuzztest/accessibilityelementoperatorcallbackstub_fuzzer/BUILD.gn index fa2363d4..06798b32 100644 --- a/common/interface/test/fuzztest/accessibilityelementoperatorcallbackstub_fuzzer/BUILD.gn +++ b/common/interface/test/fuzztest/accessibilityelementoperatorcallbackstub_fuzzer/BUILD.gn @@ -33,6 +33,7 @@ ohos_fuzztest("AccessibilityElementOperatorCallbackStubFuzzTest") { ] external_deps = [ "c_utils:utils", + "ffrt:libffrt", "input:libmmi-client", "ipc:ipc_single", ] diff --git a/common/interface/test/fuzztest/accessibleabilitymanagerservicestub_fuzzer/accessibleabilitymanagerservicestub_fuzzer.cpp b/common/interface/test/fuzztest/accessibleabilitymanagerservicestub_fuzzer/accessibleabilitymanagerservicestub_fuzzer.cpp index fe8858aa..72b2cfcf 100644 --- a/common/interface/test/fuzztest/accessibleabilitymanagerservicestub_fuzzer/accessibleabilitymanagerservicestub_fuzzer.cpp +++ b/common/interface/test/fuzztest/accessibleabilitymanagerservicestub_fuzzer/accessibleabilitymanagerservicestub_fuzzer.cpp @@ -153,6 +153,8 @@ bool HandleSetDaltonizationStateTest(const uint8_t *data, size_t size) { MessageParcel datas; bool isSetDaltonizationState = data[0] % DEVISOR_TWO; + std::u16string descriptor = AccessibleAbilityManagerServiceStubFuzzTest::GetDescriptor(); + datas.WriteInterfaceToken(descriptor); datas.WriteBool(isSetDaltonizationState); MessageParcel reply; MessageOption option; diff --git a/common/interface/test/unittest/accessibility_element_info_parcel_test.cpp b/common/interface/test/unittest/accessibility_element_info_parcel_test.cpp index da9dcb6f..d909e6e5 100644 --- a/common/interface/test/unittest/accessibility_element_info_parcel_test.cpp +++ b/common/interface/test/unittest/accessibility_element_info_parcel_test.cpp @@ -50,6 +50,8 @@ public: gridItemInfoParcel_ = std::make_shared(*gridItemInfo_); rect_ = std::make_shared(); rectParcel_ = std::make_shared(*rect_); + extraElementInfo_ = std::make_shared(); + extraElementInfoParcel_ = std::make_shared(*extraElementInfo_); GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest SetUp() End"; }; void TearDown() @@ -67,6 +69,8 @@ public: gridItemInfoParcel_ = nullptr; rect_ = nullptr; rectParcel_ = nullptr; + extraElementInfo_ = nullptr; + extraElementInfoParcel_ = nullptr; } std::shared_ptr action_ = nullptr; @@ -81,6 +85,8 @@ public: std::shared_ptr rectParcel_ = nullptr; std::shared_ptr elementInfo_ = nullptr; std::shared_ptr elementInfoParcel_ = nullptr; + std::shared_ptr extraElementInfo_ = nullptr; + std::shared_ptr extraElementInfoParcel_ = nullptr; }; /** @@ -310,5 +316,42 @@ HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Info_Unmarshalling_001, TestSi EXPECT_EQ(true, gridInfoParcel == nullptr); GTEST_LOG_(INFO) << "Grid_Info_Unmarshalling_001 end"; } + +/** + * @tc.number: Extra_Element_Info_Parcel__001 + * @tc.name: Extra_Element_Info_Parcel + * @tc.desc: Test function ReadFromParcel + */ +HWTEST_F(AccessibilityElementInfoParcelTest, Extra_Element_Info_Parcel__001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__001 start"; + if (!extraElementInfoParcel_) { + GTEST_LOG_(INFO) << "extraElementInfoParcel_ is null"; + return; + } + + Parcel parcel; + EXPECT_EQ(false, extraElementInfoParcel_->ReadFromParcel(parcel)); + GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__001 end"; +} + +/** + * @tc.number: Extra_Element_Info_Parcel__002 + * @tc.name: Extra_Element_Info_Parcel + * @tc.desc: Test function Unmarshalling + */ +HWTEST_F(AccessibilityElementInfoParcelTest, Extra_Element_Info_Parcel__002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__002 start"; + if (!extraElementInfoParcel_) { + GTEST_LOG_(INFO) << "extraElementInfoParcel_ is null"; + return; + } + + Parcel parcel; + sptr extraElementInfoParcel = extraElementInfoParcel_->Unmarshalling(parcel); + EXPECT_EQ(true, extraElementInfoParcel == nullptr); + GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__002 end"; +} } // namespace Accessibility } // namespace OHOS \ No newline at end of file diff --git a/frameworks/aafwk/include/accessibility_element_operator_callback_impl.h b/frameworks/aafwk/include/accessibility_element_operator_callback_impl.h index 413274cd..2e241af7 100644 --- a/frameworks/aafwk/include/accessibility_element_operator_callback_impl.h +++ b/frameworks/aafwk/include/accessibility_element_operator_callback_impl.h @@ -16,8 +16,8 @@ #ifndef ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_IMPL_H #define ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_IMPL_H -#include #include "accessibility_element_operator_callback_stub.h" +#include "ffrt_inner.h" namespace OHOS { namespace Accessibility { @@ -86,7 +86,7 @@ public: virtual void SetCursorPositionResult(const int32_t cursorPosition, const int32_t requestId) override; private: - std::promise promise_; + ffrt::promise promise_; bool executeActionResult_ = false; AccessibilityElementInfo accessibilityInfoResult_ = {}; std::vector elementInfosResult_; diff --git a/frameworks/aafwk/include/accessible_ability_client_impl.h b/frameworks/aafwk/include/accessible_ability_client_impl.h index d263ea97..700be551 100644 --- a/frameworks/aafwk/include/accessible_ability_client_impl.h +++ b/frameworks/aafwk/include/accessible_ability_client_impl.h @@ -19,11 +19,11 @@ #include #include #include -#include -#include #include "accessible_ability_channel_client.h" #include "accessible_ability_client.h" #include "accessible_ability_client_stub.h" +#include "ffrt.h" +#include "ffrt_inner.h" #include "i_accessible_ability_manager_service.h" #include "refbase.h" #include "system_ability_load_callback_stub.h" @@ -388,7 +388,7 @@ private: private: std::map>> elementCache_; std::deque windowIdSet_; - std::mutex elementCacheMutex_; + ffrt::mutex elementCacheMutex_; }; class SceneBoardWindowElementMap { @@ -403,7 +403,7 @@ private: void RemovePairByWindowId(int32_t windowId); private: std::map windowElementMap_; - std::mutex mapMutex_; + ffrt::mutex mapMutex_; }; class AccessibleAbilityDeathRecipient final : public IRemoteObject::DeathRecipient { @@ -455,14 +455,14 @@ private: uint32_t cacheMode_ = 0; int32_t cacheWindowId_ = -1; std::map cacheElementInfos_; - std::mutex mutex_; + ffrt::mutex mutex_; std::atomic isConnected_ = false; // used for query element info in batch ElementCacheInfo elementCacheInfo_; SceneBoardWindowElementMap windowElementMap_; - std::condition_variable proxyConVar_; - std::mutex conVarMutex_; + ffrt::condition_variable proxyConVar_; + ffrt::mutex conVarMutex_; }; } // namespace Accessibility } // namespace OHOS diff --git a/frameworks/aafwk/src/accessibility_ui_test_ability_impl.cpp b/frameworks/aafwk/src/accessibility_ui_test_ability_impl.cpp index 4e357fec..6aaa045e 100644 --- a/frameworks/aafwk/src/accessibility_ui_test_ability_impl.cpp +++ b/frameworks/aafwk/src/accessibility_ui_test_ability_impl.cpp @@ -15,8 +15,8 @@ #include "accessibility_ui_test_ability_impl.h" -#include #include "accessible_ability_client_impl.h" +#include "ffrt.h" #include "hilog_wrapper.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" @@ -24,12 +24,12 @@ namespace OHOS { namespace Accessibility { -static std::mutex g_Mutex; +static ffrt::mutex g_Mutex; static std::shared_ptr g_Instance = nullptr; std::shared_ptr AccessibilityUITestAbility::GetInstance() { - std::lock_guard lock(g_Mutex); + std::lock_guard lock(g_Mutex); if (!g_Instance) { g_Instance = std::make_shared(); } diff --git a/frameworks/aafwk/src/accessible_ability_channel_client.cpp b/frameworks/aafwk/src/accessible_ability_channel_client.cpp index 947f88ef..ec650b66 100644 --- a/frameworks/aafwk/src/accessible_ability_channel_client.cpp +++ b/frameworks/aafwk/src/accessible_ability_channel_client.cpp @@ -68,7 +68,7 @@ RetError AccessibleAbilityChannelClient::FindFocusedElementInfo(int32_t accessib HILOG_ERROR("FindFocusedElementInfo Failed to create elementOperator."); return RET_ERR_NULLPTR; } - std::future promiseFuture = elementOperator->promise_.get_future(); + ffrt::future promiseFuture = elementOperator->promise_.get_future(); int32_t windowId = accessibilityWindowId; if (accessibilityWindowId == ANY_WINDOW_ID && focusType == FOCUS_TYPE_ACCESSIBILITY && @@ -86,8 +86,8 @@ RetError AccessibleAbilityChannelClient::FindFocusedElementInfo(int32_t accessib HILOG_DEBUG("channelId:%{public}d, windowId:%{public}d, elementId:%{public}" PRId64 ", focusType:%{public}d", channelId_, windowId, elementId, focusType); - std::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("FindFocusedElementInfo Failed to wait result"); return RET_ERR_TIME_OUT; } @@ -132,7 +132,7 @@ RetError AccessibleAbilityChannelClient::GetCursorPosition( HILOG_ERROR("GetCursorPosition Failed to create elementOperator."); return RET_ERR_NULLPTR; } - std::future promiseFuture = elementOperator->promise_.get_future(); + ffrt::future promiseFuture = elementOperator->promise_.get_future(); RetError ret = proxy_->GetCursorPosition(accessibilityWindowId, elementId, requestId, elementOperator); if (ret != RET_OK) { @@ -140,8 +140,8 @@ RetError AccessibleAbilityChannelClient::GetCursorPosition( return ret; } - std::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("GetCursorPosition Failed to wait result"); return RET_ERR_TIME_OUT; } @@ -173,7 +173,7 @@ RetError AccessibleAbilityChannelClient::ExecuteAction(int32_t accessibilityWind HILOG_ERROR("ExecuteAction Failed to create elementOperator."); return RET_ERR_NULLPTR; } - std::future promiseFuture = elementOperator->promise_.get_future(); + ffrt::future promiseFuture = elementOperator->promise_.get_future(); RetError ret = proxy_->ExecuteAction(accessibilityWindowId, elementId, action, actionArguments, requestId, elementOperator); @@ -182,8 +182,8 @@ RetError AccessibleAbilityChannelClient::ExecuteAction(int32_t accessibilityWind return ret; } - std::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait result"); return RET_ERR_TIME_OUT; } @@ -238,7 +238,7 @@ RetError AccessibleAbilityChannelClient::SearchElementInfosByAccessibilityId(int HILOG_ERROR("SearchElementInfosByAccessibilityId Failed to create elementOperator."); return RET_ERR_NULLPTR; } - std::future promiseFuture = elementOperator->promise_.get_future(); + ffrt::future promiseFuture = elementOperator->promise_.get_future(); ElementBasicInfo elementBasicInfo {}; elementBasicInfo.windowId = accessibilityWindowId; elementBasicInfo.treeId = treeId; @@ -252,8 +252,8 @@ RetError AccessibleAbilityChannelClient::SearchElementInfosByAccessibilityId(int return ret; } - std::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("SearchElementInfosByAccessibilityId Failed to wait result"); return RET_ERR_TIME_OUT; } @@ -323,7 +323,7 @@ RetError AccessibleAbilityChannelClient::SearchElementInfosByText(int32_t access HILOG_ERROR("SearchElementInfosByText Failed to create elementOperator."); return RET_ERR_NULLPTR; } - std::future promiseFuture = elementOperator->promise_.get_future(); + ffrt::future promiseFuture = elementOperator->promise_.get_future(); RetError ret = proxy_->SearchElementInfosByText(accessibilityWindowId, elementId, text, requestId, elementOperator); @@ -332,8 +332,8 @@ RetError AccessibleAbilityChannelClient::SearchElementInfosByText(int32_t access return ret; } - std::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("SearchElementInfosByText Failed to wait result"); return RET_ERR_TIME_OUT; } @@ -365,7 +365,7 @@ RetError AccessibleAbilityChannelClient::FocusMoveSearch(int32_t accessibilityWi HILOG_ERROR("FocusMoveSearch Failed to create elementOperator."); return RET_ERR_NULLPTR; } - std::future promiseFuture = elementOperator->promise_.get_future(); + ffrt::future promiseFuture = elementOperator->promise_.get_future(); RetError ret = proxy_->FocusMoveSearch(accessibilityWindowId, elementId, direction, requestId, elementOperator); if (ret != RET_OK) { @@ -373,8 +373,8 @@ RetError AccessibleAbilityChannelClient::FocusMoveSearch(int32_t accessibilityWi return ret; } - std::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("FocusMoveSearch Failed to wait result"); return RET_ERR_TIME_OUT; } diff --git a/frameworks/aafwk/src/accessible_ability_client_impl.cpp b/frameworks/aafwk/src/accessible_ability_client_impl.cpp index 54f67f20..bb49c2dd 100644 --- a/frameworks/aafwk/src/accessible_ability_client_impl.cpp +++ b/frameworks/aafwk/src/accessible_ability_client_impl.cpp @@ -39,7 +39,7 @@ namespace { constexpr int32_t CONFIG_PARAMETER_VALUE_SIZE = 10; constexpr int64_t ROOT_NONE_ID = -1; constexpr int64_t NODE_ID_MAX = 0x7FFFFFFE; - std::mutex g_Mutex; + ffrt::mutex g_Mutex; sptr g_Instance = nullptr; constexpr int32_t SA_CONNECT_TIMEOUT = 500; // ms } // namespace @@ -47,7 +47,7 @@ namespace { sptr AccessibleAbilityClient::GetInstance() { HILOG_DEBUG(); - std::lock_guard lock(g_Mutex); + std::lock_guard lock(g_Mutex); if (g_Instance == nullptr) { g_Instance = new(std::nothrow) AccessibleAbilityClientImpl(); } @@ -57,7 +57,7 @@ sptr AccessibleAbilityClient::GetInstance() sptr AccessibleAbilityClientImpl::GetAbilityClientImplement() { HILOG_DEBUG(); - std::lock_guard lock(g_Mutex); + std::lock_guard lock(g_Mutex); if (g_Instance == nullptr) { g_Instance = new(std::nothrow) AccessibleAbilityClientImpl(); } @@ -81,7 +81,7 @@ AccessibleAbilityClientImpl::AccessibleAbilityClientImpl() AccessibleAbilityClientImpl::~AccessibleAbilityClientImpl() { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ && serviceProxy_->AsObject()) { HILOG_DEBUG("Remove service death recipient"); serviceProxy_->AsObject()->RemoveDeathRecipient(accessibilityServiceDeathRecipient_); @@ -144,7 +144,7 @@ void AccessibleAbilityClientImpl::OnParameterChanged(const char *key, const char } AccessibleAbilityClientImpl *implPtr = static_cast(context); - std::lock_guard lock(implPtr->mutex_); + std::lock_guard lock(implPtr->mutex_); if (implPtr->InitAccessibilityServiceProxy()) { HILOG_INFO("InitAccessibilityServiceProxy success"); } @@ -160,7 +160,7 @@ sptr AccessibleAbilityClientImp bool AccessibleAbilityClientImpl::LoadAccessibilityService() { - std::unique_lock lock(conVarMutex_); + std::unique_lock lock(conVarMutex_); sptr loadCallback = new AccessibilityLoadCallback(); if (loadCallback == nullptr) { return false; @@ -183,7 +183,7 @@ bool AccessibleAbilityClientImpl::LoadAccessibilityService() void AccessibleAbilityClientImpl::LoadSystemAbilitySuccess(const sptr &remoteObject) { - std::lock_guard lock(conVarMutex_); + std::lock_guard lock(conVarMutex_); char value[CONFIG_PARAMETER_VALUE_SIZE] = "default"; int retSysParam = GetParameter(SYSTEM_PARAMETER_AAMS_SERVICE.c_str(), "false", value, CONFIG_PARAMETER_VALUE_SIZE); if (retSysParam >= 0 && !std::strcmp(value, "true")) { @@ -196,7 +196,7 @@ void AccessibleAbilityClientImpl::LoadSystemAbilitySuccess(const sptr lock(conVarMutex_); + std::lock_guard lock(conVarMutex_); HILOG_WARN("LoadSystemAbilityFail."); proxyConVar_.notify_one(); } @@ -211,7 +211,7 @@ RetError AccessibleAbilityClientImpl::RegisterAbilityListener( const std::shared_ptr &listener) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (listener_) { HILOG_DEBUG("listener already exists."); return RET_ERR_REGISTER_EXIST; @@ -231,7 +231,7 @@ void AccessibleAbilityClientImpl::Init(const sptr &ch std::shared_ptr listener = nullptr; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!listener_) { HILOG_ERROR("listener_ is nullptr."); return; @@ -268,7 +268,7 @@ void AccessibleAbilityClientImpl::Disconnect(const int32_t channelId) std::shared_ptr listener = nullptr; { isConnected_ = false; - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); // Delete death recipient if (channelClient_ && channelClient_->GetRemote()) { HILOG_ERROR("Remove death recipient"); @@ -291,7 +291,7 @@ void AccessibleAbilityClientImpl::OnAccessibilityEvent(const AccessibilityEventI HILOG_DEBUG(); std::shared_ptr listener = nullptr; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return; @@ -309,7 +309,7 @@ void AccessibleAbilityClientImpl::OnKeyPressEvent(const MMI::KeyEvent &keyEvent, std::shared_ptr listener = nullptr; std::shared_ptr channel = nullptr; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); listener = listener_; channel = channelClient_; } @@ -334,7 +334,7 @@ RetError AccessibleAbilityClientImpl::GetFocus(const int32_t focusType, Accessib return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if ((focusType != FOCUS_TYPE_INPUT) && (focusType != FOCUS_TYPE_ACCESSIBILITY)) { HILOG_ERROR("focusType is not allowed."); return RET_ERR_INVALID_PARAM; @@ -357,7 +357,7 @@ RetError AccessibleAbilityClientImpl::GetFocusByElementInfo(const AccessibilityE return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if ((focusType != FOCUS_TYPE_INPUT) && (focusType != FOCUS_TYPE_ACCESSIBILITY)) { HILOG_ERROR("focusType is not allowed."); return RET_ERR_INVALID_PARAM; @@ -384,7 +384,7 @@ RetError AccessibleAbilityClientImpl::InjectGesture(const std::shared_ptr lock(mutex_); + std::lock_guard lock(mutex_); if (!gesturePath) { HILOG_ERROR("The gesturePath is null."); return RET_ERR_INVALID_PARAM; @@ -413,7 +413,7 @@ RetError AccessibleAbilityClientImpl::GetRoot(AccessibilityElementInfo &elementI return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ == nullptr && !LoadAccessibilityService()) { HILOG_ERROR("Failed to connect to aams"); return RET_ERR_SAMGR; @@ -448,7 +448,7 @@ RetError AccessibleAbilityClientImpl::GetRootByWindow(const AccessibilityWindowI return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -472,7 +472,7 @@ RetError AccessibleAbilityClientImpl::GetWindow(const int32_t windowId, Accessib return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -488,7 +488,7 @@ RetError AccessibleAbilityClientImpl::GetRootBatch(std::vector lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -575,7 +575,7 @@ RetError AccessibleAbilityClientImpl::GetRootByWindowBatch(const AccessibilityWi return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ == nullptr && !LoadAccessibilityService()) { HILOG_ERROR("failed to connect to aams"); return RET_ERR_SAMGR; @@ -605,7 +605,7 @@ RetError AccessibleAbilityClientImpl::GetWindows(std::vector lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -622,7 +622,7 @@ RetError AccessibleAbilityClientImpl::GetWindows(const uint64_t displayId, return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -640,7 +640,7 @@ RetError AccessibleAbilityClientImpl::GetNext(const AccessibilityElementInfo &el return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -662,7 +662,7 @@ RetError AccessibleAbilityClientImpl::GetChildElementInfo(const int32_t index, c return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -691,7 +691,7 @@ RetError AccessibleAbilityClientImpl::GetChildren(const AccessibilityElementInfo HILOG_ERROR("connection is broken"); return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -760,7 +760,7 @@ RetError AccessibleAbilityClientImpl::GetByContent(const AccessibilityElementInf return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -860,7 +860,7 @@ RetError AccessibleAbilityClientImpl::GetSource(const AccessibilityEventInfo &ev return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -884,7 +884,7 @@ RetError AccessibleAbilityClientImpl::GetParentElementInfo(const AccessibilityEl return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -924,7 +924,7 @@ RetError AccessibleAbilityClientImpl::GetByElementId(const int64_t elementId, return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ == nullptr && !LoadAccessibilityService()) { HILOG_ERROR("failed to connect to aams"); return RET_ERR_SAMGR; @@ -960,7 +960,7 @@ RetError AccessibleAbilityClientImpl::GetCursorPosition(const AccessibilityEleme return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -980,7 +980,7 @@ RetError AccessibleAbilityClientImpl::ExecuteAction(const AccessibilityElementIn return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -1014,7 +1014,7 @@ RetError AccessibleAbilityClientImpl::SetTargetBundleName(const std::vector lock(mutex_); + std::lock_guard lock(mutex_); if (!channelClient_) { HILOG_ERROR("The channel is invalid."); return RET_ERR_NO_CONNECTION; @@ -1038,7 +1038,7 @@ void AccessibleAbilityClientImpl::NotifyServiceDied(const wptr &r { std::shared_ptr listener = nullptr; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!serviceProxy_) { HILOG_ERROR("serviceProxy_ is nullptr"); return; @@ -1063,7 +1063,7 @@ void AccessibleAbilityClientImpl::NotifyServiceDied(const wptr &r void AccessibleAbilityClientImpl::ResetAAClient(const wptr &remote) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (channelClient_) { sptr object = channelClient_->GetRemote(); if (object && (remote == object)) { @@ -1079,7 +1079,7 @@ void AccessibleAbilityClientImpl::ResetAAClient(const wptr &remot RetError AccessibleAbilityClientImpl::SetCacheMode(const int32_t cacheMode) { HILOG_DEBUG("set cache mode: [%{public}d]", cacheMode); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); cacheWindowId_ = -1; cacheElementInfos_.clear(); if (cacheMode < 0) { @@ -1203,7 +1203,7 @@ RetError AccessibleAbilityClientImpl::SearchElementInfoByInspectorKey(const std: return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ == nullptr && !LoadAccessibilityService()) { HILOG_ERROR("Failed to connect to aams"); return RET_ERR_SAMGR; @@ -1230,6 +1230,12 @@ RetError AccessibleAbilityClientImpl::SearchElementInfoByInspectorKey(const std: return ret; } + ret = SearchElementInfoRecursiveByWinid(windowId, ROOT_NONE_ID, GET_SOURCE_MODE, elementInfos, ROOT_TREE_ID); + if (ret != RET_OK) { + HILOG_ERROR("get window element failed."); + return ret; + } + if (elementInfos.empty()) { HILOG_ERROR("elementInfos from ace is empty"); return RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE; @@ -1237,7 +1243,7 @@ RetError AccessibleAbilityClientImpl::SearchElementInfoByInspectorKey(const std: SortElementInfosIfNecessary(elementInfos); for (auto &info : elementInfos) { if (info.GetInspectorKey() == inspectorKey) { - HILOG_DEBUG(); + HILOG_INFO("find elementInfo by inspectorKey success"); elementInfo = info; return RET_OK; } @@ -1248,7 +1254,7 @@ RetError AccessibleAbilityClientImpl::SearchElementInfoByInspectorKey(const std: RetError AccessibleAbilityClientImpl::Connect() { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ == nullptr && !LoadAccessibilityService()) { HILOG_ERROR("Failed to get aams service"); return RET_ERR_SAMGR; @@ -1264,7 +1270,7 @@ RetError AccessibleAbilityClientImpl::Connect() RetError AccessibleAbilityClientImpl::Disconnect() { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ == nullptr && !LoadAccessibilityService()) { HILOG_ERROR("Failed to get aams service"); return RET_ERR_SAMGR; @@ -1466,7 +1472,7 @@ RetError AccessibleAbilityClientImpl::SearchElementInfoByAccessibilityId(const i return RET_ERR_NO_CONNECTION; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ == nullptr) { HILOG_ERROR("failed to connect aams."); return RET_ERR_SAMGR; @@ -1499,7 +1505,7 @@ RetError AccessibleAbilityClientImpl::SearchElementInfoByAccessibilityId(const i void AccessibleAbilityClientImpl::ElementCacheInfo::AddElementCache(const int32_t windowId, const std::vector& elementInfos) { - std::lock_guard lock(elementCacheMutex_); + std::lock_guard lock(elementCacheMutex_); if (windowIdSet_.size() >= MAX_CACHE_WINDOW_SIZE) { auto winId = windowIdSet_.front(); windowIdSet_.pop_front(); @@ -1548,7 +1554,7 @@ bool AccessibleAbilityClientImpl::ElementCacheInfo::GetElementByWindowId(const i const int64_t elementId, std::vector& elementInfos) { elementInfos.clear(); // clear - std::lock_guard lock(elementCacheMutex_); + std::lock_guard lock(elementCacheMutex_); if (elementCache_.find(windowId) == elementCache_.end()) { HILOG_DEBUG("windowId %{public}d is not existed", windowId); return false; @@ -1592,7 +1598,7 @@ bool AccessibleAbilityClientImpl::ElementCacheInfo::GetElementByWindowId(const i void AccessibleAbilityClientImpl::ElementCacheInfo::RemoveElementByWindowId(const int32_t windowId) { - std::lock_guard lock(elementCacheMutex_); + std::lock_guard lock(elementCacheMutex_); HILOG_DEBUG("erase windowId %{public}d cache", windowId); for (auto iter = windowIdSet_.begin(); iter != windowIdSet_.end(); iter++) { if (*iter == windowId) { @@ -1606,7 +1612,7 @@ void AccessibleAbilityClientImpl::ElementCacheInfo::RemoveElementByWindowId(cons bool AccessibleAbilityClientImpl::ElementCacheInfo::IsExistWindowId(int32_t windowId) { - std::lock_guard lock(elementCacheMutex_); + std::lock_guard lock(elementCacheMutex_); for (auto iter = windowIdSet_.begin(); iter != windowIdSet_.end(); iter++) { if (*iter == windowId) { return true; @@ -1618,7 +1624,7 @@ bool AccessibleAbilityClientImpl::ElementCacheInfo::IsExistWindowId(int32_t wind bool AccessibleAbilityClientImpl::SceneBoardWindowElementMap::IsExistWindowId(int32_t windowId) { - std::lock_guard lock(mapMutex_); + std::lock_guard lock(mapMutex_); if (windowElementMap_.find(windowId) != windowElementMap_.end()) { return true; } @@ -1629,13 +1635,13 @@ bool AccessibleAbilityClientImpl::SceneBoardWindowElementMap::IsExistWindowId(in void AccessibleAbilityClientImpl::SceneBoardWindowElementMap::AddWindowElementIdPair(int32_t windowId, int64_t elementId) { - std::lock_guard lock(mapMutex_); + std::lock_guard lock(mapMutex_); windowElementMap_[windowId] = elementId; } std::vector AccessibleAbilityClientImpl::SceneBoardWindowElementMap::GetWindowIdList() { - std::lock_guard lock(mapMutex_); + std::lock_guard lock(mapMutex_); std::vector windowList; for (auto iter = windowElementMap_.begin(); iter != windowElementMap_.end(); iter++) { windowList.push_back(iter->first); @@ -1646,7 +1652,7 @@ std::vector AccessibleAbilityClientImpl::SceneBoardWindowElementMap::Ge int32_t AccessibleAbilityClientImpl::SceneBoardWindowElementMap::GetWindowIdByElementId(int64_t elementId) { - std::lock_guard lock(mapMutex_); + std::lock_guard lock(mapMutex_); for (auto iter = windowElementMap_.begin(); iter != windowElementMap_.end(); iter++) { if (iter->second == elementId) { return iter->first; @@ -1659,7 +1665,7 @@ int32_t AccessibleAbilityClientImpl::SceneBoardWindowElementMap::GetWindowIdByEl void AccessibleAbilityClientImpl::SceneBoardWindowElementMap::RemovePairByWindowIdList( std::vector& windowIdList) { - std::lock_guard lock(mapMutex_); + std::lock_guard lock(mapMutex_); for (auto windowId : windowIdList) { windowElementMap_.erase(windowId); } @@ -1667,7 +1673,7 @@ void AccessibleAbilityClientImpl::SceneBoardWindowElementMap::RemovePairByWindow void AccessibleAbilityClientImpl::SceneBoardWindowElementMap::RemovePairByWindowId(int32_t windowId) { - std::lock_guard lock(mapMutex_); + std::lock_guard lock(mapMutex_); windowElementMap_.erase(windowId); } diff --git a/frameworks/aafwk/test/BUILD.gn b/frameworks/aafwk/test/BUILD.gn index fca7264e..58288e4d 100755 --- a/frameworks/aafwk/test/BUILD.gn +++ b/frameworks/aafwk/test/BUILD.gn @@ -91,6 +91,7 @@ ohos_unittest("accessibility_ui_test_ability_impl_test") { "data_share:datashare_common", "data_share:datashare_consumer", "eventhandler:libeventhandler", + "ffrt:libffrt", "hilog:libhilog", "init:libbeget_proxy", "init:libbegetutil", @@ -178,6 +179,7 @@ ohos_unittest("accessible_ability_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", diff --git a/frameworks/aafwk/test/mock/src/mock_accessible_ability_client_impl.cpp b/frameworks/aafwk/test/mock/src/mock_accessible_ability_client_impl.cpp index 4183f6b2..7b703ba0 100644 --- a/frameworks/aafwk/test/mock/src/mock_accessible_ability_client_impl.cpp +++ b/frameworks/aafwk/test/mock/src/mock_accessible_ability_client_impl.cpp @@ -20,14 +20,14 @@ namespace OHOS { namespace Accessibility { namespace { - std::mutex g_Mutex; + ffrt::mutex g_Mutex; sptr g_Instance = nullptr; } // namespace sptr AccessibleAbilityClient::GetInstance() { HILOG_DEBUG(); - std::lock_guard lock(g_Mutex); + std::lock_guard lock(g_Mutex); bool isNull = AccessibilityAbilityUtHelper::GetInstance().GetAbilityClientNullFlag(); if (isNull) { return nullptr; @@ -42,7 +42,7 @@ sptr AccessibleAbilityClient::GetInstance() sptr AccessibleAbilityClientImpl::GetAbilityClientImplement() { HILOG_DEBUG(); - std::lock_guard lock(g_Mutex); + std::lock_guard lock(g_Mutex); bool isNull = AccessibilityAbilityUtHelper::GetInstance().GetAbilityClientNullFlag(); if (isNull) { return nullptr; diff --git a/frameworks/acfwk/include/accessibility_config_impl.h b/frameworks/acfwk/include/accessibility_config_impl.h index 8b5f1846..7644c8fd 100644 --- a/frameworks/acfwk/include/accessibility_config_impl.h +++ b/frameworks/acfwk/include/accessibility_config_impl.h @@ -16,13 +16,13 @@ #ifndef ACCESSIBILITY_CONFIG_IMPL_H #define ACCESSIBILITY_CONFIG_IMPL_H -#include -#include #include "accessibility_config.h" #include "accessibility_enable_ability_lists_observer_stub.h" #include "accessible_ability_manager_caption_observer_stub.h" #include "accessible_ability_manager_config_observer_stub.h" #include "accessible_ability_manager_service_proxy.h" +#include "ffrt.h" +#include "ffrt_inner.h" #include "event_handler.h" #include "refbase.h" #include "system_ability_load_callback_stub.h" @@ -330,13 +330,13 @@ private: std::vector shortkeyMultiTarget_ {}; std::vector> enableAbilityListsObservers_; std::map>> configObservers_; - std::mutex mutex_; + ffrt::mutex mutex_; std::shared_ptr runner_; std::shared_ptr handler_; - std::condition_variable proxyConVar_; - std::mutex conVarMutex_; // mutex for proxyConVar + ffrt::condition_variable proxyConVar_; + ffrt::mutex conVarMutex_; // mutex for proxyConVar }; } // namespace AccessibilityConfig } // namespace OHOS diff --git a/frameworks/acfwk/src/accessibility_config_impl.cpp b/frameworks/acfwk/src/accessibility_config_impl.cpp index 850a8e32..de147941 100644 --- a/frameworks/acfwk/src/accessibility_config_impl.cpp +++ b/frameworks/acfwk/src/accessibility_config_impl.cpp @@ -86,7 +86,7 @@ bool AccessibilityConfig::Impl::ConnectToService() bool AccessibilityConfig::Impl::ConnectToServiceAsync() { HILOG_DEBUG("ConnectToServiceAsync start."); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (InitAccessibilityServiceProxy()) { (void)RegisterToService(); InitConfigValues(); @@ -135,7 +135,7 @@ bool AccessibilityConfig::Impl::InitAccessibilityServiceProxy() bool AccessibilityConfig::Impl::LoadAccessibilityService() { - std::unique_lock lock(conVarMutex_); + std::unique_lock lock(conVarMutex_); sptr loadCallback = new AccessibilityLoadCallback(this); if (loadCallback == nullptr) { return false; @@ -160,7 +160,7 @@ bool AccessibilityConfig::Impl::LoadAccessibilityService() void AccessibilityConfig::Impl::LoadSystemAbilitySuccess(const sptr &remoteObject) { - std::lock_guard lock(conVarMutex_); + std::lock_guard lock(conVarMutex_); char value[CONFIG_PARAMETER_VALUE_SIZE] = "default"; int retSysParam = GetParameter(SYSTEM_PARAMETER_AAMS_NAME.c_str(), "false", value, CONFIG_PARAMETER_VALUE_SIZE); if (retSysParam >= 0 && !std::strcmp(value, "true")) { @@ -188,7 +188,7 @@ void AccessibilityConfig::Impl::LoadSystemAbilitySuccess(const sptr lock(conVarMutex_); + std::lock_guard lock(conVarMutex_); HILOG_WARN("LoadSystemAbilityFail."); proxyConVar_.notify_one(); } @@ -255,7 +255,7 @@ sptr AccessibilityConfig::Impl: void AccessibilityConfig::Impl::ResetService(const wptr &remote) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ != nullptr) { sptr object = serviceProxy_->AsObject(); if (object != nullptr && (remote == object)) { @@ -296,7 +296,7 @@ bool AccessibilityConfig::Impl::CheckSaStatus() Accessibility::RetError AccessibilityConfig::Impl::EnableAbility(const std::string &name, const uint32_t capabilities) { HILOG_INFO("name = [%{private}s] capabilities = [%{private}u]", name.c_str(), capabilities); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -307,7 +307,7 @@ Accessibility::RetError AccessibilityConfig::Impl::EnableAbility(const std::stri Accessibility::RetError AccessibilityConfig::Impl::DisableAbility(const std::string &name) { HILOG_INFO("name = [%{private}s]", name.c_str()); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -317,7 +317,7 @@ Accessibility::RetError AccessibilityConfig::Impl::DisableAbility(const std::str Accessibility::RetError AccessibilityConfig::Impl::GetCaptionsState(bool &state) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -329,7 +329,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetCaptionsState(bool &state) Accessibility::RetError AccessibilityConfig::Impl::GetCaptionsProperty(CaptionProperty &caption) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -342,7 +342,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetCaptionsProperty(CaptionPr Accessibility::RetError AccessibilityConfig::Impl::SetCaptionsProperty(const CaptionProperty& caption) { HILOG_INFO(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -353,7 +353,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetCaptionsProperty(const Cap Accessibility::RetError AccessibilityConfig::Impl::SetCaptionsState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -395,7 +395,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SubscribeConfigObserver(const const std::shared_ptr &observer, const bool retFlag) { HILOG_DEBUG("id = [%{public}d]", static_cast(id)); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); std::map>>::iterator it = configObservers_.find(id); if (it != configObservers_.end()) { @@ -418,7 +418,7 @@ Accessibility::RetError AccessibilityConfig::Impl::UnsubscribeConfigObserver(con const std::shared_ptr &observer) { HILOG_INFO("id = [%{public}d]", static_cast(id)); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); std::map>>::iterator it = configObservers_.find(id); if (it != configObservers_.end()) { @@ -441,7 +441,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerCaptionPropertyChanged HILOG_DEBUG(); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (captionProperty_.GetFontScale() == property.GetFontScale() && captionProperty_.GetFontColor() == property.GetFontColor() && !strcmp(captionProperty_.GetFontFamily().c_str(), property.GetFontFamily().c_str()) && @@ -465,7 +465,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerCaptionPropertyChanged Accessibility::RetError AccessibilityConfig::Impl::SetScreenMagnificationState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -476,7 +476,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetScreenMagnificationState(c Accessibility::RetError AccessibilityConfig::Impl::SetShortKeyState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -487,7 +487,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetShortKeyState(const bool s Accessibility::RetError AccessibilityConfig::Impl::SetMouseKeyState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -497,7 +497,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetMouseKeyState(const bool s Accessibility::RetError AccessibilityConfig::Impl::GetScreenMagnificationState(bool &state) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -510,7 +510,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetScreenMagnificationState(b Accessibility::RetError AccessibilityConfig::Impl::GetShortKeyState(bool &state) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -523,7 +523,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetShortKeyState(bool &state) Accessibility::RetError AccessibilityConfig::Impl::GetMouseKeyState(bool &state) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -538,7 +538,7 @@ void AccessibilityConfig::Impl::UpdateCaptionEnabled(const bool enabled) { std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (captionState_ == enabled) { return; } @@ -557,7 +557,7 @@ void AccessibilityConfig::Impl::UpdateScreenMagnificationEnabled(const bool enab { std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (screenMagnifier_ == enabled) { return; } @@ -576,7 +576,7 @@ void AccessibilityConfig::Impl::UpdateShortKeyEnabled(const bool enabled) { std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (shortkey_ == enabled) { return; } @@ -595,7 +595,7 @@ void AccessibilityConfig::Impl::UpdateMouseKeyEnabled(const bool enabled) { std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (mouseKey_ == enabled) { return; } @@ -614,7 +614,7 @@ void AccessibilityConfig::Impl::UpdateAudioMonoEnabled(const bool enabled) { std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (audioMono_ == enabled) { return; } @@ -633,7 +633,7 @@ void AccessibilityConfig::Impl::UpdateAnimationOffEnabled(const bool enabled) { std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (animationOff_ == enabled) { return; } @@ -653,7 +653,7 @@ void AccessibilityConfig::Impl::UpdateInvertColorEnabled(const bool enabled) { std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (invertColor_ == enabled) { return; } @@ -673,7 +673,7 @@ void AccessibilityConfig::Impl::UpdateHighContrastTextEnabled(const bool enabled HILOG_INFO("enabled = [%{public}s]", enabled ? "True" : "False"); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (highContrastText_ == enabled) { return; } @@ -693,7 +693,7 @@ void AccessibilityConfig::Impl::UpdateDaltonizationStateEnabled(const bool enabl HILOG_INFO("enabled = [%{public}s]", enabled ? "True" : "False"); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (daltonizationState_ == enabled) { return; } @@ -719,7 +719,7 @@ void AccessibilityConfig::Impl::UpdateIgnoreRepeatClickStateEnabled(const bool e { std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (ignoreRepeatClickState_ == enabled) { return; } @@ -857,7 +857,7 @@ void AccessibilityConfig::Impl::NotifyAnimationOffChanged( Accessibility::RetError AccessibilityConfig::Impl::SetMouseAutoClick(const int32_t time) { HILOG_INFO("time = [%{public}d]", time); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -868,7 +868,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetMouseAutoClick(const int32 Accessibility::RetError AccessibilityConfig::Impl::SetShortkeyTarget(const std::string& name) { HILOG_INFO("name = [%{public}s]", name.c_str()); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -879,7 +879,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetShortkeyTarget(const std:: Accessibility::RetError AccessibilityConfig::Impl::SetShortkeyMultiTarget(const std::vector& name) { HILOG_INFO("start"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -889,7 +889,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetShortkeyMultiTarget(const Accessibility::RetError AccessibilityConfig::Impl::GetMouseAutoClick(int32_t &time) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -902,7 +902,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetMouseAutoClick(int32_t &ti Accessibility::RetError AccessibilityConfig::Impl::GetShortkeyTarget(std::string &name) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -915,7 +915,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetShortkeyTarget(std::string Accessibility::RetError AccessibilityConfig::Impl::GetShortkeyMultiTarget(std::vector &name) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1085,7 +1085,7 @@ void AccessibilityConfig::Impl::NotifyIgnoreRepeatClickStateChanged( Accessibility::RetError AccessibilityConfig::Impl::SetHighContrastTextState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1096,7 +1096,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetHighContrastTextState(cons Accessibility::RetError AccessibilityConfig::Impl::SetInvertColorState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1107,7 +1107,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetInvertColorState(const boo Accessibility::RetError AccessibilityConfig::Impl::SetDaltonizationState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1118,7 +1118,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetDaltonizationState(const b Accessibility::RetError AccessibilityConfig::Impl::SetDaltonizationColorFilter(const DALTONIZATION_TYPE type) { HILOG_INFO("type = [%{public}u]", static_cast(type)); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1129,7 +1129,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetDaltonizationColorFilter(c Accessibility::RetError AccessibilityConfig::Impl::SetContentTimeout(const uint32_t timer) { HILOG_INFO("timer = [%{public}u]", timer); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1140,7 +1140,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetContentTimeout(const uint3 Accessibility::RetError AccessibilityConfig::Impl::SetAnimationOffState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1151,7 +1151,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetAnimationOffState(const bo Accessibility::RetError AccessibilityConfig::Impl::SetBrightnessDiscount(const float brightness) { HILOG_INFO("brightness = [%{public}f]", brightness); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1162,7 +1162,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetBrightnessDiscount(const f Accessibility::RetError AccessibilityConfig::Impl::SetAudioMonoState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1173,7 +1173,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetAudioMonoState(const bool Accessibility::RetError AccessibilityConfig::Impl::SetAudioBalance(const float balance) { HILOG_INFO("balance = [%{public}f]", balance); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1184,7 +1184,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetAudioBalance(const float b Accessibility::RetError AccessibilityConfig::Impl::SetClickResponseTime(const CLICK_RESPONSE_TIME time) { HILOG_INFO("click response time = [%{public}u]", time); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1195,7 +1195,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetClickResponseTime(const CL Accessibility::RetError AccessibilityConfig::Impl::SetIgnoreRepeatClickState(const bool state) { HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1206,7 +1206,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetIgnoreRepeatClickState(con Accessibility::RetError AccessibilityConfig::Impl::SetIgnoreRepeatClickTime(const IGNORE_REPEAT_CLICK_TIME time) { HILOG_INFO("ignore repeat click time = [%{public}u]", time); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1216,7 +1216,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SetIgnoreRepeatClickTime(cons Accessibility::RetError AccessibilityConfig::Impl::GetInvertColorState(bool &state) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1229,7 +1229,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetInvertColorState(bool &sta Accessibility::RetError AccessibilityConfig::Impl::GetHighContrastTextState(bool &state) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1242,7 +1242,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetHighContrastTextState(bool Accessibility::RetError AccessibilityConfig::Impl::GetDaltonizationState(bool &state) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1255,7 +1255,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetDaltonizationState(bool &s Accessibility::RetError AccessibilityConfig::Impl::GetDaltonizationColorFilter(DALTONIZATION_TYPE &type) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1270,7 +1270,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetDaltonizationColorFilter(D Accessibility::RetError AccessibilityConfig::Impl::GetContentTimeout(uint32_t &timer) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1283,7 +1283,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetContentTimeout(uint32_t &t Accessibility::RetError AccessibilityConfig::Impl::GetAnimationOffState(bool &state) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1296,7 +1296,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetAnimationOffState(bool &st Accessibility::RetError AccessibilityConfig::Impl::GetBrightnessDiscount(float &brightness) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1309,7 +1309,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetBrightnessDiscount(float & Accessibility::RetError AccessibilityConfig::Impl::GetAudioMonoState(bool &state) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1322,7 +1322,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetAudioMonoState(bool &state Accessibility::RetError AccessibilityConfig::Impl::GetAudioBalance(float &balance) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1335,7 +1335,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetAudioBalance(float &balanc Accessibility::RetError AccessibilityConfig::Impl::GetClickResponseTime(CLICK_RESPONSE_TIME &time) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1350,7 +1350,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetClickResponseTime(CLICK_RE Accessibility::RetError AccessibilityConfig::Impl::GetIgnoreRepeatClickState(bool &state) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1363,7 +1363,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetIgnoreRepeatClickState(boo Accessibility::RetError AccessibilityConfig::Impl::GetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_TIME &time) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!GetServiceProxy()) { HILOG_ERROR("Failed to get accessibility service"); return Accessibility::RET_ERR_SAMGR; @@ -1380,7 +1380,7 @@ Accessibility::RetError AccessibilityConfig::Impl::SubscribeEnableAbilityListsOb const std::shared_ptr &observer) { HILOG_INFO(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (std::any_of(enableAbilityListsObservers_.begin(), enableAbilityListsObservers_.end(), [&observer](const std::shared_ptr &listObserver) { return listObserver == observer; @@ -1397,7 +1397,7 @@ Accessibility::RetError AccessibilityConfig::Impl::UnsubscribeEnableAbilityLists const std::shared_ptr &observer) { HILOG_INFO(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto iter = enableAbilityListsObservers_.begin(); iter != enableAbilityListsObservers_.end(); iter++) { if (*iter == observer) { HILOG_DEBUG("erase observer"); @@ -1414,7 +1414,7 @@ void AccessibilityConfig::Impl::OnAccessibilityEnableAbilityListsChanged() HILOG_DEBUG("observer's size is %{public}zu", enableAbilityListsObservers_.size()); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); observers = enableAbilityListsObservers_; } for (auto &enableAbilityListsObserver : observers) { @@ -1427,7 +1427,7 @@ void AccessibilityConfig::Impl::OnAccessibilityInstallAbilityListsChanged() HILOG_DEBUG("observer's size is %{public}zu", enableAbilityListsObservers_.size()); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); observers = enableAbilityListsObservers_; } for (auto &enableAbilityListsObserver : observers) { @@ -1513,7 +1513,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerAudioBalanceChanged(co HILOG_DEBUG("audioBalance = [%{public}f}", audioBalance); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (audioBalance_ == audioBalance) { return; } @@ -1535,7 +1535,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerBrightnessDiscountChan std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (brightnessDiscount_ == brightnessDiscount) { return; } @@ -1556,7 +1556,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerContentTimeoutChanged( HILOG_DEBUG("contentTimeout = [%{public}u}", contentTimeout); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (contentTimeout_ == contentTimeout) { return; } @@ -1577,7 +1577,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerDaltonizationColorFilt HILOG_DEBUG("filterType = [%{public}u}", filterType); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (daltonizationColorFilter_ == filterType) { HILOG_DEBUG("filterType[%{public}u]", daltonizationColorFilter_); return; @@ -1599,7 +1599,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerMouseAutoClickChanged( HILOG_DEBUG("mouseAutoClick = [%{public}d}", mouseAutoClick); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (mouseAutoClick_ == mouseAutoClick) { return; } @@ -1620,7 +1620,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerShortkeyTargetChanged( HILOG_DEBUG("shortkeyTarget = [%{public}s}", shortkeyTarget.c_str()); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (shortkeyTarget_.length() > 0 && shortkeyTarget.length() > 0 && !std::strcmp(shortkeyTarget_.c_str(), shortkeyTarget.c_str())) { return; @@ -1643,7 +1643,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerShortkeyMultiTargetCha HILOG_DEBUG("start"); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); // need to add, if no change, do not inform shortkeyMultiTarget_ = shortkeyMultiTarget; std::map>>::iterator it = @@ -1663,7 +1663,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerClickResponseTimeChang HILOG_DEBUG("clickResponseTime = [%{public}u}", clickResponseTime); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (clickResponseTime_ == clickResponseTime) { return; } @@ -1684,7 +1684,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerIgnoreRepeatClickTimeC HILOG_DEBUG("ignoreRepeatClickTime = [%{public}u}", time); std::vector> observers; { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (ignoreRepeatClickTime_ == time) { return; } diff --git a/frameworks/acfwk/test/BUILD.gn b/frameworks/acfwk/test/BUILD.gn index fe1869cb..9a5ad252 100644 --- a/frameworks/acfwk/test/BUILD.gn +++ b/frameworks/acfwk/test/BUILD.gn @@ -79,6 +79,7 @@ ohos_unittest("ac_unit_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_core", diff --git a/frameworks/acfwk/test/mock/src/mock_service_registry.cpp b/frameworks/acfwk/test/mock/src/mock_service_registry.cpp index 9a97db1d..7c809acb 100644 --- a/frameworks/acfwk/test/mock/src/mock_service_registry.cpp +++ b/frameworks/acfwk/test/mock/src/mock_service_registry.cpp @@ -32,7 +32,6 @@ SystemAbilityManagerClient& SystemAbilityManagerClient::GetInstance() sptr SystemAbilityManagerClient::GetSystemAbilityManager() { - std::lock_guard lock(systemAbilityManagerLock_); if (systemAbilityManager_ != nullptr) { return systemAbilityManager_; } diff --git a/frameworks/asacfwk/include/accessibility_element_operator_impl.h b/frameworks/asacfwk/include/accessibility_element_operator_impl.h index b9978374..8aa50627 100644 --- a/frameworks/asacfwk/include/accessibility_element_operator_impl.h +++ b/frameworks/asacfwk/include/accessibility_element_operator_impl.h @@ -22,6 +22,7 @@ #include "accessibility_element_operator_stub.h" #include "accessibility_element_operator.h" #include "nocopyable.h" +#include "ffrt.h" namespace OHOS { namespace Accessibility { @@ -222,7 +223,7 @@ public: private: int32_t AddRequest(int32_t requestId, const sptr &callback); - std::mutex mutex_; + ffrt::mutex mutex_; int32_t windowId_ = 0; AccessibilityElementOperatorCallback &operatorCallback_; std::shared_ptr operator_ = nullptr; diff --git a/frameworks/asacfwk/include/accessibility_system_ability_client_impl.h b/frameworks/asacfwk/include/accessibility_system_ability_client_impl.h index 144e3b64..61280e37 100644 --- a/frameworks/asacfwk/include/accessibility_system_ability_client_impl.h +++ b/frameworks/asacfwk/include/accessibility_system_ability_client_impl.h @@ -17,11 +17,11 @@ #define ACCESSIBILITY_SYSTEM_ABILITY_CLIENT_IMPL_H #include -#include -#include #include "accessibility_element_operator_impl.h" #include "accessibility_system_ability_client.h" #include "accessible_ability_manager_state_observer_stub.h" +#include "ffrt.h" +#include "ffrt_inner.h" #include "i_accessible_ability_manager_service.h" #include "refbase.h" #include "system_ability_load_callback_stub.h" @@ -302,7 +302,7 @@ private: void ReregisterElementOperator(); uint32_t state_{0}; - std::mutex mutex_; + ffrt::mutex mutex_; StateArray stateArray_; StateObserversArray stateObserversArray_; @@ -312,8 +312,8 @@ private: sptr serviceProxy_ = nullptr; sptr stateObserver_ = nullptr; - std::condition_variable proxyConVar_; - std::mutex conVarMutex_; // mutex for proxyConVar + ffrt::condition_variable proxyConVar_; + ffrt::mutex conVarMutex_; // mutex for proxyConVar }; } // namespace Accessibility } // namespace OHOS diff --git a/frameworks/asacfwk/src/accessibility_element_operator_impl.cpp b/frameworks/asacfwk/src/accessibility_element_operator_impl.cpp index 9f766017..d2f12658 100644 --- a/frameworks/asacfwk/src/accessibility_element_operator_impl.cpp +++ b/frameworks/asacfwk/src/accessibility_element_operator_impl.cpp @@ -166,7 +166,7 @@ void AccessibilityElementOperatorImpl::SetParentWindowId(const int32_t parentWin int32_t AccessibilityElementOperatorImpl::AddRequest(int32_t requestId, const sptr &callback) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); requestWindId_[requestId] = windowId_; auto iter = requests_.find(requestId); @@ -188,7 +188,7 @@ void AccessibilityElementOperatorImpl::SetSearchElementInfoByAccessibilityIdResu const std::list &infos, const int32_t requestId) { HILOG_DEBUG("requestId is %{public}d", requestId); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); std::vector filterInfos = TranslateListToVector(infos); auto iter = requests_.find(requestId); if (iter != requests_.end()) { @@ -221,7 +221,7 @@ void AccessibilityElementOperatorImpl::SetSearchElementInfoByTextResult( const std::list &infos, const int32_t requestId) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); std::vector myInfos = TranslateListToVector(infos); auto iter = requests_.find(requestId); if (iter != requests_.end()) { @@ -238,7 +238,7 @@ void AccessibilityElementOperatorImpl::SetFindFocusedElementInfoResult( const AccessibilityElementInfo &info, const int32_t requestId) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto iter = requests_.find(requestId); if (iter != requests_.end()) { if (iter->second != nullptr) { @@ -254,7 +254,7 @@ void AccessibilityElementOperatorImpl::SetFocusMoveSearchResult( const AccessibilityElementInfo &info, const int32_t requestId) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto iter = requests_.find(requestId); if (iter != requests_.end()) { if (iter->second != nullptr) { @@ -270,7 +270,7 @@ void AccessibilityElementOperatorImpl::SetExecuteActionResult( const bool succeeded, const int32_t requestId) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto iter = requests_.find(requestId); if (iter != requests_.end()) { if (iter->second != nullptr) { @@ -286,7 +286,7 @@ void AccessibilityElementOperatorImpl::SetExecuteActionResult( void AccessibilityElementOperatorImpl::SetCursorPositionResult(const int32_t cursorPosition, const int32_t requestId) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto iter = requests_.find(requestId); if (iter != requests_.end()) { if (iter->second != nullptr) { diff --git a/frameworks/asacfwk/src/accessibility_system_ability_client_impl.cpp b/frameworks/asacfwk/src/accessibility_system_ability_client_impl.cpp index 07efea37..141137b0 100644 --- a/frameworks/asacfwk/src/accessibility_system_ability_client_impl.cpp +++ b/frameworks/asacfwk/src/accessibility_system_ability_client_impl.cpp @@ -27,12 +27,12 @@ namespace { constexpr int32_t SA_CONNECT_TIMEOUT = 500; // ms } // namespaces -static std::mutex g_Mutex; +static ffrt::mutex g_Mutex; static std::shared_ptr g_Instance = nullptr; std::shared_ptr AccessibilitySystemAbilityClient::GetInstance() { HILOG_DEBUG(); - std::lock_guard lock(g_Mutex); + std::lock_guard lock(g_Mutex); if (!g_Instance) { g_Instance = std::make_shared(); } else { @@ -113,7 +113,7 @@ bool AccessibilitySystemAbilityClientImpl::ConnectToService() bool AccessibilitySystemAbilityClientImpl::LoadAccessibilityService() { - std::unique_lock lock(conVarMutex_); + std::unique_lock lock(conVarMutex_); sptr loadCallback = new AccessibilityLoadCallback(); if (loadCallback == nullptr) { return false; @@ -136,7 +136,7 @@ bool AccessibilitySystemAbilityClientImpl::LoadAccessibilityService() void AccessibilitySystemAbilityClientImpl::LoadSystemAbilitySuccess(const sptr &remoteObject) { - std::lock_guard lock(conVarMutex_); + std::lock_guard lock(conVarMutex_); if (serviceProxy_ != nullptr) { HILOG_INFO("serviceProxy_ isn't nullptr"); proxyConVar_.notify_one(); @@ -161,7 +161,7 @@ void AccessibilitySystemAbilityClientImpl::LoadSystemAbilitySuccess(const sptr lock(conVarMutex_); + std::lock_guard lock(conVarMutex_); HILOG_WARN("LoadSystemAbilityFail."); proxyConVar_.notify_one(); } @@ -198,7 +198,7 @@ void AccessibilitySystemAbilityClientImpl::Init() void AccessibilitySystemAbilityClientImpl::ResetService(const wptr &remote) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ != nullptr) { sptr object = serviceProxy_->AsObject(); if (object && (remote == object)) { @@ -213,7 +213,7 @@ RetError AccessibilitySystemAbilityClientImpl::RegisterElementOperator( const int32_t windowId, const std::shared_ptr &operation) { HILOG_INFO("Register windowId[%{public}d] start", windowId); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!operation) { HILOG_ERROR("Input operation is null"); return RET_ERR_INVALID_PARAM; @@ -249,7 +249,7 @@ RetError AccessibilitySystemAbilityClientImpl::RegisterElementOperator(Registrat HILOG_DEBUG("parentWindowId:%{public}d, parentTreeId:%{public}d, windowId:%{public}d,nodeId:%{public}" PRId64 "", parameter.parentWindowId, parameter.parentTreeId, parameter.windowId, parameter.elementId); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (parameter.windowId < 0 || parameter.elementId < 0 || parameter.parentTreeId < 0 || parameter.parentWindowId < 0) { return RET_ERR_INVALID_PARAM; @@ -291,7 +291,7 @@ void AccessibilitySystemAbilityClientImpl::ReregisterElementOperator() RetError AccessibilitySystemAbilityClientImpl::DeregisterElementOperator(const int32_t windowId) { HILOG_INFO("Deregister windowId[%{public}d] start", windowId); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ == nullptr) { HILOG_ERROR("Failed to get aams service"); @@ -315,7 +315,7 @@ RetError AccessibilitySystemAbilityClientImpl::DeregisterElementOperator(const i RetError AccessibilitySystemAbilityClientImpl::DeregisterElementOperator(const int32_t windowId, const int32_t treeId) { HILOG_INFO("Deregister windowId[%{public}d] treeId[%{public}d] start", windowId, treeId); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ == nullptr) { HILOG_ERROR("Failed to get aams service"); @@ -328,7 +328,7 @@ RetError AccessibilitySystemAbilityClientImpl::DeregisterElementOperator(const i RetError AccessibilitySystemAbilityClientImpl::IsEnabled(bool &isEnabled) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); isEnabled = stateArray_[AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED]; return RET_OK; } @@ -336,7 +336,7 @@ RetError AccessibilitySystemAbilityClientImpl::IsEnabled(bool &isEnabled) RetError AccessibilitySystemAbilityClientImpl::IsTouchExplorationEnabled(bool &isEnabled) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); isEnabled = stateArray_[AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED]; return RET_OK; } @@ -345,7 +345,7 @@ RetError AccessibilitySystemAbilityClientImpl::GetAbilityList(const uint32_t acc const AbilityStateType stateType, std::vector &infos) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); bool check = false; if ((accessibilityAbilityTypes & AccessibilityAbilityTypes::ACCESSIBILITY_ABILITY_TYPE_SPOKEN) || (accessibilityAbilityTypes & AccessibilityAbilityTypes::ACCESSIBILITY_ABILITY_TYPE_HAPTIC) || @@ -387,7 +387,7 @@ bool AccessibilitySystemAbilityClientImpl::CheckEventType(EventType eventType) RetError AccessibilitySystemAbilityClientImpl::SendEvent(const EventType eventType, const int64_t componentId) { HILOG_DEBUG("componentId[%{public}" PRId64 "], eventType[%{public}d]", componentId, eventType); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!CheckEventType(eventType)) { return RET_ERR_INVALID_PARAM; } @@ -408,7 +408,7 @@ RetError AccessibilitySystemAbilityClientImpl::SendEvent(const EventType eventTy RetError AccessibilitySystemAbilityClientImpl::SendEvent(const AccessibilityEventInfo &event) { HILOG_DEBUG("EventType[%{public}d]", event.GetEventType()); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!CheckEventType(event.GetEventType())) { return RET_ERR_INVALID_PARAM; } @@ -427,7 +427,7 @@ RetError AccessibilitySystemAbilityClientImpl::SubscribeStateObserver( const std::shared_ptr &observer, const uint32_t eventType) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (eventType >= AccessibilityStateEventType::EVENT_TYPE_MAX) { HILOG_ERROR("Input eventType is out of scope"); return RET_ERR_INVALID_PARAM; @@ -452,7 +452,7 @@ RetError AccessibilitySystemAbilityClientImpl::UnsubscribeStateObserver( const std::shared_ptr &observer, const uint32_t eventType) { HILOG_DEBUG("eventType is [%{public}d]", eventType); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (eventType >= AccessibilityStateEventType::EVENT_TYPE_MAX) { HILOG_ERROR("Input eventType is out of scope"); return RET_ERR_INVALID_PARAM; @@ -501,7 +501,7 @@ void AccessibilitySystemAbilityClientImpl::NotifyStateChanged(uint32_t eventType RetError AccessibilitySystemAbilityClientImpl::GetEnabledAbilities(std::vector &enabledAbilities) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ == nullptr) { HILOG_ERROR("Failed to get aams service"); return RET_ERR_SAMGR; @@ -517,7 +517,7 @@ void AccessibilitySystemAbilityClientImpl::OnAccessibleAbilityManagerStateChange { HILOG_DEBUG("stateType[%{public}d}", stateType); SetAccessibilityState(stateType); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (stateType & STATE_ACCESSIBILITY_ENABLED) { NotifyStateChanged(AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED, true); } else { @@ -546,7 +546,7 @@ void AccessibilitySystemAbilityClientImpl::OnAccessibleAbilityManagerStateChange void AccessibilitySystemAbilityClientImpl::SetSearchElementInfoByAccessibilityIdResult( const std::list &infos, const int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); HILOG_DEBUG("search element requestId[%{public}d]", requestId); if (serviceProxy_ == nullptr) { HILOG_ERROR("serviceProxy_ is nullptr"); @@ -563,9 +563,9 @@ void AccessibilitySystemAbilityClientImpl::SetSearchElementInfoByAccessibilityId if (callback->GetFilter()) { AccessibilityElementOperatorImpl::SetFiltering(filterInfos); } + serviceProxy_->RemoveRequestId(requestId); callback->SetSearchElementInfoByAccessibilityIdResult(filterInfos, requestId); AccessibilityElementOperatorImpl::EraseCallback(requestId); - serviceProxy_->RemoveRequestId(requestId); } else { HILOG_INFO("callback is nullptr"); } @@ -574,7 +574,7 @@ void AccessibilitySystemAbilityClientImpl::SetSearchElementInfoByAccessibilityId void AccessibilitySystemAbilityClientImpl::SetSearchElementInfoByTextResult( const std::list &infos, const int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); HILOG_DEBUG("requestId[%{public}d]", requestId); if (serviceProxy_ == nullptr) { HILOG_ERROR("serviceProxy_ is nullptr"); @@ -585,9 +585,9 @@ void AccessibilitySystemAbilityClientImpl::SetSearchElementInfoByTextResult( AccessibilityElementOperatorImpl::GetCallbackByRequestId(requestId); if (requestId >= 0) { if (callback != nullptr) { + serviceProxy_->RemoveRequestId(requestId); callback->SetSearchElementInfoByTextResult(filterInfos, requestId); AccessibilityElementOperatorImpl::EraseCallback(requestId); - serviceProxy_->RemoveRequestId(requestId); } else { HILOG_INFO("callback is nullptr"); } @@ -597,7 +597,7 @@ void AccessibilitySystemAbilityClientImpl::SetSearchElementInfoByTextResult( void AccessibilitySystemAbilityClientImpl::SetFindFocusedElementInfoResult( const AccessibilityElementInfo &info, const int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); HILOG_DEBUG("requestId[%{public}d]", requestId); if (serviceProxy_ == nullptr) { HILOG_ERROR("serviceProxy_ is nullptr"); @@ -607,9 +607,9 @@ void AccessibilitySystemAbilityClientImpl::SetFindFocusedElementInfoResult( AccessibilityElementOperatorImpl::GetCallbackByRequestId(requestId); if (requestId >= 0) { if (callback != nullptr) { + serviceProxy_->RemoveRequestId(requestId); callback->SetFindFocusedElementInfoResult(info, requestId); AccessibilityElementOperatorImpl::EraseCallback(requestId); - serviceProxy_->RemoveRequestId(requestId); } else { HILOG_INFO("callback is nullptr"); } @@ -619,7 +619,7 @@ void AccessibilitySystemAbilityClientImpl::SetFindFocusedElementInfoResult( void AccessibilitySystemAbilityClientImpl::SetFocusMoveSearchResult( const AccessibilityElementInfo &info, const int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); HILOG_DEBUG("requestId[%{public}d]", requestId); if (serviceProxy_ == nullptr) { HILOG_ERROR("serviceProxy_ is nullptr"); @@ -629,9 +629,9 @@ void AccessibilitySystemAbilityClientImpl::SetFocusMoveSearchResult( AccessibilityElementOperatorImpl::GetCallbackByRequestId(requestId); if (requestId >= 0) { if (callback != nullptr) { + serviceProxy_->RemoveRequestId(requestId); callback->SetFocusMoveSearchResult(info, requestId); AccessibilityElementOperatorImpl::EraseCallback(requestId); - serviceProxy_->RemoveRequestId(requestId); } else { HILOG_INFO("callback is nullptr"); } @@ -641,7 +641,7 @@ void AccessibilitySystemAbilityClientImpl::SetFocusMoveSearchResult( void AccessibilitySystemAbilityClientImpl::SetExecuteActionResult( const bool succeeded, const int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); HILOG_DEBUG("requestId[%{public}d]", requestId); if (serviceProxy_ == nullptr) { HILOG_ERROR("serviceProxy_ is nullptr"); @@ -651,9 +651,9 @@ void AccessibilitySystemAbilityClientImpl::SetExecuteActionResult( AccessibilityElementOperatorImpl::GetCallbackByRequestId(requestId); if (requestId >= 0) { if (callback != nullptr) { + serviceProxy_->RemoveRequestId(requestId); callback->SetExecuteActionResult(succeeded, requestId); AccessibilityElementOperatorImpl::EraseCallback(requestId); - serviceProxy_->RemoveRequestId(requestId); } else { HILOG_INFO("callback is nullptr"); } @@ -663,7 +663,7 @@ void AccessibilitySystemAbilityClientImpl::SetExecuteActionResult( void AccessibilitySystemAbilityClientImpl::SetCursorPositionResult( const int32_t cursorPosition, const int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); HILOG_DEBUG("requestId[%{public}d] cursorPosition[%{public}d]", requestId, cursorPosition); if (serviceProxy_ == nullptr) { HILOG_ERROR("serviceProxy_ is nullptr"); @@ -673,9 +673,9 @@ void AccessibilitySystemAbilityClientImpl::SetCursorPositionResult( AccessibilityElementOperatorImpl::GetCallbackByRequestId(requestId); if (requestId >= 0) { if (callback != nullptr) { + serviceProxy_->RemoveRequestId(requestId); callback->SetCursorPositionResult(cursorPosition, requestId); AccessibilityElementOperatorImpl::EraseCallback(requestId); - serviceProxy_->RemoveRequestId(requestId); } else { HILOG_INFO("callback is nullptr"); } @@ -742,7 +742,7 @@ void AccessibilitySystemAbilityClientImpl::SetPerformActionResult(const bool suc RetError AccessibilitySystemAbilityClientImpl::GetFocusedWindowId(int32_t &focusedWindowId) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (serviceProxy_ == nullptr) { HILOG_ERROR("Failed to get aams service"); return RET_ERR_SAMGR; @@ -778,7 +778,7 @@ void AccessibilitySystemAbilityClientImpl::AccessibilitySaStatusChange::OnAddSys if (!g_Instance) { return; } - std::lock_guard lock(g_Instance->mutex_); + std::lock_guard lock(g_Instance->mutex_); if (g_Instance->serviceProxy_) { return; } diff --git a/frameworks/asacfwk/test/BUILD.gn b/frameworks/asacfwk/test/BUILD.gn index 83a387df..c3bcad4b 100644 --- a/frameworks/asacfwk/test/BUILD.gn +++ b/frameworks/asacfwk/test/BUILD.gn @@ -79,6 +79,7 @@ ohos_unittest("asac_unit_test") { "data_share:datashare_common", "data_share:datashare_consumer", "eventhandler:libeventhandler", + "ffrt:libffrt", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_core", diff --git a/frameworks/common/src/accessibility_element_info.cpp b/frameworks/common/src/accessibility_element_info.cpp index 562c0ad1..8bfcc5e0 100644 --- a/frameworks/common/src/accessibility_element_info.cpp +++ b/frameworks/common/src/accessibility_element_info.cpp @@ -608,39 +608,39 @@ const std::string &AccessibleAction::GetDescriptionInfo() const return description_; } -RangeInfo::RangeInfo(int32_t min, int32_t max, int32_t current) +RangeInfo::RangeInfo(double min, double max, double current) { min_ = min; max_ = max; current_ = current; } -int32_t RangeInfo::GetMin() const +double RangeInfo::GetMin() const { return min_; } -int32_t RangeInfo::GetMax() const +double RangeInfo::GetMax() const { return max_; } -int32_t RangeInfo::GetCurrent() const +double RangeInfo::GetCurrent() const { return current_; } -void RangeInfo::SetMin(int32_t min) +void RangeInfo::SetMin(double min) { min_ = min; } -void RangeInfo::SetMax(int32_t max) +void RangeInfo::SetMax(double max) { max_ = max; } -void RangeInfo::SetCurrent(int32_t current) +void RangeInfo::SetCurrent(double current) { current_ = current; } diff --git a/frameworks/common/test/unittest/accessibility_element_info_test.cpp b/frameworks/common/test/unittest/accessibility_element_info_test.cpp index b7a5b9a8..aecd5e8f 100644 --- a/frameworks/common/test/unittest/accessibility_element_info_test.cpp +++ b/frameworks/common/test/unittest/accessibility_element_info_test.cpp @@ -1373,5 +1373,111 @@ HWTEST_F(AccessibilityElementInfoTest, SetAccessibilityLevel_001, TestSize.Level EXPECT_STREQ(elementInfo_->GetAccessibilityLevel().c_str(), "test"); GTEST_LOG_(INFO) << "SetAccessibilityLevel_001 end"; } + +/** + * @tc.number: SetZIndex_001 + * @tc.name: SetZIndex + * @tc.desc: Test function SetZIndex, GetZIndex + */ +HWTEST_F(AccessibilityElementInfoTest, SetZIndex_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetZIndex_001 start"; + elementInfo_->SetZIndex(1); + EXPECT_EQ(elementInfo_->GetZIndex(), 1); + GTEST_LOG_(INFO) << "SetZIndex_001 end"; +} + +/** + * @tc.number: SetOpacity_001 + * @tc.name: SetOpacity + * @tc.desc: Test function SetOpacity, GetOpacity + */ +HWTEST_F(AccessibilityElementInfoTest, SetOpacity_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetOpacity_001 start"; + elementInfo_->SetOpacity(0.5f); + EXPECT_FLOAT_EQ(elementInfo_->GetOpacity(), 0.5f); + GTEST_LOG_(INFO) << "SetOpacity_001 end"; +} + +/** + * @tc.number: SetBackgroundColor_001 + * @tc.name: SetBackgroundColor + * @tc.desc: Test function SetBackgroundColor, GetBackgroundColor + */ +HWTEST_F(AccessibilityElementInfoTest, SetBackgroundColor_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetBackgroundColor_001 start"; + elementInfo_->SetBackgroundColor("test"); + EXPECT_STREQ(elementInfo_->GetBackgroundColor().c_str(), "test"); + GTEST_LOG_(INFO) << "SetBackgroundColor_001 end"; +} + +/** + * @tc.number: SetBackgroundImage_001 + * @tc.name: SetBackgroundImage + * @tc.desc: Test function SetBackgroundImage, GetBackgroundImage + */ +HWTEST_F(AccessibilityElementInfoTest, SetBackgroundImage_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetBackgroundImage_001 start"; + elementInfo_->SetBackgroundImage("test"); + EXPECT_STREQ(elementInfo_->GetBackgroundImage().c_str(), "test"); + GTEST_LOG_(INFO) << "SetBackgroundImage_001 end"; +} + +/** + * @tc.number: SetBlur_001 + * @tc.name: SetBlur + * @tc.desc: Test function SetBlur, GetBlur + */ +HWTEST_F(AccessibilityElementInfoTest, SetBlur_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetBlur_001 start"; + elementInfo_->SetBlur("test"); + EXPECT_STREQ(elementInfo_->GetBlur().c_str(), "test"); + GTEST_LOG_(INFO) << "SetBlur_001 end"; +} + +/** + * @tc.number: SetHitTestBehavior_001 + * @tc.name: SetHitTestBehavior + * @tc.desc: Test function SetHitTestBehavior, GetHitTestBehavior + */ +HWTEST_F(AccessibilityElementInfoTest, SetHitTestBehavior_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetHitTestBehavior_001 start"; + elementInfo_->SetHitTestBehavior("test"); + EXPECT_STREQ(elementInfo_->GetHitTestBehavior().c_str(), "test"); + GTEST_LOG_(INFO) << "SetHitTestBehavior_001 end"; +} + +/** + * @tc.number: SetExtraElement_001 + * @tc.name: SetExtraElement + * @tc.desc: Test function SetExtraElement, GetExtraElement + */ +HWTEST_F(AccessibilityElementInfoTest, SetExtraElement_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetExtraElement_001 start"; + ExtraElementInfo extraElementInfo {}; + extraElementInfo.SetExtraElementInfo("Column", "1"); + elementInfo_->SetExtraElement(extraElementInfo); + EXPECT_TRUE(elementInfo_->GetExtraElement().GetExtraElementInfoValueStr().size() == 1); + GTEST_LOG_(INFO) << "SetExtraElement_001 end"; +} + +/** + * @tc.number: SetNavDestinationId_001 + * @tc.name: SetNavDestinationId + * @tc.desc: Test function SetNavDestinationId, GetNavDestinationId + */ +HWTEST_F(AccessibilityElementInfoTest, SetNavDestinationId_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetNavDestinationId_001 start"; + elementInfo_->SetNavDestinationId(1); + EXPECT_TRUE(elementInfo_->GetNavDestinationId() == 1); + GTEST_LOG_(INFO) << "SetNavDestinationId_001 end"; +} } // namespace Accessibility } // namespace OHOS \ No newline at end of file diff --git a/interfaces/innerkits/aafwk/BUILD.gn b/interfaces/innerkits/aafwk/BUILD.gn index 2466a4ad..11e1d924 100644 --- a/interfaces/innerkits/aafwk/BUILD.gn +++ b/interfaces/innerkits/aafwk/BUILD.gn @@ -67,6 +67,7 @@ ohos_shared_library("accessibleability") { external_deps = [ "c_utils:utils", + "ffrt:libffrt", "hilog:libhilog", "hitrace:hitrace_meter", "init:libbeget_proxy", diff --git a/interfaces/innerkits/acfwk/BUILD.gn b/interfaces/innerkits/acfwk/BUILD.gn index 638d8f9f..f889f2d1 100755 --- a/interfaces/innerkits/acfwk/BUILD.gn +++ b/interfaces/innerkits/acfwk/BUILD.gn @@ -66,6 +66,7 @@ ohos_shared_library("accessibilityconfig") { external_deps = [ "c_utils:utils", "eventhandler:libeventhandler", + "ffrt:libffrt", "hilog:libhilog", "init:libbeget_proxy", "init:libbegetutil", diff --git a/interfaces/innerkits/acfwk/include/accessibility_config_observer.h b/interfaces/innerkits/acfwk/include/accessibility_config_observer.h index ad9b3ec7..f604742d 100644 --- a/interfaces/innerkits/acfwk/include/accessibility_config_observer.h +++ b/interfaces/innerkits/acfwk/include/accessibility_config_observer.h @@ -20,6 +20,7 @@ #include #include #include "accessibility_config.h" +#include "ffrt.h" #include "napi/native_api.h" #include "napi/native_node_api.h" @@ -71,7 +72,7 @@ public: void UnsubscribeObservers(OHOS::AccessibilityConfig::CONFIG_ID id); private: - std::mutex mutex_; + ffrt::mutex mutex_; std::vector> observers_ = {}; }; #endif // ACCESSIBILITY_CONFIG_OBSERVER_H \ No newline at end of file diff --git a/interfaces/innerkits/asacfwk/BUILD.gn b/interfaces/innerkits/asacfwk/BUILD.gn index 9d823365..b26c6e3a 100644 --- a/interfaces/innerkits/asacfwk/BUILD.gn +++ b/interfaces/innerkits/asacfwk/BUILD.gn @@ -64,6 +64,7 @@ ohos_shared_library("accessibilityclient") { external_deps = [ "c_utils:utils", + "ffrt:libffrt", "hilog:libhilog", "init:libbeget_proxy", "init:libbegetutil", diff --git a/interfaces/innerkits/asacfwk/include/accessibility_system_ability_client.h b/interfaces/innerkits/asacfwk/include/accessibility_system_ability_client.h index 47140d9b..96f6367c 100644 --- a/interfaces/innerkits/asacfwk/include/accessibility_system_ability_client.h +++ b/interfaces/innerkits/asacfwk/include/accessibility_system_ability_client.h @@ -200,7 +200,7 @@ public: return; } splitTreeId = (static_cast(elementId) >> ELEMENT_MOVE_BIT); - splitElementId = MAX_ELEMENT_ID & elementId; + splitElementId = (static_cast(elementId) & MAX_ELEMENT_ID); } }; } // namespace Accessibility diff --git a/interfaces/innerkits/common/include/accessibility_element_info.h b/interfaces/innerkits/common/include/accessibility_element_info.h index a336e850..074e1458 100644 --- a/interfaces/innerkits/common/include/accessibility_element_info.h +++ b/interfaces/innerkits/common/include/accessibility_element_info.h @@ -75,48 +75,48 @@ public: * @param max The max value * @param current current value */ - RangeInfo(int32_t min, int32_t max, int32_t current); + RangeInfo(double min, double max, double current); /** * @brief Gets the min value. * @return min value */ - int32_t GetMin() const; + double GetMin() const; /** * @brief Gets the max value. * @return max value. */ - int32_t GetMax() const; + double GetMax() const; /** * @brief Gets the current value. * @return current value. */ - int32_t GetCurrent() const; + double GetCurrent() const; /** * @brief Sets the min value. * @param min min value */ - void SetMin(int32_t min); + void SetMin(double min); /** * @brief Sets the max value. * @param max max value. */ - void SetMax(int32_t max); + void SetMax(double max); /** * @brief Sets the current value. * @param current current value */ - void SetCurrent(int32_t current); + void SetCurrent(double current); protected: - int32_t min_ = 0; - int32_t max_ = 0; - int32_t current_ = 0; + double min_ = 0; + double max_ = 0; + double current_ = 0; }; /** diff --git a/interfaces/innerkits/test/benchmarktest/accessibility_config_test/BUILD.gn b/interfaces/innerkits/test/benchmarktest/accessibility_config_test/BUILD.gn index 17a7d5aa..c593de01 100644 --- a/interfaces/innerkits/test/benchmarktest/accessibility_config_test/BUILD.gn +++ b/interfaces/innerkits/test/benchmarktest/accessibility_config_test/BUILD.gn @@ -32,6 +32,7 @@ ohos_benchmarktest("BenchmarkTestForAccessibilityConfig") { "access_token:libnativetoken", "access_token:libtoken_setproc", "c_utils:utils", + "ffrt:libffrt", ] } diff --git a/interfaces/innerkits/test/benchmarktest/accessibility_config_test/accessibility_config_test.cpp b/interfaces/innerkits/test/benchmarktest/accessibility_config_test/accessibility_config_test.cpp index 10798d9f..f92d79da 100644 --- a/interfaces/innerkits/test/benchmarktest/accessibility_config_test/accessibility_config_test.cpp +++ b/interfaces/innerkits/test/benchmarktest/accessibility_config_test/accessibility_config_test.cpp @@ -14,9 +14,9 @@ */ #include -#include #include "accessibility_config.h" #include "accesstoken_kit.h" +#include "ffrt_inner.h" #include "nativetoken_kit.h" #include "token_setproc.h" @@ -33,13 +33,13 @@ namespace { complete_.set_value(); } - void SetCompletePromise(std::promise &promise) + void SetCompletePromise(ffrt::promise &promise) { complete_ = std::move(promise); } private: - std::promise complete_; + ffrt::promise complete_; }; static bool g_flag = true; @@ -85,8 +85,8 @@ namespace { config.GetScreenMagnificationState(value); for (auto _ : state) { /* @tc.steps: step1.call SetScreenMagnificationState in loop */ - std::promise complete; - std::future syncFuture = complete.get_future(); + ffrt::promise complete; + ffrt::future syncFuture = complete.get_future(); configObserver->SetCompletePromise(complete); config.SetScreenMagnificationState(!value); @@ -132,8 +132,8 @@ namespace { for (auto _ : state) { /* @tc.steps: step1.call SetShortkeyTarget in loop */ - std::promise complete; - std::future syncFuture = complete.get_future(); + ffrt::promise complete; + ffrt::future syncFuture = complete.get_future(); configObserver->SetCompletePromise(complete); config.SetShortkeyTarget(nameStr); syncFuture.wait(); @@ -183,8 +183,8 @@ namespace { for (auto _ : state) { /* @tc.steps: step1.call SetContentTimeout in loop */ value++; - std::promise complete; - std::future syncFuture = complete.get_future(); + ffrt::promise complete; + ffrt::future syncFuture = complete.get_future(); configObserver->SetCompletePromise(complete); config.SetContentTimeout(value); diff --git a/interfaces/innerkits/test/benchmarktest/accessible_ability_client_test/BUILD.gn b/interfaces/innerkits/test/benchmarktest/accessible_ability_client_test/BUILD.gn index ec6a3076..c2dfa897 100644 --- a/interfaces/innerkits/test/benchmarktest/accessible_ability_client_test/BUILD.gn +++ b/interfaces/innerkits/test/benchmarktest/accessible_ability_client_test/BUILD.gn @@ -26,6 +26,8 @@ ohos_benchmarktest("BenchmarkTestForAccessibleAbilityClient") { "../../../aafwk:accessibleability", "../../../common:accessibility_common", ] + + external_deps = [ "ffrt:libffrt" ] } group("benchmarktest") { @@ -36,4 +38,6 @@ group("benchmarktest") { # deps file ":BenchmarkTestForAccessibleAbilityClient", ] + + external_deps = [ "ffrt:libffrt" ] } diff --git a/interfaces/innerkits/test/benchmarktest/accessible_ability_client_test/accessible_ability_client_test.cpp b/interfaces/innerkits/test/benchmarktest/accessible_ability_client_test/accessible_ability_client_test.cpp index 47f1b033..ffe461b1 100644 --- a/interfaces/innerkits/test/benchmarktest/accessible_ability_client_test/accessible_ability_client_test.cpp +++ b/interfaces/innerkits/test/benchmarktest/accessible_ability_client_test/accessible_ability_client_test.cpp @@ -14,9 +14,9 @@ */ #include -#include #include "accessibility_ui_test_ability.h" #include "accessible_ability_listener.h" +#include "ffrt_inner.h" using namespace OHOS::Accessibility; @@ -43,13 +43,13 @@ namespace { return false; } - void SetCompletePromise(std::promise &promise) + void SetCompletePromise(ffrt::promise &promise) { complete_ = std::move(promise); } private: - std::promise complete_; + ffrt::promise complete_; }; class AccessibleAbilityClientTest : public benchmark::Fixture { @@ -78,8 +78,8 @@ namespace { AccessibilityUITestAbility::GetInstance()->RegisterAbilityListener(listener_); // Connect - std::promise connected; - std::future syncFuture = connected.get_future(); + ffrt::promise connected; + ffrt::future syncFuture = connected.get_future(); listener_->SetCompletePromise(connected); AccessibilityUITestAbility::GetInstance()->Connect(); syncFuture.wait(); @@ -88,8 +88,8 @@ namespace { void AccessibleAbilityClientTest::TearDown(const ::benchmark::State &state) { // Disconnect - std::promise disconnect; - std::future syncFuture = disconnect.get_future(); + ffrt::promise disconnect; + ffrt::future syncFuture = disconnect.get_future(); listener_->SetCompletePromise(disconnect); AccessibilityUITestAbility::GetInstance()->Disconnect(); syncFuture.wait(); diff --git a/interfaces/innerkits/test/fuzztest/accessibilitysystemabilityclient_fuzzer/BUILD.gn b/interfaces/innerkits/test/fuzztest/accessibilitysystemabilityclient_fuzzer/BUILD.gn index e927ecb7..63273a17 100644 --- a/interfaces/innerkits/test/fuzztest/accessibilitysystemabilityclient_fuzzer/BUILD.gn +++ b/interfaces/innerkits/test/fuzztest/accessibilitysystemabilityclient_fuzzer/BUILD.gn @@ -33,7 +33,10 @@ ohos_fuzztest("AccessibilitySystemAbilityClientFuzzTest") { "../../../asacfwk:accessibilityclient", "../../../common:accessibility_common", ] - external_deps = [ "c_utils:utils" ] + external_deps = [ + "c_utils:utils", + "ffrt:libffrt", + ] } ############################################################################### diff --git a/interfaces/innerkits/test/fuzztest/accessibleabilityclient_fuzzer/BUILD.gn b/interfaces/innerkits/test/fuzztest/accessibleabilityclient_fuzzer/BUILD.gn index a9c3a213..1ce6ede3 100644 --- a/interfaces/innerkits/test/fuzztest/accessibleabilityclient_fuzzer/BUILD.gn +++ b/interfaces/innerkits/test/fuzztest/accessibleabilityclient_fuzzer/BUILD.gn @@ -30,7 +30,10 @@ ohos_fuzztest("AccessibleAbilityClientFuzzTest") { "../../../aafwk:accessibleability", "../../../common:accessibility_common", ] - external_deps = [ "c_utils:utils" ] + external_deps = [ + "c_utils:utils", + "ffrt:libffrt", + ] } ############################################################################### diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index 76589897..1c6ae397 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -50,6 +50,7 @@ ohos_shared_library("accessibility_napi") { ] external_deps = [ + "ffrt:libffrt", "hilog:libhilog", "input:libmmi-client", "napi:ace_napi", diff --git a/interfaces/kits/napi/accessibility_config/BUILD.gn b/interfaces/kits/napi/accessibility_config/BUILD.gn index e94399c1..58881d73 100644 --- a/interfaces/kits/napi/accessibility_config/BUILD.gn +++ b/interfaces/kits/napi/accessibility_config/BUILD.gn @@ -50,6 +50,7 @@ ohos_shared_library("config_napi") { external_deps = [ "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", + "ffrt:libffrt", "hilog:libhilog", "input:libmmi-client", "ipc:ipc_core", diff --git a/interfaces/kits/napi/accessibility_config/include/napi_accessibility_config.h b/interfaces/kits/napi/accessibility_config/include/napi_accessibility_config.h index 5f3f27e2..2e594744 100644 --- a/interfaces/kits/napi/accessibility_config/include/napi_accessibility_config.h +++ b/interfaces/kits/napi/accessibility_config/include/napi_accessibility_config.h @@ -18,12 +18,13 @@ #include #include -#include -#include "accessibility_utils.h" +#include "accessibility_config.h" #include "accessibility_config_observer.h" +#include "accessibility_utils.h" +#include "ffrt.h" #include "napi/native_api.h" #include "napi/native_node_api.h" -#include "accessibility_config.h" + namespace OHOS { namespace Accessibility { @@ -54,7 +55,7 @@ public: void UnsubscribeInstallObservers(); private: - std::mutex mutex_; + ffrt::mutex mutex_; std::vector> enableAbilityListsObservers_ = {}; std::vector> installAbilityListsObservers_ = {}; }; diff --git a/interfaces/kits/napi/accessibility_config/src/napi_accessibility_config.cpp b/interfaces/kits/napi/accessibility_config/src/napi_accessibility_config.cpp index 56bf50b9..6be3e10d 100644 --- a/interfaces/kits/napi/accessibility_config/src/napi_accessibility_config.cpp +++ b/interfaces/kits/napi/accessibility_config/src/napi_accessibility_config.cpp @@ -974,7 +974,7 @@ void EnableAbilityListsObserverImpl::SubscribeToFramework() void EnableAbilityListsObserverImpl::OnEnableAbilityListsStateChanged() { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto &observer : enableAbilityListsObservers_) { observer->OnEnableAbilityListsStateChanged(); } @@ -983,7 +983,7 @@ void EnableAbilityListsObserverImpl::OnEnableAbilityListsStateChanged() void EnableAbilityListsObserverImpl::OnInstallAbilityListsStateChanged() { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto &observer : installAbilityListsObservers_) { if (observer) { observer->OnEnableAbilityListsStateChanged(); @@ -996,7 +996,7 @@ void EnableAbilityListsObserverImpl::OnInstallAbilityListsStateChanged() void EnableAbilityListsObserverImpl::SubscribeObserver(napi_env env, napi_value observer) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto iter = enableAbilityListsObservers_.begin(); iter != enableAbilityListsObservers_.end();) { if (CheckObserverEqual(env, observer, (*iter)->env_, (*iter)->callback_)) { HILOG_DEBUG("Observer exist"); @@ -1018,7 +1018,7 @@ void EnableAbilityListsObserverImpl::SubscribeObserver(napi_env env, napi_value void EnableAbilityListsObserverImpl::SubscribeInstallObserver(napi_env env, napi_value observer) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto iter = installAbilityListsObservers_.begin(); iter != installAbilityListsObservers_.end();) { if (CheckObserverEqual(env, observer, (*iter)->env_, (*iter)->callback_)) { HILOG_DEBUG("Observer exist"); @@ -1040,7 +1040,7 @@ void EnableAbilityListsObserverImpl::SubscribeInstallObserver(napi_env env, napi void EnableAbilityListsObserverImpl::UnsubscribeObserver(napi_env env, napi_value observer) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto iter = enableAbilityListsObservers_.begin(); iter != enableAbilityListsObservers_.end();) { if (CheckObserverEqual(env, observer, (*iter)->env_, (*iter)->callback_)) { enableAbilityListsObservers_.erase(iter); @@ -1054,14 +1054,14 @@ void EnableAbilityListsObserverImpl::UnsubscribeObserver(napi_env env, napi_valu void EnableAbilityListsObserverImpl::UnsubscribeObservers() { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); enableAbilityListsObservers_.clear(); } void EnableAbilityListsObserverImpl::UnsubscribeInstallObserver(napi_env env, napi_value observer) { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto iter = installAbilityListsObservers_.begin(); iter != installAbilityListsObservers_.end();) { if (CheckObserverEqual(env, observer, (*iter)->env_, (*iter)->callback_)) { installAbilityListsObservers_.erase(iter); @@ -1075,6 +1075,6 @@ void EnableAbilityListsObserverImpl::UnsubscribeInstallObserver(napi_env env, na void EnableAbilityListsObserverImpl::UnsubscribeInstallObservers() { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); installAbilityListsObservers_.clear(); } diff --git a/interfaces/kits/napi/accessibility_extension_module_loader/BUILD.gn b/interfaces/kits/napi/accessibility_extension_module_loader/BUILD.gn index e498414c..11ea698e 100644 --- a/interfaces/kits/napi/accessibility_extension_module_loader/BUILD.gn +++ b/interfaces/kits/napi/accessibility_extension_module_loader/BUILD.gn @@ -66,6 +66,7 @@ ohos_shared_library("accessibility_extension_module") { "ability_runtime:runtime", "c_utils:utils", "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", "hilog:libhilog", "input:libmmi-client", "napi:ace_napi", diff --git a/interfaces/kits/napi/accessibility_extension_module_loader/include/napi_accessibility_element.h b/interfaces/kits/napi/accessibility_extension_module_loader/include/napi_accessibility_element.h index 594579bd..7867c88d 100644 --- a/interfaces/kits/napi/accessibility_extension_module_loader/include/napi_accessibility_element.h +++ b/interfaces/kits/napi/accessibility_extension_module_loader/include/napi_accessibility_element.h @@ -148,7 +148,7 @@ public: static void GetWindowInfoIsFocused(NAccessibilityElementData *callbackInfo, napi_value &value); static void GetWindowInfoWindowId(NAccessibilityElementData *callbackInfo, napi_value &value); - static thread_local napi_ref consRef_; + static napi_ref consRef_; private: static void AttributeNamesComplete(napi_env env, napi_status status, void* data); static void AttributeValueExecute(napi_env env, void* data); diff --git a/interfaces/kits/napi/accessibility_extension_module_loader/include/napi_accessibility_extension.h b/interfaces/kits/napi/accessibility_extension_module_loader/include/napi_accessibility_extension.h index 392c8da9..04ae83db 100644 --- a/interfaces/kits/napi/accessibility_extension_module_loader/include/napi_accessibility_extension.h +++ b/interfaces/kits/napi/accessibility_extension_module_loader/include/napi_accessibility_extension.h @@ -17,9 +17,9 @@ #define NAPI_ACCESSIBILITY_EXTENSION_H #include -#include #include "accessibility_extension.h" #include "accessible_ability_listener.h" +#include "ffrt_inner.h" #include "js_runtime.h" #include "napi_accessibility_element.h" #include "native_engine/native_reference.h" @@ -153,12 +153,12 @@ private: struct ExtensionCallbackInfo { napi_env env_; NAccessibilityExtension *extension_; - std::promise syncPromise_; + ffrt::promise syncPromise_; }; struct KeyEventCallbackInfo : public ExtensionCallbackInfo { std::shared_ptr keyEvent_; - std::promise syncPromise_; + ffrt::promise syncPromise_; }; struct AccessibilityEventInfoCallbackInfo : public ExtensionCallbackInfo { diff --git a/interfaces/kits/napi/accessibility_extension_module_loader/src/napi_accessibility_element.cpp b/interfaces/kits/napi/accessibility_extension_module_loader/src/napi_accessibility_element.cpp index 69d61ae5..07c84fd7 100644 --- a/interfaces/kits/napi/accessibility_extension_module_loader/src/napi_accessibility_element.cpp +++ b/interfaces/kits/napi/accessibility_extension_module_loader/src/napi_accessibility_element.cpp @@ -109,7 +109,7 @@ namespace { }; } // namespace -thread_local napi_ref NAccessibilityElement::consRef_ = nullptr; +napi_ref NAccessibilityElement::consRef_ = nullptr; void NAccessibilityElement::DefineJSAccessibilityElement(napi_env env) { @@ -611,10 +611,6 @@ void NAccessibilityElement::GetExtraElementInfo(NAccessibilityElementData *callb HILOG_DEBUG("GetExtraElementInfo: size is extraElementValueInt : [%{public}zu]", mapValIsInt.size()); - if (mapValIsStr.empty() && mapValIsInt.empty()) { - HILOG_ERROR("extraElement map is null"); - return; - } auto iter = mapValIsStr.find(keyStr); if (iter != mapValIsStr.end()) { NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_string_utf8(callbackInfo->env_, @@ -624,7 +620,10 @@ void NAccessibilityElement::GetExtraElementInfo(NAccessibilityElementData *callb auto seconditer = mapValIsInt.find(keyStr); if (seconditer != mapValIsInt.end()) { NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_int32(callbackInfo->env_, seconditer->second, &value)); + return; } + + napi_get_undefined(callbackInfo->env_, &value); } void NAccessibilityElement::GetElementInfoCheckboxGroup(NAccessibilityElementData *callbackInfo, napi_value &value) @@ -836,7 +835,7 @@ void NAccessibilityElement::GetElementInfoValueMax(NAccessibilityElementData *ca if (!CheckElementInfoParameter(callbackInfo, value)) { return; } - NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_int32(callbackInfo->env_, + NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_double(callbackInfo->env_, callbackInfo->accessibilityElement_.elementInfo_->GetRange().GetMax(), &value)); } @@ -845,7 +844,7 @@ void NAccessibilityElement::GetElementInfoValueMin(NAccessibilityElementData *ca if (!CheckElementInfoParameter(callbackInfo, value)) { return; } - NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_int32(callbackInfo->env_, + NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_double(callbackInfo->env_, callbackInfo->accessibilityElement_.elementInfo_->GetRange().GetMin(), &value)); } @@ -854,7 +853,7 @@ void NAccessibilityElement::GetElementInfoValueNow(NAccessibilityElementData *ca if (!CheckElementInfoParameter(callbackInfo, value)) { return; } - NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_int32(callbackInfo->env_, + NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_double(callbackInfo->env_, callbackInfo->accessibilityElement_.elementInfo_->GetRange().GetCurrent(), &value)); } @@ -1293,7 +1292,7 @@ void NAccessibilityElement::GetElementInfoAllAttribute5(NAccessibilityElementDat napi_env env = callbackInfo->env_; napi_value checkBox = nullptr; GetElementInfoCheckboxGroup(callbackInfo, checkBox); - NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "checkBox", checkBox)); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "checkboxGroupSelectedStatus", checkBox)); napi_value row = nullptr; GetElementInfoRow(callbackInfo, row); @@ -1305,7 +1304,7 @@ void NAccessibilityElement::GetElementInfoAllAttribute5(NAccessibilityElementDat napi_value sideBarContainer = nullptr; GetElementInfoSideBarContainer(callbackInfo, sideBarContainer); - NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "sideBarContainer", sideBarContainer)); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "sideBarContainerStates", sideBarContainer)); napi_value listItemIndex = nullptr; GetElementInfoListItemIndex(callbackInfo, listItemIndex); diff --git a/interfaces/kits/napi/accessibility_extension_module_loader/src/napi_accessibility_extension.cpp b/interfaces/kits/napi/accessibility_extension_module_loader/src/napi_accessibility_extension.cpp index 958a64af..ba3db1ea 100644 --- a/interfaces/kits/napi/accessibility_extension_module_loader/src/napi_accessibility_extension.cpp +++ b/interfaces/kits/napi/accessibility_extension_module_loader/src/napi_accessibility_extension.cpp @@ -222,7 +222,7 @@ void NAccessibilityExtension::OnAbilityDisconnected() return; } work->data = static_cast(callbackInfo); - std::future syncFuture = callbackInfo->syncPromise_.get_future(); + ffrt::future syncFuture = callbackInfo->syncPromise_.get_future(); int ret = uv_queue_work_with_qos( loop, @@ -575,7 +575,7 @@ bool NAccessibilityExtension::OnKeyPressEvent(const std::shared_ptrdata = static_cast(callbackInfo); - std::future syncFuture = callbackInfo->syncPromise_.get_future(); + ffrt::future syncFuture = callbackInfo->syncPromise_.get_future(); if (OnKeyPressEventExec(work, loop)) { HILOG_ERROR("Failed to execute OnKeyPressEvent work queue"); diff --git a/interfaces/kits/napi/include/napi_accessibility_system_ability_client.h b/interfaces/kits/napi/include/napi_accessibility_system_ability_client.h index 12321a18..e7ee596f 100644 --- a/interfaces/kits/napi/include/napi_accessibility_system_ability_client.h +++ b/interfaces/kits/napi/include/napi_accessibility_system_ability_client.h @@ -55,7 +55,7 @@ public: void UnsubscribeObservers(); private: - std::mutex mutex_; + ffrt::mutex mutex_; OHOS::Accessibility::AccessibilityStateEventType type_; std::vector> observers_ = {}; }; @@ -131,8 +131,8 @@ public: static napi_value GetCaptionWindowColor(napi_env env, napi_callback_info info); static napi_value SetCaptionWindowColor(napi_env env, napi_callback_info info); - static thread_local napi_ref aaConsRef_; - static thread_local napi_ref aaStyleConsRef_; + static napi_ref aaConsRef_; + static napi_ref aaStyleConsRef_; static std::shared_ptr accessibilityStateListeners_; static std::shared_ptr touchGuideStateListeners_; static std::shared_ptr captionListeners_; diff --git a/interfaces/kits/napi/src/napi_accessibility_config_observer.cpp b/interfaces/kits/napi/src/napi_accessibility_config_observer.cpp index c1951bba..c52429bf 100644 --- a/interfaces/kits/napi/src/napi_accessibility_config_observer.cpp +++ b/interfaces/kits/napi/src/napi_accessibility_config_observer.cpp @@ -617,7 +617,7 @@ void NAccessibilityConfigObserverImpl::OnConfigChanged( const OHOS::AccessibilityConfig::CONFIG_ID id, const OHOS::AccessibilityConfig::ConfigValue& value) { HILOG_INFO(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto &observer : observers_) { if (observer && observer->configId_ == id) { observer->OnConfigChanged(value); @@ -629,7 +629,7 @@ void NAccessibilityConfigObserverImpl::SubscribeObserver(napi_env env, OHOS::AccessibilityConfig::CONFIG_ID id, napi_value observer) { HILOG_INFO(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto iter = observers_.begin(); iter != observers_.end();) { if (CheckObserverEqual(env, observer, (*iter)->env_, (*iter)->handlerRef_)) { HILOG_DEBUG("SubscribeObserver Observer exist"); @@ -651,7 +651,7 @@ void NAccessibilityConfigObserverImpl::UnsubscribeObserver(napi_env env, OHOS::AccessibilityConfig::CONFIG_ID id, napi_value observer) { HILOG_INFO(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto iter = observers_.begin(); iter != observers_.end();) { if ((*iter)->configId_ == id) { if (CheckObserverEqual(env, observer, (*iter)->env_, (*iter)->handlerRef_)) { @@ -669,7 +669,7 @@ void NAccessibilityConfigObserverImpl::UnsubscribeObserver(napi_env env, void NAccessibilityConfigObserverImpl::UnsubscribeObservers(OHOS::AccessibilityConfig::CONFIG_ID id) { HILOG_INFO(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto iter = observers_.begin(); iter != observers_.end();) { if ((*iter)->configId_ == id) { iter = observers_.erase(iter); diff --git a/interfaces/kits/napi/src/napi_accessibility_system_ability_client.cpp b/interfaces/kits/napi/src/napi_accessibility_system_ability_client.cpp index 31ce868a..7e5a0ad7 100644 --- a/interfaces/kits/napi/src/napi_accessibility_system_ability_client.cpp +++ b/interfaces/kits/napi/src/napi_accessibility_system_ability_client.cpp @@ -42,8 +42,8 @@ std::shared_ptr NAccessibilityClient::touchGuideStateListener std::shared_ptr NAccessibilityClient::captionListeners_ = std::make_shared(); -thread_local napi_ref NAccessibilityClient::aaConsRef_; -thread_local napi_ref NAccessibilityClient::aaStyleConsRef_; +napi_ref NAccessibilityClient::aaConsRef_; +napi_ref NAccessibilityClient::aaStyleConsRef_; #define ACCESSIBILITY_NAPI_ASSERT(env, cond, errCode) \ do { \ @@ -1338,7 +1338,7 @@ void StateListenerImpl::SubscribeToFramework() void StateListenerImpl::OnStateChanged(const bool state) { HILOG_INFO(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto &observer : observers_) { observer->OnStateChanged(state); } @@ -1347,7 +1347,7 @@ void StateListenerImpl::OnStateChanged(const bool state) void StateListenerImpl::SubscribeObserver(napi_env env, napi_value observer) { HILOG_INFO(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto iter = observers_.begin(); iter != observers_.end();) { if (CheckObserverEqual(env, observer, (*iter)->env_, (*iter)->handlerRef_)) { HILOG_DEBUG("SubscribeObserver Observer exist"); @@ -1368,7 +1368,7 @@ void StateListenerImpl::SubscribeObserver(napi_env env, napi_value observer) void StateListenerImpl::UnsubscribeObserver(napi_env env, napi_value observer) { HILOG_INFO(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto iter = observers_.begin(); iter != observers_.end();) { if (CheckObserverEqual(env, observer, (*iter)->env_, (*iter)->handlerRef_)) { observers_.erase(iter); @@ -1382,6 +1382,6 @@ void StateListenerImpl::UnsubscribeObserver(napi_env env, napi_value observer) void StateListenerImpl::UnsubscribeObservers() { HILOG_INFO(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); observers_.clear(); } \ No newline at end of file diff --git a/interfaces/kits/napi/src/napi_accessibility_utils.cpp b/interfaces/kits/napi/src/napi_accessibility_utils.cpp index f9d42ef1..f887f460 100644 --- a/interfaces/kits/napi/src/napi_accessibility_utils.cpp +++ b/interfaces/kits/napi/src/napi_accessibility_utils.cpp @@ -47,6 +47,8 @@ namespace { constexpr int32_t ALPHA_MOVE = 24; constexpr int32_t COLOR_MOVE = 8; const char UNICODE_BODY = '0'; + const std::string FULL_VALUE = "1"; + const std::string HALF_VALUE = "0"; } // namespace using namespace OHOS::Accessibility; using namespace OHOS::AccessibilityConfig; @@ -908,6 +910,8 @@ void ConvertActionArgsJSToNAPI( napi_value propertyNameValue = nullptr; bool hasProperty = false; std::string str = ""; + std::map scrollValueMap = { {"halfScreen", HALF_VALUE}, {"fullScreen", FULL_VALUE} }; + std::string scrollValue = FULL_VALUE; bool seleFlag = false; switch (action) { case ActionType::ACCESSIBILITY_ACTION_NEXT_HTML_ITEM: @@ -965,6 +969,32 @@ void ConvertActionArgsJSToNAPI( args.insert(std::pair("spanId", str.c_str())); } break; + case ActionType::ACCESSIBILITY_ACTION_SCROLL_FORWARD: + napi_create_string_utf8(env, "scrolltype", NAPI_AUTO_LENGTH, &propertyNameValue); + str = ConvertStringJSToNAPI(env, object, propertyNameValue, hasProperty); + if (hasProperty) { + if (scrollValueMap.find(str) != scrollValueMap.end()) { + scrollValue = scrollValueMap.find(str)->second; + HILOG_DEBUG("ScrollValue %{public}s", scrollValue.c_str()); + } else { + HILOG_DEBUG("Input is empty, output fullScreen, value is 1"); + } + args.insert(std::pair("scrolltype", scrollValue.c_str())); + } + break; + case ActionType::ACCESSIBILITY_ACTION_SCROLL_BACKWARD: + napi_create_string_utf8(env, "scrolltype", NAPI_AUTO_LENGTH, &propertyNameValue); + str = ConvertStringJSToNAPI(env, object, propertyNameValue, hasProperty); + if (hasProperty) { + if (scrollValueMap.find(str) != scrollValueMap.end()) { + scrollValue = scrollValueMap.find(str)->second; + HILOG_DEBUG("ScrollValue %{public}s", scrollValue.c_str()); + } else { + HILOG_DEBUG("Input is empty, output fullScreen, value is 1"); + } + args.insert(std::pair("scrolltype", scrollValue.c_str())); + } + break; default: break; } diff --git a/services/aams/BUILD.gn b/services/aams/BUILD.gn index 7ad4d634..7de8d73d 100755 --- a/services/aams/BUILD.gn +++ b/services/aams/BUILD.gn @@ -112,9 +112,8 @@ ohos_shared_library("accessibleabilityms") { "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", - "data_share:datashare_consumer", - "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -124,7 +123,6 @@ ohos_shared_library("accessibleabilityms") { "input:libmmi-client", "ipc:ipc_single", "os_account:os_account_innerkits", - "power_manager:powermgr_client", "preferences:native_preferences", "safwk:system_ability_fwk", "samgr:samgr_proxy", @@ -132,6 +130,18 @@ ohos_shared_library("accessibleabilityms") { "window_manager:libwm", ] + if (accessibility_feature_power_manager) { + external_deps += [ "power_manager:powermgr_client" ] + } + + if (accessibility_feature_display_manager) { + external_deps += [ "display_manager:displaymgr" ] + } + + if (accessibility_feature_data_share) { + external_deps += [ "data_share:datashare_consumer" ] + } + install_enable = true subsystem_name = "barrierfree" diff --git a/services/aams/include/accessibility_account_data.h b/services/aams/include/accessibility_account_data.h index 9a353291..c141273f 100644 --- a/services/aams/include/accessibility_account_data.h +++ b/services/aams/include/accessibility_account_data.h @@ -260,7 +260,7 @@ public: void AddConfigCallback(const sptr& callback); void RemoveConfigCallback(const wptr& callback); - const std::vector> &GetConfigCallbacks(); + const std::vector> GetConfigCallbacks(); void SetConfigCallbacks(std::vector>& observer); void GetImportantEnabledAbilities(std::map &importantEnabledAbilities) const; @@ -329,7 +329,7 @@ private: size_t GetSize(); private: std::map> connectionMap_; - std::mutex mutex_; + ffrt::mutex mutex_; }; int32_t id_; @@ -343,13 +343,15 @@ private: AccessibilityAbility connectedA11yAbilities_; // key: bundleName/abilityName AccessibilityAbility connectingA11yAbilities_; // key: bundleName/abilityName std::vector> enableAbilityListsObservers_; - std::mutex asacConnectionsMutex_; + ffrt::mutex enableAbilityListObserversMutex_; // mutex for enableAbilityListsObservers_ std::map> asacConnections_; // key: windowId + ffrt::mutex asacConnectionsMutex_; // mutex for map asacConnections_ CaptionPropertyCallbacks captionPropertyCallbacks_; + ffrt::mutex captionPropertyCallbacksMutex_; // mutex for captionPropertyCallbacks_ std::vector installedAbilities_; std::vector enabledAbilities_; // bundleName/abilityName std::vector> configCallbacks_; - std::mutex configCallbacksMutex_; // mutex for vector configCallbacks_ + ffrt::mutex configCallbacksMutex_; // mutex for vector configCallbacks_ std::shared_ptr config_ = nullptr; }; @@ -364,7 +366,7 @@ public: void Clear(); private: std::map> accountDataMap_; - std::mutex accountDataMutex_; + ffrt::mutex accountDataMutex_; }; } // namespace Accessibility } // namespace OHOS diff --git a/services/aams/include/accessibility_circle_drawing_manager.h b/services/aams/include/accessibility_circle_drawing_manager.h index 94190a8d..859c87ba 100644 --- a/services/aams/include/accessibility_circle_drawing_manager.h +++ b/services/aams/include/accessibility_circle_drawing_manager.h @@ -62,7 +62,7 @@ public: int32_t imageWidth_; int32_t imageHeight_; int32_t half_; - int32_t startAngle_; + int32_t startAngle_ = 0; float dispalyDensity_; }; } // namespace Accessibility diff --git a/services/aams/include/accessibility_datashare_helper.h b/services/aams/include/accessibility_datashare_helper.h index a4968ddf..4ed3254b 100644 --- a/services/aams/include/accessibility_datashare_helper.h +++ b/services/aams/include/accessibility_datashare_helper.h @@ -18,7 +18,11 @@ #include "accessibility_setting_observer.h" #include "accessibility_def.h" + +#ifdef OHOS_BUILD_ENABLE_DATA_SHARE #include "datashare_helper.h" +#endif +#include "ffrt.h" namespace OHOS { namespace Accessibility { @@ -56,8 +60,10 @@ public: RetError UnregisterObserver(const std::string& key); private: +#ifdef OHOS_BUILD_ENABLE_DATA_SHARE std::shared_ptr CreateDatashareHelper(); bool DestoryDatashareHelper(std::shared_ptr& helper); +#endif Uri AssembleUri(const std::string& key); private: @@ -65,9 +71,10 @@ private: int32_t accountId_; std::string uriProxyStr_; sptr remoteObj_ = nullptr; +#ifdef OHOS_BUILD_ENABLE_DATA_SHARE std::shared_ptr dataShareHelper_ = nullptr; - - static std::mutex observerMutex_; +#endif + static ffrt::mutex observerMutex_; std::map> settingObserverMap_; }; } // namespace Accessibility diff --git a/services/aams/include/accessibility_display_manager.h b/services/aams/include/accessibility_display_manager.h index ab75785a..8bce14a7 100644 --- a/services/aams/include/accessibility_display_manager.h +++ b/services/aams/include/accessibility_display_manager.h @@ -39,6 +39,7 @@ public: OHOS::Rosen::DisplayOrientation GetOrientation(); bool IsFoldable(); Rosen::FoldDisplayMode GetFoldDisplayMode(); + void SetDisplayScale(const uint64_t screenId, float scaleX, float scaleY, float pivotX, float pivotY); void RegisterDisplayListener(const std::shared_ptr &handler); void UnregisterDisplayListener(); diff --git a/services/aams/include/accessibility_setting_provider.h b/services/aams/include/accessibility_setting_provider.h index 62d71315..f22885ed 100644 --- a/services/aams/include/accessibility_setting_provider.h +++ b/services/aams/include/accessibility_setting_provider.h @@ -16,7 +16,6 @@ #ifndef ACCESSIBILITY_SETTING_PROVIDER_H #define ACCESSIBILITY_SETTING_PROVIDER_H -#include "datashare_helper.h" #include "errors.h" #include "mutex" #include "accessibility_setting_observer.h" @@ -53,7 +52,7 @@ protected: private: static AccessibilitySettingProvider* instance_; - static std::mutex mutex_; + static ffrt::mutex mutex_; }; } // namespace Accessibility } // namespace OHOS diff --git a/services/aams/include/accessibility_settings_config.h b/services/aams/include/accessibility_settings_config.h index 9d4a5bb6..0677af4d 100644 --- a/services/aams/include/accessibility_settings_config.h +++ b/services/aams/include/accessibility_settings_config.h @@ -38,6 +38,7 @@ public: RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption); RetError SetCaptionState(const bool state); RetError SetScreenMagnificationState(const bool state); + RetError SetScreenMagnificationType(const uint32_t type); RetError SetShortKeyState(const bool state); RetError SetShortKeyOnLockScreenState(const bool state); RetError SetShortKeyTimeout(const int32_t time); @@ -86,6 +87,7 @@ public: uint32_t GetClickResponseTime() const; bool GetIgnoreRepeatClickState() const; uint32_t GetIgnoreRepeatClickTime() const; + uint32_t GetScreenMagnificationType() const; const std::vector GetEnabledAccessibilityServices(); RetError AddEnabledAccessibilityService(const std::string &serviceName); @@ -112,6 +114,7 @@ private: bool gesturesSimulation_ = false; bool filteringKeyEvents_ = false; bool isScreenMagnificationState_ = false; + uint32_t screenMagnificationType_ = 0; bool isCaptionState_ = false; AccessibilityConfig::CaptionProperty captionProperty_; bool isMouseKeyState_ = false; @@ -137,7 +140,7 @@ private: std::vector enabledAccessibilityServices_ {}; // bundleName/abilityName std::shared_ptr datashare_ = nullptr; - std::mutex interfaceMutex_; + ffrt::mutex interfaceMutex_; }; } // namespace Accessibility } // namespace OHOS diff --git a/services/aams/include/accessibility_touch_guider.h b/services/aams/include/accessibility_touch_guider.h index 1bc13d06..795342df 100644 --- a/services/aams/include/accessibility_touch_guider.h +++ b/services/aams/include/accessibility_touch_guider.h @@ -28,7 +28,7 @@ namespace OHOS { namespace Accessibility { class TouchGuider; -const int64_t EXIT_GESTURE_REC_TIMEOUT = 2000; // millisecond +const int64_t EXIT_GESTURE_REC_TIMEOUT = 400; // millisecond const double MAX_DRAG_GESTURE_COSINE = 0.525321989; const int32_t MINI_POINTER_DISTANCE_DIP = 200; const int32_t INDEX_0 = 0; @@ -295,7 +295,7 @@ private: virtual void SetExecuteActionResult(const bool succeeded, const int32_t requestId) override; private: - std::promise promise_; + ffrt::promise promise_; bool executeActionResult_ = false; AccessibilityElementInfo accessibilityInfoResult_ = {}; std::vector elementInfosResult_; @@ -382,6 +382,12 @@ private: */ void RecordReceivedEvent(MMI::PointerEvent &event); + /** + * @brief Send touch event to specific AccessibleAbility. + * @param event the touch event from Multimodal + */ + void SendTouchEventToAA(MMI::PointerEvent &event); + /** * @brief Clear received recorder info. */ diff --git a/services/aams/include/accessibility_window_manager.h b/services/aams/include/accessibility_window_manager.h index c58f63dd..f7bf7f8c 100644 --- a/services/aams/include/accessibility_window_manager.h +++ b/services/aams/include/accessibility_window_manager.h @@ -18,10 +18,10 @@ #include #include -#include #include #include "accessibility_window_info.h" #include "event_handler.h" +#include "ffrt.h" #include "singleton.h" #include "window_manager.h" @@ -86,7 +86,7 @@ public: void Clear(); private: std::map windowElementMap_; - std::mutex mapMutex_; + ffrt::mutex mapMutex_; }; SceneBoardElementIdMap sceneBoardElementIdMap_ = {}; @@ -126,7 +126,7 @@ private: sptr windowListener_ = nullptr; std::shared_ptr eventHandler_ = nullptr; - std::recursive_mutex interfaceMutex_; // mutex for interface to make sure AccessibilityWindowManager thread-safe + ffrt::recursive_mutex interfaceMutex_; // mutex for interface to make sure AccessibilityWindowManager thread-safe }; } // namespace Accessibility } // namespace OHOS diff --git a/services/aams/include/accessibility_zoom_gesture.h b/services/aams/include/accessibility_zoom_gesture.h index c0444c22..232871af 100644 --- a/services/aams/include/accessibility_zoom_gesture.h +++ b/services/aams/include/accessibility_zoom_gesture.h @@ -19,6 +19,7 @@ #include "accessibility_event_transmission.h" #include "event_handler.h" #include "pointer_event.h" +#include "dm_common.h" namespace OHOS { namespace Accessibility { @@ -63,35 +64,48 @@ private: void RecognizeInReadyState(MMI::PointerEvent &event); void RecognizeInZoomState(MMI::PointerEvent &event); void RecognizeInSlidingState(MMI::PointerEvent &event); - void RecognizeScroll(MMI::PointerEvent &event); - void RecognizeScale(MMI::PointerEvent &event); + void RecognizeScroll(MMI::PointerEvent &event, ZOOM_FOCUS_COORDINATE &coordinate); + void RecognizeScale(MMI::PointerEvent &event, ZOOM_FOCUS_COORDINATE &coordinate); void CalcFocusCoordinate(MMI::PointerEvent &event, ZOOM_FOCUS_COORDINATE &coordinate); float CalcScaleSpan(MMI::PointerEvent &event, ZOOM_FOCUS_COORDINATE coordinate); + bool IsTapOnInputMethod(MMI::PointerEvent &event); bool IsDownValid(); bool IsUpValid(); + bool IsMoveValid(); bool IsTripleTaps(); void OnTripleTaps(MMI::PointerEvent &event); int64_t CalcIntervalTime(std::shared_ptr firstEvent, std::shared_ptr secondEvent); float CalcSeparationDistance(std::shared_ptr firstEvent, std::shared_ptr secondEvent); + void GetWindowParam(); void OnZoom(int32_t centerX, int32_t centerY); void OffZoom(); void OnScroll(float offsetX, float offsetY); - void OnScale(float scaleRatio, float focusX, float focusY); + void OnScale(float scaleSpan); bool startScaling_ = false; - float preSpan_ = 0; - float lastSpan_ = 0; + float preSpan_ = 0.0f; + float lastSpan_ = 0.0f; + float screenSpan_ = 0.0f; float lastScrollFocusX_ = 0.0f; float lastScrollFocusY_ = 0.0f; float tapDistance_ = 0.0f; float multiTapDistance_ = 0.0f; + uint64_t screenId_ = -1; + uint32_t screenWidth_ = 0; + uint32_t screenHeight_ = 0; + float anchorPointX_ = 0.0f; + float anchorPointY_ = 0.0f; + float scaleRatio_ = 2.0f; ACCESSIBILITY_ZOOM_STATE state_ = READY_STATE; + OHOS::Rosen::DisplayOrientation orientation_ = + OHOS::Rosen::DisplayOrientation::UNKNOWN; std::shared_ptr preLastDownEvent_ = nullptr; std::shared_ptr lastDownEvent_ = nullptr; std::shared_ptr preLastUpEvent_ = nullptr; std::shared_ptr lastUpEvent_ = nullptr; + std::shared_ptr currentMoveEvent_ = nullptr; std::shared_ptr zoomGestureEventHandler_ = nullptr; std::vector> cacheEvents_; }; diff --git a/services/aams/include/accessible_ability_channel.h b/services/aams/include/accessible_ability_channel.h index b17b37ff..13287ee0 100644 --- a/services/aams/include/accessible_ability_channel.h +++ b/services/aams/include/accessible_ability_channel.h @@ -16,9 +16,9 @@ #ifndef ACCESSIBLE_ABILITY_CHANNEL_H #define ACCESSIBLE_ABILITY_CHANNEL_H -#include #include "accessible_ability_channel_stub.h" #include "event_handler.h" +#include "ffrt_inner.h" #include "i_accessibility_element_operator.h" #include "key_event.h" diff --git a/services/aams/include/accessible_ability_connection.h b/services/aams/include/accessible_ability_connection.h index bf8c0f15..465120d8 100644 --- a/services/aams/include/accessible_ability_connection.h +++ b/services/aams/include/accessible_ability_connection.h @@ -16,11 +16,11 @@ #ifndef ACCESSIBLE_ABILITY_CONNECTION_H #define ACCESSIBLE_ABILITY_CONNECTION_H -#include #include "ability_connect_callback_stub.h" #include "accessibility_ability_info.h" #include "accessible_ability_channel.h" #include "accessible_ability_client_proxy.h" +#include "ffrt.h" #include "common_event_manager.h" namespace OHOS { diff --git a/services/aams/include/accessible_ability_manager_service.h b/services/aams/include/accessible_ability_manager_service.h index e81d9335..fa45d3c0 100644 --- a/services/aams/include/accessible_ability_manager_service.h +++ b/services/aams/include/accessible_ability_manager_service.h @@ -16,10 +16,8 @@ #ifndef ACCESSIBLE_ABILITY_MANAGER_SERVICE_H #define ACCESSIBLE_ABILITY_MANAGER_SERVICE_H -#include #include #include -#include #include #include "accessibility_dumper.h" @@ -235,7 +233,7 @@ public: virtual void SetCursorPositionResult(const int32_t cursorPosition, const int32_t requestId) override; private: - std::promise promise_; + ffrt::promise promise_; bool executeActionResult_ = false; AccessibilityElementInfo accessibilityInfoResult_ = {}; std::vector elementInfosResult_; @@ -304,6 +302,7 @@ public: private: void StopCallbackWait(int32_t windowId); void StopCallbackWait(int32_t windowId, int32_t treeId); + RetError CheckCallingUid(); sptr GetRealIdConnection(); bool FindFocusedElementByConnection(sptr connection, AccessibilityElementInfo &elementInfo); @@ -382,7 +381,7 @@ private: void Clear(); private: std::vector> observersList_; - std::mutex stateObserversMutex_; + ffrt::mutex stateObserversMutex_; }; RetError InnerEnableAbility(const std::string &name, const uint32_t capabilities); @@ -407,8 +406,15 @@ private: const int32_t windowId, const sptr &connection); void OnDeviceProvisioned(); + void InitializeShortKeyState(); + void RegisterProvisionCallback(); void RegisterShortKeyEvent(); bool IsNeedUnload(); + void OffZoomGesture(); + void OnScreenMagnificationStateChanged(); + void RegisterScreenMagnificationState(); + void OnScreenMagnificationTypeChanged(); + void RegisterScreenMagnificationType(); bool isReady_ = false; bool isPublished_ = false; @@ -439,7 +445,7 @@ private: sptr configCallbackDeathRecipient_ = nullptr; sptr bundleManagerDeathRecipient_ = nullptr; StateObservers stateObservers_; - std::mutex mutex_; // current used for register state observer + ffrt::mutex mutex_; // current used for register state observer std::vector> defaultConfigCallbacks_; std::shared_ptr accessibilitySettings_ = nullptr; std::vector removedAutoStartAbilities_ {}; diff --git a/services/aams/src/accessibility_account_data.cpp b/services/aams/src/accessibility_account_data.cpp index 157d094d..25c4c47d 100644 --- a/services/aams/src/accessibility_account_data.cpp +++ b/services/aams/src/accessibility_account_data.cpp @@ -142,12 +142,14 @@ void AccessibilityAccountData::AddCaptionPropertyCallback( const sptr& callback) { HILOG_DEBUG(); + std::lock_guard lock(captionPropertyCallbacksMutex_); captionPropertyCallbacks_.push_back(callback); } void AccessibilityAccountData::RemoveCaptionPropertyCallback(const wptr& callback) { HILOG_DEBUG(); + std::lock_guard lock(captionPropertyCallbacksMutex_); for (auto itr = captionPropertyCallbacks_.begin(); itr != captionPropertyCallbacks_.end(); itr++) { if ((*itr)->AsObject() == callback) { captionPropertyCallbacks_.erase(itr); @@ -160,6 +162,7 @@ void AccessibilityAccountData::AddEnableAbilityListsObserver( const sptr& observer) { HILOG_DEBUG(); + std::lock_guard lock(enableAbilityListObserversMutex_); if (std::any_of(enableAbilityListsObservers_.begin(), enableAbilityListsObservers_.end(), [observer](const sptr &listObserver) { return listObserver == observer; @@ -174,6 +177,7 @@ void AccessibilityAccountData::AddEnableAbilityListsObserver( void AccessibilityAccountData::RemoveEnableAbilityListsObserver(const wptr& observer) { HILOG_INFO(); + std::lock_guard lock(enableAbilityListObserversMutex_); for (auto itr = enableAbilityListsObservers_.begin(); itr != enableAbilityListsObservers_.end(); itr++) { if ((*itr)->AsObject() == observer) { HILOG_DEBUG("erase observer"); @@ -186,6 +190,7 @@ void AccessibilityAccountData::RemoveEnableAbilityListsObserver(const wptr lock(enableAbilityListObserversMutex_); HILOG_DEBUG("observer's size is %{public}zu", enableAbilityListsObservers_.size()); for (auto &observer : enableAbilityListsObservers_) { if (observer) { @@ -196,6 +201,7 @@ void AccessibilityAccountData::UpdateEnableAbilityListsState() void AccessibilityAccountData::UpdateInstallAbilityListsState() { + std::lock_guard lock(enableAbilityListObserversMutex_); HILOG_DEBUG("observer's size is %{public}zu", enableAbilityListsObservers_.size()); for (auto &observer : enableAbilityListsObservers_) { if (observer) { @@ -342,7 +348,9 @@ const std::map> AccessibilityAccoun const CaptionPropertyCallbacks AccessibilityAccountData::GetCaptionPropertyCallbacks() { HILOG_DEBUG("GetCaptionPropertyCallbacks start."); - return captionPropertyCallbacks_; + std::lock_guard lock(captionPropertyCallbacksMutex_); + CaptionPropertyCallbacks rtnVec = captionPropertyCallbacks_; + return rtnVec; } sptr AccessibilityAccountData::GetConnectingA11yAbility(const std::string &uri) @@ -666,14 +674,14 @@ void AccessibilityAccountData::AddConfigCallback( const sptr& callback) { HILOG_DEBUG("AddConfigCallback start."); - std::lock_guard lock(configCallbacksMutex_); + std::lock_guard lock(configCallbacksMutex_); configCallbacks_.push_back(callback); } -const std::vector> &AccessibilityAccountData::GetConfigCallbacks() +const std::vector> AccessibilityAccountData::GetConfigCallbacks() { HILOG_DEBUG("GetConfigCallbacks start."); - std::lock_guard lock(configCallbacksMutex_); + std::lock_guard lock(configCallbacksMutex_); std::vector> rtnVec = configCallbacks_; return rtnVec; } @@ -681,14 +689,14 @@ const std::vector> &AccessibilityA void AccessibilityAccountData::SetConfigCallbacks(std::vector>& observer) { HILOG_DEBUG("SetConfigCallbacks start."); - std::lock_guard lock(configCallbacksMutex_); + std::lock_guard lock(configCallbacksMutex_); configCallbacks_ = observer; } void AccessibilityAccountData::RemoveConfigCallback(const wptr& callback) { HILOG_DEBUG("RemoveConfigCallback start."); - std::lock_guard lock(configCallbacksMutex_); + std::lock_guard lock(configCallbacksMutex_); for (auto itr = configCallbacks_.begin(); itr != configCallbacks_.end(); itr++) { if ((*itr)->AsObject() == callback) { configCallbacks_.erase(itr); @@ -802,7 +810,7 @@ uint32_t AccessibilityAccountData::GetInputFilterFlag() const return 0; } uint32_t flag = 0; - if (isScreenMagnification_ && config_->GetScreenMagnificationState()) { + if (config_->GetScreenMagnificationState()) { flag |= AccessibilityInputInterceptor::FEATURE_SCREEN_MAGNIFICATION; } if (isEventTouchGuideState_) { @@ -1032,7 +1040,7 @@ void AccessibilityAccountData::AccessibilityAbility::AddAccessibilityAbility(con const sptr& connection) { HILOG_INFO("uri is %{private}s", uri.c_str()); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!connectionMap_.count(uri)) { connectionMap_[uri] = connection; HILOG_DEBUG("connectionMap_ size %{public}zu", connectionMap_.size()); @@ -1045,7 +1053,7 @@ void AccessibilityAccountData::AccessibilityAbility::AddAccessibilityAbility(con void AccessibilityAccountData::AccessibilityAbility::RemoveAccessibilityAbilityByUri(const std::string& uri) { HILOG_INFO("uri is %{private}s", uri.c_str()); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto it = connectionMap_.find(uri); if (it != connectionMap_.end()) { connectionMap_.erase(it); @@ -1058,7 +1066,7 @@ sptr AccessibilityAccountData::AccessibilityAbility const std::string& elementName) { HILOG_DEBUG("elementName is %{public}s", elementName.c_str()); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto& connection : connectionMap_) { std::string::size_type index = connection.first.find(elementName); if (index == std::string::npos) { @@ -1076,7 +1084,7 @@ sptr AccessibilityAccountData::AccessibilityAbility const std::string& uri) { HILOG_DEBUG("uri is %{private}s", uri.c_str()); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto iter = connectionMap_.find(uri); if (iter != connectionMap_.end()) { return iter->second; @@ -1087,7 +1095,7 @@ sptr AccessibilityAccountData::AccessibilityAbility void AccessibilityAccountData::AccessibilityAbility::GetAccessibilityAbilities( std::vector>& connectionList) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto& connection : connectionMap_) { connectionList.push_back(connection.second); } @@ -1096,7 +1104,7 @@ void AccessibilityAccountData::AccessibilityAbility::GetAccessibilityAbilities( void AccessibilityAccountData::AccessibilityAbility::GetAbilitiesInfo( std::vector& abilities) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto& connection : connectionMap_) { if (connection.second) { abilities.push_back(connection.second->GetAbilityInfo()); @@ -1110,7 +1118,7 @@ void AccessibilityAccountData::AccessibilityAbility::GetAbilitiesInfo( bool AccessibilityAccountData::AccessibilityAbility::IsExistCapability(Capability capability) { HILOG_DEBUG("capability %{public}d", capability); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto iter = connectionMap_.begin(); iter != connectionMap_.end(); iter++) { if (iter->second->GetAbilityInfo().GetCapabilityValues() & capability) { return true; @@ -1123,26 +1131,26 @@ bool AccessibilityAccountData::AccessibilityAbility::IsExistCapability(Capabilit void AccessibilityAccountData::AccessibilityAbility::GetAccessibilityAbilitiesMap( std::map>& connectionMap) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); connectionMap = connectionMap_; } void AccessibilityAccountData::AccessibilityAbility::Clear() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return connectionMap_.clear(); } size_t AccessibilityAccountData::AccessibilityAbility::GetSize() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return connectionMap_.size(); } void AccessibilityAccountData::AccessibilityAbility::GetDisableAbilities( std::vector &disabledAbilities) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto& connection : connectionMap_) { for (auto iter = disabledAbilities.begin(); iter != disabledAbilities.end();) { if (connection.second && (iter->GetId() == connection.second->GetAbilityInfo().GetId())) { @@ -1157,7 +1165,7 @@ void AccessibilityAccountData::AccessibilityAbility::GetDisableAbilities( void AccessibilityAccountData::AccessibilityAbility::RemoveAccessibilityAbilityByName(const std::string& bundleName, bool& result) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto& connection : connectionMap_) { std::size_t firstPos = connection.first.find_first_of('/') + 1; std::size_t endPos = connection.first.find_last_of('/'); @@ -1181,14 +1189,14 @@ void AccessibilityAccountData::AccessibilityAbility::RemoveAccessibilityAbilityB int32_t AccessibilityAccountData::AccessibilityAbility::GetSizeByUri(const std::string& uri) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return connectionMap_.count(uri); } sptr AccessibilityAccountDataMap::AddAccountData( int32_t accountId) { - std::lock_guard lock(accountDataMutex_); + std::lock_guard lock(accountDataMutex_); auto iter = accountDataMap_.find(accountId); if (iter != accountDataMap_.end()) { HILOG_WARN("accountId is existed"); @@ -1209,7 +1217,7 @@ sptr AccessibilityAccountDataMap::AddAccountData( sptr AccessibilityAccountDataMap::GetCurrentAccountData( int32_t accountId) { - std::lock_guard lock(accountDataMutex_); + std::lock_guard lock(accountDataMutex_); auto iter = accountDataMap_.find(accountId); if (iter != accountDataMap_.end()) { return iter->second; @@ -1228,7 +1236,7 @@ sptr AccessibilityAccountDataMap::GetCurrentAccountDat sptr AccessibilityAccountDataMap::GetAccountData( int32_t accountId) { - std::lock_guard lock(accountDataMutex_); + std::lock_guard lock(accountDataMutex_); auto iter = accountDataMap_.find(accountId); if (iter != accountDataMap_.end()) { return iter->second; @@ -1242,7 +1250,7 @@ sptr AccessibilityAccountDataMap::RemoveAccountData( int32_t accountId) { sptr accountData = nullptr; - std::lock_guard lock(accountDataMutex_); + std::lock_guard lock(accountDataMutex_); auto iter = accountDataMap_.find(accountId); if (iter != accountDataMap_.end()) { accountData = iter->second; @@ -1254,7 +1262,7 @@ sptr AccessibilityAccountDataMap::RemoveAccountData( void AccessibilityAccountDataMap::Clear() { - std::lock_guard lock(accountDataMutex_); + std::lock_guard lock(accountDataMutex_); accountDataMap_.clear(); } } // namespace Accessibility diff --git a/services/aams/src/accessibility_circle_drawing_manager.cpp b/services/aams/src/accessibility_circle_drawing_manager.cpp index ffd7a744..07038c95 100644 --- a/services/aams/src/accessibility_circle_drawing_manager.cpp +++ b/services/aams/src/accessibility_circle_drawing_manager.cpp @@ -44,7 +44,9 @@ constexpr int32_t DEFAULT_WIDTH = 500; constexpr int32_t DEFAULT_HEIGHT = 500; constexpr int32_t DEFAULT_HALF = 2; +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER constexpr int32_t DEFAULT_PIXEL_DENSITY = 160; +#endif constexpr int32_t HEXADECIMAL = 16; constexpr int32_t DECIMAL = 10; diff --git a/services/aams/src/accessibility_datashare_helper.cpp b/services/aams/src/accessibility_datashare_helper.cpp index 7f3a80bc..a5e4f1cb 100644 --- a/services/aams/src/accessibility_datashare_helper.cpp +++ b/services/aams/src/accessibility_datashare_helper.cpp @@ -15,10 +15,12 @@ #include "accessibility_datashare_helper.h" +#ifdef OHOS_BUILD_ENABLE_DATA_SHARE #include "datashare_errno.h" #include "datashare_predicates.h" #include "datashare_result_set.h" #include "datashare_values_bucket.h" +#endif #include "hilog_wrapper.h" #include "ipc_skeleton.h" #include "iservice_registry.h" @@ -28,11 +30,13 @@ namespace OHOS { namespace Accessibility { -std::mutex AccessibilityDatashareHelper::observerMutex_; +ffrt::mutex AccessibilityDatashareHelper::observerMutex_; namespace { +#ifdef OHOS_BUILD_ENABLE_DATA_SHARE constexpr int32_t INDEX = 0; const std::string SETTING_COLUMN_KEYWORD = "KEYWORD"; const std::string SETTING_COLUMN_VALUE = "VALUE"; +#endif constexpr int32_t DECIMAL_NOTATION = 10; const std::string SETTINGS_DATA_EXT_URI = "datashare_ext"; const std::string SETTING_GLOBAL_URI = "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA"; @@ -49,15 +53,18 @@ AccessibilityDatashareHelper::AccessibilityDatashareHelper(DATASHARE_TYPE type, AccessibilityDatashareHelper::~AccessibilityDatashareHelper() { +#ifdef OHOS_BUILD_ENABLE_DATA_SHARE if (dataShareHelper_ != nullptr) { DestoryDatashareHelper(dataShareHelper_); dataShareHelper_ = nullptr; } +#endif } std::string AccessibilityDatashareHelper::GetStringValue(const std::string& key, const std::string& defaultValue) { std::string resultStr = defaultValue; +#ifdef OHOS_BUILD_ENABLE_DATA_SHARE std::string callingIdentity = IPCSkeleton::ResetCallingIdentity(); std::shared_ptr resultSet = nullptr; do { @@ -92,6 +99,7 @@ std::string AccessibilityDatashareHelper::GetStringValue(const std::string& key, resultSet = nullptr; } IPCSkeleton::SetCallingIdentity(callingIdentity); +#endif return resultStr; } @@ -135,6 +143,7 @@ RetError AccessibilityDatashareHelper::PutStringValue(const std::string& key, co { std::string callingIdentity = IPCSkeleton::ResetCallingIdentity(); RetError rtn = RET_OK; +#ifdef OHOS_BUILD_ENABLE_DATA_SHARE do { if (dataShareHelper_ == nullptr) { rtn = RET_ERR_NULLPTR; @@ -158,6 +167,7 @@ RetError AccessibilityDatashareHelper::PutStringValue(const std::string& key, co } } while (0); IPCSkeleton::SetCallingIdentity(callingIdentity); +#endif return rtn; } @@ -210,10 +220,12 @@ void AccessibilityDatashareHelper::Initialize(int32_t systemAbilityId) HILOG_WARN("undefined DATASHARE_TYPE, use global table"); break; } +#ifdef OHOS_BUILD_ENABLE_DATA_SHARE dataShareHelper_ = CreateDatashareHelper(); if (dataShareHelper_ == nullptr) { HILOG_ERROR("create dataShareHelper_ failed"); } +#endif } sptr AccessibilityDatashareHelper::CreateObserver(const std::string& key, @@ -229,11 +241,13 @@ RetError AccessibilityDatashareHelper::RegisterObserver(const sptrGetKey()); +#ifdef OHOS_BUILD_ENABLE_DATA_SHARE if (dataShareHelper_ == nullptr) { IPCSkeleton::SetCallingIdentity(callingIdentity); return RET_ERR_NULLPTR; } dataShareHelper_->RegisterObserver(uri, observer); +#endif IPCSkeleton::SetCallingIdentity(callingIdentity); HILOG_DEBUG("succeed to register observer of uri=%{public}s", uri.ToString().c_str()); return RET_OK; @@ -249,7 +263,7 @@ RetError AccessibilityDatashareHelper::RegisterObserver(const std::string& key, if (RegisterObserver(observer) != ERR_OK) { return RET_ERR_NULLPTR; } - std::lock_guard lock(observerMutex_); + std::lock_guard lock(observerMutex_); settingObserverMap_.insert(std::make_pair(key, observer)); return RET_OK; } @@ -258,11 +272,13 @@ RetError AccessibilityDatashareHelper::UnregisterObserver(const sptrGetKey()); +#ifdef OHOS_BUILD_ENABLE_DATA_SHARE if (dataShareHelper_ == nullptr) { IPCSkeleton::SetCallingIdentity(callingIdentity); return RET_ERR_NULLPTR; } dataShareHelper_->UnregisterObserver(uri, observer); +#endif IPCSkeleton::SetCallingIdentity(callingIdentity); HILOG_DEBUG("succeed to unregister observer of uri=%{public}s", uri.ToString().c_str()); return RET_OK; @@ -270,7 +286,7 @@ RetError AccessibilityDatashareHelper::UnregisterObserver(const sptr lock(observerMutex_); + std::lock_guard lock(observerMutex_); auto iter = settingObserverMap_.find(key); if (iter != settingObserverMap_.end() && iter->second != nullptr) { sptr observer = iter->second; @@ -288,6 +304,7 @@ RetError AccessibilityDatashareHelper::UnregisterObserver(const std::string& key return RET_ERR_FAILED; } +#ifdef OHOS_BUILD_ENABLE_DATA_SHARE std::shared_ptr AccessibilityDatashareHelper::CreateDatashareHelper() { if (remoteObj_ == nullptr) { @@ -311,6 +328,7 @@ bool AccessibilityDatashareHelper::DestoryDatashareHelper(std::shared_ptr &handler) { diff --git a/services/aams/src/accessibility_gesture_recognizer.cpp b/services/aams/src/accessibility_gesture_recognizer.cpp index 79a393e8..2c52b0a4 100755 --- a/services/aams/src/accessibility_gesture_recognizer.cpp +++ b/services/aams/src/accessibility_gesture_recognizer.cpp @@ -15,6 +15,7 @@ #include "accessibility_gesture_recognizer.h" #include "hilog_wrapper.h" +#include namespace OHOS { namespace Accessibility { diff --git a/services/aams/src/accessibility_input_interceptor.cpp b/services/aams/src/accessibility_input_interceptor.cpp index 72a297e4..53a82242 100644 --- a/services/aams/src/accessibility_input_interceptor.cpp +++ b/services/aams/src/accessibility_input_interceptor.cpp @@ -235,7 +235,6 @@ void AccessibilityInputInterceptor::UpdateInterceptor() interceptorId_ = -1; } - HILOG_INFO("interceptorId:%{public}d", interceptorId_); if ((availableFunctions_ & FEATURE_MOUSE_AUTOCLICK) || (availableFunctions_ & FEATURE_TOUCH_EXPLORATION) || (availableFunctions_ & FEATURE_SCREEN_MAGNIFICATION) || @@ -248,6 +247,7 @@ void AccessibilityInputInterceptor::UpdateInterceptor() interceptorId_ = inputManager_->AddInterceptor(inputEventConsumer_, PRIORITY_EVENT, MMI::CapabilityToTags(MMI::INPUT_DEV_CAP_KEYBOARD)); } + HILOG_INFO("interceptorId:%{public}d", interceptorId_); } void AccessibilityInputInterceptor::DestroyInterceptor() diff --git a/services/aams/src/accessibility_multifinger_multitap.cpp b/services/aams/src/accessibility_multifinger_multitap.cpp index 433e72ca..3b6b673f 100644 --- a/services/aams/src/accessibility_multifinger_multitap.cpp +++ b/services/aams/src/accessibility_multifinger_multitap.cpp @@ -16,6 +16,7 @@ #include #include "accessibility_multifinger_multitap.h" #include "hilog_wrapper.h" +#include namespace OHOS { namespace Accessibility { diff --git a/services/aams/src/accessibility_screen_touch.cpp b/services/aams/src/accessibility_screen_touch.cpp index 910e53be..c27338d7 100644 --- a/services/aams/src/accessibility_screen_touch.cpp +++ b/services/aams/src/accessibility_screen_touch.cpp @@ -46,11 +46,12 @@ constexpr uint32_t IGNORE_REPEAT_CLICK_TIME_LONG = 1000; // ms constexpr uint32_t IGNORE_REPEAT_CLICK_TIME_LONGEST = 1300; // ms constexpr uint32_t CIRCLE_ANGLE = 360; +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER constexpr uint32_t START_ANGLE_PORTRAIT = -90; constexpr uint32_t START_ANGLE_LANDSCAPE = 180; constexpr uint32_t START_ANGLE_PORTRAIT_INVERTED = 90; constexpr uint32_t START_ANGLE_LANDSCAPE_INVERTED = 0; - +#endif constexpr uint32_t NUMBER_10 = 10; constexpr float TOUCH_SLOP = 8.0f; @@ -175,6 +176,7 @@ bool AccessibilityScreenTouch::GetRealIgnoreRepeatClickState() void AccessibilityScreenTouch::ConversionCoordinates(MMI::PointerEvent::PointerItem &pointerItem) { +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER AccessibilityDisplayManager &displayMgr = Singleton::GetInstance(); int32_t displayWidth = displayMgr.GetWidth(); int32_t displayHeight = displayMgr.GetHeight(); @@ -206,6 +208,7 @@ void AccessibilityScreenTouch::ConversionCoordinates(MMI::PointerEvent::PointerI default: break; } +#endif } void AccessibilityScreenTouch::DrawCircleProgress() @@ -360,9 +363,13 @@ void AccessibilityScreenTouch::HandleResponseDelayStateInnerUp(MMI::PointerEvent isStopDrawCircle_ = true; cachedDownPointerEvents_.clear(); } else { - cachedDownPointerEvents_.remove_if([&](const MMI::PointerEvent &e) { - return e.GetPointerId() == event.GetPointerId(); - }); + auto iter = std::find_if(cachedDownPointerEvents_.begin(), cachedDownPointerEvents_.end(), + [&](const MMI::PointerEvent &e) { + return e.GetPointerId() == event.GetPointerId(); + }); + if (iter != cachedDownPointerEvents_.end()) { + cachedDownPointerEvents_.erase(iter); + } } } diff --git a/services/aams/src/accessibility_setting_provider.cpp b/services/aams/src/accessibility_setting_provider.cpp index 0096fe85..5b1b15fa 100644 --- a/services/aams/src/accessibility_setting_provider.cpp +++ b/services/aams/src/accessibility_setting_provider.cpp @@ -25,7 +25,7 @@ namespace OHOS { namespace Accessibility { AccessibilitySettingProvider* AccessibilitySettingProvider::instance_; -std::mutex AccessibilitySettingProvider::mutex_; +ffrt::mutex AccessibilitySettingProvider::mutex_; namespace { constexpr int32_t DEFAULT_ACCOUNT_ID = 100; } // namespace @@ -44,7 +44,7 @@ AccessibilitySettingProvider& AccessibilitySettingProvider::GetInstance(int32_t { HILOG_DEBUG("etInstance start, systemAbilityId = %{public}d.", systemAbilityId); if (instance_ == nullptr) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (instance_ == nullptr) { instance_ = new AccessibilitySettingProvider(); instance_->Initialize(systemAbilityId); @@ -56,7 +56,7 @@ AccessibilitySettingProvider& AccessibilitySettingProvider::GetInstance(int32_t void AccessibilitySettingProvider::DeleteInstance() { HILOG_DEBUG(); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (instance_ == nullptr) { HILOG_INFO("instance_ is nullptr"); return; diff --git a/services/aams/src/accessibility_settings.cpp b/services/aams/src/accessibility_settings.cpp index ffff6751..21cdb84e 100644 --- a/services/aams/src/accessibility_settings.cpp +++ b/services/aams/src/accessibility_settings.cpp @@ -67,8 +67,8 @@ RetError AccessibilitySettings::SetShortKeyState(const bool state) return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, state]() { sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -109,8 +109,8 @@ RetError AccessibilitySettings::SetMouseAutoClick(const int32_t time) return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, time]() { sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -136,8 +136,8 @@ RetError AccessibilitySettings::SetShortkeyTarget(const std::string &name) HILOG_ERROR("handler_ is nullptr."); return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &name]() { sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -162,8 +162,8 @@ RetError AccessibilitySettings::SetShortkeyMultiTarget(const std::vector syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &name]() { sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -277,8 +277,8 @@ RetError AccessibilitySettings::SetDaltonizationColorFilter(const uint32_t filte return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, filter]() { sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -302,8 +302,8 @@ RetError AccessibilitySettings::SetContentTimeout(const uint32_t time) return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, time]() { sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -333,8 +333,8 @@ RetError AccessibilitySettings::SetBrightnessDiscount(const float discount) return Accessibility::RET_ERR_FAILED; } #endif - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, discount]() { sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -360,8 +360,8 @@ RetError AccessibilitySettings::SetAudioBalance(const float balance) return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, balance]() { sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -387,8 +387,8 @@ RetError AccessibilitySettings::SetClickResponseTime(const uint32_t time) return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, time]() { sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -415,8 +415,8 @@ RetError AccessibilitySettings::SetIgnoreRepeatClickState(const bool state) return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, state]() { sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -443,8 +443,8 @@ RetError AccessibilitySettings::SetIgnoreRepeatClickTime(const uint32_t time) return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, time]() { sptr accountData = Singleton::GetInstance().GetCurrentAccountData(); @@ -543,8 +543,8 @@ RetError AccessibilitySettings::GetScreenMagnificationState(bool &state) return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &state]() { HILOG_DEBUG(); sptr accountData = @@ -568,8 +568,8 @@ RetError AccessibilitySettings::GetShortKeyState(bool &state) return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &state]() { HILOG_DEBUG(); sptr accountData = @@ -593,8 +593,8 @@ RetError AccessibilitySettings::GetMouseKeyState(bool &state) return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &state]() { HILOG_DEBUG(); sptr accountData = @@ -613,8 +613,8 @@ RetError AccessibilitySettings::GetMouseKeyState(bool &state) RetError AccessibilitySettings::GetMouseAutoClick(int32_t &time) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &time]() { HILOG_DEBUG(); sptr accountData = @@ -634,8 +634,8 @@ RetError AccessibilitySettings::GetMouseAutoClick(int32_t &time) RetError AccessibilitySettings::GetShortkeyTarget(std::string &name) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &name]() { HILOG_DEBUG(); sptr accountData = @@ -655,8 +655,8 @@ RetError AccessibilitySettings::GetShortkeyTarget(std::string &name) RetError AccessibilitySettings::GetShortkeyMultiTarget(std::vector &name) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &name]() { HILOG_DEBUG(); sptr accountData = @@ -676,8 +676,8 @@ RetError AccessibilitySettings::GetShortkeyMultiTarget(std::vector RetError AccessibilitySettings::GetHighContrastTextState(bool &state) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &state]() { HILOG_DEBUG(); sptr accountData = @@ -697,8 +697,8 @@ RetError AccessibilitySettings::GetHighContrastTextState(bool &state) RetError AccessibilitySettings::GetDaltonizationState(bool &state) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &state]() { HILOG_DEBUG(); sptr accountData = @@ -718,8 +718,8 @@ RetError AccessibilitySettings::GetDaltonizationState(bool &state) RetError AccessibilitySettings::GetInvertColorState(bool &state) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &state]() { HILOG_DEBUG(); sptr accountData = @@ -739,8 +739,8 @@ RetError AccessibilitySettings::GetInvertColorState(bool &state) RetError AccessibilitySettings::GetAnimationOffState(bool &state) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &state]() { HILOG_DEBUG(); sptr accountData = @@ -760,8 +760,8 @@ RetError AccessibilitySettings::GetAnimationOffState(bool &state) RetError AccessibilitySettings::GetAudioMonoState(bool &state) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &state]() { HILOG_DEBUG(); sptr accountData = @@ -781,8 +781,8 @@ RetError AccessibilitySettings::GetAudioMonoState(bool &state) RetError AccessibilitySettings::GetDaltonizationColorFilter(uint32_t &type) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &type]() { HILOG_DEBUG(); sptr accountData = @@ -802,8 +802,8 @@ RetError AccessibilitySettings::GetDaltonizationColorFilter(uint32_t &type) RetError AccessibilitySettings::GetContentTimeout(uint32_t &timer) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &timer]() { HILOG_DEBUG(); sptr accountData = @@ -823,8 +823,8 @@ RetError AccessibilitySettings::GetContentTimeout(uint32_t &timer) RetError AccessibilitySettings::GetBrightnessDiscount(float &brightness) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &brightness]() { HILOG_DEBUG(); sptr accountData = @@ -844,8 +844,8 @@ RetError AccessibilitySettings::GetBrightnessDiscount(float &brightness) RetError AccessibilitySettings::GetAudioBalance(float &balance) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &balance]() { HILOG_DEBUG(); sptr accountData = @@ -865,8 +865,8 @@ RetError AccessibilitySettings::GetAudioBalance(float &balance) RetError AccessibilitySettings::GetClickResponseTime(uint32_t &time) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &time]() { HILOG_DEBUG(); sptr accountData = @@ -886,8 +886,8 @@ RetError AccessibilitySettings::GetClickResponseTime(uint32_t &time) RetError AccessibilitySettings::GetIgnoreRepeatClickState(bool &state) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &state]() { HILOG_DEBUG(); sptr accountData = @@ -907,8 +907,8 @@ RetError AccessibilitySettings::GetIgnoreRepeatClickState(bool &state) RetError AccessibilitySettings::GetIgnoreRepeatClickTime(uint32_t &time) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &time]() { HILOG_DEBUG(); sptr accountData = @@ -1133,8 +1133,8 @@ RetError AccessibilitySettings::GetCaptionProperty(AccessibilityConfig::CaptionP return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &caption]() { HILOG_DEBUG(); sptr accountData = @@ -1158,8 +1158,8 @@ RetError AccessibilitySettings::SetCaptionProperty(const AccessibilityConfig::Ca return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &caption]() { HILOG_DEBUG(); sptr accountData = @@ -1198,8 +1198,8 @@ RetError AccessibilitySettings::GetCaptionState(bool &state) return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &state]() { HILOG_DEBUG(); sptr accountData = diff --git a/services/aams/src/accessibility_settings_config.cpp b/services/aams/src/accessibility_settings_config.cpp index 841c20c8..ee4afba6 100644 --- a/services/aams/src/accessibility_settings_config.cpp +++ b/services/aams/src/accessibility_settings_config.cpp @@ -24,13 +24,15 @@ namespace Accessibility { namespace { constexpr uint32_t DEFAULT_COLOR = 0xff000000; const int32_t DEFAULT_SCALE = 100; + const int32_t SHORT_KEY_TIMEOUT_AFTER_USE = 1000; // ms const int32_t SHORT_KEY_TIMEOUT_BEFORE_USE = 3000; // ms const std::string ACCESSIBILITY = "accessibility"; const std::string TOUCH_GUIDE_STATE = "touch_guide_state"; const std::string GESTURE_KEY = "gesture_state"; const std::string CAPTION_KEY = "caption_state"; const std::string KEYEVENT_OBSERVER = "keyevent_observer"; - const std::string SCREEN_MAGNIFICATION_KEY = "screen_magnification"; + const std::string SCREEN_MAGNIFICATION_KEY = "accessibility_display_magnification_enabled"; + const std::string SCREEN_MAGNIFICATION_TYPE = "accessibility_magnification_capability"; const std::string MOUSEKEY = "mousekey"; const std::string HIGH_CONTRAST_TEXT_KEY = "high_text_contrast_enabled"; const std::string DALTONIZATION_STATE = "accessibility_display_daltonizer_enabled"; @@ -111,7 +113,14 @@ RetError AccessibilitySettingsConfig::SetScreenMagnificationState(const bool sta { HILOG_DEBUG("state = [%{public}s]", state ? "True" : "False"); isScreenMagnificationState_ = state; - return SetConfigState(SCREEN_MAGNIFICATION_KEY, state); + return RET_OK; +} + +RetError AccessibilitySettingsConfig::SetScreenMagnificationType(const uint32_t type) +{ + HILOG_DEBUG("screenMagnificationType = [%{public}u]", type); + screenMagnificationType_ = type; + return RET_OK; } RetError AccessibilitySettingsConfig::SetShortKeyState(const bool state) @@ -179,14 +188,20 @@ RetError AccessibilitySettingsConfig::SetShortkeyTarget(const std::string &name) RetError AccessibilitySettingsConfig::SetShortkeyMultiTarget(const std::vector &name) { HILOG_DEBUG(); - std::lock_guard lock(interfaceMutex_); - shortkeyMultiTarget_ = name; + std::set targets; + std::for_each(name.begin(), name.end(), [&](const std::string &target) { + if (targets.find(target) == targets.end()) { + targets.insert(target); + } + }); + std::lock_guard lock(interfaceMutex_); + shortkeyMultiTarget_ = std::vector(targets.begin(), targets.end()); if (!datashare_) { return RET_ERR_NULLPTR; } std::string stringOut = ""; - Utils::VectorToString(name, stringOut); + Utils::VectorToString(shortkeyMultiTarget_, stringOut); return datashare_->PutStringValue(SHORTCUT_SERVICE, stringOut); } @@ -377,7 +392,7 @@ const std::string &AccessibilitySettingsConfig::GetShortkeyTarget() const const std::vector AccessibilitySettingsConfig::GetShortkeyMultiTarget() { - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); std::vector rtnVec = shortkeyMultiTarget_; return rtnVec; } @@ -457,6 +472,11 @@ uint32_t AccessibilitySettingsConfig::GetClickResponseTime() const return clickResponseTime_; } +uint32_t AccessibilitySettingsConfig::GetScreenMagnificationType() const +{ + return screenMagnificationType_; +} + bool AccessibilitySettingsConfig::GetIgnoreRepeatClickState() const { return ignoreRepeatClickState_; @@ -469,14 +489,14 @@ uint32_t AccessibilitySettingsConfig::GetIgnoreRepeatClickTime() const const std::vector AccessibilitySettingsConfig::GetEnabledAccessibilityServices() { - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); std::vector rtnVec = enabledAccessibilityServices_; return rtnVec; } RetError AccessibilitySettingsConfig::AddEnabledAccessibilityService(const std::string &serviceName) { - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); auto iter = std::find(enabledAccessibilityServices_.begin(), enabledAccessibilityServices_.end(), serviceName); if (iter != enabledAccessibilityServices_.end()) { return RET_OK; @@ -493,7 +513,7 @@ RetError AccessibilitySettingsConfig::AddEnabledAccessibilityService(const std:: RetError AccessibilitySettingsConfig::RemoveEnabledAccessibilityService(const std::string &serviceName) { - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); auto iter = std::find(enabledAccessibilityServices_.begin(), enabledAccessibilityServices_.end(), serviceName); if (iter == enabledAccessibilityServices_.end()) { return RET_OK; @@ -639,6 +659,7 @@ void AccessibilitySettingsConfig::InitSetting() contentTimeout_ = static_cast(datashare_->GetIntValue(CONTENT_TIMEOUT_KEY, 0)); brightnessDiscount_ = static_cast(datashare_->GetFloatValue(BRIGHTNESS_DISCOUNT_KEY, 1.0)); audioBalance_ = static_cast(datashare_->GetFloatValue(AUDIO_BALANCE_KEY, 0)); + screenMagnificationType_ = static_cast(datashare_->GetIntValue(SCREEN_MAGNIFICATION_TYPE, 0)); clickResponseTime_ = static_cast(datashare_->GetIntValue(CLICK_RESPONCE_TIME, 0)); ignoreRepeatClickTime_ = static_cast(datashare_->GetIntValue(IGNORE_REPEAT_CLICK_TIME, 0)); } @@ -689,7 +710,6 @@ void AccessibilitySettingsConfig::OnDataClone() } else if (clickResponseTime_ > DOUBLE_CLICK_RESPONSE_TIME_MEDIUM) { SetClickResponseTime(AccessibilityConfig::ResponseDelayLong); } - if (ignoreRepeatClickTime_ == DOUBLE_IGNORE_REPEAT_CLICK_TIME_SHORT) { SetIgnoreRepeatClickTime(AccessibilityConfig::RepeatClickTimeoutShort); } else if (ignoreRepeatClickTime_ == DOUBLE_IGNORE_REPEAT_CLICK_TIME_MEDIUM) { @@ -699,7 +719,6 @@ void AccessibilitySettingsConfig::OnDataClone() } else if (ignoreRepeatClickTime_ > DOUBLE_IGNORE_REPEAT_CLICK_TIME_LONG) { SetIgnoreRepeatClickTime(AccessibilityConfig::RepeatClickTimeoutLongest); } - if (daltonizationColorFilter_ == DISPLAY_DALTONIZER_GREEN) { SetDaltonizationColorFilter(AccessibilityConfig::Deuteranomaly); } else if (daltonizationColorFilter_ == DISPLAY_DALTONIZER_RED) { @@ -707,21 +726,33 @@ void AccessibilitySettingsConfig::OnDataClone() } else if (daltonizationColorFilter_ == DISPLAY_DALTONIZER_BLUE) { SetDaltonizationColorFilter(AccessibilityConfig::Tritanomaly); } + // 1->1000 0->3000 + if (shortKeyTimeout_ == 1) { + shortKeyTimeout_ = SHORT_KEY_TIMEOUT_AFTER_USE; + } else { + shortKeyTimeout_ = SHORT_KEY_TIMEOUT_BEFORE_USE; + } + auto cleanFunc = [] (std::vector &services) -> int { + int count = 0; + for (auto iter = services.begin(); iter != services.end();) { + if (iter->find(SCREENREADER_TAG) != std::string::npos) { + iter = services.erase(iter); + count++; + } else { + iter++; + } + } + return count; + }; std::vector tmpVec = GetShortkeyMultiTarget(); - auto iter = std::find_if(tmpVec.begin(), tmpVec.end(), - [] (const std::string& service) { return service.find(SCREENREADER_TAG) != std::string::npos; }); - if (iter != tmpVec.end()) { - tmpVec.erase(iter); + if (cleanFunc(tmpVec) != 0) { tmpVec.push_back(SCREEN_READER_BUNDLE_ABILITY_NAME); SetShortkeyMultiTarget(tmpVec); } tmpVec = GetEnabledAccessibilityServices(); - iter = std::find_if(tmpVec.begin(), tmpVec.end(), - [] (const std::string& service) { return service.find(SCREENREADER_TAG) != std::string::npos; }); - if (iter != tmpVec.end()) { - RemoveEnabledAccessibilityService(*iter); + if (cleanFunc(tmpVec) != 0) { AddEnabledAccessibilityService(SCREEN_READER_BUNDLE_ABILITY_NAME); } diff --git a/services/aams/src/accessibility_touchEvent_injector.cpp b/services/aams/src/accessibility_touchEvent_injector.cpp index 73d5238a..a3e12488 100755 --- a/services/aams/src/accessibility_touchEvent_injector.cpp +++ b/services/aams/src/accessibility_touchEvent_injector.cpp @@ -17,6 +17,7 @@ #include "accessible_ability_manager_service.h" #include "hilog_wrapper.h" #include "utils.h" +#include namespace OHOS { namespace Accessibility { @@ -105,6 +106,11 @@ void TouchEventInjector::CancelGesture() pointer.SetPointerId(0); if (GetNext() != nullptr && isGestureUnderway_) { event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_CANCEL, pointer, time); + if (event == nullptr) { + HILOG_ERROR("event is nullptr"); + return; + } + SendPointerEvent(*event); isGestureUnderway_ = false; } @@ -124,6 +130,11 @@ std::shared_ptr TouchEventInjector::obtainTouchEvent(int32_t { HILOG_DEBUG(); std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); + if (pointerEvent == nullptr) { + HILOG_ERROR("pointerEvent is nullptr"); + return nullptr; + } + pointerEvent->SetPointerId(point.GetPointerId()); pointerEvent->SetTargetDisplayId(0); pointerEvent->SetPointerAction(action); @@ -208,12 +219,22 @@ void TouchEventInjector::ParseTapsEvents(int64_t startTime, pointer.SetDisplayY(py); pointer.SetDownTime(downTime); event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pointer, downTime); + if (event == nullptr) { + HILOG_ERROR("event is nullptr"); + return; + } + HILOG_DEBUG("append down event"); injectedEvents_.push_back(event); // Append up event int64_t upTime = downTime + perDurationTime * MS_TO_US; event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pointer, upTime); + if (event == nullptr) { + HILOG_ERROR("event is nullptr"); + return; + } + HILOG_DEBUG("append up event"); injectedEvents_.push_back(event); downTime = upTime + DOUBLE_TAP_MIN_TIME; @@ -255,20 +276,40 @@ void TouchEventInjector::ParseMovesEvents(int64_t startTime, if (i == 0) { // Append down event HILOG_DEBUG("append down event"); event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pointer, downTime); + if (event == nullptr) { + HILOG_ERROR("event is nullptr"); + return; + } + injectedEvents_.push_back(event); } else if (i < (positionSize - 1)) { // Append move event HILOG_DEBUG("append move event"); nowTime += perDurationTime * MS_TO_US; event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, pointer, nowTime); + if (event == nullptr) { + HILOG_ERROR("event is nullptr"); + return; + } + injectedEvents_.push_back(event); } else { // Append up event HILOG_DEBUG("append move event"); nowTime += perDurationTime * MS_TO_US; event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, pointer, nowTime); + if (event == nullptr) { + HILOG_ERROR("event is nullptr"); + return; + } + injectedEvents_.push_back(event); HILOG_DEBUG("append up event"); event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pointer, nowTime); + if (event == nullptr) { + HILOG_ERROR("event is nullptr"); + return; + } + injectedEvents_.push_back(event); } } diff --git a/services/aams/src/accessibility_touch_guider.cpp b/services/aams/src/accessibility_touch_guider.cpp index 7e7ab1b7..4225828e 100755 --- a/services/aams/src/accessibility_touch_guider.cpp +++ b/services/aams/src/accessibility_touch_guider.cpp @@ -19,6 +19,7 @@ #include "hilog_wrapper.h" #include "securec.h" #include "utils.h" +#include namespace OHOS { namespace Accessibility { @@ -77,9 +78,6 @@ void TGEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) case TouchGuider::SEND_HOVER_EXIT_MSG: HoverExitRunner(); break; - case TouchGuider::SEND_TOUCH_INTERACTION_END_MSG: - tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); - break; case TouchGuider::SEND_TOUCH_GUIDE_END_MSG: tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_END); break; @@ -88,6 +86,18 @@ void TGEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) } } +void TouchGuider::SendTouchEventToAA(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + if (event.GetPointerIds().size() == POINTER_COUNT_1) { + if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN) { + SendAccessibilityEventToAA(EventType::TYPE_TOUCH_BEGIN); + } else if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP) { + SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); + } + } +} + bool TouchGuider::OnPointerEvent(MMI::PointerEvent &event) { HILOG_DEBUG(); @@ -114,6 +124,7 @@ bool TouchGuider::OnPointerEvent(MMI::PointerEvent &event) return true; } RecordReceivedEvent(event); + SendTouchEventToAA(event); if (!multiFingerGestureRecognizer_.IsMultiFingerGestureStarted() && gestureRecognizer_.OnPointerEvent(event)) { return true; @@ -297,7 +308,6 @@ bool TouchGuider::TouchGuideListener::OnDoubleTap(MMI::PointerEvent &event) server_.CancelPostEventIfNeed(server_.SEND_HOVER_ENTER_MOVE_MSG); server_.CancelPostEventIfNeed(server_.SEND_HOVER_EXIT_MSG); server_.ForceSendAndRemoveEvent(server_.SEND_TOUCH_GUIDE_END_MSG, event); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); return server_.ExecuteActionOnAccessibilityFocused(ActionType::ACCESSIBILITY_ACTION_CLICK); } @@ -339,7 +349,6 @@ bool TouchGuider::TouchGuideListener::OnCompleted(GestureType gestureId) } server_.OnTouchInteractionEnd(); server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); server_.CancelPostEvent(EXIT_GESTURE_REC_MSG); server_.currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); @@ -354,7 +363,6 @@ void TouchGuider::TouchGuideListener::MultiFingerGestureOnCompleted(GestureType server_.OnTouchInteractionEnd(); server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); server_.CancelPostEvent(EXIT_GESTURE_REC_MSG); server_.currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); @@ -372,7 +380,6 @@ bool TouchGuider::TouchGuideListener::OnCancelled(MMI::PointerEvent &event) if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP && event.GetPointerIds().size() == POINTER_COUNT_1) { server_.OnTouchInteractionEnd(); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); } server_.CancelPostEvent(EXIT_GESTURE_REC_MSG); server_.currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); @@ -400,7 +407,6 @@ void TouchGuider::TouchGuideListener::MultiFingerGestureOnCancelled(const bool i server_.CancelPostEvent(EXIT_GESTURE_REC_MSG); if (isNoDelayFlag) { server_.OnTouchInteractionEnd(); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); } } @@ -477,9 +483,6 @@ void TouchGuider::HandleTouchGuidingState(MMI::PointerEvent &event) SendExitEvents(); PostHoverExit(); } - if (!HasEventPending(SEND_TOUCH_INTERACTION_END_MSG)) { - PostAccessibilityEvent(SEND_TOUCH_INTERACTION_END_MSG); - } } break; case MMI::PointerEvent::POINTER_ACTION_PULL_MOVE: @@ -516,7 +519,6 @@ void TouchGuider::HandleDraggingState(MMI::PointerEvent &event) if (event.GetPointerId() == currentPid_) { HILOG_DEBUG("single currentPid_ move: %{public}d", event.GetPointerId()); OnTouchInteractionEnd(); - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); SendEventToMultimodal(event, NO_CHANGE); currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); } @@ -526,7 +528,6 @@ void TouchGuider::HandleDraggingState(MMI::PointerEvent &event) int32_t removePid = currentPid_ == pIds[0]? pIds[1] : pIds[0]; event.RemovePointerItem(removePid); OnTouchInteractionEnd(); - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); SendEventToMultimodal(event, NO_CHANGE); currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); } @@ -565,7 +566,6 @@ void TouchGuider::HandleTransmitingState(MMI::PointerEvent &event) } SendEventToMultimodal(event, NO_CHANGE); OnTouchInteractionEnd(); - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); } break; @@ -583,7 +583,6 @@ void TouchGuider::HandlePassingThroughState(MMI::PointerEvent &event) event.GetPointerIds().size() == POINTER_COUNT_1) { SendEventToMultimodal(event, NO_CHANGE); OnTouchInteractionEnd(); - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); return; } @@ -604,7 +603,6 @@ void TouchGuider::Clear(MMI::PointerEvent &event) } CancelPostEvent(EXIT_GESTURE_REC_MSG); - CancelPostEvent(SEND_TOUCH_INTERACTION_END_MSG); CancelPostEvent(SEND_TOUCH_GUIDE_END_MSG); CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); @@ -658,8 +656,6 @@ void TouchGuider::HandleTouchGuidingStateInnerDown(MMI::PointerEvent &event) } if (!gestureRecognizer_.IsfirstTap() && !multiFingerGestureRecognizer_.IsMultiFingerGestureStarted()) { ForceSendAndRemoveEvent(SEND_TOUCH_GUIDE_END_MSG, event); - ForceSendAndRemoveEvent(SEND_TOUCH_INTERACTION_END_MSG, event); - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_BEGIN); if (!isTouchGuiding_) { if (!HasEventPending(SEND_HOVER_ENTER_MOVE_MSG)) { PostHoverEnterAndMove(event); @@ -693,8 +689,6 @@ void TouchGuider::HandleTouchGuidingStateInnerDown(MMI::PointerEvent &event) longPressOffsetY_ = static_cast(DIVIDE_2(leftTopY_ + rightBottomY_) - pointerIterm.GetDisplayY()); doubleTapLongPressDownEvent_ = std::make_shared(event); - } else { - CancelPostEvent(SEND_TOUCH_INTERACTION_END_MSG); } } @@ -783,7 +777,7 @@ void TouchGuider::HandleDraggingStateInnerMove(MMI::PointerEvent &event) HILOG_DEBUG(); std::vector pIds = event.GetPointerIds(); - int32_t pointCount = pIds.size(); + uint32_t pointCount = pIds.size(); if (pointCount == POINTER_COUNT_1) { HILOG_DEBUG("Only two pointers can be received in the dragging state"); } else if (pointCount == POINTER_COUNT_2) { @@ -1125,9 +1119,6 @@ void TouchGuider::ForceSendAndRemoveEvent(uint32_t innerEventID, MMI::PointerEve } pointerEvents_.clear(); break; - case SEND_TOUCH_INTERACTION_END_MSG: - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); - break; case SEND_TOUCH_GUIDE_END_MSG: SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_END); break; @@ -1194,10 +1185,6 @@ void TGEventHandler::HoverExitRunner() RemoveEvent(TouchGuider::SEND_TOUCH_GUIDE_END_MSG); SendEvent(TouchGuider::SEND_TOUCH_GUIDE_END_MSG, 0, EXIT_GESTURE_REC_TIMEOUT); } - if (HasInnerEvent(TouchGuider::SEND_TOUCH_INTERACTION_END_MSG)) { - RemoveEvent(TouchGuider::SEND_TOUCH_INTERACTION_END_MSG); - SendEvent(TouchGuider::SEND_TOUCH_INTERACTION_END_MSG, 0, EXIT_GESTURE_REC_TIMEOUT); - } } } // namespace Accessibility } // namespace OHOS \ No newline at end of file diff --git a/services/aams/src/accessibility_window_manager.cpp b/services/aams/src/accessibility_window_manager.cpp index 28256a8d..7b18d17c 100644 --- a/services/aams/src/accessibility_window_manager.cpp +++ b/services/aams/src/accessibility_window_manager.cpp @@ -20,6 +20,7 @@ #include "accessible_ability_manager_service.h" #include "hilog_wrapper.h" #include "utils.h" +#include namespace OHOS { namespace Accessibility { @@ -39,7 +40,7 @@ bool AccessibilityWindowManager::Init() HILOG_ERROR("get window info from wms failed. err[%{public}d]", err); return false; } - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); HILOG_DEBUG("windowInfos size is %{public}zu", windowInfos.size()); for (auto &window : windowInfos) { if (!window) { @@ -68,7 +69,7 @@ bool AccessibilityWindowManager::Init() void AccessibilityWindowManager::DeInit() { HILOG_DEBUG(); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); a11yWindows_.clear(); subWindows_.clear(); sceneBoardElementIdMap_.Clear(); @@ -79,7 +80,7 @@ void AccessibilityWindowManager::DeInit() void AccessibilityWindowManager::WinDeInit() { HILOG_DEBUG(); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); a11yWindows_.clear(); subWindows_.clear(); sceneBoardElementIdMap_.Clear(); @@ -162,7 +163,7 @@ void AccessibilityWindowManager::OnWindowUpdate(const std::vector lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); int32_t winId = windowId; HILOG_DEBUG("ConvertToRealWindowId called, windowId[%{public}d], focusType[%{public}d]", windowId, focusType); if (windowId == ACTIVE_WINDOW_ID) { @@ -339,7 +340,7 @@ AccessibilityWindowInfo AccessibilityWindowManager::CreateAccessibilityWindowInf void AccessibilityWindowManager::SetActiveWindow(int32_t windowId, bool isSendEvent) { HILOG_DEBUG("windowId is %{public}d", windowId); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); if (windowId == INVALID_WINDOW_ID) { ClearOldActiveWindow(); activeWindowId_ = INVALID_WINDOW_ID; @@ -379,7 +380,7 @@ void AccessibilityWindowManager::SetActiveWindow(int32_t windowId, bool isSendEv void AccessibilityWindowManager::SetAccessibilityFocusedWindow(int32_t windowId) { HILOG_DEBUG("windowId is %{public}d", windowId); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); if (windowId == INVALID_WINDOW_ID) { ClearAccessibilityFocused(); a11yFocusedWindowId_ = INVALID_WINDOW_ID; @@ -402,7 +403,7 @@ void AccessibilityWindowManager::SetAccessibilityFocusedWindow(int32_t windowId) std::vector AccessibilityWindowManager::GetAccessibilityWindows() { HILOG_DEBUG("a11yWindows_ size[%{public}zu]", a11yWindows_.size()); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); std::vector> windowInfos; std::vector windows; Rosen::WMError err = OHOS::Rosen::WindowManager::GetInstance().GetAccessibilityWindowInfo(windowInfos); @@ -430,7 +431,7 @@ std::vector AccessibilityWindowManager::GetAccessibilit bool AccessibilityWindowManager::GetAccessibilityWindow(int32_t windowId, AccessibilityWindowInfo &window) { HILOG_DEBUG("start windowId(%{public}d)", windowId); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); std::vector> windowInfos; Rosen::WMError err = OHOS::Rosen::WindowManager::GetInstance().GetAccessibilityWindowInfo(windowInfos); if (err != Rosen::WMError::WM_OK) { @@ -457,7 +458,7 @@ bool AccessibilityWindowManager::GetAccessibilityWindow(int32_t windowId, Access bool AccessibilityWindowManager::IsValidWindow(int32_t windowId) { HILOG_DEBUG("start windowId(%{public}d)", windowId); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); auto it = std::find_if(a11yWindows_.begin(), a11yWindows_.end(), [windowId](const std::map::value_type &window) { return window.first == windowId; @@ -471,7 +472,7 @@ bool AccessibilityWindowManager::IsValidWindow(int32_t windowId) void AccessibilityWindowManager::SetWindowSize(int32_t windowId, Rect rect) { HILOG_DEBUG("start windowId(%{public}d)", windowId); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); auto it = std::find_if(a11yWindows_.begin(), a11yWindows_.end(), [windowId](const std::map::value_type &window) { return window.first == windowId; @@ -585,7 +586,7 @@ bool AccessibilityWindowManager::EqualProperty(Accessibility::AccessibilityWindo void AccessibilityWindowManager::WindowUpdateAdded(const std::vector>& infos) { HILOG_DEBUG(); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); for (auto &windowInfo : infos) { if (!windowInfo) { HILOG_ERROR("invalid windowInfo"); @@ -615,7 +616,7 @@ void AccessibilityWindowManager::WindowUpdateAdded(const std::vector>& infos) { HILOG_DEBUG(); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); auto &aams = Singleton::GetInstance(); for (auto &windowInfo : infos) { if (!windowInfo) { @@ -644,7 +645,7 @@ void AccessibilityWindowManager::WindowUpdateRemoved(const std::vector>& infos) { HILOG_DEBUG(); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); auto &aams = Singleton::GetInstance(); for (auto &windowInfo : infos) { if (!windowInfo) { @@ -672,7 +673,7 @@ void AccessibilityWindowManager::WindowUpdateFocused(const std::vector>& infos) { HILOG_DEBUG(); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); auto &aams = Singleton::GetInstance(); for (auto &windowInfo : infos) { if (!windowInfo) { @@ -693,7 +694,7 @@ void AccessibilityWindowManager::WindowUpdateBounds(const std::vector>& infos) { HILOG_DEBUG(); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); for (auto &windowInfo : infos) { if (!windowInfo) { HILOG_ERROR("invalid windowInfo"); @@ -717,7 +718,7 @@ void AccessibilityWindowManager::WindowUpdateActive(const std::vector>& infos) { HILOG_DEBUG(); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); auto &aams = Singleton::GetInstance(); for (auto &windowInfo : infos) { if (!windowInfo) { @@ -737,7 +738,7 @@ void AccessibilityWindowManager::WindowUpdateProperty(const std::vector lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); HILOG_DEBUG("WindowUpdateType type[%{public}d]", type); auto &aams = Singleton::GetInstance(); switch (type) { @@ -785,7 +786,7 @@ void AccessibilityWindowManager::WindowUpdateTypeEvent(const int32_t realWidId, void AccessibilityWindowManager::WindowUpdateAll(const std::vector>& infos) { HILOG_DEBUG(); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); auto oldA11yWindows_ = a11yWindows_; HILOG_DEBUG("WindowUpdateAll info size(%{public}zu), oldA11yWindows_ size(%{public}zu)", infos.size(), oldA11yWindows_.size()); @@ -838,7 +839,7 @@ void AccessibilityWindowManager::WindowUpdateAll(const std::vector lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); if (activeWindowId_ == INVALID_WINDOW_ID) { HILOG_DEBUG("active window id is invalid"); return; @@ -856,7 +857,7 @@ void AccessibilityWindowManager::ClearOldActiveWindow() void AccessibilityWindowManager::ClearAccessibilityFocused() { HILOG_DEBUG("a11yFocused window id is %{public}d", a11yFocusedWindowId_); - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); if (a11yFocusedWindowId_ == INVALID_WINDOW_ID) { HILOG_DEBUG("a11yFocused window id is invalid"); return; @@ -896,7 +897,7 @@ void AccessibilityWindowManager::ClearAccessibilityFocused() int64_t AccessibilityWindowManager::GetSceneBoardElementId(const int32_t windowId, const int64_t elementId) { - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); if (elementId != INVALID_SCENE_BOARD_ELEMENT_ID) { return elementId; } @@ -913,7 +914,7 @@ int64_t AccessibilityWindowManager::GetSceneBoardElementId(const int32_t windowI void AccessibilityWindowManager::GetRealWindowAndElementId(int32_t& windowId, int64_t& elementId) { // sceneboard window id, element id is not equal -1 - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); if (subWindows_.count(windowId) && elementId != INVALID_SCENE_BOARD_ELEMENT_ID) { windowId = SCENE_BOARD_WINDOW_ID; HILOG_INFO("windowId %{public}d, elementId %{public}" PRId64 "", windowId, elementId); @@ -938,7 +939,7 @@ void AccessibilityWindowManager::GetRealWindowAndElementId(int32_t& windowId, in void AccessibilityWindowManager::GetSceneBoardInnerWinId(int32_t windowId, int64_t elementId, int32_t& innerWid) { - std::lock_guard lock(interfaceMutex_); + std::lock_guard lock(interfaceMutex_); if (windowId != SCENE_BOARD_WINDOW_ID) { return; } @@ -954,31 +955,31 @@ void AccessibilityWindowManager::GetSceneBoardInnerWinId(int32_t windowId, int64 void AccessibilityWindowManager::SceneBoardElementIdMap::InsertPair(const int32_t windowId, const int64_t elementId) { - std::lock_guard lock(mapMutex_); + std::lock_guard lock(mapMutex_); windowElementMap_[windowId] = elementId; } void AccessibilityWindowManager::SceneBoardElementIdMap::RemovePair(const int32_t windowId) { - std::lock_guard lock(mapMutex_); + std::lock_guard lock(mapMutex_); windowElementMap_.erase(windowId); } bool AccessibilityWindowManager::SceneBoardElementIdMap::CheckWindowIdPair(const int32_t windowId) { - std::lock_guard lock(mapMutex_); + std::lock_guard lock(mapMutex_); return windowElementMap_.count(windowId); } void AccessibilityWindowManager::SceneBoardElementIdMap::Clear() { - std::lock_guard lock(mapMutex_); + std::lock_guard lock(mapMutex_); windowElementMap_.clear(); } std::map AccessibilityWindowManager::SceneBoardElementIdMap::GetAllPairs() { - std::lock_guard lock(mapMutex_); + std::lock_guard lock(mapMutex_); return windowElementMap_; } diff --git a/services/aams/src/accessibility_zoom_gesture.cpp b/services/aams/src/accessibility_zoom_gesture.cpp index ddc76af5..6b2b40d0 100755 --- a/services/aams/src/accessibility_zoom_gesture.cpp +++ b/services/aams/src/accessibility_zoom_gesture.cpp @@ -17,20 +17,29 @@ #include "accessible_ability_manager_service.h" #include "hilog_wrapper.h" #include "window_accessibility_controller.h" +#include "accessibility_window_manager.h" namespace OHOS { namespace Accessibility { namespace { constexpr size_t POINTER_COUNT_1 = 1; + constexpr size_t POINTER_COUNT_2 = 2; constexpr float TAP_MIN_DISTANCE = 8.0f; constexpr int32_t MULTI_TAP_TIMER = 300; // ms - constexpr int32_t LONG_PRESS_TIMER = 500; // ms + constexpr int32_t LONG_PRESS_TIMER = 300; // ms constexpr int64_t US_TO_MS = 1000; - constexpr float MIN_SCALE_SPAN = 26.0f; constexpr float DOUBLE_TAP_SLOP = 100.0f; constexpr float HALF = 0.5f; + constexpr uint32_t DOUBLE = 2; constexpr uint32_t TRIPLE_TAP_COUNT = 3; constexpr float DEFAULT_SCALE = 2.0f; + constexpr float NORMAL_SCALE = 1.0f; + constexpr float MAX_SCALE = 8.0f; + constexpr uint32_t INPUT_METHOD_WINDOW_TYPE = 2105; + constexpr float EPS = 1e-6; + constexpr float MIN_SCROLL_SPAN = 10.0f; + constexpr float MIN_SCALE_SPAN = 20.0f; + constexpr float DEFAULT_ANCHOR = 0.5f; } // namespace AccessibilityZoomGesture::AccessibilityZoomGesture() @@ -53,11 +62,43 @@ AccessibilityZoomGesture::AccessibilityZoomGesture() float densityPixels = display->GetVirtualPixelRatio(); multiTapDistance_ = densityPixels * DOUBLE_TAP_SLOP + 0.5f; #else - HILOG_DEBUG("not support display manager") + HILOG_DEBUG("not support display manager"); multiTapDistance_ = 1 * DOUBLE_TAP_SLOP + 0.5f; #endif } +bool AccessibilityZoomGesture::IsTapOnInputMethod(MMI::PointerEvent &event) +{ + size_t pointerCount = event.GetPointerIds().size(); + if (pointerCount != POINTER_COUNT_1) { + HILOG_DEBUG("not single finger."); + return false; + } + std::vector windowInfos = + Singleton::GetInstance().GetAccessibilityWindows(); + for (auto &window : windowInfos) { + if (window.GetWindowType() == INPUT_METHOD_WINDOW_TYPE) { + Rect inputRect = window.GetRectInScreen(); + int32_t leftTopX = inputRect.GetLeftTopXScreenPostion(); + int32_t leftTopY = inputRect.GetLeftTopYScreenPostion(); + int32_t rightBottomX = inputRect.GetRightBottomXScreenPostion(); + int32_t rightBottomY = inputRect.GetRightBottomYScreenPostion(); + + MMI::PointerEvent::PointerItem item; + event.GetPointerItem(event.GetPointerId(), item); + int32_t itemX = item.GetDisplayX(); + int32_t itemY = item.GetDisplayY(); + if ((itemX >= leftTopX) && (itemX <= rightBottomX) && + (itemY >= leftTopY) && (itemY <= rightBottomY)) { + HILOG_INFO("tap on input method window."); + return true; + } + } + } + HILOG_DEBUG("have no input method window."); + return false; +} + bool AccessibilityZoomGesture::OnPointerEvent(MMI::PointerEvent &event) { HILOG_DEBUG("state_ is %{public}d.", state_); @@ -68,6 +109,11 @@ bool AccessibilityZoomGesture::OnPointerEvent(MMI::PointerEvent &event) return false; } + if (IsTapOnInputMethod(event)) { + EventTransmission::OnPointerEvent(event); + return true; + } + switch (state_) { case READY_STATE: CacheEvents(event); @@ -88,7 +134,7 @@ bool AccessibilityZoomGesture::OnPointerEvent(MMI::PointerEvent &event) void AccessibilityZoomGesture::TransferState(ACCESSIBILITY_ZOOM_STATE state) { - HILOG_DEBUG("state:%{public}d.", state); + HILOG_DEBUG("old state= %{public}d, new state= %{public}d", state_, state); state_ = state; } @@ -116,6 +162,12 @@ void AccessibilityZoomGesture::CacheEvents(MMI::PointerEvent &event) lastUpEvent_ = pointerEvent; } break; + case MMI::PointerEvent::POINTER_ACTION_MOVE: + if (pointerCount == POINTER_COUNT_1) { + HILOG_DEBUG("Cache pointer move."); + currentMoveEvent_ = pointerEvent; + } + break; default: HILOG_DEBUG("Action is %{public}d", action); break; @@ -191,6 +243,14 @@ void AccessibilityZoomGesture::RecognizeInReadyState(MMI::PointerEvent &event) HILOG_DEBUG("action:%{public}d, pointerCount:%{public}zu", action, pointerCount); } break; + case MMI::PointerEvent::POINTER_ACTION_MOVE: + if ((pointerCount == POINTER_COUNT_1) && IsMoveValid()) { + HILOG_DEBUG("move valid."); + } else { + SendCacheEventsToNext(); + HILOG_DEBUG("action:%{public}d, pointerCount:%{public}zu", action, pointerCount); + } + break; case MMI::PointerEvent::POINTER_ACTION_CANCEL: SendCacheEventsToNext(); break; @@ -208,7 +268,8 @@ void AccessibilityZoomGesture::RecognizeInZoomState(MMI::PointerEvent &event) HILOG_DEBUG(); int32_t action = event.GetPointerAction(); - size_t pointerCount = event.GetPointerIds().size(); + std::vector pointerIdList = event.GetPointerIds(); + size_t pointerCount = pointerIdList.size(); bool isTripleTaps = false; HILOG_DEBUG("action:%{public}d, pointerCount:%{public}zu", action, pointerCount); @@ -221,21 +282,18 @@ void AccessibilityZoomGesture::RecognizeInZoomState(MMI::PointerEvent &event) } else { SendCacheEventsToNext(); } - } else if (pointerCount > POINTER_COUNT_1) { + } else if (pointerCount == POINTER_COUNT_2) { TransferState(SLIDING_STATE); ClearCacheEventsAndMsg(); ZOOM_FOCUS_COORDINATE focusXY = {0.0f, 0.0f}; CalcFocusCoordinate(event, focusXY); - // Used for scroll algorithm. lastScrollFocusX_ = focusXY.centerX; lastScrollFocusY_ = focusXY.centerY; - // Used for scale algorithm. float span = CalcScaleSpan(event, focusXY); - if (span >= MIN_SCALE_SPAN) { - startScaling_ = true; - preSpan_ = lastSpan_ = span; - } + preSpan_ = lastSpan_ = span; + } else { + HILOG_INFO("invalid pointer count."); } break; case MMI::PointerEvent::POINTER_ACTION_UP: @@ -245,6 +303,14 @@ void AccessibilityZoomGesture::RecognizeInZoomState(MMI::PointerEvent &event) SendCacheEventsToNext(); } break; + case MMI::PointerEvent::POINTER_ACTION_MOVE: + if ((pointerCount == POINTER_COUNT_1) && IsMoveValid()) { + HILOG_DEBUG("move valid."); + } else { + SendCacheEventsToNext(); + HILOG_DEBUG("action:%{public}d, pointerCount:%{public}zu", action, pointerCount); + } + break; case MMI::PointerEvent::POINTER_ACTION_CANCEL: SendCacheEventsToNext(); HILOG_DEBUG("action:%{public}d", action); @@ -264,10 +330,13 @@ void AccessibilityZoomGesture::RecognizeInSlidingState(MMI::PointerEvent &event) int32_t action = event.GetPointerAction(); size_t pointerCount = event.GetPointerIds().size(); + ZOOM_FOCUS_COORDINATE coordinate = {0.0f, 0.0f}; + CalcFocusCoordinate(event, coordinate); - // Recognize scroll and zoom gestures. - RecognizeScroll(event); - RecognizeScale(event); + if (pointerCount == POINTER_COUNT_2) { + RecognizeScale(event, coordinate); + RecognizeScroll(event, coordinate); + } HILOG_DEBUG("action:%{public}d, pointerCount:%{public}zu", action, pointerCount); switch (action) { @@ -284,14 +353,11 @@ void AccessibilityZoomGesture::RecognizeInSlidingState(MMI::PointerEvent &event) } } -void AccessibilityZoomGesture::RecognizeScroll(MMI::PointerEvent &event) +void AccessibilityZoomGesture::RecognizeScroll(MMI::PointerEvent &event, ZOOM_FOCUS_COORDINATE &coordinate) { HILOG_DEBUG(); int32_t action = event.GetPointerAction(); - ZOOM_FOCUS_COORDINATE coordinate = {0.0f, 0.0f}; - CalcFocusCoordinate(event, coordinate); - switch (action) { case MMI::PointerEvent::POINTER_ACTION_DOWN: case MMI::PointerEvent::POINTER_ACTION_UP: @@ -301,7 +367,7 @@ void AccessibilityZoomGesture::RecognizeScroll(MMI::PointerEvent &event) case MMI::PointerEvent::POINTER_ACTION_MOVE: { float offsetX = coordinate.centerX - lastScrollFocusX_; float offsetY = coordinate.centerY - lastScrollFocusY_; - if ((abs(offsetX) > 1) || (abs(offsetY) > 1)) { + if ((abs(offsetX) > MIN_SCROLL_SPAN) || (abs(offsetY) > MIN_SCROLL_SPAN)) { lastScrollFocusX_ = coordinate.centerX; lastScrollFocusY_ = coordinate.centerY; OnScroll(offsetX, offsetY); @@ -313,13 +379,13 @@ void AccessibilityZoomGesture::RecognizeScroll(MMI::PointerEvent &event) } } -void AccessibilityZoomGesture::RecognizeScale(MMI::PointerEvent &event) +void AccessibilityZoomGesture::RecognizeScale(MMI::PointerEvent &event, ZOOM_FOCUS_COORDINATE &coordinate) { HILOG_DEBUG(); int32_t action = event.GetPointerAction(); size_t pointerCount = event.GetPointerIds().size(); - if (((action == MMI::PointerEvent::POINTER_ACTION_UP) && (pointerCount == POINTER_COUNT_1)) || + if (((action == MMI::PointerEvent::POINTER_ACTION_UP) && (pointerCount != POINTER_COUNT_2)) || (action == MMI::PointerEvent::POINTER_ACTION_CANCEL)) { HILOG_DEBUG("Scaling is end"); startScaling_ = false; @@ -327,19 +393,24 @@ void AccessibilityZoomGesture::RecognizeScale(MMI::PointerEvent &event) return; } - ZOOM_FOCUS_COORDINATE focusXY = {0.0f, 0.0f}; - CalcFocusCoordinate(event, focusXY); - float span = CalcScaleSpan(event, focusXY); + float span = CalcScaleSpan(event, coordinate); + + if (action == MMI::PointerEvent::POINTER_ACTION_MOVE) { + if (abs(preSpan_ - span) >= MIN_SCALE_SPAN) { + startScaling_ = true; + HILOG_DEBUG("start scaling."); + } + } if (!startScaling_) { // When the span is greater than or equal to MIN_SCALE_SPAN, start scaling. - if (span >= MIN_SCALE_SPAN) { + if (abs(preSpan_ - span) >= MIN_SCALE_SPAN) { startScaling_ = true; - preSpan_ = lastSpan_ = span; + HILOG_DEBUG("start scaling."); } } else { // When the span is smaller than the MIN_SCALE_SPAN, // the scale recognition will be restarted. - if (span < MIN_SCALE_SPAN) { + if (abs(lastSpan_ - span) < 1) { startScaling_ = false; preSpan_ = lastSpan_ = span; } @@ -358,12 +429,11 @@ void AccessibilityZoomGesture::RecognizeScale(MMI::PointerEvent &event) HILOG_DEBUG("Action(%{public}d) is not move", action); return; } - - lastSpan_ = span; - float ratio = lastSpan_ / preSpan_; - if (ratio != 1) { - OnScale(ratio, focusXY.centerX, focusXY.centerY); - preSpan_ = lastSpan_; + + float scaleSpan = (span - lastSpan_) * scaleRatio_; + if (scaleSpan != 0) { + OnScale(scaleSpan); + lastSpan_ = span; } } @@ -399,8 +469,8 @@ void AccessibilityZoomGesture::CalcFocusCoordinate(MMI::PointerEvent &event, ZOO } MMI::PointerEvent::PointerItem item; event.GetPointerItem(pointerId, item); - sumX += static_cast(item.GetDisplayX()); - sumY += static_cast(item.GetDisplayY()); + sumX += static_cast(item.GetRawDisplayX()); + sumY += static_cast(item.GetRawDisplayY()); } coordinate.centerX = sumX / count; @@ -441,8 +511,8 @@ float AccessibilityZoomGesture::CalcScaleSpan(MMI::PointerEvent &event, ZOOM_FOC } MMI::PointerEvent::PointerItem item; event.GetPointerItem(pointerId, item); - sumSpanX += static_cast(abs(item.GetDisplayX() - coordinate.centerX)); - sumSpanY += static_cast(abs(item.GetDisplayY() - coordinate.centerY)); + sumSpanX += static_cast(abs(item.GetRawDisplayX() - coordinate.centerX)); + sumSpanY += static_cast(abs(item.GetRawDisplayY() - coordinate.centerY)); } float spanX = sumSpanX / count; @@ -489,6 +559,27 @@ bool AccessibilityZoomGesture::IsUpValid() return true; } +bool AccessibilityZoomGesture::IsMoveValid() +{ + HILOG_DEBUG(); + + if (!lastDownEvent_) { + HILOG_DEBUG("The move event is invailid"); + return false; + } + + if (CalcIntervalTime(lastDownEvent_, currentMoveEvent_) >= LONG_PRESS_TIMER) { + HILOG_DEBUG("The time has exceeded the long press time"); + return false; + } + + if (CalcSeparationDistance(lastDownEvent_, currentMoveEvent_) >= tapDistance_) { + HILOG_DEBUG("The distance has exceeded the threshold"); + return false; + } + return true; +} + bool AccessibilityZoomGesture::IsTripleTaps() { HILOG_DEBUG(); @@ -596,34 +687,131 @@ void AccessibilityZoomGesture::ZoomGestureEventHandler::ProcessEvent(const AppEx } } +void AccessibilityZoomGesture::GetWindowParam() +{ + HILOG_DEBUG(); +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER + AccessibilityDisplayManager &displayMgr = Singleton::GetInstance(); + uint64_t currentScreen = displayMgr.GetDefaultDisplayId(); + OHOS::Rosen::DisplayOrientation currentOrientation = displayMgr.GetOrientation(); + if ((currentScreen != screenId_) || (currentOrientation != orientation_)) { + HILOG_INFO("display id or orientation changed."); + screenId_ = currentScreen; + orientation_ = currentOrientation; + sptr display = displayMgr.GetDisplay(screenId_); + screenWidth_ = display->GetWidth(); + screenHeight_ = display->GetHeight(); + HILOG_INFO("screenWidth_ = %{public}d, screenHeight_ = %{public}d.", screenWidth_, screenHeight_); + } + screenSpan_ = hypot(screenWidth_, screenHeight_); +#else + HILOG_INFO("not support zoom"); +#endif +} + void AccessibilityZoomGesture::OnZoom(int32_t anchorX, int32_t anchorY) { HILOG_DEBUG("anchorX:%{public}d, anchorY:%{public}d.", anchorX, anchorY); +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER + GetWindowParam(); + if (screenWidth_ == 0 || screenHeight_ == 0) { + HILOG_ERROR("screen param invalid."); + return; + } + anchorPointX_ = static_cast(anchorX); + anchorPointY_ = static_cast(anchorY); - OHOS::Rosen::WindowAccessibilityController::GetInstance().SetAnchorAndScale(anchorX, anchorY, DEFAULT_SCALE); + float x = anchorPointX_ / screenWidth_; + float y = anchorPointY_ / screenHeight_; + scaleRatio_ = DEFAULT_SCALE; + AccessibilityDisplayManager &displayMgr = Singleton::GetInstance(); + displayMgr.SetDisplayScale(screenId_, scaleRatio_, scaleRatio_, x, y); +#else + HILOG_INFO("not support zoom"); + return; +#endif } void AccessibilityZoomGesture::OffZoom() { HILOG_DEBUG(); - - OHOS::Rosen::WindowAccessibilityController::GetInstance().OffWindowZoom(); +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER + AccessibilityDisplayManager &displayMgr = Singleton::GetInstance(); + uint64_t currentScreen = displayMgr.GetDefaultDisplayId(); + displayMgr.SetDisplayScale(currentScreen, NORMAL_SCALE, NORMAL_SCALE, DEFAULT_ANCHOR, DEFAULT_ANCHOR); +#else + HILOG_INFO("not support zoom"); + return; +#endif } void AccessibilityZoomGesture::OnScroll(float offsetX, float offsetY) { HILOG_DEBUG("offsetX:%{public}f, offsetY:%{public}f.", offsetX, offsetY); +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER + GetWindowParam(); + if (screenWidth_ == 0 || screenHeight_ == 0) { + HILOG_ERROR("screen param invalid."); + return; + } - OHOS::Rosen::WindowAccessibilityController::GetInstance().SetAnchorOffset( - static_cast(offsetX), static_cast(offsetY)); + if (abs(scaleRatio_) < EPS) { + HILOG_ERROR("scaleRatio_ param invalid."); + return; + } + anchorPointX_ -= (offsetX * DOUBLE / scaleRatio_); + anchorPointY_ -= (offsetY * DOUBLE / scaleRatio_); + + if (anchorPointX_ < 0) { + anchorPointX_ = 0; + } + if (anchorPointX_ > screenWidth_) { + anchorPointX_ = screenWidth_; + } + if (anchorPointY_ < 0) { + anchorPointY_ = 0; + } + if (anchorPointY_ > screenHeight_) { + anchorPointY_ = screenHeight_; + } + + float x = anchorPointX_ / screenWidth_; + float y = anchorPointY_ / screenHeight_; + AccessibilityDisplayManager &displayMgr = Singleton::GetInstance(); + displayMgr.SetDisplayScale(screenId_, scaleRatio_, scaleRatio_, x, y); +#else + HILOG_INFO("not support zoom"); + return; +#endif } -void AccessibilityZoomGesture::OnScale(float scaleRatio, float focusX, float focusY) +void AccessibilityZoomGesture::OnScale(float scaleSpan) { - HILOG_DEBUG("scaleRatio:%{public}f, focusX:%{public}f, focusY:%{public}f.", scaleRatio, focusX, focusY); + HILOG_DEBUG(); +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER + GetWindowParam(); + if (screenWidth_ == 0 || screenHeight_ == 0 || abs(screenSpan_) < EPS) { + HILOG_ERROR("screen param invalid."); + return; + } - OHOS::Rosen::WindowAccessibilityController::GetInstance().SetAnchorAndScale( - static_cast(focusX), static_cast(focusY), scaleRatio); + float ratio = scaleSpan / screenSpan_; + scaleRatio_ = scaleRatio_ + ratio; + if (scaleRatio_ > MAX_SCALE) { + scaleRatio_ = MAX_SCALE; + } + if (scaleRatio_ < DEFAULT_SCALE) { + scaleRatio_ = DEFAULT_SCALE; + } + + float x = anchorPointX_ / screenWidth_; + float y = anchorPointY_ / screenHeight_; + AccessibilityDisplayManager &displayMgr = Singleton::GetInstance(); + displayMgr.SetDisplayScale(screenId_, scaleRatio_, scaleRatio_, x, y); +#else + HILOG_INFO("not support zoom"); + return; +#endif } } // namespace Accessibility } // namespace OHOS diff --git a/services/aams/src/accessible_ability_channel.cpp b/services/aams/src/accessible_ability_channel.cpp index 1576dd5c..6e4041c5 100644 --- a/services/aams/src/accessible_ability_channel.cpp +++ b/services/aams/src/accessible_ability_channel.cpp @@ -67,8 +67,8 @@ RetError AccessibleAbilityChannel::SearchElementInfoByAccessibilityId(const Elem return RET_ERR_NULLPTR; } - std::shared_ptr> syncPromise = std::make_shared>(); - std::future syncFuture = syncPromise->get_future(); + std::shared_ptr> syncPromise = std::make_shared>(); + ffrt::future syncFuture = syncPromise->get_future(); eventHandler_->PostTask([this, syncPromise, windowId, elementId, treeId, requestId, callback, mode, isFilter]() { HILOG_DEBUG("search element accountId[%{public}d], name[%{public}s]", accountId_, clientName_.c_str()); @@ -98,8 +98,8 @@ RetError AccessibleAbilityChannel::SearchElementInfoByAccessibilityId(const Elem syncPromise->set_value(RET_OK); }, "SearchElementInfoByAccessibilityId"); - std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait SearchElementInfoByAccessibilityId result"); return RET_ERR_TIME_OUT; } @@ -125,8 +125,8 @@ RetError AccessibleAbilityChannel::SearchElementInfosByText(const int32_t access int32_t treeId = AccessibleAbilityManagerService::GetTreeIdBySplitElementId(elementId); HILOG_DEBUG("SearchElementInfosByText :channel SearchElementInfo treeId: %{public}d", treeId); - std::shared_ptr> syncPromise = std::make_shared>(); - std::future syncFuture = syncPromise->get_future(); + std::shared_ptr> syncPromise = std::make_shared>(); + ffrt::future syncFuture = syncPromise->get_future(); eventHandler_->PostTask([this, syncPromise, accessibilityWindowId, elementId, treeId, text, requestId, callback]() { HILOG_DEBUG("accountId[%{public}d], name[%{public}s]", accountId_, clientName_.c_str()); @@ -149,8 +149,8 @@ RetError AccessibleAbilityChannel::SearchElementInfosByText(const int32_t access syncPromise->set_value(RET_OK); }, "SearchElementInfosByText"); - std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait SearchElementInfosByText result"); return RET_ERR_TIME_OUT; } @@ -174,8 +174,8 @@ RetError AccessibleAbilityChannel::FindFocusedElementInfo(const int32_t accessib return RET_ERR_NULLPTR; } - std::shared_ptr> syncPromise = std::make_shared>(); - std::future syncFuture = syncPromise->get_future(); + std::shared_ptr> syncPromise = std::make_shared>(); + ffrt::future syncFuture = syncPromise->get_future(); int32_t treeId = AccessibleAbilityManagerService::GetTreeIdBySplitElementId(elementId); HILOG_DEBUG("FindFocusedElementInfo :channel FindFocusedElementInfo treeId: %{public}d", treeId); eventHandler_->PostTask([this, syncPromise, accessibilityWindowId, elementId, treeId, @@ -199,8 +199,8 @@ RetError AccessibleAbilityChannel::FindFocusedElementInfo(const int32_t accessib syncPromise->set_value(RET_OK); }, "FindFocusedElementInfo"); - std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait FindFocusedElementInfo result"); return RET_ERR_TIME_OUT; } @@ -223,8 +223,8 @@ RetError AccessibleAbilityChannel::FocusMoveSearch(const int32_t accessibilityWi return RET_ERR_NULLPTR; } - std::shared_ptr> syncPromise = std::make_shared>(); - std::future syncFuture = syncPromise->get_future(); + std::shared_ptr> syncPromise = std::make_shared>(); + ffrt::future syncFuture = syncPromise->get_future(); int32_t treeId = AccessibleAbilityManagerService::GetTreeIdBySplitElementId(elementId); HILOG_DEBUG("FocusMoveSearch :channel FocusMoveSearch treeId: %{public}d", treeId); eventHandler_->PostTask([this, syncPromise, accessibilityWindowId, @@ -249,8 +249,8 @@ RetError AccessibleAbilityChannel::FocusMoveSearch(const int32_t accessibilityWi syncPromise->set_value(RET_OK); }, "FocusMoveSearch"); - std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait FocusMoveSearch result"); return RET_ERR_TIME_OUT; } @@ -356,8 +356,8 @@ RetError AccessibleAbilityChannel::ExecuteAction(const int32_t accessibilityWind return RET_OK; } SetFocusWindowIdAndElementId(accessibilityWindowId, elementId, action); - std::shared_ptr> syncPromise = std::make_shared>(); - std::future syncFuture = syncPromise->get_future(); + std::shared_ptr> syncPromise = std::make_shared>(); + ffrt::future syncFuture = syncPromise->get_future(); int32_t treeId = AccessibleAbilityManagerService::GetTreeIdBySplitElementId(elementId); eventHandler_->PostTask([this, syncPromise, accessibilityWindowId, elementId, treeId, action, actionArguments, requestId, callback]() { @@ -378,8 +378,8 @@ RetError AccessibleAbilityChannel::ExecuteAction(const int32_t accessibilityWind syncPromise->set_value(RET_OK); }, "ExecuteAction"); - std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait ExecuteAction result"); return RET_ERR_TIME_OUT; } @@ -408,9 +408,9 @@ RetError AccessibleAbilityChannel::GetWindow(const int32_t windowId, Accessibili return RET_ERR_NULLPTR; } - std::shared_ptr> syncPromise = std::make_shared>(); + std::shared_ptr> syncPromise = std::make_shared>(); std::shared_ptr tmpWindowInfo = std::make_shared(windowInfo); - std::future syncFuture = syncPromise->get_future(); + ffrt::future syncFuture = syncPromise->get_future(); eventHandler_->PostTask([this, windowId, tmpWindowInfo, syncPromise]() { HILOG_DEBUG("windowId:%{public}d", windowId); sptr clientConnection = GetConnection(accountId_, clientName_); @@ -432,8 +432,8 @@ RetError AccessibleAbilityChannel::GetWindow(const int32_t windowId, Accessibili } }, "GetWindow"); - std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait GetWindow result"); return RET_ERR_TIME_OUT; } @@ -470,9 +470,9 @@ RetError AccessibleAbilityChannel::GetWindows(uint64_t displayId, std::vector> syncPromise = std::make_shared>(); + std::shared_ptr> syncPromise = std::make_shared>(); auto tmpWindows = std::make_shared>(windows); - std::future syncFuture = syncPromise->get_future(); + ffrt::future syncFuture = syncPromise->get_future(); eventHandler_->PostTask([this, displayId, tmpWindows, syncPromise]() { HILOG_DEBUG(); sptr clientConnection = GetConnection(accountId_, clientName_); @@ -504,8 +504,8 @@ RetError AccessibleAbilityChannel::GetWindows(uint64_t displayId, std::vectorset_value(RET_OK); }, "GetWindows"); - std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait GetWindows result"); return RET_ERR_TIME_OUT; } @@ -549,8 +549,8 @@ RetError AccessibleAbilityChannel::GetCursorPosition(const int32_t accessibility HILOG_ERROR("eventHandler_ is nullptr."); return RET_ERR_NULLPTR; } - std::shared_ptr> syncPromise = std::make_shared>(); - std::future syncFuture = syncPromise->get_future(); + std::shared_ptr> syncPromise = std::make_shared>(); + ffrt::future syncFuture = syncPromise->get_future(); int32_t treeId = AccessibleAbilityManagerService::GetTreeIdBySplitElementId(elementId); HILOG_DEBUG("GetCursorPosition :channel GetCursorPosition treeId: %{public}d", treeId); eventHandler_->PostTask([this, syncPromise, accessibilityWindowId, elementId, treeId, @@ -573,8 +573,8 @@ RetError AccessibleAbilityChannel::GetCursorPosition(const int32_t accessibility syncPromise->set_value(RET_OK); }, "GetCursorPosition"); - std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait GetCursorPosition result"); return RET_ERR_TIME_OUT; } @@ -591,8 +591,8 @@ RetError AccessibleAbilityChannel::SendSimulateGesture( return RET_ERR_NULLPTR; } - std::shared_ptr> syncPromise = std::make_shared>(); - std::future syncFuture = syncPromise->get_future(); + std::shared_ptr> syncPromise = std::make_shared>(); + ffrt::future syncFuture = syncPromise->get_future(); eventHandler_->PostTask([this, gesturePath, syncPromise]() { HILOG_DEBUG(); sptr clientConnection = GetConnection(accountId_, clientName_); @@ -619,8 +619,8 @@ RetError AccessibleAbilityChannel::SendSimulateGesture( syncPromise->set_value(RET_OK); }, "SendSimulateGesture"); - std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait SendSimulateGesture result"); return RET_ERR_TIME_OUT; } @@ -636,8 +636,8 @@ RetError AccessibleAbilityChannel::SetTargetBundleName(const std::vector> syncPromise = std::make_shared>(); - std::future syncFuture = syncPromise->get_future(); + std::shared_ptr> syncPromise = std::make_shared>(); + ffrt::future syncFuture = syncPromise->get_future(); eventHandler_->PostTask([this, targetBundleNames, syncPromise]() { HILOG_DEBUG(); sptr clientConnection = GetConnection(accountId_, clientName_); @@ -651,8 +651,8 @@ RetError AccessibleAbilityChannel::SetTargetBundleName(const std::vectorset_value(RET_OK); }, "SetTargetBundleName"); - std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait SetTargetBundleName result"); return RET_ERR_TIME_OUT; } diff --git a/services/aams/src/accessible_ability_manager_service.cpp b/services/aams/src/accessible_ability_manager_service.cpp index ebc8207a..9cb734c4 100644 --- a/services/aams/src/accessible_ability_manager_service.cpp +++ b/services/aams/src/accessible_ability_manager_service.cpp @@ -54,14 +54,19 @@ namespace { const std::string SCREEN_READER_BUNDLE_ABILITY_NAME = "com.huawei.hmos.screenreader/AccessibilityExtAbility"; const std::string DEVICE_PROVISIONED = "device_provisioned"; const std::string USER_SETUP_COMPLETED = "user_setup_complete"; + const std::string SCREEN_MAGNIFICATION_KEY = "accessibility_display_magnification_enabled"; + const std::string SCREEN_MAGNIFICATION_TYPE = "accessibility_magnification_capability"; const std::string DELAY_UNLOAD_TASK = "TASK_UNLOAD_ACCESSIBILITY_SA"; const std::string ACCESSIBILITY_CLONE_FLAG = "accessibility_config_clone"; + const std::string SHORTCUT_ENABLED = "accessibility_shortcut_enabled"; + constexpr int32_t INVALID_SHORTCUT_STATE = 2; 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; constexpr int32_t REQUEST_ID_MAX = 0xFFFFFFFF; constexpr int32_t REQUEST_ID_MIN = 0x0000FFFF; constexpr int32_t DEFAULT_ACCOUNT_ID = 100; + constexpr int32_t ROOT_UID = 0; constexpr int32_t UNLOAD_TASK_INTERNAL = 3 * 60 * 1000; // ms constexpr int32_t TREE_ID_INVALID = 0; constexpr uint32_t ELEMENT_MOVE_BIT = 40; @@ -109,7 +114,7 @@ void AccessibleAbilityManagerService::OnStart() { HILOG_INFO("AccessibleAbilityManagerService::OnStart start"); if (!runner_) { - runner_ = AppExecFwk::EventRunner::Create(AAMS_SERVICE_NAME); + runner_ = AppExecFwk::EventRunner::Create(AAMS_SERVICE_NAME, AppExecFwk::ThreadMode::FFRT); if (!runner_) { HILOG_ERROR("AccessibleAbilityManagerService::OnStart failed:create AAMS runner failed"); return; @@ -125,7 +130,7 @@ void AccessibleAbilityManagerService::OnStart() } if (!actionRunner_) { - actionRunner_ = AppExecFwk::EventRunner::Create(AAMS_ACTION_RUNNER_NAME); + actionRunner_ = AppExecFwk::EventRunner::Create(AAMS_ACTION_RUNNER_NAME, AppExecFwk::ThreadMode::FFRT); if (!actionRunner_) { HILOG_ERROR("AccessibleAbilityManagerService::OnStart failed:create AAMS action runner failed"); return; @@ -162,13 +167,15 @@ void AccessibleAbilityManagerService::OnStop() return; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise]() { HILOG_DEBUG(); Singleton::GetInstance().UnSubscriberEvent(); +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER Singleton::GetInstance().UnregisterDisplayListener(); +#endif Singleton::GetInstance().DeregisterWindowListener(); currentAccountId_ = -1; @@ -238,6 +245,8 @@ void AccessibleAbilityManagerService::OnAddSystemAbility(int32_t systemAbilityId HILOG_DEBUG("AAMS is ready!"); RegisterShortKeyEvent(); PostDelayUnloadTask(); + RegisterScreenMagnificationState(); + RegisterScreenMagnificationType(); }, "OnAddSystemAbility"); } @@ -261,7 +270,9 @@ void AccessibleAbilityManagerService::OnRemoveSystemAbility(int32_t systemAbilit if (isReady_) { SwitchedUser(-1); Singleton::GetInstance().UnSubscriberEvent(); +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER Singleton::GetInstance().UnregisterDisplayListener(); +#endif Singleton::GetInstance().DeregisterWindowListener(); Singleton::GetInstance().DeInit(); @@ -278,8 +289,8 @@ int AccessibleAbilityManagerService::Dump(int fd, const std::vector syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, fd, args]() { if (!accessibilityDumper_) { accessibilityDumper_ = new(std::nothrow) AccessibilityDumper(); @@ -297,7 +308,7 @@ int AccessibleAbilityManagerService::Dump(int fd, const std::vector(elementId) >> ELEMENT_MOVE_BIT); + int32_t treeId = (static_cast(elementId) >> ELEMENT_MOVE_BIT); HILOG_DEBUG("VerifyingToKenId: treeId[%{public}d], windowId[%{public}d], elementId[%{public}" PRId64 "]", treeId, windowId, elementId); if (elementId == ELEMENT_ID_INVALID || windowId == WINDOW_ID_INVALID) { @@ -378,7 +389,7 @@ uint32_t AccessibleAbilityManagerService::RegisterStateObserver( return 0; } - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!stateObserversDeathRecipient_) { stateObserversDeathRecipient_ = new(std::nothrow) StateCallbackDeathRecipient(); if (!stateObserversDeathRecipient_) { @@ -409,8 +420,8 @@ void AccessibleAbilityManagerService::GetRealWindowAndElementId(int32_t& windowI return; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([&, this]() { Singleton::GetInstance().GetRealWindowAndElementId(windowId, elementId); syncPromise.set_value(); @@ -426,8 +437,8 @@ void AccessibleAbilityManagerService::GetSceneBoardInnerWinId(int32_t windowId, return; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([&, this]() { Singleton::GetInstance().GetSceneBoardInnerWinId(windowId, elementId, innerWid); syncPromise.set_value(); @@ -467,10 +478,10 @@ bool AccessibleAbilityManagerService::FindFocusedElementByConnection(sptr focusFuture = focusCallback->promise_.get_future(); + ffrt::future focusFuture = focusCallback->promise_.get_future(); connection->GetProxy()->FindFocusedElementInfo(elementId, focusType, GenerateRequestId(), focusCallback); - std::future_status waitFocus = focusFuture.wait_for(std::chrono::milliseconds(timeOut)); - if (waitFocus != std::future_status::ready) { + ffrt::future_status waitFocus = focusFuture.wait_for(std::chrono::milliseconds(timeOut)); + if (waitFocus != ffrt::future_status::ready) { HILOG_ERROR("FindFocusedElementInfo Failed to wait result"); return false; } @@ -506,15 +517,15 @@ bool AccessibleAbilityManagerService::FindFocusedElement(AccessibilityElementInf HILOG_ERROR("Failed to create callBack."); return false; } - std::future promiseFuture = callBack->promise_.get_future(); + ffrt::future promiseFuture = callBack->promise_.get_future(); GetElementOperatorConnection(connection, elementId, elementOperator); if (elementOperator == nullptr) { HILOG_ERROR("elementOperator is nullptr"); return false; } elementOperator->SearchElementInfoByAccessibilityId(elementId, GenerateRequestId(), callBack, 0); - std::future_status waitFocus = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (waitFocus != std::future_status::ready) { + ffrt::future_status waitFocus = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (waitFocus != ffrt::future_status::ready) { ipcTimeoutNum_++; HILOG_ERROR("Failed to wait result, number %{public}" PRId64 "", ipcTimeoutNum_); return false; @@ -566,7 +577,7 @@ bool AccessibleAbilityManagerService::ExecuteActionOnAccessibilityFocused(const HILOG_ERROR("Failed to create actionCallback."); return false; } - std::future actionFuture = actionCallback->promise_.get_future(); + ffrt::future actionFuture = actionCallback->promise_.get_future(); if (treeId > TREE_ID_INVALID) { if (connection->GetCardProxy(treeId) != nullptr) { connection->GetCardProxy(treeId)->ExecuteAction(elementId, action, @@ -578,8 +589,8 @@ bool AccessibleAbilityManagerService::ExecuteActionOnAccessibilityFocused(const } else { connection->GetProxy()->ExecuteAction(elementId, action, actionArguments, GenerateRequestId(), actionCallback); } - std::future_status waitAction = actionFuture.wait_for(std::chrono::milliseconds(timeOut)); - if (waitAction != std::future_status::ready) { + ffrt::future_status waitAction = actionFuture.wait_for(std::chrono::milliseconds(timeOut)); + if (waitAction != ffrt::future_status::ready) { HILOG_ERROR("ExecuteAction Failed to wait result"); return false; } @@ -616,8 +627,8 @@ uint32_t AccessibleAbilityManagerService::RegisterCaptionObserver( return ERR_INVALID_VALUE; } - std::shared_ptr> syncPromise = std::make_shared>(); - std::future syncFuture = syncPromise->get_future(); + std::shared_ptr> syncPromise = std::make_shared>(); + ffrt::future syncFuture = syncPromise->get_future(); actionHandler_->PostTask([this, syncPromise, callback]() { HILOG_DEBUG(); sptr accountData = GetCurrentAccountData(); @@ -646,8 +657,8 @@ uint32_t AccessibleAbilityManagerService::RegisterCaptionObserver( 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) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait RegisterCaptionObserver result"); return RET_ERR_TIME_OUT; } @@ -663,8 +674,8 @@ void AccessibleAbilityManagerService::RegisterEnableAbilityListsObserver( return; } - std::shared_ptr> syncPromisePtr = std::make_shared>(); - std::future syncFuture = syncPromisePtr->get_future(); + std::shared_ptr> syncPromisePtr = std::make_shared>(); + ffrt::future syncFuture = syncPromisePtr->get_future(); actionHandler_->PostTask([this, syncPromisePtr, observer]() { HILOG_DEBUG(); sptr accountData = GetCurrentAccountData(); @@ -691,8 +702,8 @@ void AccessibleAbilityManagerService::RegisterEnableAbilityListsObserver( syncPromisePtr->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) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait RegisterEnableAbilityListsObserver result"); return; } @@ -708,8 +719,8 @@ RetError AccessibleAbilityManagerService::GetAbilityList(const uint32_t abilityT return RET_ERR_INVALID_PARAM; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &infos, abilityTypes, stateType]() { sptr accountData = GetCurrentAccountData(); if (!accountData) { @@ -743,6 +754,9 @@ RetError AccessibleAbilityManagerService::RegisterElementOperator( return RET_ERR_NULLPTR; } uint32_t tokenId = IPCSkeleton::GetCallingTokenID(); + if (CheckCallingUid() != RET_OK) { + return RET_ERR_SAMGR; + } handler_->PostTask([=]() { HILOG_INFO("Register windowId[%{public}d]", windowId); HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "RegisterElementOperator"); @@ -808,21 +822,7 @@ RetError AccessibleAbilityManagerService::RegisterElementOperatorChildWork(const HILOG_ERROR("Get current account data failed!!"); return RET_ERR_REGISTER_EXIST; } - operation->SetBelongTreeId(treeId); - operation->SetParentWindowId(parameter.parentWindowId); - sptr oldConnection = - accountData->GetAccessibilityWindowConnection(parameter.windowId); - bool isParentConectionExist = false; - if (isApp && oldConnection) { - if (oldConnection->GetCardProxy(treeId) != nullptr) { - HILOG_WARN("no need to register again."); - return RET_ERR_REGISTER_EXIST; - } else { - oldConnection->SetCardProxy(treeId, operation); - SetTokenIdMapAndRootParentId(oldConnection, treeId, nodeId, tokenId); - isParentConectionExist = true; - } - } + sptr parentConnection = accountData->GetAccessibilityWindowConnection(parameter.parentWindowId); if (isApp && parentConnection) { @@ -833,20 +833,22 @@ RetError AccessibleAbilityManagerService::RegisterElementOperatorChildWork(const } else { HILOG_DEBUG("parentAamsOper is nullptr"); } + } else { + return RET_ERR_NO_CONNECTION; } - if (isParentConectionExist == false) { - DeleteConnectionAndDeathRecipient(parameter.windowId, oldConnection); - sptr connection = - new(std::nothrow) AccessibilityWindowConnection(parameter.windowId, - treeId, operation, currentAccountId_); - if (connection == nullptr) { - Utils::RecordUnavailableEvent(A11yUnavailableEvent::CONNECT_EVENT, - A11yError::ERROR_CONNECT_TARGET_APPLICATION_FAILED); - HILOG_ERROR("New AccessibilityWindowConnection failed!!"); + + operation->SetBelongTreeId(treeId); + operation->SetParentWindowId(parameter.parentWindowId); + sptr oldConnection = + accountData->GetAccessibilityWindowConnection(parameter.windowId); + if (isApp && oldConnection) { + if (oldConnection->GetCardProxy(treeId) != nullptr) { + HILOG_WARN("no need to register again."); return RET_ERR_REGISTER_EXIST; + } else { + oldConnection->SetCardProxy(treeId, operation); + SetTokenIdMapAndRootParentId(oldConnection, treeId, nodeId, tokenId); } - SetTokenIdMapAndRootParentId(connection, treeId, nodeId, tokenId); - accountData->AddAccessibilityWindowConnection(parameter.windowId, connection); } return RET_OK; } @@ -862,6 +864,9 @@ void AccessibleAbilityManagerService::SetTokenIdMapAndRootParentId( RetError AccessibleAbilityManagerService::RegisterElementOperator(Registration parameter, const sptr &operation, bool isApp) { + if (CheckCallingUid() != RET_OK) { + return RET_ERR_SAMGR; + } static std::atomic treeId(1); int32_t treeIdSingle = treeId.fetch_add(1, std::memory_order_relaxed); if (treeIdSingle > TREE_ID_MAX) { @@ -1062,8 +1067,8 @@ bool AccessibleAbilityManagerService::GetEnabledState() return false; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise]() { HILOG_DEBUG(); sptr accountData = GetCurrentAccountData(); @@ -1091,8 +1096,8 @@ bool AccessibleAbilityManagerService::GetTouchGuideState() return false; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise]() { HILOG_DEBUG(); sptr accountData = GetCurrentAccountData(); @@ -1115,8 +1120,8 @@ bool AccessibleAbilityManagerService::GetGestureState() return false; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise]() { HILOG_DEBUG(); sptr accountData = GetCurrentAccountData(); @@ -1139,8 +1144,8 @@ bool AccessibleAbilityManagerService::GetKeyEventObserverState() return false; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise]() { HILOG_DEBUG(); sptr accountData = GetCurrentAccountData(); @@ -1163,8 +1168,8 @@ RetError AccessibleAbilityManagerService::EnableAbility(const std::string &name, return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &name, &capabilities]() { HILOG_DEBUG(); RetError result = InnerEnableAbility(name, capabilities); @@ -1237,8 +1242,8 @@ RetError AccessibleAbilityManagerService::GetEnabledAbilities(std::vector syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, &enabledAbilities]() { HILOG_DEBUG(); sptr accountData = GetCurrentAccountData(); @@ -1261,8 +1266,8 @@ RetError AccessibleAbilityManagerService::DisableAbility(const std::string &name return RET_ERR_NULLPTR; } - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); actionHandler_->PostTask([this, &syncPromise, &name]() { HILOG_DEBUG(); RetError result = InnerDisableAbility(name); @@ -1312,8 +1317,8 @@ RetError AccessibleAbilityManagerService::EnableUITestAbility(const sptr syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); handler_->PostTask([this, &syncPromise, obj]() { HILOG_DEBUG(); sptr accountData = GetCurrentAccountData(); @@ -1346,8 +1351,8 @@ RetError AccessibleAbilityManagerService::DisableUITestAbility() return RET_ERR_NULLPTR; } - std::shared_ptr> syncPromise = std::make_shared>(); - std::future syncFuture = syncPromise->get_future(); + std::shared_ptr> syncPromise = std::make_shared>(); + ffrt::future syncFuture = syncPromise->get_future(); handler_->PostTask([this, syncPromise]() { HILOG_DEBUG(); sptr accountData = GetCurrentAccountData(); @@ -1369,8 +1374,8 @@ RetError AccessibleAbilityManagerService::DisableUITestAbility() syncPromise->set_value(RET_OK); }, "TASK_DISABLE_UI_TEST_ABILITIES"); - std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait DisableUITestAbility result"); return RET_ERR_TIME_OUT; } @@ -1387,7 +1392,9 @@ bool AccessibleAbilityManagerService::Init() { HILOG_DEBUG(); Singleton::GetInstance().SubscriberEvent(handler_); +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER Singleton::GetInstance().RegisterDisplayListener(handler_); +#endif Singleton::GetInstance().RegisterWindowListener(handler_); bool result = Singleton::GetInstance().Init(); HILOG_DEBUG("wms init result is %{public}d", result); @@ -1582,7 +1589,6 @@ void AccessibleAbilityManagerService::SwitchedUser(int32_t accountId) std::map importantEnabledAbilities; SCREENREADER_STATE screenReaderState = SCREENREADER_STATE::UNINIT; - // Clear last account's data if (currentAccountId_ != -1) { HILOG_DEBUG(); sptr accountData = GetCurrentAccountData(); @@ -1597,11 +1603,7 @@ void AccessibleAbilityManagerService::SwitchedUser(int32_t accountId) accountData->OnAccountSwitched(); UpdateAccessibilityManagerService(); } - - // Switch account id currentAccountId_ = accountId; - - // Initialize data for current account sptr accountData = GetCurrentAccountData(); if (!accountData) { HILOG_ERROR("accountData is nullptr."); @@ -1631,6 +1633,8 @@ void AccessibleAbilityManagerService::SwitchedUser(int32_t accountId) UpdateAllSetting(); UpdateAutoStartAbilities(); RegisterShortKeyEvent(); + RegisterScreenMagnificationState(); + RegisterScreenMagnificationType(); } void AccessibleAbilityManagerService::PackageRemoved(const std::string &bundleName) @@ -1856,10 +1860,10 @@ bool AccessibleAbilityManagerService::GetParentElementRecursively(int32_t window return false; } - std::future promiseFuture = callBack->promise_.get_future(); + ffrt::future promiseFuture = callBack->promise_.get_future(); elementOperator->SearchElementInfoByAccessibilityId(elementId, GenerateRequestId(), callBack, 0); - std::future_status waitFocus = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (waitFocus != std::future_status::ready) { + ffrt::future_status waitFocus = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (waitFocus != ffrt::future_status::ready) { ipcTimeoutNum_++; HILOG_ERROR("Failed to wait result, number %{public}" PRId64 "", ipcTimeoutNum_); return false; @@ -2249,8 +2253,8 @@ RetError AccessibleAbilityManagerService::GetIgnoreRepeatClickTime(uint32_t &tim void AccessibleAbilityManagerService::GetAllConfigs(AccessibilityConfigData &configData) { HILOG_DEBUG(); - std::promise syncPromise; - std::future syncFuture = syncPromise.get_future(); + ffrt::promise syncPromise; + ffrt::future syncFuture = syncPromise.get_future(); actionHandler_->PostTask([this, &syncPromise, &configData]() { HILOG_DEBUG(); sptr accountData = GetCurrentAccountData(); @@ -2280,8 +2284,8 @@ void AccessibleAbilityManagerService::GetAllConfigs(AccessibilityConfigData &con syncPromise.set_value(); }, "TASK_GET_ALL_CONFIGS"); - std::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); - if (wait != std::future_status::ready) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait GetAllConfigs result"); return; } @@ -2379,8 +2383,8 @@ uint32_t AccessibleAbilityManagerService::RegisterConfigObserver( return ERR_INVALID_VALUE; } - std::shared_ptr> syncPromisePtr = std::make_shared>(); - std::future syncFuture = syncPromisePtr->get_future(); + std::shared_ptr> syncPromisePtr = std::make_shared>(); + ffrt::future syncFuture = syncPromisePtr->get_future(); actionHandler_->PostTask([this, syncPromisePtr, callback]() { HILOG_DEBUG(); sptr accountData = GetCurrentAccountData(); @@ -2409,8 +2413,8 @@ uint32_t AccessibleAbilityManagerService::RegisterConfigObserver( syncPromisePtr->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) { + ffrt::future_status wait = syncFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR)); + if (wait != ffrt::future_status::ready) { HILOG_ERROR("Failed to wait RegisterConfigObserver result"); return RET_ERR_TIME_OUT; } @@ -2554,7 +2558,7 @@ void AccessibleAbilityManagerService::OnBundleManagerDied(const wptr& stateObserver) { - std::lock_guard lock(stateObserversMutex_); + std::lock_guard lock(stateObserversMutex_); auto iter = std::find(observersList_.begin(), observersList_.end(), stateObserver); if (iter == observersList_.end()) { observersList_.push_back(stateObserver); @@ -2567,7 +2571,7 @@ void AccessibleAbilityManagerService::StateObservers::AddStateObserver( void AccessibleAbilityManagerService::StateObservers::OnStateObservers(uint32_t state) { - std::lock_guard lock(stateObserversMutex_); + std::lock_guard lock(stateObserversMutex_); for (auto& stateObserver : observersList_) { if (stateObserver) { stateObserver->OnStateChanged(state); @@ -2577,7 +2581,7 @@ void AccessibleAbilityManagerService::StateObservers::OnStateObservers(uint32_t void AccessibleAbilityManagerService::StateObservers::RemoveStateObserver(const wptr &remote) { - std::lock_guard lock(stateObserversMutex_); + std::lock_guard lock(stateObserversMutex_); auto iter = std::find_if(observersList_.begin(), observersList_.end(), [remote](const sptr& stateObserver) { return stateObserver->AsObject() == remote; @@ -2589,7 +2593,7 @@ void AccessibleAbilityManagerService::StateObservers::RemoveStateObserver(const void AccessibleAbilityManagerService::StateObservers::Clear() { - std::lock_guard lock(stateObserversMutex_); + std::lock_guard lock(stateObserversMutex_); observersList_.clear(); } @@ -2619,6 +2623,53 @@ void AccessibleAbilityManagerService::OnDeviceProvisioned() } } +void AccessibleAbilityManagerService::InitializeShortKeyState() +{ + sptr accountData = GetCurrentAccountData(); + if (!accountData) { + HILOG_ERROR("accountData is nullptr"); + return; + } + + bool shortKeyFlag = false; + if (accountData->GetAccountId() != DEFAULT_ACCOUNT_ID && accountData->GetConfig()->GetDbHandle() != nullptr) { + if (accountData->GetConfig()->GetDbHandle()->GetIntValue(SHORTCUT_ENABLED, INVALID_SHORTCUT_STATE) == + INVALID_SHORTCUT_STATE) { + HILOG_INFO("Initialize the shortcut key state of PrivateSpace"); + shortKeyFlag = true; + } + } else if (accountData->GetAccountId() == DEFAULT_ACCOUNT_ID) { + HILOG_INFO("Initialize the shortcut key state of MainSpace"); + shortKeyFlag = true; + } + + if (shortKeyFlag) { + accountData->GetConfig()->SetShortKeyState(true); + std::vector tmpVec { SCREEN_READER_BUNDLE_ABILITY_NAME }; + accountData->GetConfig()->SetShortkeyMultiTarget(tmpVec); + UpdateConfigState(); + Singleton::GetInstance().UpdateShortKeyRegister(); + } +} + +void AccessibleAbilityManagerService::RegisterProvisionCallback() +{ + sptr accountData = GetCurrentAccountData(); + if (!accountData) { + HILOG_ERROR("accountData is nullptr"); + return; + } + + AccessibilitySettingProvider& service = AccessibilitySettingProvider::GetInstance(POWER_MANAGER_SERVICE_ID); + AccessibilitySettingObserver::UpdateFunc func = [ = ](const std::string &state) { + Singleton::GetInstance().OnDeviceProvisioned(); + }; + service.RegisterObserver(DEVICE_PROVISIONED, func); + if (accountData->GetConfig()->GetDbHandle() != nullptr) { + accountData->GetConfig()->GetDbHandle()->RegisterObserver(USER_SETUP_COMPLETED, func); + } +} + void AccessibleAbilityManagerService::RegisterShortKeyEvent() { HILOG_DEBUG(); @@ -2637,27 +2688,136 @@ void AccessibleAbilityManagerService::RegisterShortKeyEvent() bool oobeState = false; bool userSetupState = false; provider.GetBoolValue(DEVICE_PROVISIONED, oobeState); - if (accountData->GetConfig()->GetDbHandle()) { + if (accountData->GetConfig()->GetDbHandle() != nullptr) { userSetupState = accountData->GetConfig()->GetDbHandle()->GetBoolValue(USER_SETUP_COMPLETED, false); } - if (oobeState == false || userSetupState == false) { - HILOG_DEBUG(); - accountData->GetConfig()->SetShortKeyState(true); - std::vector tmpVec { SCREEN_READER_BUNDLE_ABILITY_NAME }; - accountData->GetConfig()->SetShortkeyMultiTarget(tmpVec); - UpdateConfigState(); - Singleton::GetInstance().UpdateShortKeyRegister(); - AccessibilitySettingObserver::UpdateFunc func = [ = ](const std::string &state) { - Singleton::GetInstance().OnDeviceProvisioned(); - }; - provider.RegisterObserver(DEVICE_PROVISIONED, func); - if (accountData->GetConfig()->GetDbHandle()) { - accountData->GetConfig()->GetDbHandle()->RegisterObserver(USER_SETUP_COMPLETED, func); - } + if (accountData->GetAccountId() == DEFAULT_ACCOUNT_ID && (oobeState == false || userSetupState == false)) { + InitializeShortKeyState(); + RegisterProvisionCallback(); + } else if (accountData->GetAccountId() != DEFAULT_ACCOUNT_ID) { + InitializeShortKeyState(); } }, "REGISTER_SHORTKEY_OBSERVER"); } +void AccessibleAbilityManagerService::OffZoomGesture() +{ + HILOG_DEBUG(); +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER + AccessibilityDisplayManager &displayMgr = Singleton::GetInstance(); + uint64_t currentScreen = displayMgr.GetDefaultDisplayId(); + float normalScale = 1.0f; + float defaultAnchor = 0.5f; + displayMgr.SetDisplayScale(currentScreen, normalScale, normalScale, defaultAnchor, defaultAnchor); + return; +#else + HILOG_INFO("not support zoom"); + return; +#endif +} + +void AccessibleAbilityManagerService::OnScreenMagnificationStateChanged() +{ + HILOG_DEBUG(); + sptr accountData = GetCurrentAccountData(); + if (accountData == nullptr) { + HILOG_ERROR("accountData is nullptr"); + return; + } + + std::shared_ptr config = accountData->GetConfig(); + if (config == nullptr) { + HILOG_ERROR("config is nullptr"); + return; + } + + if (config->GetDbHandle() == nullptr) { + HILOG_ERROR("datashareHelper is nullptr"); + return; + } + + bool screenMagnificationEnabled = false; + screenMagnificationEnabled = config->GetDbHandle()->GetBoolValue(SCREEN_MAGNIFICATION_KEY, false); + config->SetScreenMagnificationState(screenMagnificationEnabled); + Singleton::GetInstance().UpdateInputFilter(); + if (!screenMagnificationEnabled) { + OffZoomGesture(); + } +} + +void AccessibleAbilityManagerService::RegisterScreenMagnificationState() +{ + HILOG_DEBUG(); + if (handler_ == nullptr) { + HILOG_ERROR("handler_ is nullptr"); + return; + } + handler_->PostTask([=]() { + sptr accountData = GetCurrentAccountData(); + if (accountData == nullptr) { + HILOG_ERROR("accountData is nullptr"); + return; + } + + AccessibilitySettingObserver::UpdateFunc func = [ = ](const std::string &state) { + Singleton::GetInstance().OnScreenMagnificationStateChanged(); + }; + if (accountData->GetConfig()->GetDbHandle()) { + accountData->GetConfig()->GetDbHandle()->RegisterObserver(SCREEN_MAGNIFICATION_KEY, func); + } + }, "REGISTER_SCREEN_ZOOM_OBSERVER"); +} + +void AccessibleAbilityManagerService::OnScreenMagnificationTypeChanged() +{ + HILOG_DEBUG(); + sptr accountData = GetCurrentAccountData(); + if (accountData == nullptr) { + HILOG_ERROR("accountData is nullptr"); + return; + } + + std::shared_ptr config = accountData->GetConfig(); + if (config == nullptr) { + HILOG_ERROR("config is nullptr"); + return; + } + + if (config->GetDbHandle() == nullptr) { + HILOG_ERROR("datashareHelper is nullptr"); + return; + } + + uint32_t screenMagnificationType = 0; + screenMagnificationType = + static_cast(config->GetDbHandle()->GetIntValue(SCREEN_MAGNIFICATION_TYPE, 0)); + config->SetScreenMagnificationType(screenMagnificationType); + Singleton::GetInstance().UpdateInputFilter(); +} + +void AccessibleAbilityManagerService::RegisterScreenMagnificationType() +{ + HILOG_DEBUG(); + if (handler_ == nullptr) { + HILOG_ERROR("handler_ is nullptr"); + return; + } + handler_->PostTask([=]() { + sptr accountData = GetCurrentAccountData(); + if (accountData == nullptr) { + HILOG_ERROR("accountData is nullptr"); + return; + } + + AccessibilitySettingObserver::UpdateFunc func = [ = ](const std::string &state) { + Singleton::GetInstance().OnScreenMagnificationTypeChanged(); + }; + if (accountData->GetConfig()->GetDbHandle()) { + accountData->GetConfig()->GetDbHandle()->RegisterObserver(SCREEN_MAGNIFICATION_TYPE, func); + } + }, "REGISTER_SCREEN_ZOOM_TYPE_OBSERVER"); +} + void AccessibleAbilityManagerService::InsertWindowIdEventPair(int32_t windowId, const AccessibilityEventInfo &event) { HILOG_DEBUG("insert event, windowId: %{public}d", windowId); @@ -2748,7 +2908,7 @@ int32_t AccessibleAbilityManagerService::GetTreeIdBySplitElementId(const int64_t void AccessibleAbilityManagerService::AddRequestId(int32_t windowId, int32_t treeId, int32_t requestId, sptr callback) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); HILOG_DEBUG("Add windowId: %{public}d treeId: %{public}d requestId: %{public}d", windowId, treeId, requestId); if (!windowRequestIdMap_.count(windowId)) { windowRequestIdMap_[windowId] = {}; @@ -2764,7 +2924,7 @@ void AccessibleAbilityManagerService::AddRequestId(int32_t windowId, int32_t tre void AccessibleAbilityManagerService::RemoveRequestId(int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); HILOG_DEBUG("RemoveRequestId requestId: %{public}d", requestId); for (auto &window : windowRequestIdMap_) { for (auto &tree : window.second) { @@ -2797,7 +2957,7 @@ void AccessibleAbilityManagerService::StopCallbackWait(int32_t windowId) void AccessibleAbilityManagerService::StopCallbackWait(int32_t windowId, int32_t treeId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); HILOG_INFO("StopCallbackWait start windowId: %{public}d treeId: %{public}d", windowId, treeId); if (!windowRequestIdMap_.count(windowId)) { return; @@ -2856,6 +3016,16 @@ int32_t AccessibleAbilityManagerService::GenerateRequestId() return requestId; } +RetError AccessibleAbilityManagerService::CheckCallingUid() +{ + int32_t accountId = Utils::GetUserIdByCallingUid(); + if (accountId != currentAccountId_ && accountId != ROOT_UID) { + HILOG_WARN("accountId is diff from currentAccountId_."); + return RET_ERR_SAMGR; + } + return RET_OK; +} + void AccessibleAbilityManagerService::OnDataClone() { AccessibilitySettingProvider& provider = AccessibilitySettingProvider::GetInstance(POWER_MANAGER_SERVICE_ID); diff --git a/services/aams/test/BUILD.gn b/services/aams/test/BUILD.gn index 576389d6..21a45678 100644 --- a/services/aams/test/BUILD.gn +++ b/services/aams/test/BUILD.gn @@ -131,6 +131,7 @@ ohos_unittest("accessibility_account_data_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -226,6 +227,7 @@ ohos_unittest("accessible_ability_manager_service_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -251,6 +253,8 @@ ohos_unittest("accessibility_touch_guider_test") { "../../../common/interface/src/accessibility_element_operator_callback_stub.cpp", "../../../common/interface/src/accessible_ability_channel_stub.cpp", "../../../common/interface/src/parcel/accessibility_element_info_parcel.cpp", + "../../../common/interface/src/parcel/accessibility_gesture_inject_path_parcel.cpp", + "../../../common/interface/src/parcel/accessibility_window_info_parcel.cpp", "../../test/mock/mock_common_event_data.cpp", "../../test/mock/mock_common_event_manager.cpp", "../../test/mock/mock_common_event_subscribe_info.cpp", @@ -309,6 +313,7 @@ ohos_unittest("accessibility_touch_guider_test") { "data_share:datashare_common", "data_share:datashare_consumer", "eventhandler:libeventhandler", + "ffrt:libffrt", "hilog:libhilog", "hisysevent:libhisysevent", "init:libbegetutil", @@ -396,6 +401,7 @@ ohos_unittest("accessibility_common_event_registry_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -491,6 +497,7 @@ ohos_unittest("accessibility_input_interceptor_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -582,6 +589,7 @@ ohos_unittest("accessibility_window_manager_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -664,6 +672,7 @@ ohos_unittest("accessibility_keyevent_filter_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -765,6 +774,7 @@ ohos_unittest("accessible_ability_connection_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -817,6 +827,7 @@ ohos_unittest("accessibility_display_manager_test") { "common_event_service:cesfwk_innerkits", "data_share:datashare_common", "data_share:datashare_consumer", + "ffrt:libffrt", "hilog:libhilog", "hisysevent:libhisysevent", "init:libbegetutil", @@ -836,6 +847,9 @@ ohos_unittest("accessibility_dumper_test") { module_out_path = module_output_path sources = [ "../../../common/interface/src/accessible_ability_channel_stub.cpp", + "../../../common/interface/src/parcel/accessibility_element_info_parcel.cpp", + "../../../common/interface/src/parcel/accessibility_gesture_inject_path_parcel.cpp", + "../../../common/interface/src/parcel/accessibility_window_info_parcel.cpp", "../../test/mock/mock_common_event_data.cpp", "../../test/mock/mock_common_event_manager.cpp", "../../test/mock/mock_common_event_subscribe_info.cpp", @@ -887,6 +901,7 @@ ohos_unittest("accessibility_dumper_test") { "data_share:datashare_common", "data_share:datashare_consumer", "eventhandler:libeventhandler", + "ffrt:libffrt", "hilog:libhilog", "hisysevent:libhisysevent", "init:libbegetutil", @@ -972,6 +987,7 @@ ohos_unittest("accessibility_touchevent_injector_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -1055,6 +1071,7 @@ ohos_unittest("accessible_ability_channel_test") { "data_share:datashare_common", "data_share:datashare_consumer", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:librender_service_client", "hilog:libhilog", "hisysevent:libhisysevent", @@ -1143,6 +1160,7 @@ ohos_unittest("accessibility_mouse_autoclick_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -1232,6 +1250,7 @@ ohos_unittest("accessibility_screen_touch_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -1282,6 +1301,7 @@ ohos_unittest("accessibility_mouse_key_test") { "common_event_service:cesfwk_innerkits", "data_share:datashare_common", "data_share:datashare_consumer", + "ffrt:libffrt", "hilog:libhilog", "hisysevent:libhisysevent", "init:libbegetutil", @@ -1367,6 +1387,7 @@ ohos_unittest("accessibility_short_key_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -1448,6 +1469,7 @@ ohos_unittest("accessibility_settings_config_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -1478,7 +1500,6 @@ ohos_unittest("accessibility_zoom_gesture_test") { "../src/accessibility_account_data.cpp", "../src/accessibility_circle_drawing_manager.cpp", "../src/accessibility_datashare_helper.cpp", - "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", @@ -1504,11 +1525,11 @@ ohos_unittest("accessibility_zoom_gesture_test") { "../src/accessible_ability_manager_service_event_handler.cpp", "../src/utils.cpp", "mock/src/mock_accessibility_common_event.cpp", + "mock/src/mock_accessibility_display_manager.cpp", "mock/src/mock_accessibility_event_transmission.cpp", "mock/src/mock_accessible_ability_client_stub_impl.cpp", "mock/src/mock_accessible_ability_manager_service.cpp", "mock/src/mock_system_ability.cpp", - "mock/src/mock_window_accessibility_controller.cpp", "unittest/accessibility_zoom_gesture_test.cpp", ] sources += aams_mock_distributeddatamgr_src @@ -1538,6 +1559,7 @@ ohos_unittest("accessibility_zoom_gesture_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", diff --git a/services/aams/test/mock/include/accessibility_ut_helper.h b/services/aams/test/mock/include/accessibility_ut_helper.h index f553e93e..86314d4a 100644 --- a/services/aams/test/mock/include/accessibility_ut_helper.h +++ b/services/aams/test/mock/include/accessibility_ut_helper.h @@ -16,8 +16,8 @@ #ifndef ACCESSIBILITY_UT_HELPER_H #define ACCESSIBILITY_UT_HELPER_H -#include #include "accessibility_event_info.h" +#include "ffrt.h" #include "hilog/log.h" #include "iremote_object.h" @@ -33,13 +33,13 @@ public: std::vector GetTouchEventActionVector() { - std::lock_guard lock(mtx_); + std::lock_guard lock(mtx_); return touchAction_; } int32_t GetTouchEventActionOfTargetIndex(int32_t index) { - std::lock_guard lock(mtx_); + std::lock_guard lock(mtx_); int32_t size = static_cast(touchAction_.size()); if (size > index) { return touchAction_[index]; @@ -49,13 +49,13 @@ public: void ClearTouchEventActionVector() { - std::lock_guard lock(mtx_); + std::lock_guard lock(mtx_); touchAction_.clear(); } void SetTouchEventActionVectors(int32_t touchAction) { - std::lock_guard lock(mtx_); + std::lock_guard lock(mtx_); touchAction_.push_back(touchAction); } @@ -156,13 +156,13 @@ public: std::vector GetEventTypeVector() { - std::lock_guard lock(mtx_); + std::lock_guard lock(mtx_); return eventType_; } EventType GetEventTypeOfTargetIndex(int32_t index) { - std::lock_guard lock(mtx_); + std::lock_guard lock(mtx_); int32_t size = static_cast(eventType_.size()); if (size > index) { return eventType_[index]; @@ -172,13 +172,13 @@ public: void ClearEventTypeActionVector() { - std::lock_guard lock(mtx_); + std::lock_guard lock(mtx_); eventType_.clear(); } void SetEventTypeVector(EventType eventType) { - std::lock_guard lock(mtx_); + std::lock_guard lock(mtx_); eventType_.push_back(eventType); } @@ -449,7 +449,7 @@ private: bool enableShortKeyTargetAbility_ = false; bool zoomState_ = false; bool scrollState_ = false; - std::mutex mtx_; + ffrt::mutex mtx_; std::vector userIds_; std::vector packages_; int32_t currentUserId_ = -1; diff --git a/services/aams/test/mock/src/aafwk/system_ability_manager.cpp b/services/aams/test/mock/src/aafwk/system_ability_manager.cpp index 66eba45b..ea5e6d4f 100644 --- a/services/aams/test/mock/src/aafwk/system_ability_manager.cpp +++ b/services/aams/test/mock/src/aafwk/system_ability_manager.cpp @@ -23,7 +23,7 @@ #include "system_ability_definition.h" namespace OHOS { -std::mutex SystemAbilityManager::instanceLock; +ffrt::mutex SystemAbilityManager::instanceLock; sptr SystemAbilityManager::instance; SystemAbilityManager::SystemAbilityManager() @@ -43,7 +43,7 @@ const sptr SystemAbilityManager::GetDBinder() const sptr SystemAbilityManager::GetInstance() { HILOG_ERROR("SystemAbilityManager::GetInstance"); - std::lock_guard autoLock(instanceLock); + std::lock_guard autoLock(instanceLock); if (!instance) { instance = new SystemAbilityManager; } diff --git a/services/aams/test/mock/src/mock_accessibility_account_data.cpp b/services/aams/test/mock/src/mock_accessibility_account_data.cpp index 4e129f22..006613b1 100644 --- a/services/aams/test/mock/src/mock_accessibility_account_data.cpp +++ b/services/aams/test/mock/src/mock_accessibility_account_data.cpp @@ -250,6 +250,11 @@ void AccessibilityAccountData::UpdateMagnificationCapability() isScreenMagnification_ = false; } +void AccessibilityAccountData::UpdateEnableAbilityListsState() +{ + return; +} + RetError AccessibilityAccountData::EnableAbility(const std::string &name, const uint32_t capabilities) { HILOG_DEBUG("start."); @@ -310,7 +315,7 @@ void AccessibilityAccountData::AddConfigCallback( configCallbacks_.push_back(callback); } -const std::vector> &AccessibilityAccountData::GetConfigCallbacks() +const std::vector> AccessibilityAccountData::GetConfigCallbacks() { HILOG_DEBUG("GetConfigCallbacks start"); return configCallbacks_; diff --git a/services/aams/test/mock/src/mock_accessibility_display_manager.cpp b/services/aams/test/mock/src/mock_accessibility_display_manager.cpp new file mode 100644 index 00000000..b73be59a --- /dev/null +++ b/services/aams/test/mock/src/mock_accessibility_display_manager.cpp @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "accessibility_display_manager.h" +#include "accessible_ability_manager_service.h" +#include "hilog_wrapper.h" +#include "accessibility_ut_helper.h" + +namespace OHOS { +namespace Accessibility { + +constexpr int32_t DEFAULT_DPI = 540; +constexpr int32_t DEFAULT_WIDTH = 1260; +constexpr int32_t DEFAULT_HEIGHT = 2720; +constexpr float DEFAULT_SCALE = 2.0f; +constexpr float NORMAL_SCALE = 1.0f; + +AccessibilityDisplayManager::AccessibilityDisplayManager() +{ +} + +AccessibilityDisplayManager::~AccessibilityDisplayManager() +{ + UnregisterDisplayListener(); +} + +const sptr AccessibilityDisplayManager::GetDisplay(uint64_t id) +{ + HILOG_DEBUG(); + return Rosen::DisplayManager::GetInstance().GetDisplayById(id); +} + +std::vector> AccessibilityDisplayManager::GetDisplays() +{ + HILOG_DEBUG(); + return Rosen::DisplayManager::GetInstance().GetAllDisplays(); +} + +const sptr AccessibilityDisplayManager::GetDefaultDisplay() +{ + HILOG_DEBUG(); + return Rosen::DisplayManager::GetInstance().GetDefaultDisplay(); +} + +uint64_t AccessibilityDisplayManager::GetDefaultDisplayId() +{ + HILOG_DEBUG(); + return Rosen::DisplayManager::GetInstance().GetDefaultDisplayId(); +} + +int32_t AccessibilityDisplayManager::GetWidth() +{ + HILOG_DEBUG(); + sptr displaySync = GetDefaultDisplaySync(); + if (displaySync == nullptr) { + HILOG_ERROR("default displaySync is null"); + return DEFAULT_WIDTH; + } + + return displaySync->GetWidth(); +} + +int32_t AccessibilityDisplayManager::GetHeight() +{ + HILOG_DEBUG(); + sptr displaySync = GetDefaultDisplaySync(); + if (displaySync == nullptr) { + HILOG_ERROR("default displaySync is null"); + return DEFAULT_HEIGHT; + } + + return displaySync->GetHeight(); +} + +OHOS::Rosen::DisplayOrientation AccessibilityDisplayManager::GetOrientation() +{ + HILOG_DEBUG(); + sptr displaySync = GetDefaultDisplaySync(); + if (displaySync == nullptr) { + HILOG_ERROR("default displaySync is null"); + return OHOS::Rosen::DisplayOrientation::PORTRAIT; + } + + auto displayInfo = displaySync->GetDisplayInfo(); + if (displayInfo == nullptr) { + HILOG_ERROR("default displayInfo is null"); + return OHOS::Rosen::DisplayOrientation::PORTRAIT; + } + + return displayInfo->GetDisplayOrientation(); +} + +sptr AccessibilityDisplayManager::GetDefaultDisplaySync() +{ + HILOG_DEBUG(); + return Rosen::DisplayManager::GetInstance().GetDefaultDisplaySync(); +} + +int32_t AccessibilityDisplayManager::GetDefaultDisplayDpi() +{ + HILOG_DEBUG(); + if (GetDefaultDisplay() == nullptr) { + HILOG_ERROR("default display is null"); + return DEFAULT_DPI; + } + + return GetDefaultDisplay()->GetDpi(); +} + +bool AccessibilityDisplayManager::IsFoldable() +{ + HILOG_DEBUG(); + return Rosen::DisplayManager::GetInstance().IsFoldable(); +} + +Rosen::FoldDisplayMode AccessibilityDisplayManager::GetFoldDisplayMode() +{ + HILOG_DEBUG(); + return Rosen::DisplayManager::GetInstance().GetFoldDisplayMode(); +} + +void AccessibilityDisplayManager::SetDisplayScale(const uint64_t screenId, + float scaleX, float scaleY, float pivotX, float pivotY) +{ + HILOG_DEBUG("scaleX = %{public}f, scaleY = %{public}f, pivotX = %{public}f, pivotY = %{public}f", + scaleX, scaleY, pivotX, pivotY); + if ((scaleX >= DEFAULT_SCALE) || (scaleY >= DEFAULT_SCALE)) { + Accessibility::AccessibilityAbilityHelper::GetInstance().SetZoomState(true); + } + + if ((scaleX == NORMAL_SCALE) || (scaleY == NORMAL_SCALE)) { + Accessibility::AccessibilityAbilityHelper::GetInstance().SetZoomState(false); + } +} + +void AccessibilityDisplayManager::RegisterDisplayListener( + const std::shared_ptr &handler) +{ + HILOG_DEBUG(); + if (listener_) { + HILOG_DEBUG("Display listener is already registed!"); + return; + } + handler_ = handler; + listener_ = new(std::nothrow) DisplayListener(); + if (!listener_) { + HILOG_ERROR("Create display listener fail!"); + return; + } + Rosen::DisplayManager::GetInstance().RegisterDisplayListener(listener_); +} + +void AccessibilityDisplayManager::UnregisterDisplayListener() +{ + HILOG_DEBUG(); + if (listener_) { + Rosen::DisplayManager::GetInstance().UnregisterDisplayListener(listener_); + listener_ = nullptr; + handler_ = nullptr; + } +} +} // namespace Accessibility +} // namespace OHOS \ No newline at end of file diff --git a/services/aams/test/mock/src/mock_accessibility_setting_provider.cpp b/services/aams/test/mock/src/mock_accessibility_setting_provider.cpp index 018fbd48..3e204d07 100644 --- a/services/aams/test/mock/src/mock_accessibility_setting_provider.cpp +++ b/services/aams/test/mock/src/mock_accessibility_setting_provider.cpp @@ -20,7 +20,7 @@ namespace OHOS { namespace Accessibility { AccessibilitySettingProvider* AccessibilitySettingProvider::instance_; -std::mutex AccessibilitySettingProvider::mutex_; +ffrt::mutex AccessibilitySettingProvider::mutex_; namespace { constexpr int32_t DEFAULT_ACCOUNT_ID = 100; } // namespace diff --git a/services/aams/test/mock/src/mock_accessibility_settings_config.cpp b/services/aams/test/mock/src/mock_accessibility_settings_config.cpp index 2eb02906..877080c4 100644 --- a/services/aams/test/mock/src/mock_accessibility_settings_config.cpp +++ b/services/aams/test/mock/src/mock_accessibility_settings_config.cpp @@ -66,6 +66,13 @@ RetError AccessibilitySettingsConfig::SetScreenMagnificationState(const bool sta return RET_OK; } +RetError AccessibilitySettingsConfig::SetScreenMagnificationType(const uint32_t type) +{ + HILOG_DEBUG("start."); + screenMagnificationType_ = type; + return RET_OK; +} + RetError AccessibilitySettingsConfig::SetShortKeyState(const bool state) { HILOG_DEBUG("start."); diff --git a/services/aams/test/mock/src/mock_accessibility_zoom_gesture.cpp b/services/aams/test/mock/src/mock_accessibility_zoom_gesture.cpp deleted file mode 100644 index 687a791f..00000000 --- a/services/aams/test/mock/src/mock_accessibility_zoom_gesture.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "accessibility_zoom_gesture.h" - -namespace OHOS { -namespace Accessibility { -/** - * Triple: DOWN UP DOWN UP DOWN - */ -AccessibilityZoomGesture::AccessibilityZoomGesture() -{ - Initialize(); -} - -AccessibilityZoomGesture::~AccessibilityZoomGesture() -{} - -void AccessibilityZoomGesture::Initialize() -{ - distance_ = GetSysDistance(); - timeout_ = GetSysTimeout(); -} - -int32_t AccessibilityZoomGesture::GetSysDistance() const -{ - return 0; -} - -int64_t AccessibilityZoomGesture::GetSysTimeout() const -{ - return 0; -} - -bool AccessibilityZoomGesture::ValidDown(MMI::PointerEvent& event) -{ - (void)event; - return true; -} - -bool AccessibilityZoomGesture::Triple(MMI::PointerEvent& event) -{ - (void)event; - return false; -} - -void AccessibilityZoomGesture::Up() -{} - -void AccessibilityZoomGesture::Reset(const MMI::PointerEvent& event) -{ - (void)event; -} - -void AccessibilityZoomGesture::Clear() -{ - upCount_ = 0; - downCount_ = 0; -} -} // namespace Accessibility -} // namespace OHOS \ No newline at end of file diff --git a/services/aams/test/mock/src/mock_accessible_ability_connection.cpp b/services/aams/test/mock/src/mock_accessible_ability_connection.cpp index 3cd0212e..b806ae49 100644 --- a/services/aams/test/mock/src/mock_accessible_ability_connection.cpp +++ b/services/aams/test/mock/src/mock_accessible_ability_connection.cpp @@ -290,5 +290,22 @@ void AccessibleAbilityConnection::OnAbilityDisconnectDoneSync(const AppExecFwk:: HILOG_DEBUG("start"); (void)element; } + +RetError AccessibleAbilityChannel::EnableScreenCurtain(bool isEnable) +{ + (void)isEnable; + return RET_OK; +} + +RetError AccessibleAbilityChannel::GetCursorPosition(const int32_t accessibilityWindowId, const int64_t elementId, + const int32_t requestId, const sptr &callback) +{ + GTEST_LOG_(INFO) << "MOCK AccessibleAbilitychannel GetCursorPosition"; + (void)accessibilityWindowId; + (void)elementId; + (void)requestId; + (void)callback; + return RET_OK; +} } // namespace Accessibility } // namespace OHOS \ No newline at end of file diff --git a/services/aams/test/mock/src/mock_accessible_ability_manager_service.cpp b/services/aams/test/mock/src/mock_accessible_ability_manager_service.cpp index 5d3f6d74..2d0d5b89 100644 --- a/services/aams/test/mock/src/mock_accessible_ability_manager_service.cpp +++ b/services/aams/test/mock/src/mock_accessible_ability_manager_service.cpp @@ -47,7 +47,7 @@ AccessibleAbilityManagerService::~AccessibleAbilityManagerService() void AccessibleAbilityManagerService::OnStart() { GTEST_LOG_(INFO) << "###AccessibleAbilityManagerService::OnStart"; - runner_ = AppExecFwk::EventRunner::Create("AccessibleAbilityManagerService"); + runner_ = AppExecFwk::EventRunner::Create("AccessibleAbilityManagerService", AppExecFwk::ThreadMode::FFRT); handler_ = std::make_shared(runner_); Singleton::GetInstance().RegisterWindowListener(handler_); Singleton::GetInstance().SubscriberEvent(handler_); @@ -261,6 +261,11 @@ void AccessibleAbilityManagerService::UpdateAllSetting() return; } +void AccessibleAbilityManagerService::UpdateInputFilter() +{ + return; +} + void AccessibleAbilityManagerService::UpdateShortKeyRegister() { return; diff --git a/services/aams/test/mock/src/mock_window_accessibility_controller.cpp b/services/aams/test/mock/src/mock_window_accessibility_controller.cpp deleted file mode 100644 index 46a54b84..00000000 --- a/services/aams/test/mock/src/mock_window_accessibility_controller.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "accessibility_ut_helper.h" -#include "window_accessibility_controller.h" - -namespace OHOS::Rosen { -WM_IMPLEMENT_SINGLE_INSTANCE(WindowAccessibilityController) -WindowAccessibilityController::WindowAccessibilityController() -{ -} - -void WindowAccessibilityController::SetAnchorAndScale(int32_t x, int32_t y, float scale) -{ - Accessibility::AccessibilityAbilityHelper::GetInstance().SetZoomState(true); -} - -void WindowAccessibilityController::SetAnchorOffset(int32_t deltaX, int32_t deltaY) -{ - Accessibility::AccessibilityAbilityHelper::GetInstance().SetScrollState(true); -} - -void WindowAccessibilityController::OffWindowZoom() -{ - Accessibility::AccessibilityAbilityHelper::GetInstance().SetZoomState(false); -} -} // namespace OHOS::Rosen \ No newline at end of file diff --git a/services/aams/test/unittest/accessibility_account_data_test.cpp b/services/aams/test/unittest/accessibility_account_data_test.cpp index 02f38f87..014dd372 100644 --- a/services/aams/test/unittest/accessibility_account_data_test.cpp +++ b/services/aams/test/unittest/accessibility_account_data_test.cpp @@ -1796,7 +1796,7 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_GetInpu AAConnection->OnAbilityConnectDoneSync(elementName, aastub); EXPECT_EQ(1, (int)accountData->GetConnectedA11yAbilities().size()); accountData->UpdateAccountCapabilities(); - EXPECT_EQ(32, accountData->GetInputFilterFlag()); + EXPECT_EQ(0, accountData->GetInputFilterFlag()); GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_GetInputFilterFlag_003 end"; } @@ -1843,6 +1843,7 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_GetAbil const int32_t accountId = 1; const std::string abilityName = "com.huawei.hmos.screenreader/AccessibilityExtAbility"; sptr accountData = new AccessibilityAccountData(accountId); + accountData->Init(); accountData->SetAbilityAutoStartState(abilityName, false); EXPECT_EQ(accountData->GetAbilityAutoStartState(abilityName), false); GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_GetAbilityAutoStartState_001 end"; diff --git a/services/aams/test/unittest/accessibility_short_key_test.cpp b/services/aams/test/unittest/accessibility_short_key_test.cpp index 7b9674fe..3c905169 100644 --- a/services/aams/test/unittest/accessibility_short_key_test.cpp +++ b/services/aams/test/unittest/accessibility_short_key_test.cpp @@ -87,8 +87,8 @@ HWTEST_F(AccessibilityShortKeyUnitTest, AccessibilityShortKey_001, TestSize.Leve { GTEST_LOG_(INFO) << "Accessibility_Short_Key_UnitTest_AccessibilityShortKey001 start"; TearDownTestCase(); - AccessibilityShortKey *test = new AccessibilityShortKey(); - delete test; + sptr test = new (std::nothrow) AccessibilityShortKey(); + test = nullptr; SetUpTestCase(); GTEST_LOG_(INFO) << "Accessibility_Short_Key_UnitTest_AccessibilityShortKey001 end"; } diff --git a/services/aams/test/unittest/accessibility_touch_guider_test.cpp b/services/aams/test/unittest/accessibility_touch_guider_test.cpp index 936027d2..991a0c0d 100755 --- a/services/aams/test/unittest/accessibility_touch_guider_test.cpp +++ b/services/aams/test/unittest/accessibility_touch_guider_test.cpp @@ -95,9 +95,9 @@ void TouchGuiderTest::PointerEventTest(std::vectorOnPointerEvent(*event); retOnPointerEvent2 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == - EventType::TYPE_TOUCH_END) { + EventType::TYPE_TOUCH_GUIDE_END) { return true; } else { return false; @@ -263,12 +263,12 @@ HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_002, TestSize.Leve }), SLEEP_TIME_3); EXPECT_TRUE(retOnPointerEvent2); EventType eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(1); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_BEGIN); + EXPECT_EQ(eventType, EventType::TYPE_TOUCH_END); int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER; int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0); EXPECT_EQ(touchAction, expectValue); eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(2); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_END); + EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_BEGIN); GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_002 end"; } @@ -308,7 +308,7 @@ HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_003, TestSize.Leve touchGuider_->OnPointerEvent(*event); retOnPointerEvent3 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == - EventType::TYPE_TOUCH_END) { + EventType::TYPE_TOUCH_GUIDE_END) { return true; } else { return false; @@ -316,7 +316,7 @@ HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_003, TestSize.Leve }), SLEEP_TIME_3); EXPECT_TRUE(retOnPointerEvent3); eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(2); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_END); + EXPECT_EQ(eventType, EventType::TYPE_TOUCH_END); GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_003 end"; } @@ -360,7 +360,7 @@ HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_004, TestSize.Leve event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP); touchGuider_->OnPointerEvent(*event); retOnPointerEvent4 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == EventType::TYPE_TOUCH_END) { + if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == EventType::TYPE_TOUCH_GUIDE_END) { return true; } else { return false; @@ -368,7 +368,7 @@ HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_004, TestSize.Leve }), SLEEP_TIME_3); EXPECT_TRUE(retOnPointerEvent4); eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(2); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_END); + EXPECT_EQ(eventType, EventType::TYPE_TOUCH_END); GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_004 end"; } @@ -935,9 +935,9 @@ HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_017, TestSize.Leve touchGuider_->OnPointerEvent(*event); eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(2); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(3); EXPECT_EQ(eventType, EventType::TYPE_TOUCH_END); + eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(3); + EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_END); auto uTgestureId = AccessibilityAbilityHelper::GetInstance().GetGestureId(); EXPECT_EQ(uTgestureId, static_cast(GestureType::GESTURE_SWIPE_LEFT)); diff --git a/services/aams/test/unittest/accessibility_window_manager_test.cpp b/services/aams/test/unittest/accessibility_window_manager_test.cpp index d8f6f545..e9affa89 100644 --- a/services/aams/test/unittest/accessibility_window_manager_test.cpp +++ b/services/aams/test/unittest/accessibility_window_manager_test.cpp @@ -329,7 +329,8 @@ HWTEST_F(AccessibilityWindowManagerTest, AccessibilityWindowManager_Unittest_Reg GTEST_LOG_(INFO) << "AccessibilityWindowManager_Unittest_RegisterWindowListener002 start"; const std::string AAMS_SERVICE_NAME = "AccessibleAbilityManagerService"; - std::shared_ptr runner_ = AppExecFwk::EventRunner::Create(AAMS_SERVICE_NAME); + std::shared_ptr runner_ = + AppExecFwk::EventRunner::Create(AAMS_SERVICE_NAME, AppExecFwk::ThreadMode::FFRT); std::shared_ptr handler_ = std::make_shared(runner_); Singleton::GetInstance().RegisterWindowListener(handler_); @@ -1538,7 +1539,8 @@ HWTEST_F(AccessibilityWindowManagerTest, AccessibilityWindowManager_Unittest_Der GTEST_LOG_(INFO) << "AccessibilityWindowManager_Unittest_DeregisterWindowListener002 start"; const std::string AAMS_SERVICE_NAME = "AccessibleAbilityManagerService"; - std::shared_ptr runner_ = AppExecFwk::EventRunner::Create(AAMS_SERVICE_NAME); + std::shared_ptr runner_ = + AppExecFwk::EventRunner::Create(AAMS_SERVICE_NAME, AppExecFwk::ThreadMode::FFRT); std::shared_ptr handler_ = std::make_shared(runner_); Singleton::GetInstance().RegisterWindowListener(handler_); diff --git a/services/aams/test/unittest/accessibility_zoom_gesture_test.cpp b/services/aams/test/unittest/accessibility_zoom_gesture_test.cpp index 1bdbe9b1..965a59ca 100644 --- a/services/aams/test/unittest/accessibility_zoom_gesture_test.cpp +++ b/services/aams/test/unittest/accessibility_zoom_gesture_test.cpp @@ -272,8 +272,8 @@ HWTEST_F(AccessibilityZoomGestureUnitTest, AccessibilityZoomGesture_Unittest_OnP item4.SetDisplayY(50); eventMove->AddPointerItem(item4); zoomGesture_->OnPointerEvent(*eventMove); - bool scrollState = AccessibilityAbilityHelper::GetInstance().GetScrollState(); - EXPECT_TRUE(!scrollState); + zoomState = AccessibilityAbilityHelper::GetInstance().GetZoomState(); + EXPECT_TRUE(zoomState); GTEST_LOG_(INFO) << "AccessibilityZoomGesture_Unittest_OnPointerEvent_005 end"; } diff --git a/services/test/BUILD.gn b/services/test/BUILD.gn index c0a7ccc0..75f3266b 100644 --- a/services/test/BUILD.gn +++ b/services/test/BUILD.gn @@ -146,6 +146,7 @@ ohos_moduletest("aams_accessibility_touch_guider_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -244,6 +245,7 @@ ohos_moduletest("aams_accessibility_touchEvent_injector_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -347,6 +349,7 @@ ohos_moduletest("aams_accessible_ability_channel_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -448,6 +451,7 @@ ohos_moduletest("aams_server_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -544,6 +548,7 @@ ohos_moduletest("aams_accessibility_keyevent_filter_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", @@ -645,6 +650,7 @@ ohos_moduletest("aams_common_event_registry_test") { "data_share:datashare_consumer", "display_manager:displaymgr", "eventhandler:libeventhandler", + "ffrt:libffrt", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hilog:libhilog", diff --git a/services/test/mock/accessibility_mt_helper.h b/services/test/mock/accessibility_mt_helper.h index a2f5bab9..a43cf024 100644 --- a/services/test/mock/accessibility_mt_helper.h +++ b/services/test/mock/accessibility_mt_helper.h @@ -18,6 +18,7 @@ #include #include "accessibility_def.h" +#include "ffrt.h" #include "hilog/log.h" #include "i_accessible_ability_channel.h" #include "iremote_object.h" @@ -41,12 +42,12 @@ public: } std::vector& GetEventType() { - std::lock_guard lock(mtx_); + std::lock_guard lock(mtx_); return mTeventType_; } EventType GetEventTypeOfTargetIndex(int32_t index) { - std::lock_guard lock(mtx_); + std::lock_guard lock(mtx_); int32_t size = static_cast(mTeventType_.size()); if (size > index) { return mTeventType_[index]; @@ -55,7 +56,7 @@ public: } void PushEventType(EventType eventType) { - std::lock_guard lock(mtx_); + std::lock_guard lock(mtx_); mTeventType_.push_back(eventType); } int32_t GetGestureId() const @@ -154,7 +155,7 @@ private: int32_t testKeyPressEvent_ = -1; int32_t testDisplayId_ = -1; int32_t testGestureSimulateResult_ = -1; - std::mutex mtx_; + ffrt::mutex mtx_; }; } // namespace Accessibility } // namespace OHOS diff --git a/services/test/mock/distributeddatamgr/src/mock_preferences_helper.cpp b/services/test/mock/distributeddatamgr/src/mock_preferences_helper.cpp index 92aec724..562cbcf1 100644 --- a/services/test/mock/distributeddatamgr/src/mock_preferences_helper.cpp +++ b/services/test/mock/distributeddatamgr/src/mock_preferences_helper.cpp @@ -17,7 +17,6 @@ namespace OHOS { namespace NativePreferences { -std::mutex PreferencesHelper::prefsCacheMutex_; std::string PreferencesHelper::GetRealPath(const std::string& path, int& errorCode) { diff --git a/services/test/mock/mock_accessibility_element_operator_impl.cpp b/services/test/mock/mock_accessibility_element_operator_impl.cpp index 580ff5b2..8597c036 100644 --- a/services/test/mock/mock_accessibility_element_operator_impl.cpp +++ b/services/test/mock/mock_accessibility_element_operator_impl.cpp @@ -144,7 +144,7 @@ int32_t MockAccessibilityElementOperatorImpl::GetWindowId() int32_t MockAccessibilityElementOperatorImpl::AddRequest(int32_t requestId, const sptr &callback) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); uint32_t compositionRequestId = static_cast(requestId) & REQUEST_ID_MASK; if (windowId_ < REQUEST_WINDOW_ID_MAX && windowId_ > 0) { @@ -164,7 +164,7 @@ int32_t MockAccessibilityElementOperatorImpl::AddRequest(int32_t requestId, void MockAccessibilityElementOperatorImpl::SetSearchElementInfoByAccessibilityIdResult( const std::list& infos, const int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); std::vector myInfos = TranslateListToVector(infos); auto iterator = requests_.find(requestId); if (iterator != requests_.end()) { @@ -181,7 +181,7 @@ void MockAccessibilityElementOperatorImpl::SetSearchElementInfoByAccessibilityId void MockAccessibilityElementOperatorImpl::SetSearchElementInfoByTextResult( const std::list& infos, const int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); std::vector myInfos = TranslateListToVector(infos); auto iterator = requests_.find(requestId); if (iterator != requests_.end()) { @@ -198,7 +198,7 @@ void MockAccessibilityElementOperatorImpl::SetSearchElementInfoByTextResult( void MockAccessibilityElementOperatorImpl::SetFindFocusedElementInfoResult( const AccessibilityElementInfo& info, const int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto iterator = requests_.find(requestId); if (iterator != requests_.end()) { if (iterator->second != nullptr) { @@ -214,7 +214,7 @@ void MockAccessibilityElementOperatorImpl::SetFindFocusedElementInfoResult( void MockAccessibilityElementOperatorImpl::SetFocusMoveSearchResult( const AccessibilityElementInfo& info, const int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto iterator = requests_.find(requestId); if (iterator != requests_.end()) { if (iterator->second != nullptr) { @@ -230,7 +230,7 @@ void MockAccessibilityElementOperatorImpl::SetFocusMoveSearchResult( void MockAccessibilityElementOperatorImpl::SetExecuteActionResult( const bool succeeded, const int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto iterator = requests_.find(requestId); if (iterator != requests_.end()) { if (iterator->second != nullptr) { @@ -246,7 +246,7 @@ void MockAccessibilityElementOperatorImpl::SetExecuteActionResult( void MockAccessibilityElementOperatorImpl::SetCursorPositionResult( const int32_t cursorPosition, const int32_t requestId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); auto iterator = requests_.find(requestId); if (iterator != requests_.end()) { if (iterator->second != nullptr) { diff --git a/services/test/mock/mock_accessibility_element_operator_impl.h b/services/test/mock/mock_accessibility_element_operator_impl.h index 19d72c14..89fb3a45 100644 --- a/services/test/mock/mock_accessibility_element_operator_impl.h +++ b/services/test/mock/mock_accessibility_element_operator_impl.h @@ -21,6 +21,7 @@ #include "accessibility_element_operator.h" #include "accessibility_element_operator_callback.h" #include "accessibility_element_operator_stub.h" +#include "ffrt.h" #include "nocopyable.h" namespace OHOS { @@ -209,7 +210,7 @@ public: private: int32_t AddRequest(int32_t requestId, const sptr &callback); - std::mutex mutex_; + ffrt::mutex mutex_; int32_t windowId_ = 0; AccessibilityElementOperatorCallback &operatorCallback_; std::shared_ptr operator_ = nullptr; diff --git a/services/test/mock/mock_accessibility_setting_provider.cpp b/services/test/mock/mock_accessibility_setting_provider.cpp index f46a02ba..3f26db94 100644 --- a/services/test/mock/mock_accessibility_setting_provider.cpp +++ b/services/test/mock/mock_accessibility_setting_provider.cpp @@ -20,7 +20,7 @@ namespace OHOS { namespace Accessibility { AccessibilitySettingProvider* AccessibilitySettingProvider::instance_; -std::mutex AccessibilitySettingProvider::mutex_; +ffrt::mutex AccessibilitySettingProvider::mutex_; namespace { constexpr int32_t DEFAULT_ACCOUNT_ID = 100; } // namespace diff --git a/services/test/mock/mock_accessible_ability_client_proxy.cpp b/services/test/mock/mock_accessible_ability_client_proxy.cpp index 6317b291..26748ab4 100644 --- a/services/test/mock/mock_accessible_ability_client_proxy.cpp +++ b/services/test/mock/mock_accessible_ability_client_proxy.cpp @@ -48,10 +48,13 @@ void AccessibleAbilityClientProxy::Disconnect(const int32_t channelId) void AccessibleAbilityClientProxy::OnAccessibilityEvent(const AccessibilityEventInfo& eventInfo) { GTEST_LOG_(INFO) << "AccessibleAbilityClientProxy OnAccessibilityEvent"; + int32_t gestureId = static_cast(eventInfo.GetGestureType()); + if (gestureId != 0) { + AccessibilityHelper::GetInstance().SetGestureId(gestureId); + } AccessibilityHelper::GetInstance().SetTestWindowId(eventInfo.GetWindowId()); AccessibilityHelper::GetInstance().SetTestWindowChangeTypes(eventInfo.GetWindowChangeTypes()); AccessibilityHelper::GetInstance().SetTestEventType(int32_t(eventInfo.GetEventType())); - AccessibilityHelper::GetInstance().SetGestureId(int32_t(eventInfo.GetGestureType())); switch (eventInfo.GetEventType()) { case TYPE_TOUCH_GUIDE_GESTURE_BEGIN: diff --git a/services/test/mock/mock_accessible_ability_manager_service_stub.cpp b/services/test/mock/mock_accessible_ability_manager_service_stub.cpp index a0b3e5ef..43ce9616 100644 --- a/services/test/mock/mock_accessible_ability_manager_service_stub.cpp +++ b/services/test/mock/mock_accessible_ability_manager_service_stub.cpp @@ -26,7 +26,7 @@ namespace { MockAccessibleAbilityManagerServiceStub::MockAccessibleAbilityManagerServiceStub() { if (!runner_) { - runner_ = AppExecFwk::EventRunner::Create("Accessibility.Config.Unittest"); + runner_ = AppExecFwk::EventRunner::Create("Accessibility.Config.Unittest", AppExecFwk::ThreadMode::FFRT); if (!runner_) { return; } diff --git a/services/test/mock/mock_os_account_manager.cpp b/services/test/mock/mock_os_account_manager.cpp index 21aac720..90844480 100644 --- a/services/test/mock/mock_os_account_manager.cpp +++ b/services/test/mock/mock_os_account_manager.cpp @@ -15,6 +15,7 @@ #include "accessibility_mt_helper.h" #include "os_account_manager.h" +#include "ffrt.h" namespace OHOS { namespace AccountSA { diff --git a/services/test/mock/mock_service_registry.cpp b/services/test/mock/mock_service_registry.cpp index cb39e488..26edd2c4 100644 --- a/services/test/mock/mock_service_registry.cpp +++ b/services/test/mock/mock_service_registry.cpp @@ -34,7 +34,6 @@ SystemAbilityManagerClient& SystemAbilityManagerClient::GetInstance() sptr SystemAbilityManagerClient::GetSystemAbilityManager() { - std::lock_guard lock(systemAbilityManagerLock_); if (systemAbilityManager_ != nullptr) { return systemAbilityManager_; } diff --git a/services/test/mock/multimodalinput/src/mock_input_manager.cpp b/services/test/mock/multimodalinput/src/mock_input_manager.cpp index d5812395..a43d97b5 100644 --- a/services/test/mock/multimodalinput/src/mock_input_manager.cpp +++ b/services/test/mock/multimodalinput/src/mock_input_manager.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include +#include "ffrt.h" #include "mock_input_manager.h" #include "hilog_wrapper.h" @@ -23,7 +23,7 @@ static int mockKeyCode = -1; static std::vector mockTouchActions; static std::function)> mockKeyEventCallback = nullptr; static std::shared_ptr mockInputEventConsumer = nullptr; -static std::mutex g_mtx; +static ffrt::mutex g_mtx; int MockInputManager::GetKeyCode() { @@ -32,19 +32,19 @@ int MockInputManager::GetKeyCode() void MockInputManager::ClearTouchActions() { - std::lock_guard lock(g_mtx); + std::lock_guard lock(g_mtx); mockTouchActions.clear(); } std::vector MockInputManager::GetTouchActions() { - std::lock_guard lock(g_mtx); + std::lock_guard lock(g_mtx); return mockTouchActions; } int32_t MockInputManager::GetTouchActionOfTargetIndex(int32_t index) { - std::lock_guard lock(g_mtx); + std::lock_guard lock(g_mtx); int32_t size = static_cast(mockTouchActions.size()); if (size > index) { return mockTouchActions[index]; @@ -90,7 +90,7 @@ void InputManager::SimulateInputEvent(std::shared_ptr keyEvent) void InputManager::SimulateInputEvent(std::shared_ptr pointerEvent) { HILOG_DEBUG(); - std::lock_guard lock(g_mtx); + std::lock_guard lock(g_mtx); int32_t touchAction = pointerEvent->GetPointerAction(); mockTouchActions.push_back(touchAction); } diff --git a/services/test/moduletest/aamstest/aams_accessibility_touchEvent_injector_test/aams_accessibility_touchEvent_injector_test.cpp b/services/test/moduletest/aamstest/aams_accessibility_touchEvent_injector_test/aams_accessibility_touchEvent_injector_test.cpp index 5fcbce3b..b46496de 100644 --- a/services/test/moduletest/aamstest/aams_accessibility_touchEvent_injector_test/aams_accessibility_touchEvent_injector_test.cpp +++ b/services/test/moduletest/aamstest/aams_accessibility_touchEvent_injector_test/aams_accessibility_touchEvent_injector_test.cpp @@ -164,7 +164,7 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_001, EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (EventType::TYPE_TOUCH_END == AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3)) { + if (EventType::TYPE_TOUCH_GUIDE_END == AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3)) { return true; } else { return false; @@ -172,8 +172,8 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_001, }), SLEEP_TIME_2); EXPECT_TRUE(ret); EXPECT_EQ(EventType::TYPE_TOUCH_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0)); - EXPECT_EQ(EventType::TYPE_TOUCH_GUIDE_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1)); - EXPECT_EQ(EventType::TYPE_TOUCH_GUIDE_END, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2)); + EXPECT_EQ(EventType::TYPE_TOUCH_END, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1)); + EXPECT_EQ(EventType::TYPE_TOUCH_GUIDE_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_001 end"; } diff --git a/services/test/moduletest/aamstest/aams_accessibility_touch_guider_test/aams_accessibility_touch_guider_test.cpp b/services/test/moduletest/aamstest/aams_accessibility_touch_guider_test/aams_accessibility_touch_guider_test.cpp index 7e73c703..de31fb3b 100755 --- a/services/test/moduletest/aamstest/aams_accessibility_touch_guider_test/aams_accessibility_touch_guider_test.cpp +++ b/services/test/moduletest/aamstest/aams_accessibility_touch_guider_test/aams_accessibility_touch_guider_test.cpp @@ -477,6 +477,8 @@ void AamsTouchGuideTest::SetUpTestCase() void AamsTouchGuideTest::TearDownTestCase() { GTEST_LOG_(INFO) << "AamsTouchGuideTest TearDownTestCase"; + AccessibilityHelper::GetInstance().SetGestureId(0); + AccessibilityHelper::GetInstance().GetEventType().clear(); Singleton::GetInstance().OnStop(); } @@ -511,6 +513,7 @@ void AamsTouchGuideTest::TearDown() sleep(SLEEP_TIME_3); aastub_ = nullptr; interceptorId_ = nullptr; + AccessibilityHelper::GetInstance().SetGestureId(0); AccessibilityHelper::GetInstance().GetEventType().clear(); MMI::MockInputManager::ClearTouchActions(); } @@ -618,7 +621,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent001, Te EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (MMI::MockInputManager::GetTouchActionOfTargetIndex(3) == MMI::PointerEvent::POINTER_ACTION_UP) { + if (MMI::MockInputManager::GetTouchActionOfTargetIndex(2) == MMI::PointerEvent::POINTER_ACTION_UP) { return true; } else { return false; @@ -627,7 +630,6 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent001, Te EXPECT_TRUE(ret); EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN); EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_MOVE); GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent001 ENDs"; } @@ -667,7 +669,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent002, Te inputEventConsumer->OnInputEvent(event); retOnPointerEvent2 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == - EventType::TYPE_TOUCH_END) { + EventType::TYPE_TOUCH_GUIDE_END) { return true; } else { return false; @@ -676,7 +678,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent002, Te EXPECT_TRUE(retOnPointerEvent2); EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_GUIDE_END); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_END); GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent002 ENDs"; } @@ -707,7 +709,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent003, Te // Determine event type bool retOnPointerEvent3 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -715,10 +717,11 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent003, Te } }), SLEEP_TIME_3); EXPECT_TRUE(retOnPointerEvent3); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), + EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // Determine action EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE); @@ -767,7 +770,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent004, Te // Determine event type bool retOnPointerEvent4 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -775,10 +778,11 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent004, Te } }), SLEEP_TIME_3); EXPECT_TRUE(retOnPointerEvent4); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), + EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // Determine action EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE); @@ -827,7 +831,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent005, Te // Determine event type bool retOnPointerEvent5 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -835,10 +839,11 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent005, Te } }), SLEEP_TIME_3); EXPECT_TRUE(retOnPointerEvent5); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), + EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // Determine action EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE); @@ -887,7 +892,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent006, Te // Determine event type bool retOnPointerEvent6 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -895,10 +900,11 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent006, Te } }), SLEEP_TIME_3); EXPECT_TRUE(retOnPointerEvent6); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), + EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // Determine action EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE); @@ -945,7 +951,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent007, Te // Determine event type bool retOnPointerEvent7 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -953,10 +959,11 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent007, Te } }), SLEEP_TIME_3); EXPECT_TRUE(retOnPointerEvent7); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), + EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // Determine action EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE); @@ -998,7 +1005,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent008, Te // Determine event type bool retOnPointerEvent8 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == - EventType::TYPE_TOUCH_END) { + EventType::TYPE_TOUCH_GUIDE_END) { return true; } else { return false; @@ -1007,9 +1014,9 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent008, Te EXPECT_TRUE(retOnPointerEvent8); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), - EventType::TYPE_TOUCH_GUIDE_BEGIN); + EventType::TYPE_TOUCH_END); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), - EventType::TYPE_TOUCH_GUIDE_END); + EventType::TYPE_TOUCH_GUIDE_BEGIN); // Determine action EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_HOVER_EXIT); @@ -1054,7 +1061,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent009, Te inputEventConsumer->OnInputEvent(event); // Determine event type bool retOnPointerEvent9 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1063,6 +1070,11 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent009, Te }), SLEEP_TIME_3); EXPECT_TRUE(retOnPointerEvent9); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_END); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4), EventType::TYPE_TOUCH_GUIDE_END); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5), EventType::TYPE_TOUCH_GUIDE_BEGIN); // Determine action EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); @@ -1106,7 +1118,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent010, Te // Determine event type bool retOnPointerEvent10 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1115,6 +1127,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent010, Te }), SLEEP_TIME_3); EXPECT_TRUE(retOnPointerEvent10); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_END); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4), EventType::TYPE_TOUCH_GUIDE_END); // Determine action EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); @@ -1144,10 +1160,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent011, Te return; } + sleep(1); + // eventType bool retOnPointerEvent11 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1159,8 +1177,6 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent011, Te EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), 25); @@ -1192,10 +1208,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent012, Te return; } + sleep(1); + // eventType bool retOnPointerEvent12 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1207,8 +1225,6 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent012, Te EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), @@ -1241,10 +1257,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent013, Te return; } + sleep(1); + // eventType bool retOnPointerEvent13 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1256,8 +1274,6 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent013, Te EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), @@ -1290,10 +1306,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent014, Te return; } + sleep(1); + // eventType bool retOnPointerEvent14 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1305,7 +1323,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent014, Te EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -1339,10 +1357,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent015, Te return; } + sleep(1); + // eventType bool retOnPointerEvent15 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1354,7 +1374,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent015, Te EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -1412,9 +1432,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent016, Te EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN); EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_MOVE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(3), MMI::PointerEvent::POINTER_ACTION_UP); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(4), MMI::PointerEvent::POINTER_ACTION_UP); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_UP); // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_INVALID)); @@ -1458,7 +1476,6 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent017, Te }), SLEEP_TIME_3); EXPECT_TRUE(retOnPointerEvent15); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 2); // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_INVALID)); @@ -1496,7 +1513,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent018, Te // eventType bool retOnPointerEvent15 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1508,7 +1525,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent018, Te EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -1543,10 +1560,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent019, Te return; } + sleep(1); + // eventType bool retOnPointerEvent15 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(7) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1554,22 +1573,15 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent019, Te } }), SLEEP_TIME_3); EXPECT_TRUE(retOnPointerEvent15); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 8); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_GUIDE_END); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_END); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(7), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), 25); // touch action to multimode - EXPECT_EQ(static_cast(MMI::MockInputManager::GetTouchActions().size()), 2); //have 2 point EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), @@ -1605,10 +1617,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent020, Te return; } + sleep(1); + // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1616,11 +1630,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent020, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -1659,10 +1672,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent021, Te return; } + sleep(1); + // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1670,11 +1685,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent021, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -1711,10 +1725,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent022, Te return; } + sleep(1); + // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1722,11 +1738,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent022, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -1763,10 +1778,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent023, Te return; } + sleep(1); + // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1774,11 +1791,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent023, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -1815,10 +1831,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent024, Te return; } + sleep(1); + // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1826,11 +1844,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent024, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(7), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -1867,10 +1884,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent025, Te return; } + sleep(1); + // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1878,11 +1897,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent025, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -1921,10 +1939,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent026, Te return; } + sleep(1); + // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1932,11 +1952,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent026, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -1975,10 +1994,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent027, Te return; } + sleep(1); + // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -1986,11 +2007,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent027, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -2029,10 +2049,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent028, Te return; } + sleep(1); + // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -2044,7 +2066,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent028, Te EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(7), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -2083,10 +2105,12 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent029, Te return; } + sleep(1); + // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -2094,11 +2118,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent029, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -2146,7 +2169,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent030, Te // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -2154,11 +2177,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent030, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -2209,7 +2231,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent031, Te // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -2217,11 +2239,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent031, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -2268,7 +2289,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent032, Te // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -2276,11 +2297,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent032, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -2327,7 +2347,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent033, Te // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -2335,11 +2355,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent033, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -2386,7 +2405,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent034, Te // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -2394,11 +2413,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent034, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -2449,7 +2467,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent035, Te // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -2457,11 +2475,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent035, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -2512,7 +2529,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent036, Te // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -2520,11 +2537,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent036, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId @@ -2575,7 +2591,7 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent037, Te // eventType bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == EventType::TYPE_TOUCH_END) { return true; } else { @@ -2583,11 +2599,10 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent037, Te } }), SLEEP_TIME_3); EXPECT_TRUE(ret); - EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // gestureId