Merge branch 'master' of gitee.com:openharmony/accessibility into master

Signed-off-by: 陈江华 <chenjianghua7@h-partners.com>
This commit is contained in:
陈江华 2024-08-06 07:21:17 +00:00 committed by Gitee
commit a211b18ab4
115 changed files with 1876 additions and 997 deletions

View File

@ -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" ]
}

View File

@ -40,6 +40,7 @@
"ability_base",
"safwk",
"bundle_framework",
"ffrt",
"hitrace",
"hilog",
"ipc",

View File

@ -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",

View File

@ -17,9 +17,9 @@
#define ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_STUB_H
#include <map>
#include <mutex>
#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<AccessibilityElementInfo> storeData_ = {};
std::mutex mutex_;
ffrt::mutex mutex_;
};
/*

View File

@ -52,28 +52,28 @@ constexpr int32_t ERR_CODE_DEFAULT = -1000;
void StoreElementData::WriteData(std::vector<AccessibilityElementInfo> &infos)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
storeData_.insert(storeData_.end(), infos.begin(), infos.end());
}
void StoreElementData::Clear()
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
storeData_.clear();
}
std::vector<AccessibilityElementInfo> StoreElementData::ReadData()
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
return storeData_;
}
size_t StoreElementData::Size()
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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,

View File

@ -77,8 +77,6 @@ AccessibilityElementOperatorStub::AccessibilityElementOperatorStub()
AccessibilityElementOperatorStub::~AccessibilityElementOperatorStub()
{
HILOG_DEBUG();
memberFuncMap_.clear();
}
int AccessibilityElementOperatorStub::OnRemoteRequest(uint32_t code, MessageParcel &data,

View File

@ -90,8 +90,6 @@ AccessibleAbilityChannelStub::AccessibleAbilityChannelStub()
AccessibleAbilityChannelStub::~AccessibleAbilityChannelStub()
{
HILOG_DEBUG();
memberFuncMap_.clear();
}
int AccessibleAbilityChannelStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,

View File

@ -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<IRemoteObject> remote = data.ReadRemoteObject();
if (!remote) {
if (remote == nullptr) {
HILOG_ERROR("object is nullptr.");
return ERR_INVALID_VALUE;
}
sptr<IAccessibleAbilityChannel> channel = iface_cast<IAccessibleAbilityChannel>(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<MMI::KeyEvent> 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;

View File

@ -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(

View File

@ -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;
}

View File

@ -33,6 +33,7 @@ ohos_fuzztest("AccessibilityElementOperatorCallbackStubFuzzTest") {
]
external_deps = [
"c_utils:utils",
"ffrt:libffrt",
"input:libmmi-client",
"ipc:ipc_single",
]

View File

@ -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;

View File

@ -50,6 +50,8 @@ public:
gridItemInfoParcel_ = std::make_shared<GridItemInfoParcel>(*gridItemInfo_);
rect_ = std::make_shared<Rect>();
rectParcel_ = std::make_shared<RectParcel>(*rect_);
extraElementInfo_ = std::make_shared<ExtraElementInfo>();
extraElementInfoParcel_ = std::make_shared<ExtraElementInfoParcel>(*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<AccessibleAction> action_ = nullptr;
@ -81,6 +85,8 @@ public:
std::shared_ptr<RectParcel> rectParcel_ = nullptr;
std::shared_ptr<AccessibilityElementInfo> elementInfo_ = nullptr;
std::shared_ptr<AccessibilityElementInfoParcel> elementInfoParcel_ = nullptr;
std::shared_ptr<ExtraElementInfo> extraElementInfo_ = nullptr;
std::shared_ptr<ExtraElementInfoParcel> 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 = extraElementInfoParcel_->Unmarshalling(parcel);
EXPECT_EQ(true, extraElementInfoParcel == nullptr);
GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__002 end";
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -16,8 +16,8 @@
#ifndef ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_IMPL_H
#define ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_IMPL_H
#include <future>
#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<void> promise_;
ffrt::promise<void> promise_;
bool executeActionResult_ = false;
AccessibilityElementInfo accessibilityInfoResult_ = {};
std::vector<AccessibilityElementInfo> elementInfosResult_;

View File

@ -19,11 +19,11 @@
#include <atomic>
#include <deque>
#include <memory>
#include <mutex>
#include <condition_variable>
#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<int32_t, std::map<int32_t, std::shared_ptr<AccessibilityElementInfo>>> elementCache_;
std::deque<int32_t> windowIdSet_;
std::mutex elementCacheMutex_;
ffrt::mutex elementCacheMutex_;
};
class SceneBoardWindowElementMap {
@ -403,7 +403,7 @@ private:
void RemovePairByWindowId(int32_t windowId);
private:
std::map<int32_t, int64_t> 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<int64_t, AccessibilityElementInfo> cacheElementInfos_;
std::mutex mutex_;
ffrt::mutex mutex_;
std::atomic<bool> 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

View File

@ -15,8 +15,8 @@
#include "accessibility_ui_test_ability_impl.h"
#include <mutex>
#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<AccessibilityUITestAbilityImpl> g_Instance = nullptr;
std::shared_ptr<AccessibilityUITestAbility> AccessibilityUITestAbility::GetInstance()
{
std::lock_guard<std::mutex> lock(g_Mutex);
std::lock_guard<ffrt::mutex> lock(g_Mutex);
if (!g_Instance) {
g_Instance = std::make_shared<AccessibilityUITestAbilityImpl>();
}

View File

@ -68,7 +68,7 @@ RetError AccessibleAbilityChannelClient::FindFocusedElementInfo(int32_t accessib
HILOG_ERROR("FindFocusedElementInfo Failed to create elementOperator.");
return RET_ERR_NULLPTR;
}
std::future<void> promiseFuture = elementOperator->promise_.get_future();
ffrt::future<void> 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<void> promiseFuture = elementOperator->promise_.get_future();
ffrt::future<void> 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<void> promiseFuture = elementOperator->promise_.get_future();
ffrt::future<void> 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<void> promiseFuture = elementOperator->promise_.get_future();
ffrt::future<void> 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<void> promiseFuture = elementOperator->promise_.get_future();
ffrt::future<void> 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<void> promiseFuture = elementOperator->promise_.get_future();
ffrt::future<void> 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;
}

View File

@ -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<AccessibleAbilityClientImpl> g_Instance = nullptr;
constexpr int32_t SA_CONNECT_TIMEOUT = 500; // ms
} // namespace
@ -47,7 +47,7 @@ namespace {
sptr<AccessibleAbilityClient> AccessibleAbilityClient::GetInstance()
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(g_Mutex);
std::lock_guard<ffrt::mutex> lock(g_Mutex);
if (g_Instance == nullptr) {
g_Instance = new(std::nothrow) AccessibleAbilityClientImpl();
}
@ -57,7 +57,7 @@ sptr<AccessibleAbilityClient> AccessibleAbilityClient::GetInstance()
sptr<AccessibleAbilityClientImpl> AccessibleAbilityClientImpl::GetAbilityClientImplement()
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(g_Mutex);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibleAbilityClientImpl *>(context);
std::lock_guard<std::mutex> lock(implPtr->mutex_);
std::lock_guard<ffrt::mutex> lock(implPtr->mutex_);
if (implPtr->InitAccessibilityServiceProxy()) {
HILOG_INFO("InitAccessibilityServiceProxy success");
}
@ -160,7 +160,7 @@ sptr<Accessibility::IAccessibleAbilityManagerService> AccessibleAbilityClientImp
bool AccessibleAbilityClientImpl::LoadAccessibilityService()
{
std::unique_lock<std::mutex> lock(conVarMutex_);
std::unique_lock<ffrt::mutex> lock(conVarMutex_);
sptr<AccessibilityLoadCallback> loadCallback = new AccessibilityLoadCallback();
if (loadCallback == nullptr) {
return false;
@ -183,7 +183,7 @@ bool AccessibleAbilityClientImpl::LoadAccessibilityService()
void AccessibleAbilityClientImpl::LoadSystemAbilitySuccess(const sptr<IRemoteObject> &remoteObject)
{
std::lock_guard<std::mutex> lock(conVarMutex_);
std::lock_guard<ffrt::mutex> 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<IRemoteObj
void AccessibleAbilityClientImpl::LoadSystemAbilityFail()
{
std::lock_guard<std::mutex> lock(conVarMutex_);
std::lock_guard<ffrt::mutex> lock(conVarMutex_);
HILOG_WARN("LoadSystemAbilityFail.");
proxyConVar_.notify_one();
}
@ -211,7 +211,7 @@ RetError AccessibleAbilityClientImpl::RegisterAbilityListener(
const std::shared_ptr<AccessibleAbilityListener> &listener)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (listener_) {
HILOG_DEBUG("listener already exists.");
return RET_ERR_REGISTER_EXIST;
@ -231,7 +231,7 @@ void AccessibleAbilityClientImpl::Init(const sptr<IAccessibleAbilityChannel> &ch
std::shared_ptr<AccessibleAbilityListener> listener = nullptr;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (!listener_) {
HILOG_ERROR("listener_ is nullptr.");
return;
@ -268,7 +268,7 @@ void AccessibleAbilityClientImpl::Disconnect(const int32_t channelId)
std::shared_ptr<AccessibleAbilityListener> listener = nullptr;
{
isConnected_ = false;
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibleAbilityListener> listener = nullptr;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibleAbilityListener> listener = nullptr;
std::shared_ptr<AccessibleAbilityChannelClient> channel = nullptr;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<Access
return RET_ERR_NO_CONNECTION;
}
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
@ -488,7 +488,7 @@ RetError AccessibleAbilityClientImpl::GetRootBatch(std::vector<AccessibilityElem
return RET_ERR_NO_CONNECTION;
}
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibilityWindow
return RET_ERR_NO_CONNECTION;
}
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std:
return RET_ERR_NO_CONNECTION;
}
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
@ -1038,7 +1038,7 @@ void AccessibleAbilityClientImpl::NotifyServiceDied(const wptr<IRemoteObject> &r
{
std::shared_ptr<AccessibleAbilityListener> listener = nullptr;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (!serviceProxy_) {
HILOG_ERROR("serviceProxy_ is nullptr");
return;
@ -1063,7 +1063,7 @@ void AccessibleAbilityClientImpl::NotifyServiceDied(const wptr<IRemoteObject> &r
void AccessibleAbilityClientImpl::ResetAAClient(const wptr<IRemoteObject> &remote)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (channelClient_) {
sptr<IRemoteObject> object = channelClient_->GetRemote();
if (object && (remote == object)) {
@ -1079,7 +1079,7 @@ void AccessibleAbilityClientImpl::ResetAAClient(const wptr<IRemoteObject> &remot
RetError AccessibleAbilityClientImpl::SetCacheMode(const int32_t cacheMode)
{
HILOG_DEBUG("set cache mode: [%{public}d]", cacheMode);
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibilityElementInfo>& elementInfos)
{
std::lock_guard<std::mutex> lock(elementCacheMutex_);
std::lock_guard<ffrt::mutex> 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<AccessibilityElementInfo>& elementInfos)
{
elementInfos.clear(); // clear
std::lock_guard<std::mutex> lock(elementCacheMutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(elementCacheMutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(elementCacheMutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mapMutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mapMutex_);
std::lock_guard<ffrt::mutex> lock(mapMutex_);
windowElementMap_[windowId] = elementId;
}
std::vector<int32_t> AccessibleAbilityClientImpl::SceneBoardWindowElementMap::GetWindowIdList()
{
std::lock_guard<std::mutex> lock(mapMutex_);
std::lock_guard<ffrt::mutex> lock(mapMutex_);
std::vector<int32_t> windowList;
for (auto iter = windowElementMap_.begin(); iter != windowElementMap_.end(); iter++) {
windowList.push_back(iter->first);
@ -1646,7 +1652,7 @@ std::vector<int32_t> AccessibleAbilityClientImpl::SceneBoardWindowElementMap::Ge
int32_t AccessibleAbilityClientImpl::SceneBoardWindowElementMap::GetWindowIdByElementId(int64_t elementId)
{
std::lock_guard<std::mutex> lock(mapMutex_);
std::lock_guard<ffrt::mutex> 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<int32_t>& windowIdList)
{
std::lock_guard<std::mutex> lock(mapMutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mapMutex_);
std::lock_guard<ffrt::mutex> lock(mapMutex_);
windowElementMap_.erase(windowId);
}

View File

@ -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",

View File

@ -20,14 +20,14 @@
namespace OHOS {
namespace Accessibility {
namespace {
std::mutex g_Mutex;
ffrt::mutex g_Mutex;
sptr<AccessibleAbilityClientImpl> g_Instance = nullptr;
} // namespace
sptr<AccessibleAbilityClient> AccessibleAbilityClient::GetInstance()
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(g_Mutex);
std::lock_guard<ffrt::mutex> lock(g_Mutex);
bool isNull = AccessibilityAbilityUtHelper::GetInstance().GetAbilityClientNullFlag();
if (isNull) {
return nullptr;
@ -42,7 +42,7 @@ sptr<AccessibleAbilityClient> AccessibleAbilityClient::GetInstance()
sptr<AccessibleAbilityClientImpl> AccessibleAbilityClientImpl::GetAbilityClientImplement()
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(g_Mutex);
std::lock_guard<ffrt::mutex> lock(g_Mutex);
bool isNull = AccessibilityAbilityUtHelper::GetInstance().GetAbilityClientNullFlag();
if (isNull) {
return nullptr;

View File

@ -16,13 +16,13 @@
#ifndef ACCESSIBILITY_CONFIG_IMPL_H
#define ACCESSIBILITY_CONFIG_IMPL_H
#include <mutex>
#include <condition_variable>
#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<std::string> shortkeyMultiTarget_ {};
std::vector<std::shared_ptr<AccessibilityEnableAbilityListsObserver>> enableAbilityListsObservers_;
std::map<CONFIG_ID, std::vector<std::shared_ptr<AccessibilityConfigObserver>>> configObservers_;
std::mutex mutex_;
ffrt::mutex mutex_;
std::shared_ptr<AppExecFwk::EventRunner> runner_;
std::shared_ptr<AppExecFwk::EventHandler> 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

View File

@ -86,7 +86,7 @@ bool AccessibilityConfig::Impl::ConnectToService()
bool AccessibilityConfig::Impl::ConnectToServiceAsync()
{
HILOG_DEBUG("ConnectToServiceAsync start.");
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (InitAccessibilityServiceProxy()) {
(void)RegisterToService();
InitConfigValues();
@ -135,7 +135,7 @@ bool AccessibilityConfig::Impl::InitAccessibilityServiceProxy()
bool AccessibilityConfig::Impl::LoadAccessibilityService()
{
std::unique_lock<std::mutex> lock(conVarMutex_);
std::unique_lock<ffrt::mutex> lock(conVarMutex_);
sptr<AccessibilityLoadCallback> loadCallback = new AccessibilityLoadCallback(this);
if (loadCallback == nullptr) {
return false;
@ -160,7 +160,7 @@ bool AccessibilityConfig::Impl::LoadAccessibilityService()
void AccessibilityConfig::Impl::LoadSystemAbilitySuccess(const sptr<IRemoteObject> &remoteObject)
{
std::lock_guard<std::mutex> lock(conVarMutex_);
std::lock_guard<ffrt::mutex> 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<IRemoteObjec
void AccessibilityConfig::Impl::LoadSystemAbilityFail()
{
std::lock_guard<std::mutex> lock(conVarMutex_);
std::lock_guard<ffrt::mutex> lock(conVarMutex_);
HILOG_WARN("LoadSystemAbilityFail.");
proxyConVar_.notify_one();
}
@ -255,7 +255,7 @@ sptr<Accessibility::IAccessibleAbilityManagerService> AccessibilityConfig::Impl:
void AccessibilityConfig::Impl::ResetService(const wptr<IRemoteObject> &remote)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (serviceProxy_ != nullptr) {
sptr<IRemoteObject> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibilityConfigObserver> &observer, const bool retFlag)
{
HILOG_DEBUG("id = [%{public}d]", static_cast<int32_t>(id));
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
std::map<CONFIG_ID, std::vector<std::shared_ptr<AccessibilityConfigObserver>>>::iterator it =
configObservers_.find(id);
if (it != configObservers_.end()) {
@ -418,7 +418,7 @@ Accessibility::RetError AccessibilityConfig::Impl::UnsubscribeConfigObserver(con
const std::shared_ptr<AccessibilityConfigObserver> &observer)
{
HILOG_INFO("id = [%{public}d]", static_cast<int32_t>(id));
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
std::map<CONFIG_ID, std::vector<std::shared_ptr<AccessibilityConfigObserver>>>::iterator it =
configObservers_.find(id);
if (it != configObservers_.end()) {
@ -441,7 +441,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerCaptionPropertyChanged
HILOG_DEBUG();
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (captionState_ == enabled) {
return;
}
@ -557,7 +557,7 @@ void AccessibilityConfig::Impl::UpdateScreenMagnificationEnabled(const bool enab
{
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (screenMagnifier_ == enabled) {
return;
}
@ -576,7 +576,7 @@ void AccessibilityConfig::Impl::UpdateShortKeyEnabled(const bool enabled)
{
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (shortkey_ == enabled) {
return;
}
@ -595,7 +595,7 @@ void AccessibilityConfig::Impl::UpdateMouseKeyEnabled(const bool enabled)
{
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (mouseKey_ == enabled) {
return;
}
@ -614,7 +614,7 @@ void AccessibilityConfig::Impl::UpdateAudioMonoEnabled(const bool enabled)
{
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (audioMono_ == enabled) {
return;
}
@ -633,7 +633,7 @@ void AccessibilityConfig::Impl::UpdateAnimationOffEnabled(const bool enabled)
{
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (animationOff_ == enabled) {
return;
}
@ -653,7 +653,7 @@ void AccessibilityConfig::Impl::UpdateInvertColorEnabled(const bool enabled)
{
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (daltonizationState_ == enabled) {
return;
}
@ -719,7 +719,7 @@ void AccessibilityConfig::Impl::UpdateIgnoreRepeatClickStateEnabled(const bool e
{
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::string>& name)
{
HILOG_INFO("start");
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::string> &name)
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<uint32_t>(type));
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibilityEnableAbilityListsObserver> &observer)
{
HILOG_INFO();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (std::any_of(enableAbilityListsObservers_.begin(), enableAbilityListsObservers_.end(),
[&observer](const std::shared_ptr<AccessibilityEnableAbilityListsObserver> &listObserver) {
return listObserver == observer;
@ -1397,7 +1397,7 @@ Accessibility::RetError AccessibilityConfig::Impl::UnsubscribeEnableAbilityLists
const std::shared_ptr<AccessibilityEnableAbilityListsObserver> &observer)
{
HILOG_INFO();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::shared_ptr<AccessibilityEnableAbilityListsObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::shared_ptr<AccessibilityEnableAbilityListsObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (audioBalance_ == audioBalance) {
return;
}
@ -1535,7 +1535,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerBrightnessDiscountChan
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (brightnessDiscount_ == brightnessDiscount) {
return;
}
@ -1556,7 +1556,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerContentTimeoutChanged(
HILOG_DEBUG("contentTimeout = [%{public}u}", contentTimeout);
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (contentTimeout_ == contentTimeout) {
return;
}
@ -1577,7 +1577,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerDaltonizationColorFilt
HILOG_DEBUG("filterType = [%{public}u}", filterType);
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (mouseAutoClick_ == mouseAutoClick) {
return;
}
@ -1620,7 +1620,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerShortkeyTargetChanged(
HILOG_DEBUG("shortkeyTarget = [%{public}s}", shortkeyTarget.c_str());
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
// need to add, if no change, do not inform
shortkeyMultiTarget_ = shortkeyMultiTarget;
std::map<CONFIG_ID, std::vector<std::shared_ptr<AccessibilityConfigObserver>>>::iterator it =
@ -1663,7 +1663,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerClickResponseTimeChang
HILOG_DEBUG("clickResponseTime = [%{public}u}", clickResponseTime);
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (clickResponseTime_ == clickResponseTime) {
return;
}
@ -1684,7 +1684,7 @@ void AccessibilityConfig::Impl::OnAccessibleAbilityManagerIgnoreRepeatClickTimeC
HILOG_DEBUG("ignoreRepeatClickTime = [%{public}u}", time);
std::vector<std::shared_ptr<AccessibilityConfigObserver>> observers;
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (ignoreRepeatClickTime_ == time) {
return;
}

View File

@ -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",

View File

@ -32,7 +32,6 @@ SystemAbilityManagerClient& SystemAbilityManagerClient::GetInstance()
sptr<ISystemAbilityManager> SystemAbilityManagerClient::GetSystemAbilityManager()
{
std::lock_guard<std::mutex> lock(systemAbilityManagerLock_);
if (systemAbilityManager_ != nullptr) {
return systemAbilityManager_;
}

View File

@ -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<IAccessibilityElementOperatorCallback> &callback);
std::mutex mutex_;
ffrt::mutex mutex_;
int32_t windowId_ = 0;
AccessibilityElementOperatorCallback &operatorCallback_;
std::shared_ptr<AccessibilityElementOperator> operator_ = nullptr;

View File

@ -17,11 +17,11 @@
#define ACCESSIBILITY_SYSTEM_ABILITY_CLIENT_IMPL_H
#include <array>
#include <mutex>
#include <condition_variable>
#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<IAccessibleAbilityManagerService> serviceProxy_ = nullptr;
sptr<AccessibleAbilityManagerStateObserverImpl> 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

View File

@ -166,7 +166,7 @@ void AccessibilityElementOperatorImpl::SetParentWindowId(const int32_t parentWin
int32_t AccessibilityElementOperatorImpl::AddRequest(int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback)
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
requestWindId_[requestId] = windowId_;
auto iter = requests_.find(requestId);
@ -188,7 +188,7 @@ void AccessibilityElementOperatorImpl::SetSearchElementInfoByAccessibilityIdResu
const std::list<AccessibilityElementInfo> &infos, const int32_t requestId)
{
HILOG_DEBUG("requestId is %{public}d", requestId);
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
std::vector<AccessibilityElementInfo> filterInfos = TranslateListToVector(infos);
auto iter = requests_.find(requestId);
if (iter != requests_.end()) {
@ -221,7 +221,7 @@ void AccessibilityElementOperatorImpl::SetSearchElementInfoByTextResult(
const std::list<AccessibilityElementInfo> &infos, const int32_t requestId)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
std::vector<AccessibilityElementInfo> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
auto iter = requests_.find(requestId);
if (iter != requests_.end()) {
if (iter->second != nullptr) {

View File

@ -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<AccessibilitySystemAbilityClientImpl> g_Instance = nullptr;
std::shared_ptr<AccessibilitySystemAbilityClient> AccessibilitySystemAbilityClient::GetInstance()
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(g_Mutex);
std::lock_guard<ffrt::mutex> lock(g_Mutex);
if (!g_Instance) {
g_Instance = std::make_shared<AccessibilitySystemAbilityClientImpl>();
} else {
@ -113,7 +113,7 @@ bool AccessibilitySystemAbilityClientImpl::ConnectToService()
bool AccessibilitySystemAbilityClientImpl::LoadAccessibilityService()
{
std::unique_lock<std::mutex> lock(conVarMutex_);
std::unique_lock<ffrt::mutex> lock(conVarMutex_);
sptr<AccessibilityLoadCallback> loadCallback = new AccessibilityLoadCallback();
if (loadCallback == nullptr) {
return false;
@ -136,7 +136,7 @@ bool AccessibilitySystemAbilityClientImpl::LoadAccessibilityService()
void AccessibilitySystemAbilityClientImpl::LoadSystemAbilitySuccess(const sptr<IRemoteObject> &remoteObject)
{
std::lock_guard<std::mutex> lock(conVarMutex_);
std::lock_guard<ffrt::mutex> lock(conVarMutex_);
if (serviceProxy_ != nullptr) {
HILOG_INFO("serviceProxy_ isn't nullptr");
proxyConVar_.notify_one();
@ -161,7 +161,7 @@ void AccessibilitySystemAbilityClientImpl::LoadSystemAbilitySuccess(const sptr<I
void AccessibilitySystemAbilityClientImpl::LoadSystemAbilityFail()
{
std::lock_guard<std::mutex> lock(conVarMutex_);
std::lock_guard<ffrt::mutex> lock(conVarMutex_);
HILOG_WARN("LoadSystemAbilityFail.");
proxyConVar_.notify_one();
}
@ -198,7 +198,7 @@ void AccessibilitySystemAbilityClientImpl::Init()
void AccessibilitySystemAbilityClientImpl::ResetService(const wptr<IRemoteObject> &remote)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (serviceProxy_ != nullptr) {
sptr<IRemoteObject> object = serviceProxy_->AsObject();
if (object && (remote == object)) {
@ -213,7 +213,7 @@ RetError AccessibilitySystemAbilityClientImpl::RegisterElementOperator(
const int32_t windowId, const std::shared_ptr<AccessibilityElementOperator> &operation)
{
HILOG_INFO("Register windowId[%{public}d] start", windowId);
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibilityAbilityInfo> &infos)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (!CheckEventType(event.GetEventType())) {
return RET_ERR_INVALID_PARAM;
}
@ -427,7 +427,7 @@ RetError AccessibilitySystemAbilityClientImpl::SubscribeStateObserver(
const std::shared_ptr<AccessibilityStateObserver> &observer, const uint32_t eventType)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibilityStateObserver> &observer, const uint32_t eventType)
{
HILOG_DEBUG("eventType is [%{public}d]", eventType);
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::string> &enabledAbilities)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibilityElementInfo> &infos, const int32_t requestId)
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibilityElementInfo> &infos, const int32_t requestId)
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(g_Instance->mutex_);
std::lock_guard<ffrt::mutex> lock(g_Instance->mutex_);
if (g_Instance->serviceProxy_) {
return;
}

View File

@ -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",

View File

@ -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;
}

View File

@ -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

View File

@ -67,6 +67,7 @@ ohos_shared_library("accessibleability") {
external_deps = [
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbeget_proxy",

View File

@ -66,6 +66,7 @@ ohos_shared_library("accessibilityconfig") {
external_deps = [
"c_utils:utils",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hilog:libhilog",
"init:libbeget_proxy",
"init:libbegetutil",

View File

@ -20,6 +20,7 @@
#include <string>
#include <uv.h>
#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<std::shared_ptr<NAccessibilityConfigObserver>> observers_ = {};
};
#endif // ACCESSIBILITY_CONFIG_OBSERVER_H

View File

@ -64,6 +64,7 @@ ohos_shared_library("accessibilityclient") {
external_deps = [
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"init:libbeget_proxy",
"init:libbegetutil",

View File

@ -200,7 +200,7 @@ public:
return;
}
splitTreeId = (static_cast<uint64_t>(elementId) >> ELEMENT_MOVE_BIT);
splitElementId = MAX_ELEMENT_ID & elementId;
splitElementId = (static_cast<uint64_t>(elementId) & MAX_ELEMENT_ID);
}
};
} // namespace Accessibility

View File

@ -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;
};
/**

View File

@ -32,6 +32,7 @@ ohos_benchmarktest("BenchmarkTestForAccessibilityConfig") {
"access_token:libnativetoken",
"access_token:libtoken_setproc",
"c_utils:utils",
"ffrt:libffrt",
]
}

View File

@ -14,9 +14,9 @@
*/
#include <benchmark/benchmark.h>
#include <future>
#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<void> &promise)
void SetCompletePromise(ffrt::promise<void> &promise)
{
complete_ = std::move(promise);
}
private:
std::promise<void> complete_;
ffrt::promise<void> 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<void> complete;
std::future syncFuture = complete.get_future();
ffrt::promise<void> 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<void> complete;
std::future syncFuture = complete.get_future();
ffrt::promise<void> 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<void> complete;
std::future syncFuture = complete.get_future();
ffrt::promise<void> complete;
ffrt::future syncFuture = complete.get_future();
configObserver->SetCompletePromise(complete);
config.SetContentTimeout(value);

