mirror of
https://github.com/openharmony/accessibility.git
synced 2026-08-24 22:11:28 -04:00
CO-authored-by: OpenCode+GLM5
Signed-off-by: Sean_Su <suleheng@huawei.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "accessibility_element_info_parcel.h"
|
||||
#include "accessibility_virtual_node_parcel.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "accessibility_constants.h"
|
||||
#include <cinttypes>
|
||||
|
||||
#define SWITCH_BEGIN(code) switch (code) {
|
||||
@@ -447,6 +448,10 @@ ErrCode AccessibilityElementOperatorStub::HandleAddAccessibilityVirtualNode(Mess
|
||||
HILOG_DEBUG();
|
||||
int64_t rootId = data.ReadInt64();
|
||||
int32_t nodeCount = data.ReadInt32();
|
||||
if (nodeCount < 0 || nodeCount > MAX_ALLOW_SIZE) {
|
||||
HILOG_ERROR("nodeCount is invalid: %{public}d", nodeCount);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::vector<AccessibilityVirtualNode> nodes;
|
||||
for (int32_t i = 0; i < nodeCount; i++) {
|
||||
sptr<AccessibilityVirtualNodeParcel> nodeParcel = data.ReadStrongParcelable<AccessibilityVirtualNodeParcel>();
|
||||
|
||||
@@ -47,6 +47,7 @@ ApiEventReporter::~ApiEventReporter()
|
||||
// LCOV_EXCL_START
|
||||
bool ApiEventReporter::IsAppEventProcessorValid()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(g_apiOperationMutex);
|
||||
if (g_processorId <= NULLPTR_PROCCESSORID) {
|
||||
g_processorId = AddProcessor();
|
||||
}
|
||||
@@ -228,7 +229,6 @@ void ApiEventReporter::ParseApiOperationManagement(std::istringstream &stream, A
|
||||
int64_t ApiEventReporter::AddProcessor()
|
||||
{
|
||||
HILOG_INFO("AddProcessor enter.");
|
||||
std::lock_guard<std::mutex> lock(g_apiOperationMutex);
|
||||
ApiReportConfig reportConfig;
|
||||
ApiEventConfig eventConfig;
|
||||
if (g_fileContent.empty()) {
|
||||
|
||||
@@ -28,6 +28,7 @@ ReadableRulesNode::~ReadableRulesNode() = default;
|
||||
|
||||
bool ReadableRulesChecker::CheckInit(const std::string& readableRules)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
isChecked_ = true;
|
||||
if (!IsInited()) {
|
||||
Init(readableRules);
|
||||
@@ -45,7 +46,7 @@ void ReadableRulesChecker::Init(const std::string& rules)
|
||||
isInited_ = false;
|
||||
|
||||
nlohmann::json jsonRoot = nlohmann::json::parse(rules, nullptr, false);
|
||||
if (jsonRoot.is_null() || jsonRoot.is_discarded()) {
|
||||
if (jsonRoot.is_null() || jsonRoot.is_discarded() || !jsonRoot.is_object()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
|
||||
#include "rules_defines.h"
|
||||
#include "custom_props.h"
|
||||
@@ -69,6 +70,7 @@ private:
|
||||
bool ParseRules(const nlohmann::json& jsonRoot);
|
||||
|
||||
void Init(const std::string& rules);
|
||||
std::mutex mutex_;
|
||||
RulesDefines rulesDefines_;
|
||||
CustomProps customProps_;
|
||||
std::vector<ReadableRule> rules_;
|
||||
|
||||
@@ -666,6 +666,7 @@ void ANIAccessibilityConfig::SetSyncboolean(ani_env *env, ani_object object, ani
|
||||
}
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("SetSyncboolean configId = %{public}d, ret = %{public}d", configId, static_cast<int32_t>(ret));
|
||||
return;
|
||||
@@ -707,6 +708,7 @@ ani_boolean ANIAccessibilityConfig::GetSyncboolean(ani_env *env, ani_object obje
|
||||
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return ANI_FALSE;
|
||||
}
|
||||
HILOG_INFO("GetSyncboolean configId = %{public}d, ret = %{public}d", configId, static_cast<int32_t>(ret));
|
||||
return static_cast<ani_boolean>(state);
|
||||
@@ -730,6 +732,7 @@ void ANIAccessibilityConfig::SetSyncDouble(ani_env *env, ani_object object, ani_
|
||||
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("SetSyncDouble configId = %{public}d, ret = %{public}d", configId, static_cast<int32_t>(ret));
|
||||
return;
|
||||
@@ -755,6 +758,7 @@ ani_double ANIAccessibilityConfig::GetSyncDouble(ani_env *env, ani_object object
|
||||
HILOG_INFO("getSyncNumber configId = %{public}d, ret = %{public}d", configId, static_cast<int32_t>(ret));
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return static_cast<ani_double>(floatData);
|
||||
@@ -777,6 +781,7 @@ void ANIAccessibilityConfig::SetSyncInt(ani_env *env, ani_object object, ani_enu
|
||||
}
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("SetSyncInt configId = %{public}d, ret = %{public}d", configId, static_cast<int32_t>(ret));
|
||||
return;
|
||||
@@ -805,6 +810,7 @@ ani_int ANIAccessibilityConfig::GetSyncInt(ani_env *env, ani_object object, ani_
|
||||
HILOG_INFO("getSyncNumber configId = %{public}d, ret = %{public}d", configId, static_cast<int32_t>(ret));
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return static_cast<ani_int>(int32Data);
|
||||
@@ -818,6 +824,7 @@ void ANIAccessibilityConfig::SetSyncString(ani_env *env, ani_object object, ani_
|
||||
auto ret = instance.SetShortkeyTarget(nameStr);
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("Set shortkey target ret = %{public}d", static_cast<int32_t>(ret));
|
||||
return;
|
||||
@@ -833,6 +840,7 @@ ani_string ANIAccessibilityConfig::GetSyncString(ani_env *env, ani_object object
|
||||
if (ret != RET_OK) {
|
||||
HILOG_ERROR("GetSyncString failed! ret = %{public}d", static_cast<int32_t>(ret));
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return nullptr;
|
||||
}
|
||||
env->String_NewUTF8(result.c_str(), result.size(), &retResult);
|
||||
return retResult;
|
||||
@@ -850,6 +858,7 @@ void ANIAccessibilityConfig::SetSyncVectorString(ani_env *env, ani_object object
|
||||
auto ret = instance.SetShortkeyMultiTarget(valueList);
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("Set shortkey multi-target ret = %{public}d", static_cast<int32_t>(ret));
|
||||
return;
|
||||
@@ -865,6 +874,7 @@ ani_object ANIAccessibilityConfig::GetSyncVectorString(ani_env *env, ani_object
|
||||
if (ret != RET_OK) {
|
||||
HILOG_ERROR("GetSyncVecotorString failed! ret = %{public}d", static_cast<int32_t>(ret));
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ANIUtils::CreateArray(env, multiList);
|
||||
@@ -880,6 +890,7 @@ void ANIAccessibilityConfig::SetSyncDaltonizationColorFilter(ani_env *env, ani_o
|
||||
auto ret = instance.SetDaltonizationColorFilter(filter);
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("SetSyncDaltonizationColorFilter ret = %{public}d", static_cast<int32_t>(ret));
|
||||
return;
|
||||
@@ -895,6 +906,7 @@ ani_string ANIAccessibilityConfig::GetSyncDaltonizationColorFilter(ani_env *env,
|
||||
if (ret != RET_OK) {
|
||||
HILOG_ERROR("GetSyncDaltonizationColorFilter failed! ret = %{public}d", static_cast<int32_t>(ret));
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return nullptr;
|
||||
}
|
||||
std::string result = ConvertDaltonizationTypeToString(type);
|
||||
env->String_NewUTF8(result.c_str(), result.size(), &retResult);
|
||||
@@ -911,6 +923,7 @@ void ANIAccessibilityConfig::SetSyncClickResponseTime(ani_env *env, ani_object o
|
||||
auto ret = instance.SetClickResponseTime(time);
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("SetSyncClickResponseTime ret = %{public}d", static_cast<int32_t>(ret));
|
||||
return;
|
||||
@@ -927,6 +940,7 @@ ani_string ANIAccessibilityConfig::GetSyncClickResponseTime(ani_env *env, ani_ob
|
||||
if (ret != RET_OK) {
|
||||
HILOG_ERROR("GetSyncClickResponseTimer failed! ret = %{public}d", static_cast<int32_t>(ret));
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return nullptr;
|
||||
}
|
||||
std::string result = ConvertClickResponseTimeTypeToString(time);
|
||||
env->String_NewUTF8(result.c_str(), result.size(), &retResult);
|
||||
@@ -943,6 +957,7 @@ void ANIAccessibilityConfig::SetSyncRepeatClickInterval(ani_env *env, ani_object
|
||||
auto ret = instance.SetIgnoreRepeatClickTime(time);
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("SetSyncRepeatClickInterval ret = %{public}d", static_cast<int32_t>(ret));
|
||||
return;
|
||||
@@ -959,6 +974,7 @@ ani_string ANIAccessibilityConfig::GetSyncRepeatClickInterval(ani_env *env, ani_
|
||||
if (ret != RET_OK) {
|
||||
HILOG_ERROR("GetSyncRepeatClickInterval failed! ret = %{public}d", static_cast<int32_t>(ret));
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return nullptr;
|
||||
}
|
||||
std::string result = ConvertIgnoreRepeatClickTimeTypeToString(time);
|
||||
env->String_NewUTF8(result.c_str(), result.size(), &retResult);
|
||||
@@ -1014,6 +1030,7 @@ void ANIAccessibilityConfig::SetSyncCaptionsStyle(ani_env *env, ani_object objec
|
||||
}
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("SetSyncCaptionsStyle ret = %{public}d", static_cast<int32_t>(ret));
|
||||
return;
|
||||
@@ -1090,6 +1107,7 @@ ani_object ANIAccessibilityConfig::GetSyncCaptionsStyle(ani_env *env, ani_object
|
||||
if (ret != RET_OK) {
|
||||
HILOG_ERROR("GetSyncCaptionsStyle failed! ret = %{public}d", static_cast<int32_t>(ret));
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return CreateJsAccessibilityCaptionProperty(env, captionProperty);
|
||||
@@ -1126,6 +1144,7 @@ void ANIAccessibilityConfig::EnableAbilitySync(ani_env *env, ani_string name, an
|
||||
auto ret = instance.EnableAbility(nameStr, ParseCapabilitiesFromVec(strings), false);
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("EnableAbilitySync ret = %{public}d", static_cast<int32_t>(ret));
|
||||
return;
|
||||
@@ -1184,6 +1203,7 @@ void ANIAccessibilityConfig::DisableAbilitySync(ani_env *env, ani_string name)
|
||||
auto ret = instance.DisableAbility(nameStr);
|
||||
if (ret != RET_OK) {
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("DisableAbilitySync ret = %{public}d", static_cast<int32_t>(ret));
|
||||
return;
|
||||
@@ -1292,6 +1312,7 @@ void ANIAccessibilityConfig::SetMagnificationState(ani_env *env, ani_boolean sta
|
||||
if (ret != RET_OK) {
|
||||
HILOG_ERROR("SetMagnificationState failed, ret = %{public}d", static_cast<int32_t>(ret));
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1483,9 +1504,24 @@ void ANIAccessibilityConfig::OffSeniorModeStateChangeForApps(ani_env *env)
|
||||
ani_boolean ANIAccessibilityConfig::GetSeniorModeStateForApp(ani_env *env, ani_string bundleName, ani_int appIndex)
|
||||
{
|
||||
HILOG_INFO("getSeniorModeStateForApp");
|
||||
if (bundleName == nullptr) {
|
||||
HILOG_ERROR("bundleName is nullptr");
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(RetError::RET_ERR_INVALID_PARAM));
|
||||
return static_cast<ani_boolean>(false);
|
||||
}
|
||||
bool state = false;
|
||||
std::string bundleNameStr = ANIUtils::ANIStringToStdString(env, bundleName);
|
||||
if (bundleNameStr.empty()) {
|
||||
HILOG_ERROR("bundleName is empty");
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(RetError::RET_ERR_INVALID_PARAM));
|
||||
return static_cast<ani_boolean>(false);
|
||||
}
|
||||
int32_t appIndexInt = static_cast<int32_t>(appIndex);
|
||||
if (appIndexInt < 0) {
|
||||
HILOG_ERROR("appIndex is invalid: %{public}d", appIndexInt);
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(RetError::RET_ERR_INVALID_PARAM));
|
||||
return static_cast<ani_boolean>(false);
|
||||
}
|
||||
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
|
||||
OHOS::Accessibility::RetError ret = instance.GetSeniorModeStateForApp(bundleNameStr, appIndexInt, state);
|
||||
if (ret != OHOS::Accessibility::RET_OK) {
|
||||
@@ -1549,6 +1585,7 @@ void ANIAccessibilityConfig::SetSeniorModeStateForApp(ani_env *env, ani_array se
|
||||
if (ret != OHOS::Accessibility::RET_OK) {
|
||||
HILOG_ERROR("SetSeniorModeStateForApp failed: %{public}d", ret);
|
||||
ANIUtils::ThrowBusinessError(env, ANIUtils::QueryRetMsg(ret));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
static bool SetLongPropertyRef(ani_env *env, ani_object &object, const std::string &propName, int64_t propValue);
|
||||
static ani_object CreateObject(ani_env *env, ani_class cls, ...);
|
||||
static bool ConvertStringToInt64(std::string &str, int64_t &value);
|
||||
static void CheckNumber(ani_env *env, std::string value);
|
||||
static bool CheckNumber(ani_env *env, std::string value);
|
||||
static void SetScrollTypeParam(ani_env *env, ani_object obj, std::map<std::string, std::string>& args);
|
||||
static void SetSelectionParam(ani_env *env, ani_object obj, std::map<std::string, std::string>& args);
|
||||
static void SetAccessibilityFocusSceneParam(ani_env *env, ani_object obj, std::map<std::string, std::string>& args);
|
||||
|
||||
@@ -32,10 +32,24 @@ const std::string FULL_VALUE = "1";
|
||||
|
||||
std::string ANIUtils::ANIStringToStdString(ani_env *env, ani_string ani_str)
|
||||
{
|
||||
if (ani_str == nullptr) {
|
||||
HILOG_ERROR("ani_str is nullptr");
|
||||
return "";
|
||||
}
|
||||
ani_size strSize = 0;
|
||||
if (env->String_GetUTF8Size(ani_str, &strSize) != ANI_OK) {
|
||||
HILOG_ERROR("String_GetUTF8Size failed");
|
||||
return "";
|
||||
}
|
||||
|
||||
ani_size strSize;
|
||||
env->String_GetUTF8Size(ani_str, &strSize);
|
||||
|
||||
std::vector<char> buffer(strSize + 1); // +1 for null terminator
|
||||
if (env->String_GetUTF8(ani_str, utf8_buffer, strSize + 1, &bytes_written) != ANI_OK) {
|
||||
HILOG_ERROR("String_GetUTF8 failed");
|
||||
return "";
|
||||
}
|
||||
char* utf8_buffer = buffer.data();
|
||||
|
||||
ani_size bytes_written = 0;
|
||||
@@ -1282,7 +1296,7 @@ bool ANIUtils::ConvertStringToInt64(std::string &str, int64_t &value)
|
||||
return errCode == std::errc{} && ptr == str.data() + str.size();
|
||||
}
|
||||
|
||||
void ANIUtils::CheckNumber(ani_env *env, std::string value)
|
||||
bool ANIUtils::CheckNumber(ani_env *env, std::string value)
|
||||
{
|
||||
int num;
|
||||
std::stringstream streamStr;
|
||||
@@ -1290,7 +1304,9 @@ void ANIUtils::CheckNumber(ani_env *env, std::string value)
|
||||
if (!(streamStr >> num)) {
|
||||
HILOG_ERROR("check number failed!");
|
||||
ThrowBusinessError(env, QueryRetMsg(RetError::RET_ERR_INVALID_PARAM));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ANIUtils::SetScrollTypeParam(ani_env *env, ani_object obj, std::map<std::string, std::string>& args)
|
||||
@@ -1320,12 +1336,16 @@ void ANIUtils::SetSelectionParam(ani_env *env, ani_object obj, std::map<std::str
|
||||
std::string str = "";
|
||||
if (env->Object_GetFieldByName_Ref(obj, "selectTextBegin", &fiedNameValue) == ANI_OK) {
|
||||
str = ANIStringToStdString(env, static_cast<ani_string>(fiedNameValue));
|
||||
CheckNumber(env, str);
|
||||
if (!CheckNumber(env, str)) {
|
||||
return;
|
||||
}
|
||||
args.insert(std::pair<std::string, std::string>("selectTextBegin", str.c_str()));
|
||||
}
|
||||
if (env->Object_GetFieldByName_Ref(obj, "selectTextEnd", &fiedNameValue) == ANI_OK) {
|
||||
str = ANIStringToStdString(env, static_cast<ani_string>(fiedNameValue));
|
||||
CheckNumber(env, str);
|
||||
if (!CheckNumber(env, str)) {
|
||||
return;
|
||||
}
|
||||
args.insert(std::pair<std::string, std::string>("selectTextEnd", str.c_str()));
|
||||
}
|
||||
if (env->Object_GetFieldByName_Boolean(obj, "selectTextInForWard", &forWard) == ANI_OK) {
|
||||
@@ -1383,7 +1403,9 @@ void ANIUtils::ConvertActionArgsJSToANI(ani_env *env, ani_object obj,
|
||||
case ActionType::ACCESSIBILITY_ACTION_SET_CURSOR_POSITION:
|
||||
if (env->Object_GetFieldByName_Ref(obj, "offset", &fiedNameValue) == ANI_OK) {
|
||||
str = ANIStringToStdString(env, static_cast<ani_string>(fiedNameValue));
|
||||
CheckNumber(env, str);
|
||||
if (!CheckNumber(env, str)) {
|
||||
return;
|
||||
}
|
||||
args.insert(std::pair<std::string, std::string>("offset", str.c_str()));
|
||||
}
|
||||
break;
|
||||
@@ -1396,7 +1418,9 @@ void ANIUtils::ConvertActionArgsJSToANI(ani_env *env, ani_object obj,
|
||||
case ActionType::ACCESSIBILITY_ACTION_SPAN_CLICK:
|
||||
if (env->Object_GetFieldByName_Ref(obj, "spanId", &fiedNameValue) == ANI_OK) {
|
||||
str = ANIStringToStdString(env, static_cast<ani_string>(fiedNameValue));
|
||||
CheckNumber(env, str);
|
||||
if (!CheckNumber(env, str)) {
|
||||
return;
|
||||
}
|
||||
args.insert(std::pair<std::string, std::string>("spanId", str.c_str()));
|
||||
}
|
||||
break;
|
||||
|
||||
+98
-10
@@ -346,8 +346,9 @@ void NAccessibilityElement::ConvertElementInfoToJS(napi_env env, napi_value resu
|
||||
pAccessibilityElement,
|
||||
[](napi_env env, void* data, void* hint) {
|
||||
AccessibilityElement* info = static_cast<AccessibilityElement*>(data);
|
||||
delete info;
|
||||
info = nullptr;
|
||||
if (info != nullptr) {
|
||||
delete info;
|
||||
}
|
||||
},
|
||||
nullptr,
|
||||
nullptr);
|
||||
@@ -355,6 +356,7 @@ void NAccessibilityElement::ConvertElementInfoToJS(napi_env env, napi_value resu
|
||||
delete pAccessibilityElement;
|
||||
pAccessibilityElement = nullptr;
|
||||
HILOG_ERROR("failed to wrap JS object");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("napi_wrap status: %{public}d", (int)sts);
|
||||
}
|
||||
@@ -463,6 +465,14 @@ napi_value NAccessibilityElement::AttributeNames(napi_env env, napi_callback_inf
|
||||
reinterpret_cast<void*>(callbackInfo),
|
||||
&callbackInfo->work_);
|
||||
if (ret != napi_ok) {
|
||||
if (callbackInfo->callback_ != nullptr) {
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
callbackInfo->callback_ = nullptr;
|
||||
}
|
||||
if (callbackInfo->deferred_ != nullptr) {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, nullptr);
|
||||
callbackInfo->deferred_ = nullptr;
|
||||
}
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
return nullptr;
|
||||
@@ -548,8 +558,6 @@ napi_value NAccessibilityElement::AttributeValue(napi_env env, napi_callback_inf
|
||||
if (errCode == NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM) {
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete accessibilityElement;
|
||||
accessibilityElement = nullptr;
|
||||
napi_value err = CreateBusinessError(env, RetError::RET_ERR_INVALID_PARAM);
|
||||
HILOG_ERROR("invalid param");
|
||||
napi_throw(env, err);
|
||||
@@ -603,6 +611,14 @@ napi_value NAccessibilityElement::AttributeValueAsync(
|
||||
auto ret = napi_create_async_work(env, nullptr, resource, NAccessibilityElement::AttributeValueExecute,
|
||||
NAccessibilityElement::AttributeValueComplete, reinterpret_cast<void*>(callbackInfo), &callbackInfo->work_);
|
||||
if (ret != napi_ok) {
|
||||
if (callbackInfo->callback_ != nullptr) {
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
callbackInfo->callback_ = nullptr;
|
||||
}
|
||||
if (callbackInfo->deferred_ != nullptr) {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, nullptr);
|
||||
callbackInfo->deferred_ = nullptr;
|
||||
}
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
return nullptr;
|
||||
@@ -2115,6 +2131,14 @@ napi_value NAccessibilityElement::ActionNames(napi_env env, napi_callback_info i
|
||||
reinterpret_cast<void*>(callbackInfo),
|
||||
&callbackInfo->work_);
|
||||
if (ret != napi_ok) {
|
||||
if (callbackInfo->callback_ != nullptr) {
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
callbackInfo->callback_ = nullptr;
|
||||
}
|
||||
if (callbackInfo->deferred_ != nullptr) {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, nullptr);
|
||||
callbackInfo->deferred_ = nullptr;
|
||||
}
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
return nullptr;
|
||||
@@ -2231,8 +2255,6 @@ napi_value NAccessibilityElement::PerformAction(napi_env env, napi_callback_info
|
||||
if (argc < ARGS_SIZE_ONE || !ParseString(env, actionName, argv[PARAM0])) {
|
||||
HILOG_ERROR("argc is invalid: %{public}zu", argc);
|
||||
errCode = NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM;
|
||||
delete accessibilityElement;
|
||||
accessibilityElement = nullptr;
|
||||
napi_value err = CreateBusinessError(env, RetError::RET_ERR_INVALID_PARAM);
|
||||
HILOG_ERROR("invalid param");
|
||||
napi_throw(env, err);
|
||||
@@ -2267,8 +2289,6 @@ napi_value NAccessibilityElement::ExecuteAction(napi_env env, napi_callback_info
|
||||
action < 0 || static_cast<uint32_t>(action) >= ACTION_NAMES.size()) {
|
||||
HILOG_ERROR("parameter is invalid: argc=%{public}zu, action=%{public}d", argc, action);
|
||||
errCode = NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM;
|
||||
delete accessibilityElement;
|
||||
accessibilityElement = nullptr;
|
||||
napi_value err = CreateBusinessError(env, RetError::RET_ERR_INVALID_PARAM);
|
||||
HILOG_ERROR("invalid param");
|
||||
napi_throw(env, err);
|
||||
@@ -2364,6 +2384,14 @@ napi_value NAccessibilityElement::PerformActionConstructPromise(napi_env env, si
|
||||
auto ret = napi_create_async_work(env, nullptr, resource, PerformActionExecute, PerformActionComplete,
|
||||
reinterpret_cast<void*>(callbackInfo), &callbackInfo->work_);
|
||||
if (ret != napi_ok) {
|
||||
if (callbackInfo->callback_ != nullptr) {
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
callbackInfo->callback_ = nullptr;
|
||||
}
|
||||
if (callbackInfo->deferred_ != nullptr) {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, nullptr);
|
||||
callbackInfo->deferred_ = nullptr;
|
||||
}
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
return nullptr;
|
||||
@@ -2524,6 +2552,14 @@ napi_value NAccessibilityElement::FindElementsByCondition(napi_env env, napi_cal
|
||||
auto ret = napi_create_async_work(callbackInfo->env_, nullptr, resource, FindElementsByConditionExecute,
|
||||
FindElementsByConditionComplete, reinterpret_cast<void*>(callbackInfo), &callbackInfo->work_);
|
||||
if (ret != napi_ok) {
|
||||
if (callbackInfo->callback_ != nullptr) {
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
callbackInfo->callback_ = nullptr;
|
||||
}
|
||||
if (callbackInfo->deferred_ != nullptr) {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, nullptr);
|
||||
callbackInfo->deferred_ = nullptr;
|
||||
}
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
return nullptr;
|
||||
@@ -2746,6 +2782,14 @@ napi_value NAccessibilityElement::FindElementByFocusDirection(napi_env env, napi
|
||||
auto ret = napi_create_async_work(callbackInfo->env_, nullptr, resource, FindElementExecute,
|
||||
FindElementComplete, reinterpret_cast<void*>(callbackInfo), &callbackInfo->work_);
|
||||
if (ret != napi_ok) {
|
||||
if (callbackInfo->callback_ != nullptr) {
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
callbackInfo->callback_ = nullptr;
|
||||
}
|
||||
if (callbackInfo->deferred_ != nullptr) {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, nullptr);
|
||||
callbackInfo->deferred_ = nullptr;
|
||||
}
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
return nullptr;
|
||||
@@ -2854,8 +2898,22 @@ RetError NAccessibilityElement::RunFindElementAsync(NAPICbInfo& cbInfo, NAccessi
|
||||
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(elementData->env_, "FindElement", NAPI_AUTO_LENGTH, &resource);
|
||||
napi_create_async_work(elementData->env_, nullptr, resource, FindElementExecute,
|
||||
napi_status napiRet = napi_create_async_work(elementData->env_, nullptr, resource, FindElementExecute,
|
||||
FindElementComplete, reinterpret_cast<void*>(elementData), &elementData->work_);
|
||||
if (napiRet != napi_ok) {
|
||||
HILOG_ERROR("napi_create_async_work failed for FindElement");
|
||||
if (elementData->callback_ != nullptr) {
|
||||
napi_delete_reference(elementData->env_, elementData->callback_);
|
||||
elementData->callback_ = nullptr;
|
||||
}
|
||||
if (elementData->deferred_ != nullptr) {
|
||||
napi_reject_deferred(elementData->env_, elementData->deferred_, nullptr);
|
||||
elementData->deferred_ = nullptr;
|
||||
}
|
||||
delete elementData;
|
||||
elementData = nullptr;
|
||||
return RetError::RET_ERR_FAILED;
|
||||
}
|
||||
napi_queue_async_work_with_qos(elementData->env_, elementData->work_, napi_qos_user_initiated);
|
||||
|
||||
return RetError::RET_OK;
|
||||
@@ -2866,8 +2924,22 @@ RetError NAccessibilityElement::RunAttributeValueAsync(NAPICbInfo& cbInfo, NAcce
|
||||
{
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(elementData->env_, "AttributeValue", NAPI_AUTO_LENGTH, &resource);
|
||||
napi_create_async_work(elementData->env_, nullptr, resource, AttributeValueExecute,
|
||||
napi_status napiRet = napi_create_async_work(elementData->env_, nullptr, resource, AttributeValueExecute,
|
||||
AttributeValueComplete, reinterpret_cast<void*>(elementData), &elementData->work_);
|
||||
if (napiRet != napi_ok) {
|
||||
HILOG_ERROR("napi_create_async_work failed for AttributeValue");
|
||||
if (elementData->callback_ != nullptr) {
|
||||
napi_delete_reference(elementData->env_, elementData->callback_);
|
||||
elementData->callback_ = nullptr;
|
||||
}
|
||||
if (elementData->deferred_ != nullptr) {
|
||||
napi_reject_deferred(elementData->env_, elementData->deferred_, nullptr);
|
||||
elementData->deferred_ = nullptr;
|
||||
}
|
||||
delete elementData;
|
||||
elementData = nullptr;
|
||||
return RetError::RET_ERR_FAILED;
|
||||
}
|
||||
napi_queue_async_work_with_qos(elementData->env_, elementData->work_, napi_qos_user_initiated);
|
||||
|
||||
return RetError::RET_OK;
|
||||
@@ -2962,6 +3034,14 @@ napi_value NAccessibilityElement::GetCursorPositionAsync(napi_env env, size_t ar
|
||||
auto ret = napi_create_async_work(callbackInfo->env_, nullptr, resource, GetCursorPositionExecute,
|
||||
GetCursorPositionComplete, reinterpret_cast<void*>(callbackInfo), &callbackInfo->work_);
|
||||
if (ret != napi_ok) {
|
||||
if (callbackInfo->callback_ != nullptr) {
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
callbackInfo->callback_ = nullptr;
|
||||
}
|
||||
if (callbackInfo->deferred_ != nullptr) {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, nullptr);
|
||||
callbackInfo->deferred_ = nullptr;
|
||||
}
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
return nullptr;
|
||||
@@ -2994,6 +3074,14 @@ napi_value NAccessibilityElement::FindElementAsync(napi_env env, size_t argc, na
|
||||
auto ret = napi_create_async_work(callbackInfo->env_, nullptr, resource, FindElementExecute,
|
||||
FindElementComplete, reinterpret_cast<void*>(callbackInfo), &callbackInfo->work_);
|
||||
if (ret != napi_ok) {
|
||||
if (callbackInfo->callback_ != nullptr) {
|
||||
napi_delete_reference(env, callbackInfo->callback_);
|
||||
callbackInfo->callback_ = nullptr;
|
||||
}
|
||||
if (callbackInfo->deferred_ != nullptr) {
|
||||
napi_reject_deferred(env, callbackInfo->deferred_, nullptr);
|
||||
callbackInfo->deferred_ = nullptr;
|
||||
}
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
return nullptr;
|
||||
|
||||
@@ -2020,8 +2020,12 @@ void StateListenerImpl::SubscribeObserver(napi_env env, napi_value observer, boo
|
||||
}
|
||||
}
|
||||
|
||||
napi_ref ref;
|
||||
napi_create_reference(env, observer, 1, &ref);
|
||||
napi_ref ref = nullptr;
|
||||
napi_status refStatus = napi_create_reference(env, observer, 1, &ref);
|
||||
if (refStatus != napi_ok || ref == nullptr) {
|
||||
HILOG_ERROR("napi_create_reference failed in SubscribeObserver");
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<StateListener> stateListener = std::make_shared<StateListener>(env, ref, isBoolObserver);
|
||||
|
||||
observers_.emplace_back(stateListener);
|
||||
@@ -2077,6 +2081,12 @@ napi_value NAccessibilityClient::SubscribeSelfSeniorMode(napi_env env, napi_call
|
||||
napi_throw(env, err);
|
||||
return nullptr;
|
||||
}
|
||||
if (!CheckJsFunction(env, args[PARAM0])) {
|
||||
HILOG_ERROR("SubscribeSelfSeniorMode argument is not a function");
|
||||
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_INVALID_PARAM);
|
||||
napi_throw(env, err);
|
||||
return nullptr;
|
||||
}
|
||||
seniorModeStateForAppListeners_->SubscribeObserver(env, args[PARAM0]);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ namespace {
|
||||
const uint32_t COLOR_TRANSPARENT = 0x00000000;
|
||||
const std::string HALF_VALUE = "0";
|
||||
const std::string FULL_VALUE = "1";
|
||||
napi_status status = napi_ok;
|
||||
} // namespace
|
||||
using namespace OHOS::Accessibility;
|
||||
using namespace OHOS::AccessibilityConfig;
|
||||
|
||||
napi_status ParseResourceIdFromNAPI(napi_env env, napi_value value, uint32_t &idValue)
|
||||
{
|
||||
napi_status status = napi_ok;
|
||||
bool hasProperty = false;
|
||||
napi_value propertyName = nullptr;
|
||||
status = napi_create_string_utf8(env, "id", NAPI_AUTO_LENGTH, &propertyName);
|
||||
@@ -48,9 +48,9 @@ napi_status ParseResourceIdFromNAPI(napi_env env, napi_value value, uint32_t &id
|
||||
return status;
|
||||
}
|
||||
status = napi_has_property(env, value, propertyName, &hasProperty);
|
||||
if (!hasProperty) {
|
||||
if (status != napi_ok || !hasProperty) {
|
||||
HILOG_ERROR("property is null");
|
||||
return status;
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
napi_value itemValue = nullptr;
|
||||
napi_get_property(env, value, propertyName, &itemValue);
|
||||
@@ -62,6 +62,7 @@ napi_status ParseResourceIdFromNAPI(napi_env env, napi_value value, uint32_t &id
|
||||
napi_status ParseResourceBundleNameFromNAPI(napi_env env, napi_value value,
|
||||
std::string &bundleNameValue)
|
||||
{
|
||||
napi_status status = napi_ok;
|
||||
bool hasProperty = false;
|
||||
napi_value propertyName = nullptr;
|
||||
status = napi_create_string_utf8(env, "bundleName", NAPI_AUTO_LENGTH, &propertyName);
|
||||
@@ -70,9 +71,9 @@ napi_status ParseResourceBundleNameFromNAPI(napi_env env, napi_value value,
|
||||
return status;
|
||||
}
|
||||
status = napi_has_property(env, value, propertyName, &hasProperty);
|
||||
if (!hasProperty) {
|
||||
if (status != napi_ok || !hasProperty) {
|
||||
HILOG_ERROR("property is null");
|
||||
return status;
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
napi_value itemValue = nullptr;
|
||||
status = napi_get_property(env, value, propertyName, &itemValue);
|
||||
@@ -87,6 +88,7 @@ napi_status ParseResourceBundleNameFromNAPI(napi_env env, napi_value value,
|
||||
|
||||
napi_status ParseSeniorModeStateFromNAPI(napi_env env, napi_value value, bool &state)
|
||||
{
|
||||
napi_status status = napi_ok;
|
||||
bool hasProperty = false;
|
||||
napi_value propertyName = nullptr;
|
||||
status = napi_create_string_utf8(env, "seniorModeState", NAPI_AUTO_LENGTH, &propertyName);
|
||||
@@ -95,9 +97,9 @@ napi_status ParseSeniorModeStateFromNAPI(napi_env env, napi_value value, bool &s
|
||||
return status;
|
||||
}
|
||||
status = napi_has_property(env, value, propertyName, &hasProperty);
|
||||
if (!hasProperty) {
|
||||
if (status != napi_ok || !hasProperty) {
|
||||
HILOG_ERROR("property is null");
|
||||
return status;
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
napi_value itemValue = nullptr;
|
||||
status = napi_get_property(env, value, propertyName, &itemValue);
|
||||
@@ -111,6 +113,7 @@ napi_status ParseSeniorModeStateFromNAPI(napi_env env, napi_value value, bool &s
|
||||
|
||||
napi_status ParseAppIndexFromNAPI(napi_env env, napi_value value, int32_t &appIndex)
|
||||
{
|
||||
napi_status status = napi_ok;
|
||||
bool hasProperty = false;
|
||||
napi_value propertyName = nullptr;
|
||||
status = napi_create_string_utf8(env, "appIndex", NAPI_AUTO_LENGTH, &propertyName);
|
||||
@@ -136,6 +139,7 @@ napi_status ParseAppIndexFromNAPI(napi_env env, napi_value value, int32_t &appIn
|
||||
napi_status ParseResourceModuleNameFromNAPI(napi_env env, napi_value value,
|
||||
std::string &moduleNameValue)
|
||||
{
|
||||
napi_status status = napi_ok;
|
||||
bool hasProperty = false;
|
||||
napi_value propertyName = nullptr;
|
||||
status = napi_create_string_utf8(env, "moduleName", NAPI_AUTO_LENGTH, &propertyName);
|
||||
@@ -144,9 +148,9 @@ napi_status ParseResourceModuleNameFromNAPI(napi_env env, napi_value value,
|
||||
return status;
|
||||
}
|
||||
status = napi_has_property(env, value, propertyName, &hasProperty);
|
||||
if (!hasProperty) {
|
||||
if (status != napi_ok || !hasProperty) {
|
||||
HILOG_ERROR("property is null");
|
||||
return status;
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
napi_value itemValue = nullptr;
|
||||
status = napi_get_property(env, value, propertyName, &itemValue);
|
||||
@@ -162,6 +166,7 @@ napi_status ParseResourceModuleNameFromNAPI(napi_env env, napi_value value,
|
||||
napi_status ParseResourceParamsFromNAPI(napi_env env, napi_value value,
|
||||
std::vector<std::tuple<int32_t, std::string>> &resourceParamsValue)
|
||||
{
|
||||
napi_status status = napi_ok;
|
||||
bool hasProperty = false;
|
||||
napi_value propertyName = nullptr;
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
@@ -171,9 +176,9 @@ napi_status ParseResourceParamsFromNAPI(napi_env env, napi_value value,
|
||||
return status;
|
||||
}
|
||||
status = napi_has_property(env, value, propertyName, &hasProperty);
|
||||
if (!hasProperty) {
|
||||
if (status != napi_ok || !hasProperty) {
|
||||
HILOG_ERROR("property is null");
|
||||
return status;
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
napi_value paramsValue = nullptr;
|
||||
status = napi_get_property(env, value, propertyName, ¶msValue);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <vector>
|
||||
#include <future>
|
||||
#include <chrono>
|
||||
#include <atomic>
|
||||
|
||||
#include "accessibility_element_info.h"
|
||||
#include "accessibility_element_operator_callback_stub.h"
|
||||
@@ -58,6 +59,7 @@ public:
|
||||
const int32_t requestId) override;
|
||||
|
||||
ffrt::promise<void> promise_;
|
||||
std::atomic<bool> promiseSet_ {false};
|
||||
bool executeActionResult_ = false;
|
||||
AccessibilityElementInfo accessibilityInfoResult_ = {};
|
||||
std::vector<AccessibilityElementInfo> elementInfosResult_;
|
||||
@@ -72,6 +74,7 @@ public:
|
||||
OperateVirtualNodeResult operateVirtualNodeResult_ = OperateVirtualNodeResult::VIRTUAL_NODE_NOT_SUPPORT;
|
||||
|
||||
bool ValidateElementInfos(const std::list<AccessibilityElementInfo>& infos);
|
||||
void SetPromiseValue();
|
||||
};
|
||||
|
||||
} // namespace Accessibility
|
||||
|
||||
@@ -560,6 +560,10 @@ void AccessibleAbilityManagerService::SendTouchGuideGestureToAA(uint64_t display
|
||||
ErrCode AccessibleAbilityManagerService::SendEvent(
|
||||
const AccessibilityEventInfoParcel &eventInfoParcel, int32_t flag)
|
||||
{
|
||||
if (flag < 0 || flag > 1) {
|
||||
HILOG_ERROR("Invalid flag: %{public}d", flag);
|
||||
return RET_ERR_INVALID_PARAM;
|
||||
}
|
||||
return InnerSendEvent(eventInfoParcel, flag, InnerGetCallingUid());
|
||||
}
|
||||
|
||||
@@ -1088,7 +1092,7 @@ bool AccessibleAbilityManagerService::CheckPermission(const std::string &permiss
|
||||
|
||||
ErrCode AccessibleAbilityManagerService::GetCaptionProperty(CaptionPropertyParcel &caption, bool isPermissionRequired)
|
||||
{
|
||||
if (isPermissionRequired && !IsSystemApp()) {
|
||||
if (!IsSystemApp()) {
|
||||
HILOG_WARN("Not system app");
|
||||
return RET_ERR_NOT_SYSTEM_APP;
|
||||
}
|
||||
@@ -1098,11 +1102,11 @@ ErrCode AccessibleAbilityManagerService::GetCaptionProperty(CaptionPropertyParce
|
||||
ErrCode AccessibleAbilityManagerService::SetCaptionProperty(const CaptionPropertyParcel &caption,
|
||||
bool isPermissionRequired)
|
||||
{
|
||||
if (isPermissionRequired && !IsSystemApp()) {
|
||||
if (!IsSystemApp()) {
|
||||
HILOG_WARN("Not system app");
|
||||
return RET_ERR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if (isPermissionRequired && !CheckPermission(OHOS_PERMISSION_WRITE_ACCESSIBILITY_CONFIG)) {
|
||||
if (!CheckPermission(OHOS_PERMISSION_WRITE_ACCESSIBILITY_CONFIG)) {
|
||||
HILOG_WARN("SetCaptionProperty permission denied.");
|
||||
return RET_ERR_NO_PERMISSION;
|
||||
}
|
||||
@@ -1111,11 +1115,11 @@ ErrCode AccessibleAbilityManagerService::SetCaptionProperty(const CaptionPropert
|
||||
|
||||
ErrCode AccessibleAbilityManagerService::SetCaptionState(const bool state, bool isPermissionRequired)
|
||||
{
|
||||
if (isPermissionRequired && !IsSystemApp()) {
|
||||
if (!IsSystemApp()) {
|
||||
HILOG_WARN("Not system app");
|
||||
return RET_ERR_NOT_SYSTEM_APP;
|
||||
}
|
||||
if (isPermissionRequired && !CheckPermission(OHOS_PERMISSION_WRITE_ACCESSIBILITY_CONFIG)) {
|
||||
if (!CheckPermission(OHOS_PERMISSION_WRITE_ACCESSIBILITY_CONFIG)) {
|
||||
HILOG_WARN("SetCaptionProperty permission denied.");
|
||||
return RET_ERR_NO_PERMISSION;
|
||||
}
|
||||
@@ -1124,7 +1128,7 @@ ErrCode AccessibleAbilityManagerService::SetCaptionState(const bool state, bool
|
||||
|
||||
ErrCode AccessibleAbilityManagerService::GetCaptionState(bool &state, bool isPermissionRequired)
|
||||
{
|
||||
if (isPermissionRequired && !IsSystemApp()) {
|
||||
if (!IsSystemApp()) {
|
||||
HILOG_WARN("Not system app");
|
||||
return RET_ERR_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,14 @@ ElementOperatorCallbackImpl::ElementOperatorCallbackImpl(int32_t accountId) : ac
|
||||
{
|
||||
}
|
||||
|
||||
void ElementOperatorCallbackImpl::SetPromiseValue()
|
||||
{
|
||||
bool expected = false;
|
||||
if (promiseSet_.compare_exchange_strong(expected, true)) {
|
||||
promise_.set_value();
|
||||
}
|
||||
}
|
||||
|
||||
void ElementOperatorCallbackImpl::SetFindFocusedElementInfoResult(
|
||||
const AccessibilityElementInfo &info, const int32_t requestId)
|
||||
{
|
||||
@@ -32,10 +40,10 @@ void ElementOperatorCallbackImpl::SetFindFocusedElementInfoResult(
|
||||
info.GetAccessibilityId(), accountId_) == RET_OK) {
|
||||
HILOG_DEBUG("VerifyingToKenId ok");
|
||||
accessibilityInfoResult_ = info;
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
} else {
|
||||
HILOG_ERROR("VerifyingToKenId failed");
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,38 +51,38 @@ void ElementOperatorCallbackImpl::SetSearchElementInfoByTextResult(
|
||||
const std::vector<AccessibilityElementInfo> &infos, const int32_t requestId)
|
||||
{
|
||||
HILOG_DEBUG("Response [requestId:%{public}d]", requestId);
|
||||
for (auto info : infos) {
|
||||
if (Singleton<AccessibleAbilityManagerService>::GetInstance().VerifyingToKenId(info.GetWindowId(),
|
||||
info.GetAccessibilityId(), accountId_) == RET_OK) {
|
||||
HILOG_DEBUG("VerifyingToKenId ok");
|
||||
} else {
|
||||
HILOG_ERROR("VerifyingToKenId failed");
|
||||
elementInfosResult_.clear();
|
||||
promise_.set_value();
|
||||
return;
|
||||
if (!infos.empty()) {
|
||||
for (auto info : infos) {
|
||||
if (Singleton<AccessibleAbilityManagerService>::GetInstance().VerifyingToKenId(info.GetWindowId(),
|
||||
info.GetAccessibilityId(), accountId_) != RET_OK) {
|
||||
HILOG_ERROR("VerifyingToKenId failed");
|
||||
elementInfosResult_.clear();
|
||||
SetPromiseValue();
|
||||
return;
|
||||
}
|
||||
}
|
||||
elementInfosResult_ = infos;
|
||||
}
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
}
|
||||
|
||||
void ElementOperatorCallbackImpl::SetSearchElementInfoByAccessibilityIdResult(
|
||||
const std::vector<AccessibilityElementInfo> &infos, const int32_t requestId)
|
||||
{
|
||||
HILOG_DEBUG("Response [requestId:%{public}d]", requestId);
|
||||
for (auto info : infos) {
|
||||
if (Singleton<AccessibleAbilityManagerService>::GetInstance().VerifyingToKenId(info.GetWindowId(),
|
||||
info.GetAccessibilityId(), accountId_) == RET_OK) {
|
||||
HILOG_DEBUG("VerifyingToKenId ok");
|
||||
} else {
|
||||
HILOG_ERROR("VerifyingToKenId failed");
|
||||
elementInfosResult_.clear();
|
||||
promise_.set_value();
|
||||
return;
|
||||
if (!infos.empty()) {
|
||||
for (auto info : infos) {
|
||||
if (Singleton<AccessibleAbilityManagerService>::GetInstance().VerifyingToKenId(info.GetWindowId(),
|
||||
info.GetAccessibilityId(), accountId_) != RET_OK) {
|
||||
HILOG_ERROR("VerifyingToKenId failed");
|
||||
elementInfosResult_.clear();
|
||||
SetPromiseValue();
|
||||
return;
|
||||
}
|
||||
}
|
||||
elementInfosResult_ = infos;
|
||||
}
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
}
|
||||
|
||||
void ElementOperatorCallbackImpl::SetSearchElementInfoBySpecificPropertyResult(
|
||||
@@ -93,13 +101,16 @@ void ElementOperatorCallbackImpl::SetSearchElementInfoBySpecificPropertyResult(
|
||||
}
|
||||
elementInfosResult_.assign(treeInfos.begin(), treeInfos.end());
|
||||
}
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
}
|
||||
|
||||
void ElementOperatorCallbackImpl::SetFocusMoveSearchWithConditionResult(
|
||||
const std::list<AccessibilityElementInfo> &infos, const FocusMoveResult& result, const int32_t requestId)
|
||||
{
|
||||
if (!infos.empty()) {
|
||||
if (!ValidateElementInfos(infos)) {
|
||||
return;
|
||||
}
|
||||
elementInfosResult_.assign(infos.begin(), infos.end());
|
||||
}
|
||||
HILOG_DEBUG("Response [requestId:%{public}d]", requestId);
|
||||
@@ -108,7 +119,7 @@ void ElementOperatorCallbackImpl::SetFocusMoveSearchWithConditionResult(
|
||||
parentWindowId_ = result.parentWindowId;
|
||||
changeToNewInfo_ = result.changeToNewInfo;
|
||||
needTerminate_ = result.needTerminate;
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
}
|
||||
|
||||
bool ElementOperatorCallbackImpl::ValidateElementInfos(
|
||||
@@ -121,7 +132,7 @@ bool ElementOperatorCallbackImpl::ValidateElementInfos(
|
||||
} else {
|
||||
HILOG_ERROR("VerifyingToKenId failed");
|
||||
elementInfosResult_.clear();
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -136,10 +147,10 @@ void ElementOperatorCallbackImpl::SetFocusMoveSearchResult(
|
||||
info.GetAccessibilityId(), accountId_) == RET_OK) {
|
||||
HILOG_DEBUG("VerifyingToKenId ok");
|
||||
accessibilityInfoResult_ = info;
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
} else {
|
||||
HILOG_ERROR("VerifyingToKenId failed");
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +159,7 @@ void ElementOperatorCallbackImpl::SetExecuteActionResult(const bool succeeded,
|
||||
{
|
||||
HILOG_DEBUG("Response [result:%{public}d, requestId:%{public}d]", succeeded, requestId);
|
||||
executeActionResult_ = succeeded;
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
}
|
||||
|
||||
void ElementOperatorCallbackImpl::SetCursorPositionResult(const int32_t cursorPosition,
|
||||
@@ -158,7 +169,7 @@ void ElementOperatorCallbackImpl::SetCursorPositionResult(const int32_t cursorPo
|
||||
cursorPosition);
|
||||
HILOG_DEBUG("cursorPosition [result:%{public}d, requestId:%{public}d]", cursorPosition, requestId);
|
||||
callCursorPosition_ = cursorPosition;
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
}
|
||||
|
||||
void ElementOperatorCallbackImpl::SetSearchDefaultFocusByWindowIdResult(
|
||||
@@ -172,12 +183,12 @@ void ElementOperatorCallbackImpl::SetSearchDefaultFocusByWindowIdResult(
|
||||
} else {
|
||||
HILOG_ERROR("VerifyingToKenId failed");
|
||||
elementInfosResult_.clear();
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
return;
|
||||
}
|
||||
elementInfosResult_ = infos;
|
||||
}
|
||||
promise_.set_value();
|
||||
elementInfosResult_ = infos;
|
||||
SetPromiseValue();
|
||||
}
|
||||
|
||||
void ElementOperatorCallbackImpl::SetUpdateCustomAccessibilityPropertyResult(
|
||||
@@ -185,7 +196,7 @@ void ElementOperatorCallbackImpl::SetUpdateCustomAccessibilityPropertyResult(
|
||||
{
|
||||
HILOG_DEBUG("Response [requestId:%{public}d]", requestId);
|
||||
operateVirtualNodeResult_ = result;
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
}
|
||||
|
||||
void ElementOperatorCallbackImpl::SetAddAccessibilityVirtualNodeResult(
|
||||
@@ -193,7 +204,7 @@ void ElementOperatorCallbackImpl::SetAddAccessibilityVirtualNodeResult(
|
||||
{
|
||||
HILOG_DEBUG("Response [requestId:%{public}d]", requestId);
|
||||
operateVirtualNodeResult_ = result;
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
}
|
||||
|
||||
void ElementOperatorCallbackImpl::SetRemoveAccessibilityVirtualNodeResult(
|
||||
@@ -201,7 +212,7 @@ void ElementOperatorCallbackImpl::SetRemoveAccessibilityVirtualNodeResult(
|
||||
{
|
||||
HILOG_DEBUG("Response [requestId:%{public}d]", requestId);
|
||||
operateVirtualNodeResult_ = result;
|
||||
promise_.set_value();
|
||||
SetPromiseValue();
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user