mirror of
https://gitee.com/openharmony/accessibility
synced 2025-03-01 17:55:59 +00:00
修改cppcheck静态告警问题
Signed-off-by: Mupceet <laiguizhong@huawei.com>
This commit is contained in:
parent
70ab75a553
commit
fe1f0f7fbc
@ -385,8 +385,8 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetInstalledAbilities(
|
||||
HILOG_ERROR("Failed to create info.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
bool result = reply.WriteStrongParcelable(info);
|
||||
if (!result) {
|
||||
bool writeResult = reply.WriteStrongParcelable(info);
|
||||
if (!writeResult) {
|
||||
HILOG_ERROR("WriteStrongParcelable<AccessibilityAbilityInfoParcel> failed");
|
||||
return TRANSACTION_ERR;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ bool AccessibleAbilityClientImpl::InjectGesture(const std::shared_ptr<Accessibil
|
||||
|
||||
std::vector<AccessibilityGesturePosition> positions = gesturePath->GetPositions();
|
||||
|
||||
if (positions.size() <= 0) {
|
||||
if (positions.size() == 0) {
|
||||
HILOG_ERROR("The number of gesture path position is not allowed.");
|
||||
return false;
|
||||
}
|
||||
|
@ -1111,11 +1111,12 @@ void AccessibilityConfig::Impl::SubscribeEnableAbilityListsObserver(
|
||||
{
|
||||
HILOG_INFO();
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
for (auto &enableAbilityListsObserver : enableAbilityListsObservers_) {
|
||||
if (enableAbilityListsObserver == observer) {
|
||||
HILOG_ERROR("the observer is exist");
|
||||
return;
|
||||
}
|
||||
if (std::any_of(enableAbilityListsObservers_.begin(), enableAbilityListsObservers_.end(),
|
||||
[&observer](const std::shared_ptr<AccessibilityEnableAbilityListsObserver> &listObserver) {
|
||||
return listObserver == observer;
|
||||
})) {
|
||||
HILOG_ERROR("the observer is exist");
|
||||
return;
|
||||
}
|
||||
enableAbilityListsObservers_.push_back(observer);
|
||||
HILOG_DEBUG("observer's size is %{public}zu", enableAbilityListsObservers_.size());
|
||||
|
@ -929,17 +929,15 @@ ActionType AccessibilityElementInfo::GetTriggerAction() const
|
||||
void AccessibilityElementInfo::SetContentList(const std::vector<std::string> &contentList)
|
||||
{
|
||||
contentList_.clear();
|
||||
for (auto &content : contentList) {
|
||||
contentList_.emplace_back(content);
|
||||
}
|
||||
contentList_.resize(contentList.size());
|
||||
std::copy(contentList.begin(), contentList.end(), contentList_.begin());
|
||||
}
|
||||
|
||||
void AccessibilityElementInfo::GetContentList(std::vector<std::string> &contentList) const
|
||||
{
|
||||
contentList.clear();
|
||||
for (auto &content : contentList_) {
|
||||
contentList.emplace_back(content);
|
||||
}
|
||||
contentList.resize(contentList_.size());
|
||||
std::copy(contentList_.begin(), contentList_.end(), contentList.begin());
|
||||
}
|
||||
|
||||
void AccessibilityElementInfo::SetLatestContent(const std::string &content)
|
||||
|
@ -619,7 +619,7 @@ void EnableAbilityListsObserver::OnEnableAbilityListsStateChanged()
|
||||
|
||||
uv_loop_s *loop = nullptr;
|
||||
napi_get_uv_event_loop(env_, &loop);
|
||||
uv_queue_work(
|
||||
int ret = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
@ -637,6 +637,13 @@ void EnableAbilityListsObserver::OnEnableAbilityListsStateChanged()
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Failed to execute OnEnableAbilityListsStateChanged work queue");
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void EnableAbilityListsObserverImpl::SubscribeToFramework()
|
||||
|
@ -1132,10 +1132,11 @@ void NAccessibilityElement::ActionNamesComplete(napi_env env, napi_status status
|
||||
std::vector<AccessibleAction> operations =
|
||||
callbackInfo->accessibilityElement_.elementInfo_->GetActionList();
|
||||
HILOG_DEBUG("action list size is %{public}zu", operations.size());
|
||||
for (auto &operation : operations) {
|
||||
actionNames.push_back(ConvertOperationTypeToString(operation.GetActionType()));
|
||||
}
|
||||
|
||||
actionNames.resize(operations.size());
|
||||
std::transform(operations.begin(), operations.end(), actionNames.begin(),
|
||||
[](const AccessibleAction operation) {
|
||||
return ConvertOperationTypeToString(operation.GetActionType());
|
||||
});
|
||||
napi_create_array(env, &result[PARAM1]);
|
||||
ConvertStringVecToJS(env, result[PARAM1], actionNames);
|
||||
} else {
|
||||
@ -1270,11 +1271,6 @@ void NAccessibilityElement::PerformActionComplete(napi_env env, napi_status stat
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(env, &undefined);
|
||||
if (!callbackInfo) {
|
||||
HILOG_ERROR("callbackInfo is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
napi_get_boolean(callbackInfo->env_, callbackInfo->ret_, &result[PARAM1]);
|
||||
if (callbackInfo->callback_) {
|
||||
// Callback mode
|
||||
|
@ -142,7 +142,7 @@ void NAccessibilityExtension::OnAbilityConnected()
|
||||
}
|
||||
work->data = static_cast<void*>(callbackInfo);
|
||||
|
||||
uv_queue_work(
|
||||
int ret = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
@ -154,6 +154,13 @@ void NAccessibilityExtension::OnAbilityConnected()
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret) {
|
||||
HILOG_ERROR("Failed to execute OnAbilityConnected work queue");
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
HILOG_INFO("end.");
|
||||
}
|
||||
|
||||
@ -176,7 +183,7 @@ void NAccessibilityExtension::OnAbilityDisconnected()
|
||||
}
|
||||
work->data = static_cast<void*>(callbackInfo);
|
||||
|
||||
uv_queue_work(
|
||||
int ret = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
@ -188,6 +195,13 @@ void NAccessibilityExtension::OnAbilityDisconnected()
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret) {
|
||||
HILOG_ERROR("Failed to execute OnAbilityDisconnected work queue");
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
HILOG_INFO("end.");
|
||||
}
|
||||
|
||||
@ -303,7 +317,7 @@ void NAccessibilityExtension::OnAccessibilityEvent(const AccessibilityEventInfo&
|
||||
return;
|
||||
}
|
||||
work->data = static_cast<void*>(callbackInfo);
|
||||
uv_queue_work(
|
||||
int ret = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
@ -337,6 +351,13 @@ void NAccessibilityExtension::OnAccessibilityEvent(const AccessibilityEventInfo&
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret) {
|
||||
HILOG_ERROR("Failed to execute OnAccessibilityEvent work queue");
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool NAccessibilityExtension::OnKeyPressEvent(const std::shared_ptr<MMI::KeyEvent> &keyEvent)
|
||||
@ -361,7 +382,7 @@ bool NAccessibilityExtension::OnKeyPressEvent(const std::shared_ptr<MMI::KeyEven
|
||||
work->data = static_cast<void*>(callbackInfo);
|
||||
std::future syncFuture = callbackInfo->syncPromise_.get_future();
|
||||
|
||||
uv_queue_work(
|
||||
int ret = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
@ -401,6 +422,14 @@ bool NAccessibilityExtension::OnKeyPressEvent(const std::shared_ptr<MMI::KeyEven
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret) {
|
||||
HILOG_ERROR("Failed to execute OnKeyPressEvent work queue");
|
||||
callbackInfo->syncPromise_.set_value(false);
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
bool callbackResult = syncFuture.get();
|
||||
HILOG_INFO("OnKeyPressEvent callbackResult = %{public}d", callbackResult);
|
||||
return callbackResult;
|
||||
|
@ -55,14 +55,12 @@ std::string GetStringFromNAPI(napi_env env, napi_value value);
|
||||
bool ParseBool(napi_env env, bool& param, napi_value args);
|
||||
bool ParseString(napi_env env, std::string& param, napi_value args);
|
||||
bool ParseNumber(napi_env env, napi_value args);
|
||||
bool ParseUint32(napi_env env, uint32_t& param, napi_value args);
|
||||
bool ParseInt32(napi_env env, int32_t& param, napi_value args);
|
||||
bool ParseDouble(napi_env env, double& param, napi_value args);
|
||||
napi_value GetErrorValue(napi_env env, int errCode);
|
||||
|
||||
std::string ConvertWindowTypeToString(OHOS::Accessibility::AccessibilityWindowType type);
|
||||
std::string ConvertDaltonizationTypeToString(OHOS::AccessibilityConfig::DALTONIZATION_TYPE type);
|
||||
void ConvertOperationToJS(napi_env env, napi_value result, const OHOS::Accessibility::AccessibleAction& operation);
|
||||
void ConvertGridInfoToJS(napi_env env, napi_value nGrid, const OHOS::Accessibility::GridInfo& grid);
|
||||
void ConvertGridItemToJS(napi_env env, napi_value nGridItem, const OHOS::Accessibility::GridItemInfo& gridItem);
|
||||
void ConvertRectToJS(napi_env env, napi_value result, const OHOS::Accessibility::Rect& rect);
|
||||
@ -86,16 +84,11 @@ void ConvertJSToStringVec(napi_env env, napi_value arrayValue, std::vector<std::
|
||||
void ConvertStringVecToJS(napi_env env, napi_value &result, std::vector<std::string> values);
|
||||
void ConvertJSToEventTypes(napi_env env, napi_value arrayValue, uint32_t &eventTypes);
|
||||
void ConvertJSToCapabilities(napi_env env, napi_value arrayValue, uint32_t &capabilities);
|
||||
void ConvertEnabledToJS(napi_env env, napi_value& captionsManager, bool value);
|
||||
void ConvertStyleToJS(napi_env env, napi_value& captionsManager,
|
||||
OHOS::AccessibilityConfig::CaptionProperty captionProperty_);
|
||||
uint32_t GetColorValue(napi_env env, napi_value object, napi_value propertyNameValue);
|
||||
uint32_t GetColorValue(napi_env env, napi_value value);
|
||||
uint32_t ConvertColorStringToNumer(std::string colorStr);
|
||||
std::string ConvertColorToString(uint32_t color);
|
||||
|
||||
OHOS::Accessibility::NotificationCategory ConvertStringToNotificationCategory(const std::string &type);
|
||||
OHOS::Accessibility::GestureType ConvertStringToGestureType(const std::string &type);
|
||||
OHOS::Accessibility::ActionType ConvertStringToAccessibleOperationType(const std::string &type);
|
||||
OHOS::Accessibility::AccessibilityAbilityTypes ConvertStringToAccessibilityAbilityTypes(const std::string &type);
|
||||
OHOS::Accessibility::AbilityStateType ConvertStringToAbilityStateType(const std::string &type);
|
||||
@ -105,7 +98,6 @@ OHOS::Accessibility::TextMoveUnit ConvertStringToTextMoveUnit(const std::string
|
||||
std::string ConvertTextMoveUnitToString(OHOS::Accessibility::TextMoveUnit type);
|
||||
std::string ConvertOperationTypeToString(OHOS::Accessibility::ActionType type);
|
||||
std::string CoverGestureTypeToString(OHOS::Accessibility::GestureType type);
|
||||
const std::string ConvertCategoryNotificationToString(OHOS::Accessibility::NotificationCategory category);
|
||||
const std::string ConvertWindowUpdateTypeToString(OHOS::Accessibility::WindowUpdateType type);
|
||||
const std::string ConvertAccessibilityEventTypeToString(OHOS::Accessibility::EventType type);
|
||||
void ConvertEventTypeToString(const OHOS::Accessibility::AccessibilityEventInfo &eventInfo,
|
||||
|
@ -103,7 +103,7 @@ void NAccessibilityConfigObserver::NotifyStateChanged2JS(bool enabled)
|
||||
|
||||
uv_loop_s *loop = nullptr;
|
||||
napi_get_uv_event_loop(env_, &loop);
|
||||
uv_queue_work(
|
||||
int ret = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
@ -127,6 +127,13 @@ void NAccessibilityConfigObserver::NotifyStateChanged2JS(bool enabled)
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Failed to execute NotifyStateChanged2JS work queue");
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void NAccessibilityConfigObserver::NotifyPropertyChanged2JS(const OHOS::AccessibilityConfig::CaptionProperty &caption)
|
||||
@ -152,7 +159,7 @@ void NAccessibilityConfigObserver::NotifyPropertyChanged2JS(const OHOS::Accessib
|
||||
|
||||
uv_loop_s *loop = nullptr;
|
||||
napi_get_uv_event_loop(env_, &loop);
|
||||
uv_queue_work(
|
||||
int ret = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
@ -176,6 +183,13 @@ void NAccessibilityConfigObserver::NotifyPropertyChanged2JS(const OHOS::Accessib
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Failed to execute NotifyPropertyChanged2JS work queue");
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void NAccessibilityConfigObserver::NotifyStringChanged2JS(const std::string& value)
|
||||
@ -201,7 +215,7 @@ void NAccessibilityConfigObserver::NotifyStringChanged2JS(const std::string& val
|
||||
|
||||
uv_loop_s *loop = nullptr;
|
||||
napi_get_uv_event_loop(env_, &loop);
|
||||
uv_queue_work(
|
||||
int ret = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
@ -229,6 +243,13 @@ void NAccessibilityConfigObserver::NotifyStringChanged2JS(const std::string& val
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Failed to execute NotifyStringChanged2JS work queue");
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void NAccessibilityConfigObserver::NotifyIntChanged2JS(int32_t value)
|
||||
@ -254,7 +275,7 @@ void NAccessibilityConfigObserver::NotifyIntChanged2JS(int32_t value)
|
||||
|
||||
uv_loop_s *loop = nullptr;
|
||||
napi_get_uv_event_loop(env_, &loop);
|
||||
uv_queue_work(
|
||||
int ret = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
@ -277,6 +298,13 @@ void NAccessibilityConfigObserver::NotifyIntChanged2JS(int32_t value)
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Failed to execute NotifyIntChanged2JS work queue");
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void NAccessibilityConfigObserver::NotifyUintChanged2JS(uint32_t value)
|
||||
@ -302,7 +330,7 @@ void NAccessibilityConfigObserver::NotifyUintChanged2JS(uint32_t value)
|
||||
|
||||
uv_loop_s *loop = nullptr;
|
||||
napi_get_uv_event_loop(env_, &loop);
|
||||
uv_queue_work(
|
||||
int ret = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
@ -325,6 +353,13 @@ void NAccessibilityConfigObserver::NotifyUintChanged2JS(uint32_t value)
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Failed to execute NotifyUintChanged2JS work queue");
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void NAccessibilityConfigObserver::NotifyFloatChanged2JS(float value)
|
||||
@ -350,7 +385,7 @@ void NAccessibilityConfigObserver::NotifyFloatChanged2JS(float value)
|
||||
|
||||
uv_loop_s *loop = nullptr;
|
||||
napi_get_uv_event_loop(env_, &loop);
|
||||
uv_queue_work(
|
||||
int ret = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
@ -373,6 +408,13 @@ void NAccessibilityConfigObserver::NotifyFloatChanged2JS(float value)
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Failed to execute NotifyFloatChanged2JS work queue");
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void NAccessibilityConfigObserverImpl::SubscribeToFramework()
|
||||
|
@ -403,7 +403,7 @@ void StateListener::NotifyJS(napi_env env, bool state, napi_ref handlerRef)
|
||||
|
||||
uv_loop_s *loop = nullptr;
|
||||
napi_get_uv_event_loop(env, &loop);
|
||||
uv_queue_work(
|
||||
int ret = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
@ -423,6 +423,13 @@ void StateListener::NotifyJS(napi_env env, bool state, napi_ref handlerRef)
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Failed to execute NotifyJS work queue");
|
||||
delete callbackInfo;
|
||||
callbackInfo = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void StateListener::OnStateChanged(const bool state)
|
||||
|
@ -126,16 +126,6 @@ bool ParseNumber(napi_env env, napi_value args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseUint32(napi_env env, uint32_t& param, napi_value args)
|
||||
{
|
||||
if (!ParseNumber(env, args)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
napi_get_value_uint32(env, args, ¶m);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseInt32(napi_env env, int32_t& param, napi_value args)
|
||||
{
|
||||
if (!ParseNumber(env, args)) {
|
||||
@ -470,31 +460,6 @@ void ConvertEventTypeToString(const AccessibilityEventInfo &eventInfo, std::stri
|
||||
}
|
||||
}
|
||||
|
||||
const std::string ConvertCategoryNotificationToString(NotificationCategory category)
|
||||
{
|
||||
static const std::map<NotificationCategory, const std::string> categoryTable = {
|
||||
{NotificationCategory::CATEGORY_CALL, "call"},
|
||||
{NotificationCategory::CATEGORY_MSG, "msg"},
|
||||
{NotificationCategory::CATEGORY_EMAIL, "email"},
|
||||
{NotificationCategory::CATEGORY_EVENT, "event"},
|
||||
{NotificationCategory::CATEGORY_PROMO, "promo"},
|
||||
{NotificationCategory::CATEGORY_ALARM, "alarm"},
|
||||
{NotificationCategory::CATEGORY_PROGRESS, "progress"},
|
||||
{NotificationCategory::CATEGORY_SOCIAL, "social"},
|
||||
{NotificationCategory::CATEGORY_ERR, "err"},
|
||||
{NotificationCategory::CATEGORY_TRANSPORT, "transport"},
|
||||
{NotificationCategory::CATEGORY_SYS, "sys"},
|
||||
{NotificationCategory::CATEGORY_SERVICE, "service"},
|
||||
{NotificationCategory::CATEGORY_OTHERS, ""},
|
||||
};
|
||||
|
||||
if (categoryTable.find(category) == categoryTable.end()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return categoryTable.at(category);
|
||||
}
|
||||
|
||||
std::string ConvertOperationTypeToString(ActionType type)
|
||||
{
|
||||
static const std::map<ActionType, const std::string> triggerActionTable = {
|
||||
@ -523,21 +488,6 @@ std::string ConvertOperationTypeToString(ActionType type)
|
||||
return triggerActionTable.at(type);
|
||||
}
|
||||
|
||||
void ConvertOperationToJS(napi_env env, napi_value result, const AccessibleAction& operation)
|
||||
{
|
||||
napi_value nType;
|
||||
ActionType type = operation.GetActionType();
|
||||
std::string strType = ConvertOperationTypeToString(type);
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, strType.c_str(), NAPI_AUTO_LENGTH, &nType));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "type", nType));
|
||||
HILOG_DEBUG("operationType[%{public}s]", strType.c_str());
|
||||
|
||||
napi_value nDescription;
|
||||
std::string strDescription = operation.GetDescriptionInfo();
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, strDescription.c_str(), NAPI_AUTO_LENGTH, &nDescription));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "description", nDescription));
|
||||
}
|
||||
|
||||
void ConvertGridInfoToJS(napi_env env, napi_value nGrid, const OHOS::Accessibility::GridInfo& grid)
|
||||
{
|
||||
napi_value nRowCount;
|
||||
@ -772,57 +722,6 @@ std::string ConvertTextMoveUnitToString(TextMoveUnit type)
|
||||
return textMoveUnitTable.at(type);
|
||||
}
|
||||
|
||||
NotificationCategory ConvertStringToNotificationCategory(const std::string &type)
|
||||
{
|
||||
static const std::map<const std::string, NotificationCategory> notificationCategoryTable = {
|
||||
{"call", NotificationCategory::CATEGORY_CALL},
|
||||
{"msg", NotificationCategory::CATEGORY_MSG},
|
||||
{"email", NotificationCategory::CATEGORY_EMAIL},
|
||||
{"event", NotificationCategory::CATEGORY_EVENT},
|
||||
{"promo", NotificationCategory::CATEGORY_PROMO},
|
||||
{"alarm", NotificationCategory::CATEGORY_ALARM},
|
||||
{"progress", NotificationCategory::CATEGORY_PROGRESS},
|
||||
{"social", NotificationCategory::CATEGORY_SOCIAL},
|
||||
{"err", NotificationCategory::CATEGORY_ERR},
|
||||
{"transport", NotificationCategory::CATEGORY_TRANSPORT},
|
||||
{"sys", NotificationCategory::CATEGORY_SYS},
|
||||
{"service", NotificationCategory::CATEGORY_SERVICE}};
|
||||
|
||||
if (notificationCategoryTable.find(type) == notificationCategoryTable.end()) {
|
||||
HILOG_WARN("invalid key[%{public}s]", type.c_str());
|
||||
return CATEGORY_INVALID;
|
||||
}
|
||||
|
||||
return notificationCategoryTable.at(type);
|
||||
}
|
||||
|
||||
GestureType ConvertStringToGestureType(const std::string &type)
|
||||
{
|
||||
static const std::map<const std::string, GestureType> gestureTypesTable = {
|
||||
{"left", GestureType::GESTURE_SWIPE_LEFT},
|
||||
{"leftThenRight", GestureType::GESTURE_SWIPE_LEFT_THEN_RIGHT},
|
||||
{"leftThenUp", GestureType::GESTURE_SWIPE_LEFT_THEN_UP},
|
||||
{"leftThenDown", GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN},
|
||||
{"right", GestureType::GESTURE_SWIPE_RIGHT},
|
||||
{"rightThenLeft", GestureType::GESTURE_SWIPE_RIGHT_THEN_LEFT},
|
||||
{"rightThenUp", GestureType::GESTURE_SWIPE_RIGHT_THEN_UP},
|
||||
{"rightThenDown", GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN},
|
||||
{"up", GestureType::GESTURE_SWIPE_UP},
|
||||
{"upThenLeft", GestureType::GESTURE_SWIPE_UP_THEN_LEFT},
|
||||
{"upThenRight", GestureType::GESTURE_SWIPE_UP_THEN_RIGHT},
|
||||
{"upThenDown", GestureType::GESTURE_SWIPE_UP_THEN_DOWN},
|
||||
{"down", GestureType::GESTURE_SWIPE_DOWN},
|
||||
{"downThenLeft", GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT},
|
||||
{"downThenRight", GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT},
|
||||
{"downThenUp", GestureType::GESTURE_SWIPE_DOWN_THEN_UP}};
|
||||
|
||||
if (gestureTypesTable.find(type) == gestureTypesTable.end()) {
|
||||
HILOG_WARN("invalid key[%{public}s]", type.c_str());
|
||||
return GESTURE_INVALID;
|
||||
}
|
||||
return gestureTypesTable.at(type);
|
||||
}
|
||||
|
||||
void ConvertActionArgsJSToNAPI(
|
||||
napi_env env, napi_value object, std::map<std::string, std::string>& args, OHOS::Accessibility::ActionType action)
|
||||
{
|
||||
@ -890,15 +789,14 @@ bool ConvertEventInfoJSToNAPI(napi_env env, napi_value object, AccessibilityEven
|
||||
napi_value propertyNameValue = nullptr;
|
||||
bool hasProperty = false;
|
||||
int32_t dataValue = 0;
|
||||
std::string str = "";
|
||||
EventType eventType = TYPE_VIEW_INVALID;
|
||||
std::string str;
|
||||
napi_create_string_utf8(env, "type", NAPI_AUTO_LENGTH, &propertyNameValue);
|
||||
napi_has_property(env, object, propertyNameValue, &hasProperty);
|
||||
if (hasProperty) {
|
||||
napi_value value = nullptr;
|
||||
napi_get_property(env, object, propertyNameValue, &value);
|
||||
str = GetStringFromNAPI(env, value);
|
||||
eventType = ConvertStringToEventInfoTypes(str);
|
||||
EventType eventType = ConvertStringToEventInfoTypes(str);
|
||||
eventInfo.SetEventType(eventType);
|
||||
if (eventType == TYPE_VIEW_INVALID) {
|
||||
return false;
|
||||
@ -1454,8 +1352,6 @@ std::string ConvertColorToString(uint32_t color)
|
||||
uint32_t GetColorValue(napi_env env, napi_value object, napi_value propertyNameValue)
|
||||
{
|
||||
uint32_t color = COLOR_TRANSPARENT;
|
||||
char outBuffer[CHAE_BUFFER_MAX + 1] = {0};
|
||||
size_t outSize = 0;
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
napi_value value = nullptr;
|
||||
napi_get_property(env, object, propertyNameValue, &value);
|
||||
@ -1469,6 +1365,8 @@ uint32_t GetColorValue(napi_env env, napi_value object, napi_value propertyNameV
|
||||
HILOG_DEBUG("valueType number, color is 0x%{public}x", color);
|
||||
}
|
||||
if (valueType == napi_string) {
|
||||
char outBuffer[CHAE_BUFFER_MAX + 1] = {0};
|
||||
size_t outSize = 0;
|
||||
napi_get_value_string_utf8(env, value, outBuffer, CHAE_BUFFER_MAX, &outSize);
|
||||
color = ConvertColorStringToNumer(std::string(outBuffer));
|
||||
}
|
||||
@ -1479,8 +1377,6 @@ uint32_t GetColorValue(napi_env env, napi_value object, napi_value propertyNameV
|
||||
uint32_t GetColorValue(napi_env env, napi_value value)
|
||||
{
|
||||
uint32_t color = COLOR_TRANSPARENT;
|
||||
char outBuffer[CHAE_BUFFER_MAX + 1] = {0};
|
||||
size_t outSize = 0;
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
napi_status status = napi_typeof(env, value, &valueType);
|
||||
if (status != napi_ok) {
|
||||
@ -1492,6 +1388,8 @@ uint32_t GetColorValue(napi_env env, napi_value value)
|
||||
napi_get_value_uint32(env, value, &color);
|
||||
}
|
||||
if (valueType == napi_string) {
|
||||
char outBuffer[CHAE_BUFFER_MAX + 1] = {0};
|
||||
size_t outSize = 0;
|
||||
napi_get_value_string_utf8(env, value, outBuffer, CHAE_BUFFER_MAX, &outSize);
|
||||
color = ConvertColorStringToNumer(std::string(outBuffer));
|
||||
}
|
||||
@ -1628,26 +1526,6 @@ void ConvertJSToCapabilities(napi_env env, napi_value arrayValue, uint32_t &capa
|
||||
}
|
||||
}
|
||||
|
||||
void ConvertEnabledToJS(napi_env env, napi_value& captionsManager, bool value)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
napi_value keyCode;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, value, &keyCode));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, captionsManager, "enabled", keyCode));
|
||||
}
|
||||
|
||||
void ConvertStyleToJS(
|
||||
napi_env env, napi_value& captionsManager, OHOS::AccessibilityConfig::CaptionProperty captionProperty_)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
napi_value keyCode;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_object(env, &keyCode));
|
||||
|
||||
ConvertCaptionPropertyToJS(env, keyCode, captionProperty_);
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, captionsManager, "style", keyCode));
|
||||
}
|
||||
|
||||
void ConvertStringVecToJS(napi_env env, napi_value &result, std::vector<std::string> values)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "accessibility_account_data.h"
|
||||
|
||||
#include <any>
|
||||
#include <hitrace_meter.h>
|
||||
|
||||
#include "accessibility_display_manager.h"
|
||||
@ -151,11 +152,12 @@ void AccessibilityAccountData::AddEnableAbilityListsObserver(
|
||||
const sptr<IAccessibilityEnableAbilityListsObserver>& observer)
|
||||
{
|
||||
HILOG_INFO();
|
||||
for (auto &enableAbilityListsObserver : enableAbilityListsObservers_) {
|
||||
if (enableAbilityListsObserver == observer) {
|
||||
HILOG_ERROR("observer is already exist");
|
||||
return;
|
||||
}
|
||||
if (std::any_of(enableAbilityListsObservers_.begin(), enableAbilityListsObservers_.end(),
|
||||
[observer](const sptr<IAccessibilityEnableAbilityListsObserver> &listObserver) {
|
||||
return listObserver == observer;
|
||||
})) {
|
||||
HILOG_ERROR("observer is already exist");
|
||||
return;
|
||||
}
|
||||
enableAbilityListsObservers_.push_back(observer);
|
||||
HILOG_DEBUG("observer's size is %{public}zu", enableAbilityListsObservers_.size());
|
||||
@ -208,12 +210,12 @@ void AccessibilityAccountData::AddConnectingA11yAbility(const std::string &uri,
|
||||
{
|
||||
HILOG_DEBUG("start.");
|
||||
auto iter = connectingA11yAbilities_.find(uri);
|
||||
if (iter != connectingA11yAbilities_.end()) {
|
||||
if (iter == connectingA11yAbilities_.end()) {
|
||||
connectingA11yAbilities_[uri] = connection;
|
||||
HILOG_DEBUG("Add ConnectingA11yAbility: %{public}zu", connectingA11yAbilities_.size());
|
||||
} else {
|
||||
HILOG_ERROR("The ability is already connecting, and it's uri is %{public}s", uri.c_str());
|
||||
return;
|
||||
}
|
||||
connectingA11yAbilities_[uri] = connection;
|
||||
HILOG_DEBUG("Add ConnectingA11yAbility: %{public}zu", connectingA11yAbilities_.size());
|
||||
}
|
||||
|
||||
void AccessibilityAccountData::RemoveConnectingA11yAbility(const std::string &uri)
|
||||
@ -230,11 +232,12 @@ void AccessibilityAccountData::RemoveConnectingA11yAbility(const std::string &ur
|
||||
void AccessibilityAccountData::AddEnabledAbility(const std::string &name)
|
||||
{
|
||||
HILOG_DEBUG("start.");
|
||||
for (auto &ability : enabledAbilities_) {
|
||||
if (ability == name) {
|
||||
HILOG_DEBUG("The ability is already enabled, and it's name is %{public}s", name.c_str());
|
||||
return;
|
||||
}
|
||||
if (std::any_of(enabledAbilities_.begin(), enabledAbilities_.end(),
|
||||
[name](const std::string &abilityName) {
|
||||
return abilityName == name;
|
||||
})) {
|
||||
HILOG_DEBUG("The ability is already enabled, and it's name is %{public}s", name.c_str());
|
||||
return;
|
||||
}
|
||||
enabledAbilities_.push_back(name);
|
||||
UpdateEnableAbilityListsState();
|
||||
@ -523,11 +526,12 @@ bool AccessibilityAccountData::EnableAbility(const std::string &name, const uint
|
||||
}
|
||||
|
||||
// Add enabled ability
|
||||
for (auto &enabledAbility : enabledAbilities_) {
|
||||
if (enabledAbility == name) {
|
||||
HILOG_ERROR("The ability[%{public}s] is already enabled", name.c_str());
|
||||
return false;
|
||||
}
|
||||
if (std::any_of(enabledAbilities_.begin(), enabledAbilities_.end(),
|
||||
[name](const std::string &abilityName) {
|
||||
return abilityName == name;
|
||||
})) {
|
||||
HILOG_ERROR("The ability[%{public}s] is already enabled", name.c_str());
|
||||
return false;
|
||||
}
|
||||
enabledAbilities_.push_back(name);
|
||||
UpdateEnableAbilityListsState();
|
||||
|
@ -47,9 +47,8 @@ int AccessibilityDumper::Dump(int fd, const std::vector<std::u16string>& args) c
|
||||
UniqueFd ufd = UniqueFd(fd); // auto close
|
||||
fd = ufd.Get();
|
||||
std::vector<std::string> params;
|
||||
for (auto& arg : args) {
|
||||
params.emplace_back(Str16ToStr8(arg));
|
||||
}
|
||||
std::transform(args.begin(), args.end(), std::back_inserter(params),
|
||||
[](const std::u16string &arg) { return Str16ToStr8(arg); });
|
||||
|
||||
std::string dumpInfo;
|
||||
if (params.empty()) {
|
||||
|
@ -375,8 +375,8 @@ std::vector<Pointer> AccessibilityGestureRecognizer::GetPointerPath(std::vector<
|
||||
Pointer newSeparation;
|
||||
float xUnitVector = 0;
|
||||
float yUnitVector = 0;
|
||||
float xVector = 0;
|
||||
float yVector = 0;
|
||||
float xVector;
|
||||
float yVector;
|
||||
float vectorLength = 0;
|
||||
int32_t numSinceFirstSep = 0;
|
||||
|
||||
|
@ -614,7 +614,7 @@ void AccessibilitySettingsConfig::StringToVector(const std::string &stringIn, st
|
||||
vectorResult.push_back(stringIn);
|
||||
} else {
|
||||
int32_t startWrod = 0;
|
||||
int32_t length = 0;
|
||||
int32_t length;
|
||||
for (int32_t i = 0; i <= wrodCount; i++) {
|
||||
if (i == 0) {
|
||||
length = position[i];
|
||||
|
@ -142,7 +142,7 @@ bool AccessibilityShortKey::IsTriplePress()
|
||||
HILOG_DEBUG();
|
||||
|
||||
uint32_t upEventCount = 0;
|
||||
int32_t action = MMI::KeyEvent::KEY_ACTION_UNKNOWN;
|
||||
int32_t action;
|
||||
for (auto &keyEvent : cachedKeyEvents_) {
|
||||
action = keyEvent->GetKeyAction();
|
||||
if (action == MMI::KeyEvent::KEY_ACTION_UP) {
|
||||
|
@ -204,7 +204,6 @@ void TouchEventInjector::ParseTapsEvents(int64_t startTime,
|
||||
}
|
||||
int64_t perDurationTime = static_cast<int64_t>(static_cast<uint64_t>(durationTime) / positionSize);
|
||||
int64_t downTime = startTime;
|
||||
int64_t upTime = 0;
|
||||
for (size_t i = 0; i < positionSize; i++) {
|
||||
std::shared_ptr<MMI::PointerEvent> event;
|
||||
MMI::PointerEvent::PointerItem pointer = {};
|
||||
@ -220,7 +219,7 @@ void TouchEventInjector::ParseTapsEvents(int64_t startTime,
|
||||
injectedEvents_.push_back(event);
|
||||
|
||||
// Append up event
|
||||
upTime = downTime + perDurationTime * MS_TO_US;
|
||||
int64_t upTime = downTime + perDurationTime * MS_TO_US;
|
||||
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pointer, upTime);
|
||||
HILOG_DEBUG("append up event");
|
||||
injectedEvents_.push_back(event);
|
||||
|
@ -234,7 +234,6 @@ bool TouchGuider::TouchGuideListener::OnDoubleTap(MMI::PointerEvent &event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
MMI::PointerEvent::PointerItem clickPoint = {};
|
||||
if (server_.currentState_ != static_cast<int32_t>(TouchGuideState::TOUCH_GUIDING)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -254,9 +254,9 @@ std::vector<AccessibilityWindowInfo> AccessibilityWindowManager::GetAccessibilit
|
||||
UpdateAccessibilityWindowInfo(a11yWindows_[info->wid_], info);
|
||||
}
|
||||
}
|
||||
for (auto &window : a11yWindows_) {
|
||||
windows.emplace_back(window.second);
|
||||
}
|
||||
std::transform(a11yWindows_.begin(), a11yWindows_.end(), std::back_inserter(windows),
|
||||
[](const std::map<int32_t, AccessibilityWindowInfo>::value_type &window) { return window.second; });
|
||||
|
||||
HILOG_DEBUG("window size[%{public}zu]", windows.size());
|
||||
for (auto &logWindow : windows) {
|
||||
HILOG_DEBUG("logWindow id[%{public}d]", logWindow.GetWindowId());
|
||||
@ -268,7 +268,6 @@ bool AccessibilityWindowManager::GetAccessibilityWindow(int32_t windowId, Access
|
||||
{
|
||||
HILOG_DEBUG("start windowId(%{public}d)", windowId);
|
||||
std::vector<sptr<Rosen::AccessibilityWindowInfo>> windowInfos;
|
||||
std::vector<AccessibilityWindowInfo> windows;
|
||||
Rosen::WMError err = OHOS::Rosen::WindowManager::GetInstance().GetAccessibilityWindowInfo(windowInfos);
|
||||
if (err != Rosen::WMError::WM_OK) {
|
||||
HILOG_ERROR("get window info from wms failed. err[%{public}d]", err);
|
||||
@ -289,10 +288,15 @@ bool AccessibilityWindowManager::GetAccessibilityWindow(int32_t windowId, Access
|
||||
bool AccessibilityWindowManager::IsValidWindow(int32_t windowId)
|
||||
{
|
||||
HILOG_DEBUG("start windowId(%{public}d)", windowId);
|
||||
if (a11yWindows_.count(windowId)) {
|
||||
return true;
|
||||
|
||||
auto it = std::find_if(a11yWindows_.begin(), a11yWindows_.end(),
|
||||
[windowId](const std::map<int32_t, AccessibilityWindowInfo>::value_type &window)
|
||||
{ return window.first == windowId; });
|
||||
|
||||
if (it == a11yWindows_.end()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::SetWindowSize(int32_t windowId, Rect rect)
|
||||
|
@ -123,11 +123,9 @@ void AccessibilityZoomGesture::SendCacheEventsToNext()
|
||||
HILOG_DEBUG();
|
||||
|
||||
bool isStartNewAction = false;
|
||||
int32_t action = MMI::PointerEvent::POINTER_ACTION_UNKNOWN;
|
||||
int32_t action;
|
||||
std::vector<std::shared_ptr<MMI::PointerEvent>> cacheEventsTmp;
|
||||
for (auto &pointerEvent : cacheEvents_) {
|
||||
cacheEventsTmp.emplace_back(pointerEvent);
|
||||
}
|
||||
std::copy(cacheEvents_.begin(), cacheEvents_.end(), std::back_inserter(cacheEventsTmp));
|
||||
|
||||
ClearCacheEventsAndMsg();
|
||||
|
||||
@ -383,7 +381,7 @@ void AccessibilityZoomGesture::CalcFocusCoordinate(MMI::PointerEvent &event, ZOO
|
||||
count--;
|
||||
}
|
||||
|
||||
if (count <= 0) {
|
||||
if (count == 0) {
|
||||
HILOG_DEBUG("The size of PointerIds(down) is invalid");
|
||||
return;
|
||||
}
|
||||
@ -425,7 +423,7 @@ float AccessibilityZoomGesture::CalcScaleSpan(MMI::PointerEvent &event, ZOOM_FOC
|
||||
count--;
|
||||
}
|
||||
|
||||
if (count <= 0) {
|
||||
if (count == 0) {
|
||||
HILOG_DEBUG("The size of PointerIds(down) is invalid");
|
||||
return span;
|
||||
}
|
||||
@ -489,7 +487,7 @@ bool AccessibilityZoomGesture::IsTripleTaps()
|
||||
HILOG_DEBUG();
|
||||
|
||||
uint32_t upEventCount = 0;
|
||||
int32_t action = MMI::PointerEvent::POINTER_ACTION_UNKNOWN;
|
||||
int32_t action;
|
||||
for (auto &pointerEvent : cacheEvents_) {
|
||||
action = pointerEvent->GetPointerAction();
|
||||
if (action == MMI::PointerEvent::POINTER_ACTION_UP) {
|
||||
|
@ -151,11 +151,10 @@ void AccessibleAbilityManagerService::OnAddSystemAbility(int32_t systemAbilityId
|
||||
}
|
||||
|
||||
dependentServicesStatus_[systemAbilityId] = true;
|
||||
for (auto &iter : dependentServicesStatus_) {
|
||||
if (iter.second == false) {
|
||||
HILOG_DEBUG("Not all the dependence is ready!");
|
||||
return;
|
||||
}
|
||||
if (std::any_of(dependentServicesStatus_.begin(), dependentServicesStatus_.end(),
|
||||
[](const std::map<int32_t, bool>::value_type &status) { return !status.second; })) {
|
||||
HILOG_DEBUG("Not all the dependence is ready!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Init() == false) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user