View File

@ -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" ]
}

View File

@ -14,9 +14,9 @@
*/
#include <benchmark/benchmark.h>
#include <future>
#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<void> &promise)
void SetCompletePromise(ffrt::promise<void> &promise)
{
complete_ = std::move(promise);
}
private:
std::promise<void> complete_;
ffrt::promise<void> complete_;
};
class AccessibleAbilityClientTest : public benchmark::Fixture {
@ -78,8 +78,8 @@ namespace {
AccessibilityUITestAbility::GetInstance()->RegisterAbilityListener(listener_);
// Connect
std::promise<void> connected;
std::future syncFuture = connected.get_future();
ffrt::promise<void> 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<void> disconnect;
std::future syncFuture = disconnect.get_future();
ffrt::promise<void> disconnect;
ffrt::future syncFuture = disconnect.get_future();
listener_->SetCompletePromise(disconnect);
AccessibilityUITestAbility::GetInstance()->Disconnect();
syncFuture.wait();

View File

@ -33,7 +33,10 @@ ohos_fuzztest("AccessibilitySystemAbilityClientFuzzTest") {
"../../../asacfwk:accessibilityclient",
"../../../common:accessibility_common",
]
external_deps = [ "c_utils:utils" ]
external_deps = [
"c_utils:utils",
"ffrt:libffrt",
]
}
###############################################################################

View File

@ -30,7 +30,10 @@ ohos_fuzztest("AccessibleAbilityClientFuzzTest") {
"../../../aafwk:accessibleability",
"../../../common:accessibility_common",
]
external_deps = [ "c_utils:utils" ]
external_deps = [
"c_utils:utils",
"ffrt:libffrt",
]
}
###############################################################################

View File

@ -50,6 +50,7 @@ ohos_shared_library("accessibility_napi") {
]
external_deps = [
"ffrt:libffrt",
"hilog:libhilog",
"input:libmmi-client",
"napi:ace_napi",

View File

@ -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",

View File

@ -18,12 +18,13 @@
#include <vector>
#include <map>
#include <mutex>
#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<std::shared_ptr<EnableAbilityListsObserver>> enableAbilityListsObservers_ = {};
std::vector<std::shared_ptr<EnableAbilityListsObserver>> installAbilityListsObservers_ = {};
};

View File

@ -974,7 +974,7 @@ void EnableAbilityListsObserverImpl::SubscribeToFramework()
void EnableAbilityListsObserverImpl::OnEnableAbilityListsStateChanged()
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
for (auto &observer : enableAbilityListsObservers_) {
observer->OnEnableAbilityListsStateChanged();
}
@ -983,7 +983,7 @@ void EnableAbilityListsObserverImpl::OnEnableAbilityListsStateChanged()
void EnableAbilityListsObserverImpl::OnInstallAbilityListsStateChanged()
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
enableAbilityListsObservers_.clear();
}
void EnableAbilityListsObserverImpl::UnsubscribeInstallObserver(napi_env env, napi_value observer)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
installAbilityListsObservers_.clear();
}

View File

@ -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",

View File

@ -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);

View File

@ -17,9 +17,9 @@
#define NAPI_ACCESSIBILITY_EXTENSION_H
#include <uv.h>
#include <future>
#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<void> syncPromise_;
ffrt::promise<void> syncPromise_;
};
struct KeyEventCallbackInfo : public ExtensionCallbackInfo {
std::shared_ptr<MMI::KeyEvent> keyEvent_;
std::promise<bool> syncPromise_;
ffrt::promise<bool> syncPromise_;
};
struct AccessibilityEventInfoCallbackInfo : public ExtensionCallbackInfo {

View File

@ -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);

View File

@ -222,7 +222,7 @@ void NAccessibilityExtension::OnAbilityDisconnected()
return;
}
work->data = static_cast<void*>(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_ptr<MMI::KeyEven
return false;
}
work->data = static_cast<void*>(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");

View File

@ -55,7 +55,7 @@ public:
void UnsubscribeObservers();
private:
std::mutex mutex_;
ffrt::mutex mutex_;
OHOS::Accessibility::AccessibilityStateEventType type_;
std::vector<std::shared_ptr<StateListener>> 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<StateListenerImpl> accessibilityStateListeners_;
static std::shared_ptr<StateListenerImpl> touchGuideStateListeners_;
static std::shared_ptr<NAccessibilityConfigObserverImpl> captionListeners_;

View File

@ -617,7 +617,7 @@ void NAccessibilityConfigObserverImpl::OnConfigChanged(
const OHOS::AccessibilityConfig::CONFIG_ID id, const OHOS::AccessibilityConfig::ConfigValue& value)
{
HILOG_INFO();
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
for (auto iter = observers_.begin(); iter != observers_.end();) {
if ((*iter)->configId_ == id) {
iter = observers_.erase(iter);

View File

@ -42,8 +42,8 @@ std::shared_ptr<StateListenerImpl> NAccessibilityClient::touchGuideStateListener
std::shared_ptr<NAccessibilityConfigObserverImpl> NAccessibilityClient::captionListeners_ =
std::make_shared<NAccessibilityConfigObserverImpl>();
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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
observers_.clear();
}

View File

@ -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<std::string, std::string> 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<std::string, std::string>("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<std::string, std::string>("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<std::string, std::string>("scrolltype", scrollValue.c_str()));
}
break;
default:
break;
}

View File

@ -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"

View File

@ -260,7 +260,7 @@ public:
void AddConfigCallback(const sptr<IAccessibleAbilityManagerConfigObserver>& callback);
void RemoveConfigCallback(const wptr<IRemoteObject>& callback);
const std::vector<sptr<IAccessibleAbilityManagerConfigObserver>> &GetConfigCallbacks();
const std::vector<sptr<IAccessibleAbilityManagerConfigObserver>> GetConfigCallbacks();
void SetConfigCallbacks(std::vector<sptr<IAccessibleAbilityManagerConfigObserver>>& observer);
void GetImportantEnabledAbilities(std::map<std::string, uint32_t> &importantEnabledAbilities) const;
@ -329,7 +329,7 @@ private:
size_t GetSize();
private:
std::map<std::string, sptr<AccessibleAbilityConnection>> 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<sptr<IAccessibilityEnableAbilityListsObserver>> enableAbilityListsObservers_;
std::mutex asacConnectionsMutex_;
ffrt::mutex enableAbilityListObserversMutex_; // mutex for enableAbilityListsObservers_
std::map<int32_t, sptr<AccessibilityWindowConnection>> asacConnections_; // key: windowId
ffrt::mutex asacConnectionsMutex_; // mutex for map asacConnections_
CaptionPropertyCallbacks captionPropertyCallbacks_;
ffrt::mutex captionPropertyCallbacksMutex_; // mutex for captionPropertyCallbacks_
std::vector<AccessibilityAbilityInfo> installedAbilities_;
std::vector<std::string> enabledAbilities_; // bundleName/abilityName
std::vector<sptr<IAccessibleAbilityManagerConfigObserver>> configCallbacks_;
std::mutex configCallbacksMutex_; // mutex for vector configCallbacks_
ffrt::mutex configCallbacksMutex_; // mutex for vector configCallbacks_
std::shared_ptr<AccessibilitySettingsConfig> config_ = nullptr;
};
@ -364,7 +366,7 @@ public:
void Clear();
private:
std::map<int32_t, sptr<AccessibilityAccountData>> accountDataMap_;
std::mutex accountDataMutex_;
ffrt::mutex accountDataMutex_;
};
} // namespace Accessibility
} // namespace OHOS

View File

@ -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

View File

@ -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<DataShare::DataShareHelper> CreateDatashareHelper();
bool DestoryDatashareHelper(std::shared_ptr<DataShare::DataShareHelper>& helper);
#endif
Uri AssembleUri(const std::string& key);
private:
@ -65,9 +71,10 @@ private:
int32_t accountId_;
std::string uriProxyStr_;
sptr<IRemoteObject> remoteObj_ = nullptr;
#ifdef OHOS_BUILD_ENABLE_DATA_SHARE
std::shared_ptr<DataShare::DataShareHelper> dataShareHelper_ = nullptr;
static std::mutex observerMutex_;
#endif
static ffrt::mutex observerMutex_;
std::map<std::string, sptr<AccessibilitySettingObserver>> settingObserverMap_;
};
} // namespace Accessibility

View File

@ -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<AppExecFwk::EventHandler> &handler);
void UnregisterDisplayListener();

View File

@ -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

View File

@ -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<std::string> 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<std::string> enabledAccessibilityServices_ {}; // bundleName/abilityName
std::shared_ptr<AccessibilityDatashareHelper> datashare_ = nullptr;
std::mutex interfaceMutex_;
ffrt::mutex interfaceMutex_;
};
} // namespace Accessibility
} // namespace OHOS

View File

@ -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<void> promise_;
ffrt::promise<void> promise_;
bool executeActionResult_ = false;
AccessibilityElementInfo accessibilityInfoResult_ = {};
std::vector<AccessibilityElementInfo> 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.
*/

View File

@ -18,10 +18,10 @@
#include <map>
#include <memory>
#include <mutex>
#include <set>
#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<int32_t, int64_t> windowElementMap_;
std::mutex mapMutex_;
ffrt::mutex mapMutex_;
};
SceneBoardElementIdMap sceneBoardElementIdMap_ = {};
@ -126,7 +126,7 @@ private:
sptr<AccessibilityWindowListener> windowListener_ = nullptr;
std::shared_ptr<AppExecFwk::EventHandler> 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

View File

@ -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<MMI::PointerEvent> firstEvent,
std::shared_ptr<MMI::PointerEvent> secondEvent);
float CalcSeparationDistance(std::shared_ptr<MMI::PointerEvent> firstEvent,
std::shared_ptr<MMI::PointerEvent> 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<MMI::PointerEvent> preLastDownEvent_ = nullptr;
std::shared_ptr<MMI::PointerEvent> lastDownEvent_ = nullptr;
std::shared_ptr<MMI::PointerEvent> preLastUpEvent_ = nullptr;
std::shared_ptr<MMI::PointerEvent> lastUpEvent_ = nullptr;
std::shared_ptr<MMI::PointerEvent> currentMoveEvent_ = nullptr;
std::shared_ptr<ZoomGestureEventHandler> zoomGestureEventHandler_ = nullptr;
std::vector<std::shared_ptr<MMI::PointerEvent>> cacheEvents_;
};

View File

@ -16,9 +16,9 @@
#ifndef ACCESSIBLE_ABILITY_CHANNEL_H
#define ACCESSIBLE_ABILITY_CHANNEL_H
#include <future>
#include "accessible_ability_channel_stub.h"
#include "event_handler.h"
#include "ffrt_inner.h"
#include "i_accessibility_element_operator.h"
#include "key_event.h"

View File

@ -16,11 +16,11 @@
#ifndef ACCESSIBLE_ABILITY_CONNECTION_H
#define ACCESSIBLE_ABILITY_CONNECTION_H
#include <mutex>
#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 {

View File

@ -16,10 +16,8 @@
#ifndef ACCESSIBLE_ABILITY_MANAGER_SERVICE_H
#define ACCESSIBLE_ABILITY_MANAGER_SERVICE_H
#include <future>
#include <map>
#include <memory>
#include <mutex>
#include <string>
#include "accessibility_dumper.h"
@ -235,7 +233,7 @@ public:
virtual void SetCursorPositionResult(const int32_t cursorPosition, const int32_t requestId) override;
private:
std::promise<void> promise_;
ffrt::promise<void> promise_;
bool executeActionResult_ = false;
AccessibilityElementInfo accessibilityInfoResult_ = {};
std::vector<AccessibilityElementInfo> elementInfosResult_;
@ -304,6 +302,7 @@ public:
private:
void StopCallbackWait(int32_t windowId);
void StopCallbackWait(int32_t windowId, int32_t treeId);
RetError CheckCallingUid();
sptr<AccessibilityWindowConnection> GetRealIdConnection();
bool FindFocusedElementByConnection(sptr<AccessibilityWindowConnection> connection,
AccessibilityElementInfo &elementInfo);
@ -382,7 +381,7 @@ private:
void Clear();
private:
std::vector<sptr<IAccessibleAbilityManagerStateObserver>> 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<AccessibilityWindowConnection> &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<IRemoteObject::DeathRecipient> configCallbackDeathRecipient_ = nullptr;
sptr<IRemoteObject::DeathRecipient> bundleManagerDeathRecipient_ = nullptr;
StateObservers stateObservers_;
std::mutex mutex_; // current used for register state observer
ffrt::mutex mutex_; // current used for register state observer
std::vector<sptr<IAccessibleAbilityManagerConfigObserver>> defaultConfigCallbacks_;
std::shared_ptr<AccessibilitySettings> accessibilitySettings_ = nullptr;
std::vector<std::string> removedAutoStartAbilities_ {};

View File

@ -142,12 +142,14 @@ void AccessibilityAccountData::AddCaptionPropertyCallback(
const sptr<IAccessibleAbilityManagerCaptionObserver>& callback)
{
HILOG_DEBUG();
std::lock_guard<ffrt::mutex> lock(captionPropertyCallbacksMutex_);
captionPropertyCallbacks_.push_back(callback);
}
void AccessibilityAccountData::RemoveCaptionPropertyCallback(const wptr<IRemoteObject>& callback)
{
HILOG_DEBUG();
std::lock_guard<ffrt::mutex> 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<IAccessibilityEnableAbilityListsObserver>& observer)
{
HILOG_DEBUG();
std::lock_guard<ffrt::mutex> lock(enableAbilityListObserversMutex_);
if (std::any_of(enableAbilityListsObservers_.begin(), enableAbilityListsObservers_.end(),
[observer](const sptr<IAccessibilityEnableAbilityListsObserver> &listObserver) {
return listObserver == observer;
@ -174,6 +177,7 @@ void AccessibilityAccountData::AddEnableAbilityListsObserver(
void AccessibilityAccountData::RemoveEnableAbilityListsObserver(const wptr<IRemoteObject>& observer)
{
HILOG_INFO();
std::lock_guard<ffrt::mutex> 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<IRemo
void AccessibilityAccountData::UpdateEnableAbilityListsState()
{
std::lock_guard<ffrt::mutex> 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<ffrt::mutex> 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<int32_t, sptr<AccessibilityWindowConnection>> AccessibilityAccoun
const CaptionPropertyCallbacks AccessibilityAccountData::GetCaptionPropertyCallbacks()
{
HILOG_DEBUG("GetCaptionPropertyCallbacks start.");
return captionPropertyCallbacks_;
std::lock_guard<ffrt::mutex> lock(captionPropertyCallbacksMutex_);
CaptionPropertyCallbacks rtnVec = captionPropertyCallbacks_;
return rtnVec;
}
sptr<AccessibleAbilityConnection> AccessibilityAccountData::GetConnectingA11yAbility(const std::string &uri)
@ -666,14 +674,14 @@ void AccessibilityAccountData::AddConfigCallback(
const sptr<IAccessibleAbilityManagerConfigObserver>& callback)
{
HILOG_DEBUG("AddConfigCallback start.");
std::lock_guard<std::mutex> lock(configCallbacksMutex_);
std::lock_guard<ffrt::mutex> lock(configCallbacksMutex_);
configCallbacks_.push_back(callback);
}
const std::vector<sptr<IAccessibleAbilityManagerConfigObserver>> &AccessibilityAccountData::GetConfigCallbacks()
const std::vector<sptr<IAccessibleAbilityManagerConfigObserver>> AccessibilityAccountData::GetConfigCallbacks()
{
HILOG_DEBUG("GetConfigCallbacks start.");
std::lock_guard<std::mutex> lock(configCallbacksMutex_);
std::lock_guard<ffrt::mutex> lock(configCallbacksMutex_);
std::vector<sptr<IAccessibleAbilityManagerConfigObserver>> rtnVec = configCallbacks_;
return rtnVec;
}
@ -681,14 +689,14 @@ const std::vector<sptr<IAccessibleAbilityManagerConfigObserver>> &AccessibilityA
void AccessibilityAccountData::SetConfigCallbacks(std::vector<sptr<IAccessibleAbilityManagerConfigObserver>>& observer)
{
HILOG_DEBUG("SetConfigCallbacks start.");
std::lock_guard<std::mutex> lock(configCallbacksMutex_);
std::lock_guard<ffrt::mutex> lock(configCallbacksMutex_);
configCallbacks_ = observer;
}
void AccessibilityAccountData::RemoveConfigCallback(const wptr<IRemoteObject>& callback)
{
HILOG_DEBUG("RemoveConfigCallback start.");
std::lock_guard<std::mutex> lock(configCallbacksMutex_);
std::lock_guard<ffrt::mutex> 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<AccessibleAbilityConnection>& connection)
{
HILOG_INFO("uri is %{private}s", uri.c_str());
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
auto it = connectionMap_.find(uri);
if (it != connectionMap_.end()) {
connectionMap_.erase(it);
@ -1058,7 +1066,7 @@ sptr<AccessibleAbilityConnection> AccessibilityAccountData::AccessibilityAbility
const std::string& elementName)
{
HILOG_DEBUG("elementName is %{public}s", elementName.c_str());
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibleAbilityConnection> AccessibilityAccountData::AccessibilityAbility
const std::string& uri)
{
HILOG_DEBUG("uri is %{private}s", uri.c_str());
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
auto iter = connectionMap_.find(uri);
if (iter != connectionMap_.end()) {
return iter->second;
@ -1087,7 +1095,7 @@ sptr<AccessibleAbilityConnection> AccessibilityAccountData::AccessibilityAbility
void AccessibilityAccountData::AccessibilityAbility::GetAccessibilityAbilities(
std::vector<sptr<AccessibleAbilityConnection>>& connectionList)
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<AccessibilityAbilityInfo>& abilities)
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::string, sptr<AccessibleAbilityConnection>>& connectionMap)
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
connectionMap = connectionMap_;
}
void AccessibilityAccountData::AccessibilityAbility::Clear()
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
return connectionMap_.clear();
}
size_t AccessibilityAccountData::AccessibilityAbility::GetSize()
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
return connectionMap_.size();
}
void AccessibilityAccountData::AccessibilityAbility::GetDisableAbilities(
std::vector<AccessibilityAbilityInfo> &disabledAbilities)
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
return connectionMap_.count(uri);
}
sptr<AccessibilityAccountData> AccessibilityAccountDataMap::AddAccountData(
int32_t accountId)
{
std::lock_guard<std::mutex> lock(accountDataMutex_);
std::lock_guard<ffrt::mutex> lock(accountDataMutex_);
auto iter = accountDataMap_.find(accountId);
if (iter != accountDataMap_.end()) {
HILOG_WARN("accountId is existed");
@ -1209,7 +1217,7 @@ sptr<AccessibilityAccountData> AccessibilityAccountDataMap::AddAccountData(
sptr<AccessibilityAccountData> AccessibilityAccountDataMap::GetCurrentAccountData(
int32_t accountId)
{
std::lock_guard<std::mutex> lock(accountDataMutex_);
std::lock_guard<ffrt::mutex> lock(accountDataMutex_);
auto iter = accountDataMap_.find(accountId);
if (iter != accountDataMap_.end()) {
return iter->second;
@ -1228,7 +1236,7 @@ sptr<AccessibilityAccountData> AccessibilityAccountDataMap::GetCurrentAccountDat
sptr<AccessibilityAccountData> AccessibilityAccountDataMap::GetAccountData(
int32_t accountId)
{
std::lock_guard<std::mutex> lock(accountDataMutex_);
std::lock_guard<ffrt::mutex> lock(accountDataMutex_);
auto iter = accountDataMap_.find(accountId);
if (iter != accountDataMap_.end()) {
return iter->second;
@ -1242,7 +1250,7 @@ sptr<AccessibilityAccountData> AccessibilityAccountDataMap::RemoveAccountData(
int32_t accountId)
{
sptr<AccessibilityAccountData> accountData = nullptr;
std::lock_guard<std::mutex> lock(accountDataMutex_);
std::lock_guard<ffrt::mutex> lock(accountDataMutex_);
auto iter = accountDataMap_.find(accountId);
if (iter != accountDataMap_.end()) {
accountData = iter->second;
@ -1254,7 +1262,7 @@ sptr<AccessibilityAccountData> AccessibilityAccountDataMap::RemoveAccountData(
void AccessibilityAccountDataMap::Clear()
{
std::lock_guard<std::mutex> lock(accountDataMutex_);
std::lock_guard<ffrt::mutex> lock(accountDataMutex_);
accountDataMap_.clear();
}
} // namespace Accessibility

View File

@ -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;

View File

@ -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<DataShare::DataShareResultSet> 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<AccessibilitySettingObserver> AccessibilityDatashareHelper::CreateObserver(const std::string& key,
@ -229,11 +241,13 @@ RetError AccessibilityDatashareHelper::RegisterObserver(const sptr<Accessibility
{
std::string callingIdentity = IPCSkeleton::ResetCallingIdentity();
auto uri = AssembleUri(observer->GetKey());
#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<std::mutex> lock(observerMutex_);
std::lock_guard<ffrt::mutex> lock(observerMutex_);
settingObserverMap_.insert(std::make_pair(key, observer));
return RET_OK;
}
@ -258,11 +272,13 @@ RetError AccessibilityDatashareHelper::UnregisterObserver(const sptr<Accessibili
{
std::string callingIdentity = IPCSkeleton::ResetCallingIdentity();
auto uri = AssembleUri(observer->GetKey());
#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<Accessibili
RetError AccessibilityDatashareHelper::UnregisterObserver(const std::string& key)
{
std::lock_guard<std::mutex> lock(observerMutex_);
std::lock_guard<ffrt::mutex> lock(observerMutex_);
auto iter = settingObserverMap_.find(key);
if (iter != settingObserverMap_.end() && iter->second != nullptr) {
sptr<AccessibilitySettingObserver> 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<DataShare::DataShareHelper> AccessibilityDatashareHelper::CreateDatashareHelper()
{
if (remoteObj_ == nullptr) {
@ -311,6 +328,7 @@ bool AccessibilityDatashareHelper::DestoryDatashareHelper(std::shared_ptr<DataSh
}
return true;
}
#endif
Uri AccessibilityDatashareHelper::AssembleUri(const std::string& key)
{

View File

@ -128,6 +128,15 @@ Rosen::FoldDisplayMode AccessibilityDisplayManager::GetFoldDisplayMode()
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);
Rosen::DisplayManager::GetInstance().SetDisplayScale(screenId, scaleX,
scaleY, pivotX, pivotY);
}
void AccessibilityDisplayManager::RegisterDisplayListener(
const std::shared_ptr<AppExecFwk::EventHandler> &handler)
{

View File

@ -15,6 +15,7 @@
#include "accessibility_gesture_recognizer.h"
#include "hilog_wrapper.h"
#include <cinttypes>
namespace OHOS {
namespace Accessibility {

View File

@ -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()

View File

@ -16,6 +16,7 @@
#include <cfloat>
#include "accessibility_multifinger_multitap.h"
#include "hilog_wrapper.h"
#include <cinttypes>
namespace OHOS {
namespace Accessibility {

View File

@ -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<AccessibilityDisplayManager>::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);
}
}
}

View File

@ -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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (instance_ == nullptr) {
HILOG_INFO("instance_ is nullptr");
return;

View File

@ -67,8 +67,8 @@ RetError AccessibilitySettings::SetShortKeyState(const bool state)
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, state]() {
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -109,8 +109,8 @@ RetError AccessibilitySettings::SetMouseAutoClick(const int32_t time)
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, time]() {
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -136,8 +136,8 @@ RetError AccessibilitySettings::SetShortkeyTarget(const std::string &name)
HILOG_ERROR("handler_ is nullptr.");
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &name]() {
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -162,8 +162,8 @@ RetError AccessibilitySettings::SetShortkeyMultiTarget(const std::vector<std::st
HILOG_ERROR("handler_ is nullptr.");
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &name]() {
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -277,8 +277,8 @@ RetError AccessibilitySettings::SetDaltonizationColorFilter(const uint32_t filte
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, filter]() {
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -302,8 +302,8 @@ RetError AccessibilitySettings::SetContentTimeout(const uint32_t time)
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, time]() {
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -333,8 +333,8 @@ RetError AccessibilitySettings::SetBrightnessDiscount(const float discount)
return Accessibility::RET_ERR_FAILED;
}
#endif
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, discount]() {
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -360,8 +360,8 @@ RetError AccessibilitySettings::SetAudioBalance(const float balance)
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, balance]() {
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -387,8 +387,8 @@ RetError AccessibilitySettings::SetClickResponseTime(const uint32_t time)
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, time]() {
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -415,8 +415,8 @@ RetError AccessibilitySettings::SetIgnoreRepeatClickState(const bool state)
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, state]() {
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -443,8 +443,8 @@ RetError AccessibilitySettings::SetIgnoreRepeatClickTime(const uint32_t time)
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, time]() {
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -543,8 +543,8 @@ RetError AccessibilitySettings::GetScreenMagnificationState(bool &state)
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &state]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -568,8 +568,8 @@ RetError AccessibilitySettings::GetShortKeyState(bool &state)
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &state]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -593,8 +593,8 @@ RetError AccessibilitySettings::GetMouseKeyState(bool &state)
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &state]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -613,8 +613,8 @@ RetError AccessibilitySettings::GetMouseKeyState(bool &state)
RetError AccessibilitySettings::GetMouseAutoClick(int32_t &time)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &time]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -634,8 +634,8 @@ RetError AccessibilitySettings::GetMouseAutoClick(int32_t &time)
RetError AccessibilitySettings::GetShortkeyTarget(std::string &name)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &name]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -655,8 +655,8 @@ RetError AccessibilitySettings::GetShortkeyTarget(std::string &name)
RetError AccessibilitySettings::GetShortkeyMultiTarget(std::vector<std::string> &name)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &name]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -676,8 +676,8 @@ RetError AccessibilitySettings::GetShortkeyMultiTarget(std::vector<std::string>
RetError AccessibilitySettings::GetHighContrastTextState(bool &state)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &state]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -697,8 +697,8 @@ RetError AccessibilitySettings::GetHighContrastTextState(bool &state)
RetError AccessibilitySettings::GetDaltonizationState(bool &state)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &state]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -718,8 +718,8 @@ RetError AccessibilitySettings::GetDaltonizationState(bool &state)
RetError AccessibilitySettings::GetInvertColorState(bool &state)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &state]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -739,8 +739,8 @@ RetError AccessibilitySettings::GetInvertColorState(bool &state)
RetError AccessibilitySettings::GetAnimationOffState(bool &state)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &state]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -760,8 +760,8 @@ RetError AccessibilitySettings::GetAnimationOffState(bool &state)
RetError AccessibilitySettings::GetAudioMonoState(bool &state)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &state]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -781,8 +781,8 @@ RetError AccessibilitySettings::GetAudioMonoState(bool &state)
RetError AccessibilitySettings::GetDaltonizationColorFilter(uint32_t &type)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &type]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -802,8 +802,8 @@ RetError AccessibilitySettings::GetDaltonizationColorFilter(uint32_t &type)
RetError AccessibilitySettings::GetContentTimeout(uint32_t &timer)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &timer]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -823,8 +823,8 @@ RetError AccessibilitySettings::GetContentTimeout(uint32_t &timer)
RetError AccessibilitySettings::GetBrightnessDiscount(float &brightness)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &brightness]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -844,8 +844,8 @@ RetError AccessibilitySettings::GetBrightnessDiscount(float &brightness)
RetError AccessibilitySettings::GetAudioBalance(float &balance)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &balance]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -865,8 +865,8 @@ RetError AccessibilitySettings::GetAudioBalance(float &balance)
RetError AccessibilitySettings::GetClickResponseTime(uint32_t &time)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &time]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -886,8 +886,8 @@ RetError AccessibilitySettings::GetClickResponseTime(uint32_t &time)
RetError AccessibilitySettings::GetIgnoreRepeatClickState(bool &state)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &state]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -907,8 +907,8 @@ RetError AccessibilitySettings::GetIgnoreRepeatClickState(bool &state)
RetError AccessibilitySettings::GetIgnoreRepeatClickTime(uint32_t &time)
{
HILOG_DEBUG();
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &time]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -1133,8 +1133,8 @@ RetError AccessibilitySettings::GetCaptionProperty(AccessibilityConfig::CaptionP
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &caption]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -1158,8 +1158,8 @@ RetError AccessibilitySettings::SetCaptionProperty(const AccessibilityConfig::Ca
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &caption]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =
@ -1198,8 +1198,8 @@ RetError AccessibilitySettings::GetCaptionState(bool &state)
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &state]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData =

View File

@ -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<std::string> &name)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(interfaceMutex_);
shortkeyMultiTarget_ = name;
std::set<std::string> targets;
std::for_each(name.begin(), name.end(), [&](const std::string &target) {
if (targets.find(target) == targets.end()) {
targets.insert(target);
}
});
std::lock_guard<ffrt::mutex> lock(interfaceMutex_);
shortkeyMultiTarget_ = std::vector<std::string>(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<std::string> AccessibilitySettingsConfig::GetShortkeyMultiTarget()
{
std::lock_guard<std::mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::mutex> lock(interfaceMutex_);
std::vector<std::string> 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<std::string> AccessibilitySettingsConfig::GetEnabledAccessibilityServices()
{
std::lock_guard<std::mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::mutex> lock(interfaceMutex_);
std::vector<std::string> rtnVec = enabledAccessibilityServices_;
return rtnVec;
}
RetError AccessibilitySettingsConfig::AddEnabledAccessibilityService(const std::string &serviceName)
{
std::lock_guard<std::mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::mutex> 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<uint32_t>(datashare_->GetIntValue(CONTENT_TIMEOUT_KEY, 0));
brightnessDiscount_ = static_cast<float>(datashare_->GetFloatValue(BRIGHTNESS_DISCOUNT_KEY, 1.0));
audioBalance_ = static_cast<float>(datashare_->GetFloatValue(AUDIO_BALANCE_KEY, 0));
screenMagnificationType_ = static_cast<uint32_t>(datashare_->GetIntValue(SCREEN_MAGNIFICATION_TYPE, 0));
clickResponseTime_ = static_cast<uint32_t>(datashare_->GetIntValue(CLICK_RESPONCE_TIME, 0));
ignoreRepeatClickTime_ = static_cast<uint32_t>(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<std::string> &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<std::string> 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);
}

View File

@ -17,6 +17,7 @@
#include "accessible_ability_manager_service.h"
#include "hilog_wrapper.h"
#include "utils.h"
#include <cinttypes>
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<MMI::PointerEvent> TouchEventInjector::obtainTouchEvent(int32_t
{
HILOG_DEBUG();
std::shared_ptr<MMI::PointerEvent> 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);
}
}

View File

@ -19,6 +19,7 @@
#include "hilog_wrapper.h"
#include "securec.h"
#include "utils.h"
#include <cinttypes>
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<int32_t>(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<int32_t>(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<int32_t>(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<int32_t>(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<int32_t>(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<int32_t>(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<int32_t>(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<float>(DIVIDE_2(leftTopY_ + rightBottomY_) - pointerIterm.GetDisplayY());
doubleTapLongPressDownEvent_ = std::make_shared<MMI::PointerEvent>(event);
} else {
CancelPostEvent(SEND_TOUCH_INTERACTION_END_MSG);
}
}
@ -783,7 +777,7 @@ void TouchGuider::HandleDraggingStateInnerMove(MMI::PointerEvent &event)
HILOG_DEBUG();
std::vector<int32_t> 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

View File

@ -20,6 +20,7 @@
#include "accessible_ability_manager_service.h"
#include "hilog_wrapper.h"
#include "utils.h"
#include <cinttypes>
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<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> 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<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
a11yWindows_.clear();
subWindows_.clear();
sceneBoardElementIdMap_.Clear();
@ -79,7 +80,7 @@ void AccessibilityWindowManager::DeInit()
void AccessibilityWindowManager::WinDeInit()
{
HILOG_DEBUG();
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
a11yWindows_.clear();
subWindows_.clear();
sceneBoardElementIdMap_.Clear();
@ -162,7 +163,7 @@ void AccessibilityWindowManager::OnWindowUpdate(const std::vector<sptr<Rosen::Ac
int32_t AccessibilityWindowManager::ConvertToRealWindowId(int32_t windowId, int32_t focusType)
{
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> 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<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> 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<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
if (windowId == INVALID_WINDOW_ID) {
ClearAccessibilityFocused();
a11yFocusedWindowId_ = INVALID_WINDOW_ID;
@ -402,7 +403,7 @@ void AccessibilityWindowManager::SetAccessibilityFocusedWindow(int32_t windowId)
std::vector<AccessibilityWindowInfo> AccessibilityWindowManager::GetAccessibilityWindows()
{
HILOG_DEBUG("a11yWindows_ size[%{public}zu]", a11yWindows_.size());
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
std::vector<sptr<Rosen::AccessibilityWindowInfo>> windowInfos;
std::vector<AccessibilityWindowInfo> windows;
Rosen::WMError err = OHOS::Rosen::WindowManager::GetInstance().GetAccessibilityWindowInfo(windowInfos);
@ -430,7 +431,7 @@ std::vector<AccessibilityWindowInfo> AccessibilityWindowManager::GetAccessibilit
bool AccessibilityWindowManager::GetAccessibilityWindow(int32_t windowId, AccessibilityWindowInfo &window)
{
HILOG_DEBUG("start windowId(%{public}d)", windowId);
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
std::vector<sptr<Rosen::AccessibilityWindowInfo>> 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<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
auto it = std::find_if(a11yWindows_.begin(), a11yWindows_.end(),
[windowId](const std::map<int32_t, AccessibilityWindowInfo>::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<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
auto it = std::find_if(a11yWindows_.begin(), a11yWindows_.end(),
[windowId](const std::map<int32_t, AccessibilityWindowInfo>::value_type &window) {
return window.first == windowId;
@ -585,7 +586,7 @@ bool AccessibilityWindowManager::EqualProperty(Accessibility::AccessibilityWindo
void AccessibilityWindowManager::WindowUpdateAdded(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos)
{
HILOG_DEBUG();
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
for (auto &windowInfo : infos) {
if (!windowInfo) {
HILOG_ERROR("invalid windowInfo");
@ -615,7 +616,7 @@ void AccessibilityWindowManager::WindowUpdateAdded(const std::vector<sptr<Rosen:
void AccessibilityWindowManager::WindowUpdateRemoved(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos)
{
HILOG_DEBUG();
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
auto &aams = Singleton<AccessibleAbilityManagerService>::GetInstance();
for (auto &windowInfo : infos) {
if (!windowInfo) {
@ -644,7 +645,7 @@ void AccessibilityWindowManager::WindowUpdateRemoved(const std::vector<sptr<Rose
void AccessibilityWindowManager::WindowUpdateFocused(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos)
{
HILOG_DEBUG();
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
auto &aams = Singleton<AccessibleAbilityManagerService>::GetInstance();
for (auto &windowInfo : infos) {
if (!windowInfo) {
@ -672,7 +673,7 @@ void AccessibilityWindowManager::WindowUpdateFocused(const std::vector<sptr<Rose
void AccessibilityWindowManager::WindowUpdateBounds(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos)
{
HILOG_DEBUG();
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
auto &aams = Singleton<AccessibleAbilityManagerService>::GetInstance();
for (auto &windowInfo : infos) {
if (!windowInfo) {
@ -693,7 +694,7 @@ void AccessibilityWindowManager::WindowUpdateBounds(const std::vector<sptr<Rosen
void AccessibilityWindowManager::WindowUpdateActive(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos)
{
HILOG_DEBUG();
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
for (auto &windowInfo : infos) {
if (!windowInfo) {
HILOG_ERROR("invalid windowInfo");
@ -717,7 +718,7 @@ void AccessibilityWindowManager::WindowUpdateActive(const std::vector<sptr<Rosen
void AccessibilityWindowManager::WindowUpdateProperty(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos)
{
HILOG_DEBUG();
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
auto &aams = Singleton<AccessibleAbilityManagerService>::GetInstance();
for (auto &windowInfo : infos) {
if (!windowInfo) {
@ -737,7 +738,7 @@ void AccessibilityWindowManager::WindowUpdateProperty(const std::vector<sptr<Ros
void AccessibilityWindowManager::WindowUpdateTypeEvent(const int32_t realWidId, Accessibility::WindowUpdateType type)
{
HILOG_DEBUG();
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> lock(interfaceMutex_);
HILOG_DEBUG("WindowUpdateType type[%{public}d]", type);
auto &aams = Singleton<AccessibleAbilityManagerService>::GetInstance();
switch (type) {
@ -785,7 +786,7 @@ void AccessibilityWindowManager::WindowUpdateTypeEvent(const int32_t realWidId,
void AccessibilityWindowManager::WindowUpdateAll(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos)
{
HILOG_DEBUG();
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> 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<sptr<Rosen::A
void AccessibilityWindowManager::ClearOldActiveWindow()
{
HILOG_DEBUG("active window id is %{public}d", activeWindowId_);
std::lock_guard<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> 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<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> 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<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> 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<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> 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<std::recursive_mutex> lock(interfaceMutex_);
std::lock_guard<ffrt::recursive_mutex> 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<std::mutex> lock(mapMutex_);
std::lock_guard<ffrt::mutex> lock(mapMutex_);
windowElementMap_[windowId] = elementId;
}
void AccessibilityWindowManager::SceneBoardElementIdMap::RemovePair(const int32_t windowId)
{
std::lock_guard<std::mutex> lock(mapMutex_);
std::lock_guard<ffrt::mutex> lock(mapMutex_);
windowElementMap_.erase(windowId);
}
bool AccessibilityWindowManager::SceneBoardElementIdMap::CheckWindowIdPair(const int32_t windowId)
{
std::lock_guard<std::mutex> lock(mapMutex_);
std::lock_guard<ffrt::mutex> lock(mapMutex_);
return windowElementMap_.count(windowId);
}
void AccessibilityWindowManager::SceneBoardElementIdMap::Clear()
{
std::lock_guard<std::mutex> lock(mapMutex_);
std::lock_guard<ffrt::mutex> lock(mapMutex_);
windowElementMap_.clear();
}
std::map<int32_t, int64_t> AccessibilityWindowManager::SceneBoardElementIdMap::GetAllPairs()
{
std::lock_guard<std::mutex> lock(mapMutex_);
std::lock_guard<ffrt::mutex> lock(mapMutex_);
return windowElementMap_;
}

View File

@ -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<AccessibilityWindowInfo> windowInfos =
Singleton<AccessibilityWindowManager>::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<int32_t> 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<float>(item.GetDisplayX());
sumY += static_cast<float>(item.GetDisplayY());
sumX += static_cast<float>(item.GetRawDisplayX());
sumY += static_cast<float>(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<float>(abs(item.GetDisplayX() - coordinate.centerX));
sumSpanY += static_cast<float>(abs(item.GetDisplayY() - coordinate.centerY));
sumSpanX += static_cast<float>(abs(item.GetRawDisplayX() - coordinate.centerX));
sumSpanY += static_cast<float>(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<AccessibilityDisplayManager>::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<Rosen::Display> 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<float>(anchorX);
anchorPointY_ = static_cast<float>(anchorY);
OHOS::Rosen::WindowAccessibilityController::GetInstance().SetAnchorAndScale(anchorX, anchorY, DEFAULT_SCALE);
float x = anchorPointX_ / screenWidth_;
float y = anchorPointY_ / screenHeight_;
scaleRatio_ = DEFAULT_SCALE;
AccessibilityDisplayManager &displayMgr = Singleton<AccessibilityDisplayManager>::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<AccessibilityDisplayManager>::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<int32_t>(offsetX), static_cast<int32_t>(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<AccessibilityDisplayManager>::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<int32_t>(focusX), static_cast<int32_t>(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<AccessibilityDisplayManager>::GetInstance();
displayMgr.SetDisplayScale(screenId_, scaleRatio_, scaleRatio_, x, y);
#else
HILOG_INFO("not support zoom");
return;
#endif
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -67,8 +67,8 @@ RetError AccessibleAbilityChannel::SearchElementInfoByAccessibilityId(const Elem
return RET_ERR_NULLPTR;
}
std::shared_ptr<std::promise<RetError>> syncPromise = std::make_shared<std::promise<RetError>>();
std::future syncFuture = syncPromise->get_future();
std::shared_ptr<ffrt::promise<RetError>> syncPromise = std::make_shared<ffrt::promise<RetError>>();
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<std::promise<RetError>> syncPromise = std::make_shared<std::promise<RetError>>();
std::future syncFuture = syncPromise->get_future();
std::shared_ptr<ffrt::promise<RetError>> syncPromise = std::make_shared<ffrt::promise<RetError>>();
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<std::promise<RetError>> syncPromise = std::make_shared<std::promise<RetError>>();
std::future syncFuture = syncPromise->get_future();
std::shared_ptr<ffrt::promise<RetError>> syncPromise = std::make_shared<ffrt::promise<RetError>>();
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<std::promise<RetError>> syncPromise = std::make_shared<std::promise<RetError>>();
std::future syncFuture = syncPromise->get_future();
std::shared_ptr<ffrt::promise<RetError>> syncPromise = std::make_shared<ffrt::promise<RetError>>();
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<std::promise<RetError>> syncPromise = std::make_shared<std::promise<RetError>>();
std::future syncFuture = syncPromise->get_future();
std::shared_ptr<ffrt::promise<RetError>> syncPromise = std::make_shared<ffrt::promise<RetError>>();
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<std::promise<RetError>> syncPromise = std::make_shared<std::promise<RetError>>();
std::shared_ptr<ffrt::promise<RetError>> syncPromise = std::make_shared<ffrt::promise<RetError>>();
std::shared_ptr<AccessibilityWindowInfo> tmpWindowInfo = std::make_shared<AccessibilityWindowInfo>(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<AccessibleAbilityConnection> 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<Ac
return RET_ERR_NULLPTR;
}
std::shared_ptr<std::promise<RetError>> syncPromise = std::make_shared<std::promise<RetError>>();
std::shared_ptr<ffrt::promise<RetError>> syncPromise = std::make_shared<ffrt::promise<RetError>>();
auto tmpWindows = std::make_shared<std::vector<AccessibilityWindowInfo>>(windows);
std::future syncFuture = syncPromise->get_future();
ffrt::future syncFuture = syncPromise->get_future();
eventHandler_->PostTask([this, displayId, tmpWindows, syncPromise]() {
HILOG_DEBUG();
sptr<AccessibleAbilityConnection> clientConnection = GetConnection(accountId_, clientName_);
@ -504,8 +504,8 @@ RetError AccessibleAbilityChannel::GetWindows(uint64_t displayId, std::vector<Ac
syncPromise->set_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<std::promise<RetError>> syncPromise = std::make_shared<std::promise<RetError>>();
std::future syncFuture = syncPromise->get_future();
std::shared_ptr<ffrt::promise<RetError>> syncPromise = std::make_shared<ffrt::promise<RetError>>();
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<std::promise<RetError>> syncPromise = std::make_shared<std::promise<RetError>>();
std::future syncFuture = syncPromise->get_future();
std::shared_ptr<ffrt::promise<RetError>> syncPromise = std::make_shared<ffrt::promise<RetError>>();
ffrt::future syncFuture = syncPromise->get_future();
eventHandler_->PostTask([this, gesturePath, syncPromise]() {
HILOG_DEBUG();
sptr<AccessibleAbilityConnection> 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<std::st
return RET_ERR_NULLPTR;
}
std::shared_ptr<std::promise<RetError>> syncPromise = std::make_shared<std::promise<RetError>>();
std::future syncFuture = syncPromise->get_future();
std::shared_ptr<ffrt::promise<RetError>> syncPromise = std::make_shared<ffrt::promise<RetError>>();
ffrt::future syncFuture = syncPromise->get_future();
eventHandler_->PostTask([this, targetBundleNames, syncPromise]() {
HILOG_DEBUG();
sptr<AccessibleAbilityConnection> clientConnection = GetConnection(accountId_, clientName_);
@ -651,8 +651,8 @@ RetError AccessibleAbilityChannel::SetTargetBundleName(const std::vector<std::st
syncPromise->set_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;
}

View File

@ -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<void> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<void> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise]() {
HILOG_DEBUG();
Singleton<AccessibilityCommonEvent>::GetInstance().UnSubscriberEvent();
#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER
Singleton<AccessibilityDisplayManager>::GetInstance().UnregisterDisplayListener();
#endif
Singleton<AccessibilityWindowManager>::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<AccessibilityCommonEvent>::GetInstance().UnSubscriberEvent();
#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER
Singleton<AccessibilityDisplayManager>::GetInstance().UnregisterDisplayListener();
#endif
Singleton<AccessibilityWindowManager>::GetInstance().DeregisterWindowListener();
Singleton<AccessibilityWindowManager>::GetInstance().DeInit();
@ -278,8 +289,8 @@ int AccessibleAbilityManagerService::Dump(int fd, const std::vector<std::u16stri
HILOG_ERROR("Parameters check failed!");
return RET_ERR_NULLPTR;
}
std::promise<int> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<int> 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<std::u16stri
RetError AccessibleAbilityManagerService::VerifyingToKenId(const int32_t windowId, const int64_t elementId)
{
uint32_t tokenId = IPCSkeleton::GetCallingTokenID();
int32_t treeId = (static_cast<int64_t>(elementId) >> ELEMENT_MOVE_BIT);
int32_t treeId = (static_cast<uint64_t>(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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> lock(mutex_);
if (!stateObserversDeathRecipient_) {
stateObserversDeathRecipient_ = new(std::nothrow) StateCallbackDeathRecipient();
if (!stateObserversDeathRecipient_) {
@ -409,8 +420,8 @@ void AccessibleAbilityManagerService::GetRealWindowAndElementId(int32_t& windowI
return;
}
std::promise<void> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<void> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([&, this]() {
Singleton<AccessibilityWindowManager>::GetInstance().GetRealWindowAndElementId(windowId, elementId);
syncPromise.set_value();
@ -426,8 +437,8 @@ void AccessibleAbilityManagerService::GetSceneBoardInnerWinId(int32_t windowId,
return;
}
std::promise<void> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<void> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([&, this]() {
Singleton<AccessibilityWindowManager>::GetInstance().GetSceneBoardInnerWinId(windowId, elementId, innerWid);
syncPromise.set_value();
@ -467,10 +478,10 @@ bool AccessibleAbilityManagerService::FindFocusedElementByConnection(sptr<Access
HILOG_ERROR("Failed to create focusCallback.");
return false;
}
std::future<void> focusFuture = focusCallback->promise_.get_future();
ffrt::future<void> 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<void> promiseFuture = callBack->promise_.get_future();
ffrt::future<void> 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<void> actionFuture = actionCallback->promise_.get_future();
ffrt::future<void> 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<std::promise<uint32_t>> syncPromise = std::make_shared<std::promise<uint32_t>>();
std::future syncFuture = syncPromise->get_future();
std::shared_ptr<ffrt::promise<uint32_t>> syncPromise = std::make_shared<ffrt::promise<uint32_t>>();
ffrt::future syncFuture = syncPromise->get_future();
actionHandler_->PostTask([this, syncPromise, callback]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> 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<std::promise<void>> syncPromisePtr = std::make_shared<std::promise<void>>();
std::future syncFuture = syncPromisePtr->get_future();
std::shared_ptr<ffrt::promise<void>> syncPromisePtr = std::make_shared<ffrt::promise<void>>();
ffrt::future syncFuture = syncPromisePtr->get_future();
actionHandler_->PostTask([this, syncPromisePtr, observer]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> 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<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &infos, abilityTypes, stateType]() {
sptr<AccessibilityAccountData> 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<AccessibilityWindowConnection> 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<AccessibilityWindowConnection> 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<AccessibilityWindowConnection> 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<AccessibilityWindowConnection> 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<IAccessibilityElementOperator> &operation, bool isApp)
{
if (CheckCallingUid() != RET_OK) {
return RET_ERR_SAMGR;
}
static std::atomic<int32_t> 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<bool> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<bool> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
@ -1091,8 +1096,8 @@ bool AccessibleAbilityManagerService::GetTouchGuideState()
return false;
}
std::promise<bool> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<bool> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
@ -1115,8 +1120,8 @@ bool AccessibleAbilityManagerService::GetGestureState()
return false;
}
std::promise<bool> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<bool> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
@ -1139,8 +1144,8 @@ bool AccessibleAbilityManagerService::GetKeyEventObserverState()
return false;
}
std::promise<bool> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<bool> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
@ -1163,8 +1168,8 @@ RetError AccessibleAbilityManagerService::EnableAbility(const std::string &name,
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> 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<std::s
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, &enabledAbilities]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
@ -1261,8 +1266,8 @@ RetError AccessibleAbilityManagerService::DisableAbility(const std::string &name
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> 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<IRemote
return RET_ERR_NULLPTR;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<RetError> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
handler_->PostTask([this, &syncPromise, obj]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
@ -1346,8 +1351,8 @@ RetError AccessibleAbilityManagerService::DisableUITestAbility()
return RET_ERR_NULLPTR;
}
std::shared_ptr<std::promise<RetError>> syncPromise = std::make_shared<std::promise<RetError>>();
std::future syncFuture = syncPromise->get_future();
std::shared_ptr<ffrt::promise<RetError>> syncPromise = std::make_shared<ffrt::promise<RetError>>();
ffrt::future syncFuture = syncPromise->get_future();
handler_->PostTask([this, syncPromise]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> 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<AccessibilityCommonEvent>::GetInstance().SubscriberEvent(handler_);
#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER
Singleton<AccessibilityDisplayManager>::GetInstance().RegisterDisplayListener(handler_);
#endif
Singleton<AccessibilityWindowManager>::GetInstance().RegisterWindowListener(handler_);
bool result = Singleton<AccessibilityWindowManager>::GetInstance().Init();
HILOG_DEBUG("wms init result is %{public}d", result);
@ -1582,7 +1589,6 @@ void AccessibleAbilityManagerService::SwitchedUser(int32_t accountId)
std::map<std::string, uint32_t> importantEnabledAbilities;
SCREENREADER_STATE screenReaderState = SCREENREADER_STATE::UNINIT;
// Clear last account's data
if (currentAccountId_ != -1) {
HILOG_DEBUG();
sptr<AccessibilityAccountData> 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<AccessibilityAccountData> 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<void> promiseFuture = callBack->promise_.get_future();
ffrt::future<void> 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<void> syncPromise;
std::future syncFuture = syncPromise.get_future();
ffrt::promise<void> syncPromise;
ffrt::future syncFuture = syncPromise.get_future();
actionHandler_->PostTask([this, &syncPromise, &configData]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> 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<std::promise<uint32_t>> syncPromisePtr = std::make_shared<std::promise<uint32_t>>();
std::future syncFuture = syncPromisePtr->get_future();
std::shared_ptr<ffrt::promise<uint32_t>> syncPromisePtr = std::make_shared<ffrt::promise<uint32_t>>();
ffrt::future syncFuture = syncPromisePtr->get_future();
actionHandler_->PostTask([this, syncPromisePtr, callback]() {
HILOG_DEBUG();
sptr<AccessibilityAccountData> 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<IRemoteObje
void AccessibleAbilityManagerService::StateObservers::AddStateObserver(
const sptr<IAccessibleAbilityManagerStateObserver>& stateObserver)
{
std::lock_guard<std::mutex> lock(stateObserversMutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(stateObserversMutex_);
std::lock_guard<ffrt::mutex> 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<IRemoteObject> &remote)
{
std::lock_guard<std::mutex> lock(stateObserversMutex_);
std::lock_guard<ffrt::mutex> lock(stateObserversMutex_);
auto iter = std::find_if(observersList_.begin(), observersList_.end(),
[remote](const sptr<IAccessibleAbilityManagerStateObserver>& stateObserver) {
return stateObserver->AsObject() == remote;
@ -2589,7 +2593,7 @@ void AccessibleAbilityManagerService::StateObservers::RemoveStateObserver(const
void AccessibleAbilityManagerService::StateObservers::Clear()
{
std::lock_guard<std::mutex> lock(stateObserversMutex_);
std::lock_guard<ffrt::mutex> lock(stateObserversMutex_);
observersList_.clear();
}
@ -2619,6 +2623,53 @@ void AccessibleAbilityManagerService::OnDeviceProvisioned()
}
}
void AccessibleAbilityManagerService::InitializeShortKeyState()
{
sptr<AccessibilityAccountData> 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<std::string> tmpVec { SCREEN_READER_BUNDLE_ABILITY_NAME };
accountData->GetConfig()->SetShortkeyMultiTarget(tmpVec);
UpdateConfigState();
Singleton<AccessibleAbilityManagerService>::GetInstance().UpdateShortKeyRegister();
}
}
void AccessibleAbilityManagerService::RegisterProvisionCallback()
{
sptr<AccessibilityAccountData> 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<AccessibleAbilityManagerService>::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<std::string> tmpVec { SCREEN_READER_BUNDLE_ABILITY_NAME };
accountData->GetConfig()->SetShortkeyMultiTarget(tmpVec);
UpdateConfigState();
Singleton<AccessibleAbilityManagerService>::GetInstance().UpdateShortKeyRegister();
AccessibilitySettingObserver::UpdateFunc func = [ = ](const std::string &state) {
Singleton<AccessibleAbilityManagerService>::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<AccessibilityDisplayManager>::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<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (accountData == nullptr) {
HILOG_ERROR("accountData is nullptr");
return;
}
std::shared_ptr<AccessibilitySettingsConfig> 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<AccessibleAbilityManagerService>::GetInstance().UpdateInputFilter();
if (!screenMagnificationEnabled) {
OffZoomGesture();
}
}
void AccessibleAbilityManagerService::RegisterScreenMagnificationState()
{
HILOG_DEBUG();
if (handler_ == nullptr) {
HILOG_ERROR("handler_ is nullptr");
return;
}
handler_->PostTask([=]() {
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (accountData == nullptr) {
HILOG_ERROR("accountData is nullptr");
return;
}
AccessibilitySettingObserver::UpdateFunc func = [ = ](const std::string &state) {
Singleton<AccessibleAbilityManagerService>::GetInstance().OnScreenMagnificationStateChanged();
};
if (accountData->GetConfig()->GetDbHandle()) {
accountData->GetConfig()->GetDbHandle()->RegisterObserver(SCREEN_MAGNIFICATION_KEY, func);
}
}, "REGISTER_SCREEN_ZOOM_OBSERVER");
}
void AccessibleAbilityManagerService::OnScreenMagnificationTypeChanged()
{
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (accountData == nullptr) {
HILOG_ERROR("accountData is nullptr");
return;
}
std::shared_ptr<AccessibilitySettingsConfig> 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<int64_t>(config->GetDbHandle()->GetIntValue(SCREEN_MAGNIFICATION_TYPE, 0));
config->SetScreenMagnificationType(screenMagnificationType);
Singleton<AccessibleAbilityManagerService>::GetInstance().UpdateInputFilter();
}
void AccessibleAbilityManagerService::RegisterScreenMagnificationType()
{
HILOG_DEBUG();
if (handler_ == nullptr) {
HILOG_ERROR("handler_ is nullptr");
return;
}
handler_->PostTask([=]() {
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (accountData == nullptr) {
HILOG_ERROR("accountData is nullptr");
return;
}
AccessibilitySettingObserver::UpdateFunc func = [ = ](const std::string &state) {
Singleton<AccessibleAbilityManagerService>::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<IAccessibilityElementOperatorCallback> callback)
{
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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<std::mutex> lock(mutex_);
std::lock_guard<ffrt::mutex> 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);

View File

@ -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",

View File

@ -16,8 +16,8 @@
#ifndef ACCESSIBILITY_UT_HELPER_H
#define ACCESSIBILITY_UT_HELPER_H
#include <mutex>
#include "accessibility_event_info.h"
#include "ffrt.h"
#include "hilog/log.h"
#include "iremote_object.h"
@ -33,13 +33,13 @@ public:
std::vector<int32_t> GetTouchEventActionVector()
{
std::lock_guard<std::mutex> lock(mtx_);
std::lock_guard<ffrt::mutex> lock(mtx_);
return touchAction_;
}
int32_t GetTouchEventActionOfTargetIndex(int32_t index)
{
std::lock_guard<std::mutex> lock(mtx_);
std::lock_guard<ffrt::mutex> lock(mtx_);
int32_t size = static_cast<int32_t>(touchAction_.size());
if (size > index) {
return touchAction_[index];
@ -49,13 +49,13 @@ public:
void ClearTouchEventActionVector()
{
std::lock_guard<std::mutex> lock(mtx_);
std::lock_guard<ffrt::mutex> lock(mtx_);
touchAction_.clear();
}
void SetTouchEventActionVectors(int32_t touchAction)
{
std::lock_guard<std::mutex> lock(mtx_);
std::lock_guard<ffrt::mutex> lock(mtx_);
touchAction_.push_back(touchAction);
}
@ -156,13 +156,13 @@ public:
std::vector<EventType> GetEventTypeVector()
{
std::lock_guard<std::mutex> lock(mtx_);
std::lock_guard<ffrt::mutex> lock(mtx_);
return eventType_;
}
EventType GetEventTypeOfTargetIndex(int32_t index)
{
std::lock_guard<std::mutex> lock(mtx_);
std::lock_guard<ffrt::mutex> lock(mtx_);
int32_t size = static_cast<int32_t>(eventType_.size());
if (size > index) {
return eventType_[index];
@ -172,13 +172,13 @@ public:
void ClearEventTypeActionVector()
{
std::lock_guard<std::mutex> lock(mtx_);
std::lock_guard<ffrt::mutex> lock(mtx_);
eventType_.clear();
}
void SetEventTypeVector(EventType eventType)
{
std::lock_guard<std::mutex> lock(mtx_);
std::lock_guard<ffrt::mutex> 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<int32_t> userIds_;
std::vector<std::string> packages_;
int32_t currentUserId_ = -1;

View File

@ -23,7 +23,7 @@
#include "system_ability_definition.h"
namespace OHOS {
std::mutex SystemAbilityManager::instanceLock;
ffrt::mutex SystemAbilityManager::instanceLock;
sptr<SystemAbilityManager> SystemAbilityManager::instance;
SystemAbilityManager::SystemAbilityManager()
@ -43,7 +43,7 @@ const sptr<DBinderService> SystemAbilityManager::GetDBinder() const
sptr<SystemAbilityManager> SystemAbilityManager::GetInstance()
{
HILOG_ERROR("SystemAbilityManager::GetInstance");
std::lock_guard<std::mutex> autoLock(instanceLock);
std::lock_guard<ffrt::mutex> autoLock(instanceLock);
if (!instance) {
instance = new SystemAbilityManager;
}

View File

@ -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<sptr<IAccessibleAbilityManagerConfigObserver>> &AccessibilityAccountData::GetConfigCallbacks()
const std::vector<sptr<IAccessibleAbilityManagerConfigObserver>> AccessibilityAccountData::GetConfigCallbacks()
{
HILOG_DEBUG("GetConfigCallbacks start");
return configCallbacks_;

View File

@ -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<Rosen::Display> AccessibilityDisplayManager::GetDisplay(uint64_t id)
{
HILOG_DEBUG();
return Rosen::DisplayManager::GetInstance().GetDisplayById(id);
}
std::vector<sptr<Rosen::Display>> AccessibilityDisplayManager::GetDisplays()
{
HILOG_DEBUG();
return Rosen::DisplayManager::GetInstance().GetAllDisplays();
}
const sptr<Rosen::Display> 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<Rosen::Display> displaySync = GetDefaultDisplaySync();
if (displaySync == nullptr) {
HILOG_ERROR("default displaySync is null");
return DEFAULT_WIDTH;
}
return displaySync->GetWidth();
}
int32_t AccessibilityDisplayManager::GetHeight()
{
HILOG_DEBUG();
sptr<Rosen::Display> 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<Rosen::Display> 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<Rosen::Display> 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<AppExecFwk::EventHandler> &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

View File

@ -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

View File

@ -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.");

View File

@ -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

View File

@ -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<IAccessibilityElementOperatorCallback> &callback)
{
GTEST_LOG_(INFO) << "MOCK AccessibleAbilitychannel GetCursorPosition";
(void)accessibilityWindowId;
(void)elementId;
(void)requestId;
(void)callback;
return RET_OK;
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -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<AAMSEventHandler>(runner_);
Singleton<AccessibilityWindowManager>::GetInstance().RegisterWindowListener(handler_);
Singleton<AccessibilityCommonEvent>::GetInstance().SubscriberEvent(handler_);
@ -261,6 +261,11 @@ void AccessibleAbilityManagerService::UpdateAllSetting()
return;
}
void AccessibleAbilityManagerService::UpdateInputFilter()
{
return;
}
void AccessibleAbilityManagerService::UpdateShortKeyRegister()
{
return;

View File

@ -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

View File

@ -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<AccessibilityAccountData> accountData = new AccessibilityAccountData(accountId);
accountData->Init();
accountData->SetAbilityAutoStartState(abilityName, false);
EXPECT_EQ(accountData->GetAbilityAutoStartState(abilityName), false);
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_GetAbilityAutoStartState_001 end";

View File

@ -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<AccessibilityShortKey> test = new (std::nothrow) AccessibilityShortKey();
test = nullptr;
SetUpTestCase();
GTEST_LOG_(INFO) << "Accessibility_Short_Key_UnitTest_AccessibilityShortKey001 end";
}

View File

@ -95,9 +95,9 @@ void TouchGuiderTest::PointerEventTest(std::vector<MMI::PointerEvent::PointerIte
void TouchGuiderTest::TouchGuiderExpect(EventType eventType, int32_t GestureTypeInt)
{
eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(GET_EVENT_TARGET_INDEX_2);
EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(GET_EVENT_TARGET_INDEX_3);
EXPECT_EQ(eventType, EventType::TYPE_TOUCH_END);
eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(GET_EVENT_TARGET_INDEX_3);
EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
auto uTgestureId = AccessibilityAbilityHelper::GetInstance().GetGestureId();
EXPECT_EQ(uTgestureId, GestureTypeInt);
}
@ -255,7 +255,7 @@ HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_002, TestSize.Leve
touchGuider_->OnPointerEvent(*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<int>(GestureType::GESTURE_SWIPE_LEFT));

Some files were not shown because too many files have changed in this diff Show More