修正codecheck问题

Signed-off-by: Mupceet <laiguizhong@huawei.com>
This commit is contained in:
Mupceet 2022-06-06 11:58:29 +08:00
parent 9ac5d8a4ba
commit 1b5e23e5ed
32 changed files with 803 additions and 809 deletions

View File

@ -162,7 +162,6 @@ void AccessibilityConfig::Impl::SetCaptionProperty(const CaptionProperty& captio
return;
}
serviceProxy_->SetCaptionProperty(caption);
return;
}
void AccessibilityConfig::Impl::SetCaptionState(const bool state)
@ -174,7 +173,6 @@ void AccessibilityConfig::Impl::SetCaptionState(const bool state)
return;
}
serviceProxy_->SetCaptionState(state);
return;
}
void AccessibilityConfig::Impl::NotifyCaptionStateChanged(
@ -296,7 +294,6 @@ void AccessibilityConfig::Impl::SetShortKeyState(const bool state)
return;
}
serviceProxy_->SetShortKeyState(state);
return;
}
void AccessibilityConfig::Impl::SetMouseKeyState(const bool state)
@ -308,7 +305,6 @@ void AccessibilityConfig::Impl::SetMouseKeyState(const bool state)
return;
}
serviceProxy_->SetMouseKeyState(state);
return;
}
bool AccessibilityConfig::Impl::GetScreenMagnificationState(bool &state)
@ -675,7 +671,6 @@ void AccessibilityConfig::Impl::SetMouseAutoClick(const int32_t time)
return;
}
serviceProxy_->SetMouseAutoClick(time);
return;
}
void AccessibilityConfig::Impl::SetShortkeyTarget(const std::string& name)
@ -687,7 +682,6 @@ void AccessibilityConfig::Impl::SetShortkeyTarget(const std::string& name)
return;
}
serviceProxy_->SetShortkeyTarget(name);
return;
}
bool AccessibilityConfig::Impl::GetMouseAutoClick(int32_t &time)
@ -851,7 +845,6 @@ void AccessibilityConfig::Impl::SetHighContrastTextState(const bool state)
return;
}
serviceProxy_->SetHighContrastTextState(state);
return;
}
void AccessibilityConfig::Impl::SetInvertColorState(const bool state)
@ -863,7 +856,6 @@ void AccessibilityConfig::Impl::SetInvertColorState(const bool state)
return;
}
serviceProxy_->SetInvertColorState(state);
return;
}
void AccessibilityConfig::Impl::SetDaltonizationColorFilter(const DALTONIZATION_TYPE type)
@ -875,7 +867,6 @@ void AccessibilityConfig::Impl::SetDaltonizationColorFilter(const DALTONIZATION_
return;
}
serviceProxy_->SetDaltonizationColorFilter(type);
return;
}
void AccessibilityConfig::Impl::SetContentTimeout(const uint32_t timer)
@ -887,7 +878,6 @@ void AccessibilityConfig::Impl::SetContentTimeout(const uint32_t timer)
return;
}
serviceProxy_->SetContentTimeout(timer);
return;
}
void AccessibilityConfig::Impl::SetAnimationOffState(const bool state)
@ -899,7 +889,6 @@ void AccessibilityConfig::Impl::SetAnimationOffState(const bool state)
return;
}
serviceProxy_->SetAnimationOffState(state);
return;
}
void AccessibilityConfig::Impl::SetBrightnessDiscount(const float brightness)
@ -911,7 +900,6 @@ void AccessibilityConfig::Impl::SetBrightnessDiscount(const float brightness)
return;
}
serviceProxy_->SetBrightnessDiscount(brightness);
return;
}
void AccessibilityConfig::Impl::SetAudioMonoState(const bool state)
@ -923,7 +911,6 @@ void AccessibilityConfig::Impl::SetAudioMonoState(const bool state)
return;
}
serviceProxy_->SetAudioMonoState(state);
return;
}
void AccessibilityConfig::Impl::SetAudioBalance(const float balance)
@ -935,7 +922,6 @@ void AccessibilityConfig::Impl::SetAudioBalance(const float balance)
return;
}
serviceProxy_->SetAudioBalance(balance);
return;
}
bool AccessibilityConfig::Impl::GetInvertColorState(bool &state)

View File

@ -152,8 +152,6 @@ public:
* @return
*/
void OnAccessibleAbilityManagerStateChanged(const uint32_t stateType);
private:
class AccessibleAbilityManagerStateObserverImpl : public AccessibleAbilityManagerStateObserverStub {
public:

View File

@ -76,6 +76,7 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
size_t startPos = 0;
abConfig.SetScreenMagnificationState(data[startPos++] & 0x01);
abConfig.SetShortKeyState(data[startPos++] & 0x01);
abConfig.SetMouseKeyState(data[startPos++] & 0x01);
abConfig.SetCaptionState(data[startPos++] & 0x01);
abConfig.SetHighContrastTextState(data[startPos++] & 0x01);

View File

@ -32,6 +32,7 @@ ohos_shared_library("accessibility") {
"./src/napi_accessibility_gesture_pos.cpp",
"./src/napi_accessibility_system_ability_client.cpp",
"./src/napi_accessibility_utils.cpp",
"./src/napi_accessibility_config_observer.cpp",
"./src/native_module.cpp",
]
@ -69,7 +70,7 @@ group("napi_packages") {
deps = [
":accessibility",
"//base/accessibility/interfaces/kits/napi/accessibility_config:config_napi",
"//base/accessibility/interfaces/kits/napi/accessibility_extension:accessibilityextension_napi",
"//base/accessibility/interfaces/kits/napi/accessibility_extension:accessibilityextensionability_napi",
"//base/accessibility/interfaces/kits/napi/accessibility_extension_context:accessibilityextensioncontext_napi",
"//base/accessibility/interfaces/kits/napi/accessibility_extension_module_loader:accessibility_extension_module",
]

View File

@ -19,6 +19,7 @@
#include <vector>
#include <map>
#include "napi_accessibility_utils.h"
#include "napi_accessibility_config_observer.h"
#include "napi/native_api.h"
#include "napi/native_node_api.h"
#include "accessibility_config.h"
@ -35,7 +36,7 @@ struct NAccessibilityConfigStruct {
bool setCaptionStateReturn_ = false;
bool result_ = false;
std::vector<std::shared_ptr<ConfigListener>> configListener_;
std::vector<std::shared_ptr<NAccessibilityConfigObserver>> configListener_;
};
class EnableAbilityListsObserver : public OHOS::AccessibilityConfig::AccessibilityEnableAbilityListsObserver {
public:
@ -128,7 +129,7 @@ public:
static napi_value SubscribeConfigObserver(napi_env env, napi_callback_info info);
static napi_value UnSubscribeConfigObserver(napi_env env, napi_callback_info info);
static std::vector<std::shared_ptr<EnableAbilityListsObserver>> enableAbilityListsObservers_;
static std::vector<std::shared_ptr<ConfigListener>> configListeners_;
static std::vector<std::shared_ptr<NAccessibilityConfigObserver>> configListeners_;
private:
static void SetConfigComplete(napi_env env, napi_status status, void* data);
static void SetConfigExecute(napi_env env, void* data);

View File

@ -23,7 +23,7 @@ using namespace OHOS;
using namespace OHOS::Accessibility;
using namespace OHOS::AccessibilityConfig;
std::vector<std::shared_ptr<ConfigListener>> NAccessibilityConfig::configListeners_ = {};
std::vector<std::shared_ptr<NAccessibilityConfigObserver>> NAccessibilityConfig::configListeners_ = {};
std::vector<std::shared_ptr<EnableAbilityListsObserver>> NAccessibilityConfig::enableAbilityListsObservers_ = {};
napi_value NAccessibilityConfig::EnableAbility(napi_env env, napi_callback_info info)
@ -220,7 +220,7 @@ napi_value NAccessibilityConfig::UnsubscribeState(napi_env env, napi_callback_in
void NAccessibilityConfig::SetConfigComplete(napi_env env, napi_status status, void* data)
{
HILOG_INFO("start");
NAccessibilityConfigData* callbackInfo = (NAccessibilityConfigData*)data;
NAccessibilityConfigData* callbackInfo = static_cast<NAccessibilityConfigData*>(data);
napi_value result[ARGS_SIZE_TWO] = {0};
napi_value callback = 0;
napi_value undefined = 0;
@ -244,106 +244,105 @@ void NAccessibilityConfig::SetConfigComplete(napi_env env, napi_status status, v
callbackInfo = nullptr;
}
void NAccessibilityConfig::SetConfigExecute(napi_env env, void* data) {
void NAccessibilityConfig::SetConfigExecute(napi_env env, void* data)
{
HILOG_INFO("start");
NAccessibilityConfigData* callbackInfo = (NAccessibilityConfigData*)data;
NAccessibilityConfigData* callbackInfo = static_cast<NAccessibilityConfigData*>(data);
auto &instance = Singleton<OHOS::AccessibilityConfig::AccessibilityConfig>::GetInstance();
switch (callbackInfo->id_)
{
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRASTE_TEXT:
instance.SetHighContrastTextState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
instance.SetInvertColorState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ANIMATION_OFF:
instance.SetAnimationOffState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SCREEN_MAGNIFICATION:
instance.SetScreenMagnificationState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_MONO:
instance.SetAudioMonoState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_KEY:
instance.SetMouseKeyState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY:
instance.SetShortKeyState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STATE:
instance.SetCaptionState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CONTENT_TIMEOUT:
instance.SetContentTimeout(callbackInfo->uint32Config_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_AUTOCLICK:
instance.SetMouseAutoClick(callbackInfo->int32Config_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_BALANCE:
instance.SetAudioBalance(callbackInfo->floatConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_BRIGHTNESS_DISCOUNT:
instance.SetBrightnessDiscount(callbackInfo->floatConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_DALTONIZATION_COLOR_FILTER:
{
auto filter = ConvertStringToDaltonizationTypes(callbackInfo->stringConfig_);
instance.SetDaltonizationColorFilter(filter);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY_TARGET:
instance.SetShortkeyTarget(callbackInfo->stringConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STYLE:
instance.SetCaptionProperty(callbackInfo->captionProperty_);
break;
default:
break;
switch (callbackInfo->id_) {
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRASTE_TEXT:
instance.SetHighContrastTextState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
instance.SetInvertColorState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ANIMATION_OFF:
instance.SetAnimationOffState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SCREEN_MAGNIFICATION:
instance.SetScreenMagnificationState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_MONO:
instance.SetAudioMonoState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_KEY:
instance.SetMouseKeyState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY:
instance.SetShortKeyState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STATE:
instance.SetCaptionState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CONTENT_TIMEOUT:
instance.SetContentTimeout(callbackInfo->uint32Config_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_AUTOCLICK:
instance.SetMouseAutoClick(callbackInfo->int32Config_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_BALANCE:
instance.SetAudioBalance(callbackInfo->floatConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_BRIGHTNESS_DISCOUNT:
instance.SetBrightnessDiscount(callbackInfo->floatConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_DALTONIZATION_COLOR_FILTER:
{
auto filter = ConvertStringToDaltonizationTypes(callbackInfo->stringConfig_);
instance.SetDaltonizationColorFilter(filter);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY_TARGET:
instance.SetShortkeyTarget(callbackInfo->stringConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STYLE:
instance.SetCaptionProperty(callbackInfo->captionProperty_);
break;
default:
break;
}
}
void NAccessibilityConfig::GetConfigComplete(napi_env env, napi_status status, void* data)
{
HILOG_INFO("start");
NAccessibilityConfigData* callbackInfo = (NAccessibilityConfigData*)data;
NAccessibilityConfigData* callbackInfo = static_cast<NAccessibilityConfigData*>(data);
napi_value result[ARGS_SIZE_TWO] = {0};
napi_value callback = 0;
napi_value undefined = 0;
napi_get_undefined(env, &undefined);
HILOG_INFO("callbackInfo->id_ = %{public}d", callbackInfo->id_);
switch (callbackInfo->id_)
{
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRASTE_TEXT:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ANIMATION_OFF:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SCREEN_MAGNIFICATION:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_MONO:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_KEY:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STATE:
napi_get_boolean(env, callbackInfo->boolConfig_, &result[PARAM1]);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CONTENT_TIMEOUT:
napi_create_uint32(env, callbackInfo->uint32Config_, &result[PARAM1]);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_AUTOCLICK:
napi_create_int32(env, callbackInfo->int32Config_, &result[PARAM1]);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_BALANCE:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_BRIGHTNESS_DISCOUNT:
napi_create_double(env, static_cast<double>(callbackInfo->floatConfig_), &result[PARAM1]);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_DALTONIZATION_COLOR_FILTER:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY_TARGET:
napi_create_string_utf8(env, callbackInfo->stringConfig_.c_str(), NAPI_AUTO_LENGTH, &result[PARAM1]);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STYLE:
napi_create_object(env, &result[PARAM1]);
ConvertCaptionPropertyToJS(env, result[PARAM1], callbackInfo->captionProperty_);
break;
default:
break;
switch (callbackInfo->id_) {
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRASTE_TEXT:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ANIMATION_OFF:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SCREEN_MAGNIFICATION:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_MONO:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_KEY:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STATE:
napi_get_boolean(env, callbackInfo->boolConfig_, &result[PARAM1]);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CONTENT_TIMEOUT:
napi_create_uint32(env, callbackInfo->uint32Config_, &result[PARAM1]);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_AUTOCLICK:
napi_create_int32(env, callbackInfo->int32Config_, &result[PARAM1]);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_BALANCE:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_BRIGHTNESS_DISCOUNT:
napi_create_double(env, static_cast<double>(callbackInfo->floatConfig_), &result[PARAM1]);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_DALTONIZATION_COLOR_FILTER:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY_TARGET:
napi_create_string_utf8(env, callbackInfo->stringConfig_.c_str(), NAPI_AUTO_LENGTH, &result[PARAM1]);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STYLE:
napi_create_object(env, &result[PARAM1]);
ConvertCaptionPropertyToJS(env, result[PARAM1], callbackInfo->captionProperty_);
break;
default:
break;
}
if (callbackInfo->callback_) {
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
@ -361,63 +360,63 @@ void NAccessibilityConfig::GetConfigComplete(napi_env env, napi_status status, v
callbackInfo = nullptr;
}
void NAccessibilityConfig::GetConfigExecute(napi_env env, void* data) {
void NAccessibilityConfig::GetConfigExecute(napi_env env, void* data)
{
HILOG_INFO("start");
NAccessibilityConfigData* callbackInfo = (NAccessibilityConfigData*)data;
NAccessibilityConfigData* callbackInfo = static_cast<NAccessibilityConfigData*>(data);
auto &instance = Singleton<OHOS::AccessibilityConfig::AccessibilityConfig>::GetInstance();
switch (callbackInfo->id_)
{
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRASTE_TEXT:
callbackInfo->ret_ = instance.GetHighContrastTextState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
callbackInfo->ret_ = instance.GetInvertColorState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ANIMATION_OFF:
callbackInfo->ret_ = instance.GetAnimationOffState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SCREEN_MAGNIFICATION:
callbackInfo->ret_ = instance.GetScreenMagnificationState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_MONO:
callbackInfo->ret_ = instance.GetAudioMonoState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_KEY:
callbackInfo->ret_ = instance.GetMouseKeyState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY:
callbackInfo->ret_ = instance.GetShortKeyState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STATE:
callbackInfo->ret_ = instance.GetCaptionState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CONTENT_TIMEOUT:
callbackInfo->ret_ = instance.GetContentTimeout(callbackInfo->uint32Config_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_AUTOCLICK:
callbackInfo->ret_ = instance.GetMouseAutoClick(callbackInfo->int32Config_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_BALANCE:
callbackInfo->ret_ = instance.GetAudioBalance(callbackInfo->floatConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_BRIGHTNESS_DISCOUNT:
callbackInfo->ret_ = instance.GetBrightnessDiscount(callbackInfo->floatConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_DALTONIZATION_COLOR_FILTER:
{
OHOS::AccessibilityConfig::DALTONIZATION_TYPE type;
callbackInfo->ret_ = instance.GetDaltonizationColorFilter(type);
callbackInfo->stringConfig_ = ConvertDaltonizationTypeToString(type);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY_TARGET:
callbackInfo->ret_ = instance.GetShortkeyTarget(callbackInfo->stringConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STYLE:
callbackInfo->ret_ = instance.GetCaptionProperty(callbackInfo->captionProperty_);
break;
default:
break;
switch (callbackInfo->id_) {
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRASTE_TEXT:
callbackInfo->ret_ = instance.GetHighContrastTextState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
callbackInfo->ret_ = instance.GetInvertColorState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ANIMATION_OFF:
callbackInfo->ret_ = instance.GetAnimationOffState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SCREEN_MAGNIFICATION:
callbackInfo->ret_ = instance.GetScreenMagnificationState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_MONO:
callbackInfo->ret_ = instance.GetAudioMonoState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_KEY:
callbackInfo->ret_ = instance.GetMouseKeyState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY:
callbackInfo->ret_ = instance.GetShortKeyState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STATE:
callbackInfo->ret_ = instance.GetCaptionState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CONTENT_TIMEOUT:
callbackInfo->ret_ = instance.GetContentTimeout(callbackInfo->uint32Config_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_AUTOCLICK:
callbackInfo->ret_ = instance.GetMouseAutoClick(callbackInfo->int32Config_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_BALANCE:
callbackInfo->ret_ = instance.GetAudioBalance(callbackInfo->floatConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_BRIGHTNESS_DISCOUNT:
callbackInfo->ret_ = instance.GetBrightnessDiscount(callbackInfo->floatConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_DALTONIZATION_COLOR_FILTER:
{
OHOS::AccessibilityConfig::DALTONIZATION_TYPE type;
callbackInfo->ret_ = instance.GetDaltonizationColorFilter(type);
callbackInfo->stringConfig_ = ConvertDaltonizationTypeToString(type);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY_TARGET:
callbackInfo->ret_ = instance.GetShortkeyTarget(callbackInfo->stringConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STYLE:
callbackInfo->ret_ = instance.GetCaptionProperty(callbackInfo->captionProperty_);
break;
default:
break;
}
}
@ -434,57 +433,56 @@ napi_value NAccessibilityConfig::SetConfig(napi_env env, napi_callback_info info
NAPI_CALL(env, napi_unwrap(env, jsthis, reinterpret_cast<void**>(&obj)));
HILOG_INFO("ConfigID = %{public}d", obj->GetConfigId());
switch (obj->GetConfigId())
{
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRASTE_TEXT:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ANIMATION_OFF:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SCREEN_MAGNIFICATION:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_MONO:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_KEY:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STATE:
{
bool state = false;
ParseBool(env, state, parameters[PARAM0]);
callbackInfo->boolConfig_ = state;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CONTENT_TIMEOUT:
{
uint32_t timeout = 0;
ParseUint32(env, timeout, parameters[PARAM0]);
callbackInfo->uint32Config_ = timeout;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_AUTOCLICK:
{
int32_t time = 0;
ParseInt32(env, time, parameters[PARAM0]);
callbackInfo->int32Config_ = time;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_BALANCE:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_BRIGHTNESS_DISCOUNT:
{
double doubleTemp = 0;
napi_get_value_double(env, parameters[PARAM0], &doubleTemp);
callbackInfo->floatConfig_ = static_cast<float>(doubleTemp);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_DALTONIZATION_COLOR_FILTER:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY_TARGET:
{
std::string target = "";
ParseString(env, target, parameters[PARAM0]);
callbackInfo->stringConfig_ = target;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STYLE:
ConvertObjToCaptionProperty(env, parameters[PARAM0], &callbackInfo->captionProperty_);
break;
default:
break;
switch (obj->GetConfigId()) {
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRASTE_TEXT:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ANIMATION_OFF:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SCREEN_MAGNIFICATION:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_MONO:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_KEY:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STATE:
{
bool state = false;
ParseBool(env, state, parameters[PARAM0]);
callbackInfo->boolConfig_ = state;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CONTENT_TIMEOUT:
{
uint32_t timeout = 0;
ParseUint32(env, timeout, parameters[PARAM0]);
callbackInfo->uint32Config_ = timeout;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_AUTOCLICK:
{
int32_t time = 0;
ParseInt32(env, time, parameters[PARAM0]);
callbackInfo->int32Config_ = time;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_BALANCE:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_BRIGHTNESS_DISCOUNT:
{
double doubleTemp = 0;
napi_get_value_double(env, parameters[PARAM0], &doubleTemp);
callbackInfo->floatConfig_ = static_cast<float>(doubleTemp);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_DALTONIZATION_COLOR_FILTER:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY_TARGET:
{
std::string target = "";
ParseString(env, target, parameters[PARAM0]);
callbackInfo->stringConfig_ = target;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STYLE:
ConvertObjToCaptionProperty(env, parameters[PARAM0], &callbackInfo->captionProperty_);
break;
default:
break;
}
callbackInfo->id_ = obj->GetConfigId();
@ -557,7 +555,7 @@ napi_value NAccessibilityConfig::SubscribeConfigObserver(napi_env env, napi_call
NAccessibilityConfigClass* obj;
NAPI_CALL(env, napi_unwrap(env, jsthis, reinterpret_cast<void**>(&obj)));
std::shared_ptr<ConfigListener> observer = std::make_shared<ConfigListener>();
std::shared_ptr<NAccessibilityConfigObserver> observer = std::make_shared<NAccessibilityConfigObserver>();
napi_ref handler = nullptr;
napi_create_reference(env, parameters[PARAM0], 1, &handler);
observer->SetHandler(handler);

View File

@ -27,7 +27,7 @@ EXTERN_C_START
/*
* function for module exports
*/
napi_property_descriptor configDesc[] = {
static napi_property_descriptor configDesc[] = {
DECLARE_NAPI_FUNCTION("set", NAccessibilityConfig::SetConfig),
DECLARE_NAPI_FUNCTION("get", NAccessibilityConfig::GetConfig),
DECLARE_NAPI_FUNCTION("on", NAccessibilityConfig::SubscribeConfigObserver),

View File

@ -34,7 +34,7 @@ gen_js_obj("accessibility_extension_abc") {
dep = ":gen_accessibility_extension_abc"
}
ohos_shared_library("accessibilityextension_napi") {
ohos_shared_library("accessibilityextensionability_napi") {
sources = [ "accessibility_extension_module.cpp" ]
deps = [

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
class AccessibilityExtension {
class AccessibilityExtensionAbility {
onConnect() {
console.log('onConnect');
}
@ -32,4 +32,4 @@ class AccessibilityExtension {
}
}
export default AccessibilityExtension
export default AccessibilityExtensionAbility

View File

@ -20,18 +20,18 @@ extern const char _binary_accessibility_extension_js_end[];
extern const char _binary_accessibility_extension_abc_start[];
extern const char _binary_accessibility_extension_abc_end[];
extern "C" __attribute__((constructor)) void NAPI_application_AccessibilityExtension_AutoRegister()
extern "C" __attribute__((constructor)) void NAPI_application_AccessibilityExtensionAbility_AutoRegister()
{
auto moduleManager = NativeModuleManager::GetInstance();
NativeModule newModuleInfo = {
.name = "application.AccessibilityExtension",
.fileName = "application/libaccessibilityextension_napi.so/AccessibilityExtension.js",
.name = "application.AccessibilityExtensionAbility",
.fileName = "application/libaccessibilityextensionability_napi.so/AccessibilityExtensionAbility.js",
};
moduleManager->Register(&newModuleInfo);
}
extern "C" __attribute__((visibility("default"))) void NAPI_application_AccessibilityExtension_GetJSCode(
extern "C" __attribute__((visibility("default"))) void NAPI_application_AccessibilityExtensionAbility_GetJSCode(
const char **buf, int *bufLen)
{
if (buf != nullptr) {
@ -44,7 +44,7 @@ extern "C" __attribute__((visibility("default"))) void NAPI_application_Accessib
}
// accessibility extension JS register
extern "C" __attribute__((visibility("default"))) void NAPI_application_AccessibilityExtension_GetABCCode(
extern "C" __attribute__((visibility("default"))) void NAPI_application_AccessibilityExtensionAbility_GetABCCode(
const char **buf, int *buflen)
{
if (buf != nullptr) {

View File

@ -399,7 +399,8 @@ private:
GetWindowsAsync(engine, lastParam);
}
NativeValue* GetWindowsAsync(NativeEngine& engine, NativeValue* lastParam) {
NativeValue* GetWindowsAsync(NativeEngine& engine, NativeValue* lastParam)
{
HILOG_INFO("called.");
AsyncTask::CompleteCallback complete =
[weak = context_](NativeEngine& engine, AsyncTask& task, int32_t status) {
@ -432,7 +433,8 @@ private:
return result;
}
NativeValue* GetWindowsByDisplayIdAsync(NativeEngine& engine, NativeValue* lastParam, uint64_t displayId) {
NativeValue* GetWindowsByDisplayIdAsync(NativeEngine& engine, NativeValue* lastParam, uint64_t displayId)
{
HILOG_INFO("called.");
AsyncTask::CompleteCallback complete =
[weak = context_, displayId](NativeEngine& engine, AsyncTask& task, int32_t status) {

View File

@ -0,0 +1,90 @@
/*
* 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.
*/
#ifndef NAPI_ACCESSIBILITY_CONFIG_OBSERVER_H
#define NAPI_ACCESSIBILITY_CONFIG_OBSERVER_H
#include <map>
#include <string>
#include "accessibility_config.h"
#include "napi/native_api.h"
#include "napi/native_node_api.h"
const uint32_t CONFIG_START_WORK_ARGS_SIZE = 2;
class NAccessibilityConfigObserver : public OHOS::AccessibilityConfig::AccessibilityConfigObserver {
public:
NAccessibilityConfigObserver() = default;
void NotifyStateChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, bool enabled);
void NotifyStringChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, const std::string &value);
void NotifyIntChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, int32_t value);
void NotifyUintChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, uint32_t value);
void NotifyFloatChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, float value);
void NotifyPropertyChanged2JS(
const OHOS::AccessibilityConfig::CONFIG_ID id, OHOS::AccessibilityConfig::CaptionProperty caption);
napi_value StartWork(napi_env env, size_t functionIndex, napi_value (&args)[CONFIG_START_WORK_ARGS_SIZE]);
virtual void OnConfigChanged(
const OHOS::AccessibilityConfig::CONFIG_ID id, const OHOS::AccessibilityConfig::ConfigValue& value) override;
void SetEnv(const napi_env env)
{
env_ = env;
}
napi_env GetEnv() const
{
return env_;
}
void SetHandler(const napi_ref handler)
{
handlerRef_ = handler;
}
napi_ref GetHandler() const
{
return handlerRef_;
}
void SetConfigId(const OHOS::AccessibilityConfig::CONFIG_ID id)
{
configId_ = id;
}
OHOS::AccessibilityConfig::CONFIG_ID GetConfigId() const
{
return configId_;
}
private:
static void NotifyStateChangedJS(napi_env env, bool enabled, const OHOS::AccessibilityConfig::CONFIG_ID id,
napi_ref handlerRef);
static void NotifyPropertyChangedJS(napi_env env, OHOS::AccessibilityConfig::CaptionProperty caption,
const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef);
static void NotifyStringChanged2JSInner(napi_env env, const std::string& value,
const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef);
static void NotifyIntChanged2JSInner(
napi_env env, int32_t value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef);
static void NotifyUintChanged2JSInner(
napi_env env, uint32_t value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef);
static void NotifyFloatChanged2JSInner(
napi_env env, float value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef);
private:
napi_ref handlerRef_ = nullptr;
napi_env env_ = nullptr;
OHOS::AccessibilityConfig::CONFIG_ID configId_ = OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ID_MAX;
};
#endif // NAPI_ACCESSIBILITY_CONFIG_OBSERVER_H

View File

@ -25,6 +25,7 @@
#include "accessibility_state_event.h"
#include "accessibility_ability_info.h"
#include "napi_accessibility_utils.h"
#include "napi_accessibility_config_observer.h"
const uint32_t START_WORK_ARGS_SIZE = 2;
class StateListener : public OHOS::Accessibility::AccessibilityStateObserver {
@ -85,7 +86,7 @@ struct NAccessibilitySystemAbilityClient {
std::string eventType_ = "";
std::map<std::string, std::vector<std::shared_ptr<StateListener>>> stateListeners_;
std::vector<std::shared_ptr<ConfigListener>> captionListener_;
std::vector<std::shared_ptr<NAccessibilityConfigObserver>> captionListener_;
};
class NAccessibilityClient {
@ -127,7 +128,7 @@ public:
static thread_local napi_ref aaStyleConsRef_;
static std::map<std::string, std::vector<std::shared_ptr<StateListener>>> stateListeners_;
static std::vector<std::shared_ptr<ConfigListener>> captionListeners_;
static std::vector<std::shared_ptr<NAccessibilityConfigObserver>> captionListeners_;
private:
NAccessibilityClient() = default;

View File

@ -45,7 +45,6 @@ constexpr int32_t PARAM2 = 2;
constexpr int32_t CODE_SUCCESS = 0;
constexpr int32_t CODE_FAILED = -1;
constexpr int32_t CHAE_BUFFER_MAX = 1024;
const uint32_t CONFIG_START_WORK_ARGS_SIZE = 2;
std::string GetStringFromNAPI(napi_env env, napi_value value);
bool ParseBool(napi_env env, bool& param, napi_value args);
@ -128,68 +127,4 @@ struct StateCallbackInfo: public AccessibilityCallbackInfo {
struct CaptionCallbackInfo: public AccessibilityCallbackInfo {
OHOS::AccessibilityConfig::CaptionProperty caption_;
};
class ConfigListener : public OHOS::AccessibilityConfig::AccessibilityConfigObserver {
public:
ConfigListener() = default;
void NotifyStateChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, bool enabled);
void NotifyStringChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, const std::string &value);
void NotifyIntChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, int32_t value);
void NotifyUintChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, uint32_t value);
void NotifyFloatChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, float value);
void NotifyPropertyChanged2JS(
const OHOS::AccessibilityConfig::CONFIG_ID id, OHOS::AccessibilityConfig::CaptionProperty caption);
napi_value StartWork(napi_env env, size_t functionIndex, napi_value (&args)[CONFIG_START_WORK_ARGS_SIZE]);
virtual void OnConfigChanged(
const OHOS::AccessibilityConfig::CONFIG_ID id, const OHOS::AccessibilityConfig::ConfigValue& value) override;
void SetEnv(const napi_env env)
{
env_ = env;
}
napi_env GetEnv() const
{
return env_;
}
void SetHandler(const napi_ref handler)
{
handlerRef_ = handler;
}
napi_ref GetHandler() const
{
return handlerRef_;
}
void SetConfigId(const OHOS::AccessibilityConfig::CONFIG_ID id)
{
configId_ = id;
}
OHOS::AccessibilityConfig::CONFIG_ID GetConfigId() const
{
return configId_;
}
private:
static void NotifyStateChangedJS(napi_env env, bool enabled, const OHOS::AccessibilityConfig::CONFIG_ID id,
napi_ref handlerRef);
static void NotifyPropertyChangedJS(napi_env env, OHOS::AccessibilityConfig::CaptionProperty caption,
const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef);
static void NotifyStringChanged2JSInner(napi_env env, const std::string& value,
const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef);
static void NotifyIntChanged2JSInner(
napi_env env, int32_t value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef);
static void NotifyUintChanged2JSInner(
napi_env env, uint32_t value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef);
static void NotifyFloatChanged2JSInner(
napi_env env, float value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef);
private:
napi_ref handlerRef_ = nullptr;
napi_env env_ = nullptr;
OHOS::AccessibilityConfig::CONFIG_ID configId_ = OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ID_MAX;
};
#endif // NAPI_ACCESSIBILITY_UTILS_H

View File

@ -0,0 +1,366 @@
/*
* 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 "napi_accessibility_utils.h"
#include "napi_accessibility_config_observer.h"
#include <vector>
#include <uv.h>
#include "hilog_wrapper.h"
#include "napi/native_api.h"
#include "napi/native_node_api.h"
using namespace OHOS;
using namespace OHOS::Accessibility;
using namespace OHOS::AccessibilityConfig;
napi_value NAccessibilityConfigObserver::StartWork(
napi_env env, size_t functionIndex, napi_value (&args)[CONFIG_START_WORK_ARGS_SIZE])
{
HILOG_INFO("start");
int32_t id = 0;
ParseInt32(env, id, args[0]);
configId_ = static_cast<OHOS::AccessibilityConfig::CONFIG_ID>(id);
napi_create_reference(env, args[functionIndex], 1, &handlerRef_);
env_ = env;
napi_value result = {0};
return result;
}
void NAccessibilityConfigObserver::NotifyStateChangedJS(napi_env env, bool enabled,
const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef)
{
HILOG_INFO("start");
StateCallbackInfo *callbackInfo = new StateCallbackInfo();
callbackInfo->state_ = enabled;
callbackInfo->env_ = env;
callbackInfo->ref_ = handlerRef;
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env, &loop);
uv_work_t *work = new uv_work_t;
work->data = static_cast<StateCallbackInfo*>(callbackInfo);
uv_queue_work(
loop,
work,
[](uv_work_t *work) {},
[](uv_work_t *work, int status) {
StateCallbackInfo *callbackInfo = static_cast<StateCallbackInfo*>(work->data);
napi_value jsEvent;
napi_get_boolean(callbackInfo->env_, callbackInfo->state_, &jsEvent);
napi_value handler = nullptr;
napi_value callResult = nullptr;
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &handler);
napi_value undefined = nullptr;
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
int32_t result;
napi_get_value_int32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyStateChangedJS napi_call_function result[%{public}d]", result);
delete callbackInfo;
callbackInfo = nullptr;
delete work;
work = nullptr;
});
}
void NAccessibilityConfigObserver::OnConfigChanged(const CONFIG_ID id, const ConfigValue &value)
{
HILOG_INFO("start");
switch (id) {
case CONFIG_CAPTION_STATE:
NotifyStateChanged2JS(id, value.captionState);
break;
case CONFIG_CAPTION_STYLE:
NotifyPropertyChanged2JS(id, value.captionStyle);
break;
case CONFIG_SCREEN_MAGNIFICATION:
NotifyStateChanged2JS(id, value.screenMagnifier);
break;
case CONFIG_MOUSE_KEY:
NotifyStateChanged2JS(id, value.mouseKey);
break;
case CONFIG_SHORT_KEY:
NotifyStateChanged2JS(id, value.shortkey);
break;
case CONFIG_SHORT_KEY_TARGET:
NotifyStringChanged2JS(id, value.shortkey_target);
break;
case CONFIG_MOUSE_AUTOCLICK:
NotifyIntChanged2JS(id, value.mouseAutoClick);
break;
case CONFIG_DALTONIZATION_COLOR_FILTER:
NotifyUintChanged2JS(id, value.daltonizationColorFilter);
break;
case CONFIG_CONTENT_TIMEOUT:
NotifyUintChanged2JS(id, value.contentTimeout);
break;
case CONFIG_BRIGHTNESS_DISCOUNT:
NotifyFloatChanged2JS(id, value.brightnessDiscount);
break;
case CONFIG_AUDIO_BALANCE:
NotifyFloatChanged2JS(id, value.audioBalance);
break;
default:
break;
}
}
void NAccessibilityConfigObserver::NotifyPropertyChangedJS(napi_env env,
OHOS::AccessibilityConfig::CaptionProperty caption,
const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef)
{
HILOG_INFO("start");
CaptionCallbackInfo *callbackInfo = new CaptionCallbackInfo();
callbackInfo->caption_ = caption;
callbackInfo->env_ = env;
callbackInfo->ref_ = handlerRef;
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env, &loop);
uv_work_t *work = new uv_work_t;
work->data = static_cast<CaptionCallbackInfo*>(callbackInfo);
uv_queue_work(
loop,
work,
[](uv_work_t *work) {},
[](uv_work_t *work, int status) {
CaptionCallbackInfo *callbackInfo = static_cast<CaptionCallbackInfo*>(work->data);
napi_value jsEvent;
napi_create_object(callbackInfo->env_, &jsEvent);
ConvertCaptionPropertyToJS(callbackInfo->env_, jsEvent, callbackInfo->caption_);
napi_value handler = nullptr;
napi_value callResult = nullptr;
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &handler);
napi_value undefined = nullptr;
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
int32_t result;
napi_get_value_int32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyPropertyChangedJS napi_call_function result[%{public}d]", result);
delete callbackInfo;
callbackInfo = nullptr;
delete work;
work = nullptr;
});
}
void NAccessibilityConfigObserver::NotifyStateChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, bool enabled)
{
if (GetConfigId() == id) {
NotifyStateChangedJS(GetEnv(), enabled, id, GetHandler());
}
}
void NAccessibilityConfigObserver::NotifyPropertyChanged2JS(
const OHOS::AccessibilityConfig::CONFIG_ID id, OHOS::AccessibilityConfig::CaptionProperty caption)
{
if (GetConfigId() == id) {
NotifyPropertyChangedJS(GetEnv(), caption, id, GetHandler());
}
}
void NAccessibilityConfigObserver::NotifyStringChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id,
const std::string &value)
{
if (GetConfigId() == id) {
NotifyStringChanged2JSInner(GetEnv(), value, id, GetHandler());
}
}
void NAccessibilityConfigObserver::NotifyUintChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, uint32_t value)
{
if (GetConfigId() == id) {
NotifyUintChanged2JSInner(GetEnv(), value, id, GetHandler());
}
}
void NAccessibilityConfigObserver::NotifyIntChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, int32_t value)
{
if (GetConfigId() == id) {
NotifyIntChanged2JSInner(GetEnv(), value, id, GetHandler());
}
}
void NAccessibilityConfigObserver::NotifyFloatChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, float value)
{
if (GetConfigId() == id) {
NotifyFloatChanged2JSInner(GetEnv(), value, id, GetHandler());
}
}
void NAccessibilityConfigObserver::NotifyStringChanged2JSInner(
napi_env env, const std::string& value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef)
{
HILOG_INFO("start");
StateCallbackInfo *callbackInfo = new StateCallbackInfo();
callbackInfo->stringValue_ = value;
callbackInfo->env_ = env;
callbackInfo->ref_ = handlerRef;
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env, &loop);
uv_work_t *work = new uv_work_t;
work->data = static_cast<StateCallbackInfo*>(callbackInfo);
uv_queue_work(
loop,
work,
[](uv_work_t *work) {},
[](uv_work_t *work, int status) {
StateCallbackInfo *callbackInfo = static_cast<StateCallbackInfo*>(work->data);
napi_value jsEvent;
napi_create_string_utf8(callbackInfo->env_,
callbackInfo->stringValue_.c_str(),
callbackInfo->stringValue_.length(),
&jsEvent);
napi_value handler = nullptr;
napi_value callResult = nullptr;
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &handler);
napi_value undefined = nullptr;
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
size_t result;
const uint32_t BUF_SIZE = 1024;
char buf[BUF_SIZE] = {0};
napi_get_value_string_utf8(callbackInfo->env_, callResult, buf, BUF_SIZE, &result);
HILOG_INFO("NotifyStringChanged2JSInner napi_call_function result[%{public}zu]", result);
delete callbackInfo;
callbackInfo = nullptr;
delete work;
work = nullptr;
});
}
void NAccessibilityConfigObserver::NotifyIntChanged2JSInner(
napi_env env, int32_t value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef)
{
HILOG_INFO("start");
StateCallbackInfo *callbackInfo = new StateCallbackInfo();
callbackInfo->int32Value_ = value;
callbackInfo->env_ = env;
callbackInfo->ref_ = handlerRef;
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env, &loop);
uv_work_t *work = new uv_work_t;
work->data = static_cast<StateCallbackInfo*>(callbackInfo);
uv_queue_work(
loop,
work,
[](uv_work_t *work) {},
[](uv_work_t *work, int status) {
StateCallbackInfo *callbackInfo = static_cast<StateCallbackInfo*>(work->data);
napi_value jsEvent;
napi_create_int32(callbackInfo->env_, callbackInfo->int32Value_, &jsEvent);
napi_value handler = nullptr;
napi_value callResult = nullptr;
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &handler);
napi_value undefined = nullptr;
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
int32_t result;
napi_get_value_int32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyIntChanged2JSInner napi_call_function result[%{public}d]", result);
delete callbackInfo;
callbackInfo = nullptr;
delete work;
work = nullptr;
});
}
void NAccessibilityConfigObserver::NotifyUintChanged2JSInner(
napi_env env, uint32_t value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef)
{
HILOG_INFO("start");
StateCallbackInfo *callbackInfo = new StateCallbackInfo();
callbackInfo->uint32Value_ = value;
callbackInfo->env_ = env;
callbackInfo->ref_ = handlerRef;
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env, &loop);
uv_work_t *work = new uv_work_t;
work->data = static_cast<StateCallbackInfo*>(callbackInfo);
uv_queue_work(
loop,
work,
[](uv_work_t *work) {},
[](uv_work_t *work, int status) {
StateCallbackInfo *callbackInfo = static_cast<StateCallbackInfo*>(work->data);
napi_value jsEvent;
napi_create_uint32(callbackInfo->env_, callbackInfo->uint32Value_, &jsEvent);
napi_value handler = nullptr;
napi_value callResult = nullptr;
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &handler);
napi_value undefined = nullptr;
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
uint32_t result;
napi_get_value_uint32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyUintChanged2JSInner napi_call_function result[%{public}d]", result);
delete callbackInfo;
callbackInfo = nullptr;
delete work;
work = nullptr;
});
}
void NAccessibilityConfigObserver::NotifyFloatChanged2JSInner(
napi_env env, float value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef)
{
HILOG_INFO("start");
StateCallbackInfo *callbackInfo = new StateCallbackInfo();
callbackInfo->floatValue_ = value;
callbackInfo->env_ = env;
callbackInfo->ref_ = handlerRef;
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env, &loop);
uv_work_t *work = new uv_work_t;
work->data = static_cast<StateCallbackInfo*>(callbackInfo);
uv_queue_work(
loop,
work,
[](uv_work_t *work) {},
[](uv_work_t *work, int status) {
StateCallbackInfo *callbackInfo = static_cast<StateCallbackInfo*>(work->data);
napi_value jsEvent;
napi_create_double(callbackInfo->env_, double(callbackInfo->floatValue_), &jsEvent);
napi_value handler = nullptr;
napi_value callResult = nullptr;
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &handler);
napi_value undefined = nullptr;
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
int32_t result;
napi_get_value_int32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyFloatChanged2JSInner napi_call_function result[%{public}d]", result);
delete callbackInfo;
callbackInfo = nullptr;
delete work;
work = nullptr;
});
}

View File

@ -372,7 +372,7 @@ napi_value NAccessibilityElement::FindElement(napi_env env, napi_callback_info i
}
callbackInfo->stringData_ = queryData;
return GetElementInfoByContent(callbackInfo);
case FindElementCondition::FIND_ELEMENT_CONDITION_FOCUS_TYPE:
case FindElementCondition::FIND_ELEMENT_CONDITION_FOCUS_TYPE:
if (!ParseString(env, queryData, argv[PARAM1])) {
HILOG_ERROR("ParseString for argv[1] failed");
return ErrorOperation(callbackInfo);
@ -1045,7 +1045,7 @@ napi_value NAccessibilityElement::GetElementInfoCheckable(NAccessibilityElementD
HILOG_DEBUG("GetElementInfoCheckable execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1087,7 +1087,7 @@ napi_value NAccessibilityElement::GetElementInfoChecked(NAccessibilityElementDat
HILOG_DEBUG("GetElementInfoChecked execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1129,7 +1129,7 @@ napi_value NAccessibilityElement::GetElementInfoFocusable(NAccessibilityElementD
HILOG_DEBUG("GetElementInfoFocusable execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1171,7 +1171,7 @@ napi_value NAccessibilityElement::GetElementInfoIsVisible(NAccessibilityElementD
HILOG_DEBUG("GetElementInfoIsVisible execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1213,7 +1213,7 @@ napi_value NAccessibilityElement::GetElementInfoAccessibilityFocused(NAccessibil
HILOG_DEBUG("GetElementInfoAccessibilityFocused execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1255,7 +1255,7 @@ napi_value NAccessibilityElement::GetElementInfoSelected(NAccessibilityElementDa
HILOG_DEBUG("GetElementInfoSelected execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1297,7 +1297,7 @@ napi_value NAccessibilityElement::GetElementInfoClickable(NAccessibilityElementD
HILOG_DEBUG("GetElementInfoClickable execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1339,7 +1339,7 @@ napi_value NAccessibilityElement::GetElementInfoLongClickable(NAccessibilityElem
HILOG_DEBUG("GetElementInfoLongClickable execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1381,7 +1381,7 @@ napi_value NAccessibilityElement::GetElementInfoIsEnable(NAccessibilityElementDa
HILOG_DEBUG("GetElementInfoIsEnable execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1423,7 +1423,7 @@ napi_value NAccessibilityElement::GetElementInfoIsPassword(NAccessibilityElement
HILOG_DEBUG("GetElementInfoIsPassword execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1465,7 +1465,7 @@ napi_value NAccessibilityElement::GetElementInfoScrollable(NAccessibilityElement
HILOG_DEBUG("GetElementInfoScrollable execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1507,7 +1507,7 @@ napi_value NAccessibilityElement::GetElementInfoEditable(NAccessibilityElementDa
HILOG_DEBUG("GetElementInfoEditable execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1549,7 +1549,7 @@ napi_value NAccessibilityElement::GetElementInfoPopupSupported(NAccessibilityEle
HILOG_DEBUG("GetElementInfoPopupSupported execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1591,7 +1591,7 @@ napi_value NAccessibilityElement::GetElementInfoPluralLineSupported(NAccessibili
HILOG_DEBUG("GetElementInfoPluralLineSupported execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1633,7 +1633,7 @@ napi_value NAccessibilityElement::GetElementInfoDeleteable(NAccessibilityElement
HILOG_DEBUG("GetElementInfoDeleteable execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1675,7 +1675,7 @@ napi_value NAccessibilityElement::GetElementInfoIsHint(NAccessibilityElementData
HILOG_DEBUG("GetElementInfoIsHint execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1717,7 +1717,7 @@ napi_value NAccessibilityElement::GetElementInfoIsEssential(NAccessibilityElemen
HILOG_DEBUG("GetElementInfoIsEssential execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1759,7 +1759,7 @@ napi_value NAccessibilityElement::GetElementInfoItemCount(NAccessibilityElementD
HILOG_DEBUG("GetElementInfoItemCount execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_int32(callbackInfo->env_, callbackInfo->int32Data_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1801,7 +1801,7 @@ napi_value NAccessibilityElement::GetElementInfoCurrentIndex(NAccessibilityEleme
HILOG_DEBUG("GetElementInfoCurrentIndex execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_int32(callbackInfo->env_, callbackInfo->int32Data_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1843,7 +1843,7 @@ napi_value NAccessibilityElement::GetElementInfoStartIndex(NAccessibilityElement
HILOG_DEBUG("GetElementInfoStartIndex execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_int32(callbackInfo->env_, callbackInfo->int32Data_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1885,7 +1885,7 @@ napi_value NAccessibilityElement::GetElementInfoEndIndex(NAccessibilityElementDa
HILOG_DEBUG("GetElementInfoEndIndex execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_int32(callbackInfo->env_, callbackInfo->int32Data_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -1926,7 +1926,7 @@ napi_value NAccessibilityElement::GetElementInfoRangeInfo(NAccessibilityElementD
HILOG_DEBUG("GetElementInfoRangeInfo execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_object(callbackInfo->env_, &result);
ConvertRangeInfoToJS(callbackInfo->env_, result, callbackInfo->rangeInfo_);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
@ -1968,7 +1968,7 @@ napi_value NAccessibilityElement::GetElementInfoGrid(NAccessibilityElementData *
HILOG_DEBUG("GetElementInfoGrid execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_object(callbackInfo->env_, &result);
ConvertGridInfoToJS(callbackInfo->env_, result, callbackInfo->gridInfo_);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
@ -2010,7 +2010,7 @@ napi_value NAccessibilityElement::GetElementInfoGridItem(NAccessibilityElementDa
HILOG_DEBUG("GetElementInfoGridItem execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_object(callbackInfo->env_, &result);
ConvertGridItemToJS(callbackInfo->env_, result, callbackInfo->gridItemInfo_);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
@ -2053,7 +2053,7 @@ napi_value NAccessibilityElement::GetElementInfoActiveRegion(NAccessibilityEleme
HILOG_DEBUG("GetElementInfoActiveRegion execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_int32(callbackInfo->env_, callbackInfo->int32Data_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -2095,7 +2095,7 @@ napi_value NAccessibilityElement::GetElementInfoIsContentInvalid(NAccessibilityE
HILOG_DEBUG("GetElementInfoIsContentInvalid execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -2137,7 +2137,7 @@ napi_value NAccessibilityElement::GetElementInfoError(NAccessibilityElementData
HILOG_DEBUG("GetElementInfoError execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_string_utf8(callbackInfo->env_, callbackInfo->stringData_.c_str(), NAPI_AUTO_LENGTH,
&result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
@ -2168,7 +2168,7 @@ napi_value NAccessibilityElement::GetElementInfoLabel(NAccessibilityElementData
[](napi_env env, void* data) {
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
if (callbackInfo->accessibilityElement_.elementInfo_ != nullptr) {
callbackInfo->int32Data_ =
callbackInfo->int32Data_ =
callbackInfo->accessibilityElement_.elementInfo_->GetLabeledAccessibilityId();
HILOG_DEBUG("GetElementInfoLabel: [%{public}d]", callbackInfo->int32Data_);
} else {
@ -2181,7 +2181,7 @@ napi_value NAccessibilityElement::GetElementInfoLabel(NAccessibilityElementData
HILOG_DEBUG("GetElementInfoLabel execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_int32(callbackInfo->env_, callbackInfo->int32Data_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -2223,7 +2223,7 @@ napi_value NAccessibilityElement::GetElementInfoBeginSelected(NAccessibilityElem
HILOG_DEBUG("GetElementInfoBeginSelected execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_int32(callbackInfo->env_, callbackInfo->int32Data_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -2265,7 +2265,7 @@ napi_value NAccessibilityElement::GetElementInfoEndSelected(NAccessibilityElemen
HILOG_DEBUG("GetElementInfoEndSelected execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_int32(callbackInfo->env_, callbackInfo->int32Data_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -2312,7 +2312,7 @@ napi_value NAccessibilityElement::GetElementInfoTextMoveUnit(NAccessibilityEleme
HILOG_DEBUG("GetElementInfoTextMoveUnit execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_string_utf8(callbackInfo->env_, callbackInfo->stringData_.c_str(), NAPI_AUTO_LENGTH,
&result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
@ -2361,7 +2361,7 @@ napi_value NAccessibilityElement::GetElementInfoParent(NAccessibilityElementData
HILOG_DEBUG("GetElementInfoParent execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_value constructor = nullptr;
napi_get_reference_value(env, NAccessibilityElement::consRef_, &constructor);
napi_new_instance(env, constructor, 0, nullptr, &result);
@ -2412,7 +2412,7 @@ napi_value NAccessibilityElement::GetElementInfoChilds(NAccessibilityElementData
HILOG_DEBUG("GetElementInfoChilds execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_array(env, &result);
ConvertElementInfosToJS(env, result, callbackInfo->nodeInfos_);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
@ -2455,7 +2455,7 @@ napi_value NAccessibilityElement::GetElementInfoIsFocused(NAccessibilityElementD
HILOG_DEBUG("GetElementInfoIsFocused execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -2497,7 +2497,7 @@ napi_value NAccessibilityElement::GetElementInfoComponentId(NAccessibilityElemen
HILOG_DEBUG("GetElementInfoComponentId execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_int32(callbackInfo->env_, callbackInfo->int32Data_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -2539,7 +2539,7 @@ napi_value NAccessibilityElement::GetWindowInfoIsActive(NAccessibilityElementDat
HILOG_DEBUG("GetWindowInfoIsActive execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -2580,7 +2580,7 @@ napi_value NAccessibilityElement::GetWindowInfoScreenRect(NAccessibilityElementD
HILOG_DEBUG("GetWindowInfoScreenRect execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_object(env, &result);
ConvertRectToJS(env, result, callbackInfo->screenRect_);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
@ -2623,7 +2623,7 @@ napi_value NAccessibilityElement::GetWindowInfoLayer(NAccessibilityElementData *
HILOG_DEBUG("GetWindowInfoLayer execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_int32(callbackInfo->env_, callbackInfo->int32Data_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -2666,7 +2666,7 @@ napi_value NAccessibilityElement::GetWindowInfoType(NAccessibilityElementData *c
HILOG_DEBUG("GetWindowInfoType execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_int32(callbackInfo->env_, callbackInfo->int32Data_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -2714,7 +2714,7 @@ napi_value NAccessibilityElement::GetWindowInfoAnchor(NAccessibilityElementData
HILOG_DEBUG("GetWindowInfoAnchor execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_value constructor = nullptr;
napi_get_reference_value(env, NAccessibilityElement::consRef_, &constructor);
napi_new_instance(env, constructor, 0, nullptr, &result);
@ -2765,7 +2765,7 @@ napi_value NAccessibilityElement::GetWindowInfoRootElement(NAccessibilityElement
HILOG_DEBUG("GetWindowInfoRootElement execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_value constructor = nullptr;
napi_get_reference_value(env, NAccessibilityElement::consRef_, &constructor);
napi_new_instance(env, constructor, 0, nullptr, &result);
@ -2810,7 +2810,7 @@ napi_value NAccessibilityElement::GetWindowInfoIsFocused(NAccessibilityElementDa
HILOG_DEBUG("GetWindowInfoIsFocused execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_get_boolean(callbackInfo->env_, callbackInfo->boolData_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -2852,7 +2852,7 @@ napi_value NAccessibilityElement::GetWindowInfoComponentId(NAccessibilityElement
HILOG_DEBUG("GetWindowInfoComponentId execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_int32(callbackInfo->env_, callbackInfo->int32Data_, &result);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
} else {
@ -2883,7 +2883,7 @@ napi_value NAccessibilityElement::GetElementInfoByContent(NAccessibilityElementD
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (aaClient != nullptr && callbackInfo->accessibilityElement_.elementInfo_ != nullptr) {
callbackInfo->ret_ = aaClient->GetByContent(
*(callbackInfo->accessibilityElement_.elementInfo_), callbackInfo->stringData_,
*(callbackInfo->accessibilityElement_.elementInfo_), callbackInfo->stringData_,
callbackInfo->nodeInfos_);
} else {
HILOG_ERROR("no client or element info!");
@ -2896,7 +2896,7 @@ napi_value NAccessibilityElement::GetElementInfoByContent(NAccessibilityElementD
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_array(env, &result);
ConvertElementInfosToJS(env, result, callbackInfo->nodeInfos_);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
@ -2946,7 +2946,7 @@ napi_value NAccessibilityElement::GetElementInfoByFocusType(NAccessibilityElemen
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_array(env, &result);
ConvertElementInfosToJS(env, result, callbackInfo->nodeInfos_);
napi_resolve_deferred(env, callbackInfo->deferred_, result);
@ -2980,7 +2980,7 @@ napi_value NAccessibilityElement::GetElementInfoByFocusDirection(NAccessibilityE
FocusMoveDirection direction = ConvertStringToDirection(callbackInfo->stringData_);
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (aaClient != nullptr && callbackInfo->accessibilityElement_.elementInfo_ != nullptr) {
callbackInfo->ret_ = aaClient->GetNext(*(callbackInfo->accessibilityElement_.elementInfo_),
callbackInfo->ret_ = aaClient->GetNext(*(callbackInfo->accessibilityElement_.elementInfo_),
direction, nodeInfo);
if (callbackInfo->ret_) {
callbackInfo->nodeInfos_.push_back(nodeInfo);
@ -2993,10 +2993,10 @@ napi_value NAccessibilityElement::GetElementInfoByFocusDirection(NAccessibilityE
// Execute the complete function
[](napi_env env, napi_status status, void* data) {
HILOG_DEBUG("GetElementInfoByFocusDirection execute back");
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
NAccessibilityElementData* callbackInfo = static_cast<NAccessibilityElementData*>(data);
napi_value result = nullptr;
if (callbackInfo->ret_) {
if (callbackInfo->ret_) {
napi_create_array(env, &result);
ConvertElementInfosToJS(env, result, callbackInfo->nodeInfos_);
napi_resolve_deferred(env, callbackInfo->deferred_, result);

View File

@ -27,7 +27,7 @@ thread_local napi_ref NAccessibilityClient::aaConsRef_;
thread_local napi_ref NAccessibilityClient::aaStyleConsRef_;
std::map<std::string, std::vector<std::shared_ptr<StateListener>>> NAccessibilityClient::stateListeners_ = {};
std::vector<std::shared_ptr<ConfigListener>> NAccessibilityClient::captionListeners_ = {};
std::vector<std::shared_ptr<NAccessibilityConfigObserver>> NAccessibilityClient::captionListeners_ = {};
napi_value NAccessibilityClient::IsOpenAccessibility(napi_env env, napi_callback_info info)
{
@ -648,7 +648,7 @@ napi_value NAccessibilityClient::RegisterCaptionStateCallback(napi_env env, napi
return nullptr;
}
std::shared_ptr<ConfigListener> captionListener = std::make_shared<ConfigListener>();
std::shared_ptr<NAccessibilityConfigObserver> captionListener = std::make_shared<NAccessibilityConfigObserver>();
captionListener->StartWork(env, 1, args);
captionListener->SetConfigId(type);
NAccessibilityClient::captionListeners_.push_back(captionListener);
@ -679,7 +679,7 @@ napi_value NAccessibilityClient::DeregisterCaptionStateCallback(napi_env env, na
}
for (auto it = NAccessibilityClient::captionListeners_.begin();
it != NAccessibilityClient::captionListeners_.end();) {
std::shared_ptr<ConfigListener> observer= *it;
std::shared_ptr<NAccessibilityConfigObserver> observer= *it;
auto &instance = Singleton<OHOS::AccessibilityConfig::AccessibilityConfig>::GetInstance();
if (observer->GetEnv() == env && observer->GetConfigId() == type) {
instance.UnsubscribeConfigObserver(type, observer);

View File

@ -19,7 +19,6 @@
#include <iomanip>
#include <regex>
#include <sstream>
#include <uv.h>
#include <vector>
#include "accessible_ability_client.h"
@ -61,8 +60,8 @@ bool ParseBool(napi_env env, bool& param, napi_value args)
return false;
}
if(valuetype != napi_boolean) {
HILOG_ERROR( "Wrong argument type. Boolean expected.");
if (valuetype != napi_boolean) {
HILOG_ERROR("Wrong argument type. Boolean expected.");
return false;
}
@ -80,8 +79,8 @@ bool ParseString(napi_env env, std::string& param, napi_value args)
return false;
}
if(valuetype != napi_string) {
HILOG_ERROR( "Wrong argument type. String expected.");
if (valuetype != napi_string) {
HILOG_ERROR("Wrong argument type. String expected.");
return false;
}
@ -101,8 +100,8 @@ bool ParseUint32(napi_env env, uint32_t& param, napi_value args)
}
HILOG_INFO("param=%{public}d.", valuetype);
if(valuetype != napi_number) {
HILOG_ERROR( "Wrong argument type. uint32 expected.");
if (valuetype != napi_number) {
HILOG_ERROR("Wrong argument type. uint32 expected.");
return false;
}
@ -121,11 +120,11 @@ bool ParseInt32(napi_env env, int32_t& param, napi_value args)
}
HILOG_INFO("param=%{public}d.", valuetype);
if(valuetype != napi_number) {
HILOG_ERROR( "Wrong argument type. uint32 expected.");
if (valuetype != napi_number) {
HILOG_ERROR("Wrong argument type. uint32 expected.");
return false;
}
napi_get_value_int32(env, args, &param);
return true;
}
@ -266,10 +265,10 @@ static std::vector<std::string> ParseCapabilitiesToVec(uint32_t capabilitiesValu
std::string ConvertDaltonizationTypeToString(OHOS::AccessibilityConfig::DALTONIZATION_TYPE type)
{
static const std::map<OHOS::AccessibilityConfig::DALTONIZATION_TYPE, const std::string> typeTable = {
{OHOS::AccessibilityConfig::DALTONIZATION_TYPE::Normal ,"Normal"},
{OHOS::AccessibilityConfig::DALTONIZATION_TYPE::Protanomaly ,"Protanomaly"},
{OHOS::AccessibilityConfig::DALTONIZATION_TYPE::Deuteranomaly ,"Deuteranomaly"},
{OHOS::AccessibilityConfig::DALTONIZATION_TYPE::Tritanomaly ,"Tritanomaly"}};
{OHOS::AccessibilityConfig::DALTONIZATION_TYPE::Normal, "Normal"},
{OHOS::AccessibilityConfig::DALTONIZATION_TYPE::Protanomaly, "Protanomaly"},
{OHOS::AccessibilityConfig::DALTONIZATION_TYPE::Deuteranomaly, "Deuteranomaly"},
{OHOS::AccessibilityConfig::DALTONIZATION_TYPE::Tritanomaly, "Tritanomaly"}};
if (typeTable.find(type) == typeTable.end()) {
return "";
@ -570,7 +569,7 @@ void ConvertAccessibilityEventInfoToJS(napi_env env, napi_value objEventInfo, co
case TYPE_WINDOW_UPDATE: {
WindowUpdateType windowUpdateType = eventInfo.GetWindowChangeTypes();
strType = ConvertWindowUpdateTypeToString(windowUpdateType);
break;
break;
}
default:
strType = ConvertAccessibilityEventTypeToString(type);
@ -1686,339 +1685,3 @@ void ConvertStringVecToJS(napi_env env, napi_value &result, std::vector<std::str
index++;
}
}
napi_value ConfigListener::StartWork(
napi_env env, size_t functionIndex, napi_value (&args)[CONFIG_START_WORK_ARGS_SIZE])
{
HILOG_INFO("start");
int32_t id = 0;
ParseInt32(env, id, args[0]);
configId_ = static_cast<OHOS::AccessibilityConfig::CONFIG_ID>(id);
napi_create_reference(env, args[functionIndex], 1, &handlerRef_);
env_ = env;
napi_value result = {0};
return result;
}
void ConfigListener::NotifyStateChangedJS(napi_env env, bool enabled,
const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef)
{
HILOG_INFO("start");
StateCallbackInfo *callbackInfo = new StateCallbackInfo();
callbackInfo->state_ = enabled;
callbackInfo->env_ = env;
callbackInfo->ref_ = handlerRef;
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env, &loop);
uv_work_t *work = new uv_work_t;
work->data = static_cast<StateCallbackInfo*>(callbackInfo);
uv_queue_work(
loop,
work,
[](uv_work_t *work) {},
[](uv_work_t *work, int status) {
StateCallbackInfo *callbackInfo = static_cast<StateCallbackInfo*>(work->data);
napi_value jsEvent;
napi_get_boolean(callbackInfo->env_, callbackInfo->state_, &jsEvent);
napi_value handler = nullptr;
napi_value callResult = nullptr;
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &handler);
napi_value undefined = nullptr;
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
int32_t result;
napi_get_value_int32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyStateChangedJS napi_call_function result[%{public}d]", result);
delete callbackInfo;
callbackInfo = nullptr;
delete work;
work = nullptr;
});
}
void ConfigListener::OnConfigChanged(const CONFIG_ID id, const ConfigValue &value)
{
HILOG_INFO("start");
switch (id) {
case CONFIG_CAPTION_STATE:
NotifyStateChanged2JS(id, value.captionState);
break;
case CONFIG_CAPTION_STYLE:
NotifyPropertyChanged2JS(id, value.captionStyle);
break;
case CONFIG_SCREEN_MAGNIFICATION:
NotifyStateChanged2JS(id, value.screenMagnifier);
break;
case CONFIG_MOUSE_KEY:
NotifyStateChanged2JS(id, value.mouseKey);
break;
case CONFIG_SHORT_KEY:
NotifyStateChanged2JS(id, value.shortkey);
break;
case CONFIG_SHORT_KEY_TARGET:
NotifyStringChanged2JS(id, value.shortkey_target);
break;
case CONFIG_MOUSE_AUTOCLICK:
NotifyIntChanged2JS(id, value.mouseAutoClick);
break;
case CONFIG_DALTONIZATION_COLOR_FILTER:
NotifyUintChanged2JS(id, value.daltonizationColorFilter);
break;
case CONFIG_CONTENT_TIMEOUT:
NotifyUintChanged2JS(id, value.contentTimeout);
break;
case CONFIG_BRIGHTNESS_DISCOUNT:
NotifyFloatChanged2JS(id, value.brightnessDiscount);
break;
case CONFIG_AUDIO_BALANCE:
NotifyFloatChanged2JS(id, value.audioBalance);
break;
default:
break;
}
}
void ConfigListener::NotifyPropertyChangedJS(napi_env env, OHOS::AccessibilityConfig::CaptionProperty caption,
const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef)
{
HILOG_INFO("start");
CaptionCallbackInfo *callbackInfo = new CaptionCallbackInfo();
callbackInfo->caption_ = caption;
callbackInfo->env_ = env;
callbackInfo->ref_ = handlerRef;
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env, &loop);
uv_work_t *work = new uv_work_t;
work->data = static_cast<CaptionCallbackInfo*>(callbackInfo);
uv_queue_work(
loop,
work,
[](uv_work_t *work) {},
[](uv_work_t *work, int status) {
CaptionCallbackInfo *callbackInfo = static_cast<CaptionCallbackInfo*>(work->data);
napi_value jsEvent;
napi_create_object(callbackInfo->env_, &jsEvent);
ConvertCaptionPropertyToJS(callbackInfo->env_, jsEvent, callbackInfo->caption_);
napi_value handler = nullptr;
napi_value callResult = nullptr;
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &handler);
napi_value undefined = nullptr;
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
int32_t result;
napi_get_value_int32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyPropertyChangedJS napi_call_function result[%{public}d]", result);
delete callbackInfo;
callbackInfo = nullptr;
delete work;
work = nullptr;
});
}
void ConfigListener::NotifyStateChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, bool enabled)
{
if (GetConfigId() == id) {
NotifyStateChangedJS(GetEnv(), enabled, id, GetHandler());
}
}
void ConfigListener::NotifyPropertyChanged2JS(
const OHOS::AccessibilityConfig::CONFIG_ID id, OHOS::AccessibilityConfig::CaptionProperty caption)
{
if (GetConfigId() == id) {
NotifyPropertyChangedJS(GetEnv(), caption, id, GetHandler());
}
}
void ConfigListener::NotifyStringChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, const std::string &value)
{
if (GetConfigId() == id) {
NotifyStringChanged2JSInner(GetEnv(), value, id, GetHandler());
}
}
void ConfigListener::NotifyUintChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, uint32_t value)
{
if (GetConfigId() == id) {
NotifyUintChanged2JSInner(GetEnv(), value, id, GetHandler());
}
}
void ConfigListener::NotifyIntChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, int32_t value)
{
if (GetConfigId() == id) {
NotifyIntChanged2JSInner(GetEnv(), value, id, GetHandler());
}
}
void ConfigListener::NotifyFloatChanged2JS(const OHOS::AccessibilityConfig::CONFIG_ID id, float value)
{
if (GetConfigId() == id) {
NotifyFloatChanged2JSInner(GetEnv(), value, id, GetHandler());
}
}
void ConfigListener::NotifyStringChanged2JSInner(
napi_env env, const std::string& value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef)
{
HILOG_INFO("start");
StateCallbackInfo *callbackInfo = new StateCallbackInfo();
callbackInfo->stringValue_ = value;
callbackInfo->env_ = env;
callbackInfo->ref_ = handlerRef;
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env, &loop);
uv_work_t *work = new uv_work_t;
work->data = static_cast<StateCallbackInfo*>(callbackInfo);
uv_queue_work(
loop,
work,
[](uv_work_t *work) {},
[](uv_work_t *work, int status) {
StateCallbackInfo *callbackInfo = static_cast<StateCallbackInfo*>(work->data);
napi_value jsEvent;
napi_create_string_utf8(callbackInfo->env_,
callbackInfo->stringValue_.c_str(),
callbackInfo->stringValue_.length(),
&jsEvent);
napi_value handler = nullptr;
napi_value callResult = nullptr;
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &handler);
napi_value undefined = nullptr;
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
size_t result;
const uint32_t BUF_SIZE = 1024;
char buf[BUF_SIZE] = {0};
napi_get_value_string_utf8(callbackInfo->env_, callResult, buf, BUF_SIZE, &result);
HILOG_INFO("NotifyStringChanged2JSInner napi_call_function result[%{public}zu]", result);
delete callbackInfo;
callbackInfo = nullptr;
delete work;
work = nullptr;
});
}
void ConfigListener::NotifyIntChanged2JSInner(
napi_env env, int32_t value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef)
{
HILOG_INFO("start");
StateCallbackInfo *callbackInfo = new StateCallbackInfo();
callbackInfo->int32Value_ = value;
callbackInfo->env_ = env;
callbackInfo->ref_ = handlerRef;
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env, &loop);
uv_work_t *work = new uv_work_t;
work->data = static_cast<StateCallbackInfo*>(callbackInfo);
uv_queue_work(
loop,
work,
[](uv_work_t *work) {},
[](uv_work_t *work, int status) {
StateCallbackInfo *callbackInfo = static_cast<StateCallbackInfo*>(work->data);
napi_value jsEvent;
napi_create_int32(callbackInfo->env_, callbackInfo->int32Value_, &jsEvent);
napi_value handler = nullptr;
napi_value callResult = nullptr;
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &handler);
napi_value undefined = nullptr;
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
int32_t result;
napi_get_value_int32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyIntChanged2JSInner napi_call_function result[%{public}d]", result);
delete callbackInfo;
callbackInfo = nullptr;
delete work;
work = nullptr;
});
}
void ConfigListener::NotifyUintChanged2JSInner(
napi_env env, uint32_t value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef)
{
HILOG_INFO("start");
StateCallbackInfo *callbackInfo = new StateCallbackInfo();
callbackInfo->uint32Value_ = value;
callbackInfo->env_ = env;
callbackInfo->ref_ = handlerRef;
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env, &loop);
uv_work_t *work = new uv_work_t;
work->data = static_cast<StateCallbackInfo*>(callbackInfo);
uv_queue_work(
loop,
work,
[](uv_work_t *work) {},
[](uv_work_t *work, int status) {
StateCallbackInfo *callbackInfo = static_cast<StateCallbackInfo*>(work->data);
napi_value jsEvent;
napi_create_uint32(callbackInfo->env_, callbackInfo->uint32Value_, &jsEvent);
napi_value handler = nullptr;
napi_value callResult = nullptr;
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &handler);
napi_value undefined = nullptr;
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
uint32_t result;
napi_get_value_uint32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyUintChanged2JSInner napi_call_function result[%{public}d]", result);
delete callbackInfo;
callbackInfo = nullptr;
delete work;
work = nullptr;
});
}
void ConfigListener::NotifyFloatChanged2JSInner(
napi_env env, float value, const OHOS::AccessibilityConfig::CONFIG_ID id, napi_ref handlerRef)
{
HILOG_INFO("start");
StateCallbackInfo *callbackInfo = new StateCallbackInfo();
callbackInfo->floatValue_ = value;
callbackInfo->env_ = env;
callbackInfo->ref_ = handlerRef;
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env, &loop);
uv_work_t *work = new uv_work_t;
work->data = static_cast<StateCallbackInfo*>(callbackInfo);
uv_queue_work(
loop,
work,
[](uv_work_t *work) {},
[](uv_work_t *work, int status) {
StateCallbackInfo *callbackInfo = static_cast<StateCallbackInfo*>(work->data);
napi_value jsEvent;
napi_create_double(callbackInfo->env_, double(callbackInfo->floatValue_), &jsEvent);
napi_value handler = nullptr;
napi_value callResult = nullptr;
napi_get_reference_value(callbackInfo->env_, callbackInfo->ref_, &handler);
napi_value undefined = nullptr;
napi_get_undefined(callbackInfo->env_, &undefined);
napi_call_function(callbackInfo->env_, undefined, handler, 1, &jsEvent, &callResult);
int32_t result;
napi_get_value_int32(callbackInfo->env_, callResult, &result);
HILOG_INFO("NotifyFloatChanged2JSInner napi_call_function result[%{public}d]", result);
delete callbackInfo;
callbackInfo = nullptr;
delete work;
work = nullptr;
});
}

View File

@ -289,7 +289,6 @@ public:
std::shared_ptr<AccessibilitySettingsConfig> GetCurrentConfig();
bool EnableAbility(const std::string &name, const uint32_t capabilities);
void Init();
@ -360,7 +359,6 @@ private:
std::vector<std::string> connectingA11yAbilities_; // bundleName/abilityName
std::vector<sptr<IAccessibleAbilityManagerConfigObserver>> configCallbacks_;
std::shared_ptr<AccessibilitySettingsConfig> config_ = nullptr;
};
} // namespace Accessibility
} // namespace OHOS

View File

@ -63,7 +63,7 @@ public:
* @param event the key event prepared to send
* @return
*/
void SendEventToParent(MMI::KeyEvent &event);
void SendEventToNext(MMI::KeyEvent &event);
/**
* @brief Set AccessibleAbility keyevent result.

View File

@ -25,7 +25,6 @@
namespace OHOS {
namespace Accessibility {
enum STATE : int32_t {
ACCESSIBILITY,
TOUCHGUIDE,

View File

@ -26,9 +26,8 @@ class Utils {
public:
static void Parse(const AppExecFwk::ExtensionAbilityInfo &abilityInfo, AccessibilityAbilityInitParams &initParams);
static int64_t GetSystemTime();
static std::string GetUri(const OHOS::AppExecFwk::ElementName &elementName);
static std::string GetUri(const std::string &bundleName, const std::string &abilityName);
static std::string GetUri(const std::string &bundleName, const std::string &abilityName);
};
} // namespace Accessibility
} // namespace OHOS

View File

@ -32,7 +32,7 @@ GestureHandler::GestureHandler(const std::shared_ptr<AppExecFwk::EventRunner> &r
void GestureHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
{
HILOG_DEBUG();
HILOG_INFO();
if (!event) {
HILOG_ERROR("event is null");
return;
@ -56,7 +56,7 @@ void GestureHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
AccessibilityGestureRecognizer::AccessibilityGestureRecognizer()
{
HILOG_DEBUG();
HILOG_INFO();
AccessibilityDisplayManager &displayMgr = Singleton<AccessibilityDisplayManager>::GetInstance();
auto display = displayMgr.GetDefaultDisplay();
@ -101,7 +101,7 @@ void AccessibilityGestureRecognizer::UnregisterListener()
bool AccessibilityGestureRecognizer::OnPointerEvent(MMI::PointerEvent &event)
{
HILOG_DEBUG();
HILOG_INFO();
switch (event.GetPointerAction()) {
case MMI::PointerEvent::POINTER_ACTION_DOWN:
@ -147,7 +147,7 @@ void AccessibilityGestureRecognizer::Clear()
void AccessibilityGestureRecognizer::HandleTouchDownEvent(MMI::PointerEvent &event)
{
HILOG_DEBUG();
HILOG_INFO();
Pointer mp;
MMI::PointerEvent::PointerItem pointerIterm;
@ -168,7 +168,7 @@ void AccessibilityGestureRecognizer::HandleTouchDownEvent(MMI::PointerEvent &eve
bool AccessibilityGestureRecognizer::HandleTouchMoveEvent(MMI::PointerEvent &event)
{
HILOG_DEBUG();
HILOG_INFO();
Pointer mp;
MMI::PointerEvent::PointerItem pointerIterm;
@ -217,7 +217,7 @@ bool AccessibilityGestureRecognizer::HandleTouchMoveEvent(MMI::PointerEvent &eve
bool AccessibilityGestureRecognizer::HandleTouchUpEvent(MMI::PointerEvent &event)
{
HILOG_DEBUG();
HILOG_INFO();
Pointer mp;
MMI::PointerEvent::PointerItem pointerIterm;
@ -245,7 +245,7 @@ bool AccessibilityGestureRecognizer::HandleTouchUpEvent(MMI::PointerEvent &event
bool AccessibilityGestureRecognizer::StandardGestureRecognizer(MMI::PointerEvent &event)
{
HILOG_DEBUG();
HILOG_INFO();
switch (event.GetPointerAction()) {
case MMI::PointerEvent::POINTER_ACTION_DOWN:
@ -325,7 +325,7 @@ bool AccessibilityGestureRecognizer::DoubleTapRecognized(MMI::PointerEvent &even
bool AccessibilityGestureRecognizer::recognizeDirectionGesture(MMI::PointerEvent &event)
{
HILOG_DEBUG();
HILOG_INFO();
if (!listener_) {
HILOG_ERROR("listener_ is nullptr.");
return false;
@ -363,7 +363,7 @@ int32_t AccessibilityGestureRecognizer::GetSwipeDirection(Pointer firstP, Pointe
std::vector<Pointer> AccessibilityGestureRecognizer::GetPointerPath(std::vector<Pointer> &route)
{
HILOG_DEBUG();
HILOG_INFO();
std::vector<Pointer> pointerPath;
Pointer firstSeparation = route[0];

View File

@ -30,7 +30,7 @@ namespace Accessibility {
sptr<AccessibilityInputInterceptor> AccessibilityInputInterceptor::instance_ = nullptr;
sptr<AccessibilityInputInterceptor> AccessibilityInputInterceptor::GetInstance()
{
HILOG_DEBUG();
HILOG_INFO();
if (!instance_) {
instance_ = new(std::nothrow) AccessibilityInputInterceptor();
@ -44,7 +44,7 @@ sptr<AccessibilityInputInterceptor> AccessibilityInputInterceptor::GetInstance()
AccessibilityInputInterceptor::AccessibilityInputInterceptor()
{
HILOG_DEBUG();
HILOG_INFO();
pointerEventTransmitters_ = nullptr;
keyEventTransmitters_ = nullptr;
@ -69,7 +69,7 @@ AccessibilityInputInterceptor::~AccessibilityInputInterceptor()
void AccessibilityInputInterceptor::OnKeyEvent(MMI::KeyEvent &event)
{
HILOG_DEBUG();
HILOG_INFO();
event.AddFlag(MMI::InputEvent::EVENT_FLAG_NO_INTERCEPT);
std::shared_ptr<MMI::KeyEvent> keyEvent = std::make_shared<MMI::KeyEvent>(event);
@ -82,10 +82,8 @@ void AccessibilityInputInterceptor::OnKeyEvent(MMI::KeyEvent &event)
void AccessibilityInputInterceptor::OnPointerEvent(MMI::PointerEvent &event)
{
HILOG_DEBUG();
HILOG_DEBUG("PointerAction is %{public}d.", event.GetPointerAction());
HILOG_DEBUG("SourceType is %{public}d.", event.GetSourceType());
HILOG_DEBUG("PointerId is %{public}d.", event.GetPointerId());
HILOG_INFO("PointerAction:%{public}d, SourceType:%{public}d, PointerId:%{public}d",
event.GetPointerAction(), event.GetSourceType(), event.GetPointerId());
event.AddFlag(MMI::InputEvent::EVENT_FLAG_NO_INTERCEPT);
std::shared_ptr<MMI::PointerEvent> pointerEvent = std::make_shared<MMI::PointerEvent>(event);
@ -98,7 +96,7 @@ void AccessibilityInputInterceptor::OnPointerEvent(MMI::PointerEvent &event)
void AccessibilityInputInterceptor::SetAvailableFunctions(uint32_t availableFunctions)
{
HILOG_DEBUG("function[%{public}d].", availableFunctions);
HILOG_INFO("function[%{public}d].", availableFunctions);
if (availableFunctions_ == availableFunctions) {
return;
@ -208,7 +206,7 @@ void AccessibilityInputInterceptor::UpdateInterceptor()
return;
}
HILOG_DEBUG("interceptorId_ is %{public}d.", interceptorId_);
HILOG_INFO("interceptorId_:%{public}d, keyEventInterceptorId_:%{public}d", interceptorId_, keyEventInterceptorId_);
if ((availableFunctions_ & FEATURE_MOUSE_AUTOCLICK) ||
(availableFunctions_ & FEATURE_TOUCH_EXPLORATION) ||
(availableFunctions_ & FEATURE_SCREEN_MAGNIFICATION)) {
@ -224,7 +222,6 @@ void AccessibilityInputInterceptor::UpdateInterceptor()
interceptorId_ = -1;
}
HILOG_DEBUG("keyEventInterceptorId_ is %{public}d.", keyEventInterceptorId_);
if ((availableFunctions_ & FEATURE_SHORT_KEY) ||
(availableFunctions_ & FEATURE_FILTER_KEY_EVENTS)) {
if (keyEventInterceptorId_ < 0) {
@ -254,7 +251,7 @@ void AccessibilityInputInterceptor::InterceptKeyEventCallback(std::shared_ptr<MM
void AccessibilityInputInterceptor::DestroyInterceptor()
{
HILOG_DEBUG();
HILOG_INFO("interceptorId_:%{public}d, keyEventInterceptorId_:%{public}d", interceptorId_, keyEventInterceptorId_);
if (!inputManager_) {
HILOG_DEBUG("inputManager_ is null.");
@ -273,7 +270,7 @@ void AccessibilityInputInterceptor::DestroyInterceptor()
void AccessibilityInputInterceptor::DestroyTransmitters()
{
HILOG_DEBUG();
HILOG_INFO();
if (pointerEventTransmitters_ != nullptr) {
pointerEventTransmitters_->DestroyEvents();
@ -301,7 +298,7 @@ void AccessibilityInputInterceptor::NotifyAccessibilityEvent(AccessibilityEventI
void AccessibilityInputInterceptor::ProcessPointerEvent(std::shared_ptr<MMI::PointerEvent> event) const
{
HILOG_DEBUG();
HILOG_INFO();
if (!pointerEventTransmitters_) {
HILOG_DEBUG("pointerEventTransmitters_ is empty.");
@ -314,7 +311,7 @@ void AccessibilityInputInterceptor::ProcessPointerEvent(std::shared_ptr<MMI::Poi
void AccessibilityInputInterceptor::ProcessKeyEvent(std::shared_ptr<MMI::KeyEvent> event) const
{
HILOG_DEBUG();
HILOG_INFO();
if (!keyEventTransmitters_) {
HILOG_DEBUG("keyEventTransmitters_ is empty.");
@ -328,7 +325,7 @@ void AccessibilityInputInterceptor::ProcessKeyEvent(std::shared_ptr<MMI::KeyEven
void AccessibilityInputInterceptor::SetNextEventTransmitter(sptr<EventTransmission> &header,
sptr<EventTransmission> &current, const sptr<EventTransmission> &next)
{
HILOG_DEBUG();
HILOG_INFO();
if (current != nullptr) {
current->SetNext(next);
@ -340,7 +337,7 @@ void AccessibilityInputInterceptor::SetNextEventTransmitter(sptr<EventTransmissi
AccessibilityInputEventConsumer::AccessibilityInputEventConsumer()
{
HILOG_DEBUG();
HILOG_INFO();
eventHandler_ = std::make_shared<AppExecFwk::EventHandler>(
Singleton<AccessibleAbilityManagerService>::GetInstance().GetMainRunner());
}
@ -374,10 +371,8 @@ void AccessibilityInputEventConsumer::OnInputEvent(std::shared_ptr<MMI::KeyEvent
void AccessibilityInputEventConsumer::OnInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const
{
HILOG_DEBUG("OnInputEvent pointerEvent start.");
HILOG_DEBUG("PointerAction is %{public}d.", pointerEvent->GetPointerAction());
HILOG_DEBUG("SourceType is %{public}d.", pointerEvent->GetSourceType());
HILOG_DEBUG("PointerId is %{public}d.", pointerEvent->GetPointerId());
HILOG_INFO("PointerAction:%{public}d, SourceType:%{public}d, PointerId:%{public}d.",
pointerEvent->GetPointerAction(), pointerEvent->GetSourceType(), pointerEvent->GetPointerId());
auto interceptor = AccessibilityInputInterceptor::GetInstance();
if (!interceptor) {

View File

@ -25,7 +25,7 @@ namespace {
static bool IsWantedKeyEvent(MMI::KeyEvent &event)
{
HILOG_DEBUG("start");
HILOG_INFO("start");
int32_t keyCode = event.GetKeyCode();
if (keyCode == MMI::KeyEvent::KEYCODE_VOLUME_UP || keyCode == MMI::KeyEvent::KEYCODE_VOLUME_DOWN) {
@ -36,7 +36,7 @@ static bool IsWantedKeyEvent(MMI::KeyEvent &event)
KeyEventFilter::KeyEventFilter()
{
HILOG_DEBUG();
HILOG_INFO();
runner_ = Singleton<AccessibleAbilityManagerService>::GetInstance().GetMainRunner();
if (!runner_) {
@ -60,7 +60,7 @@ KeyEventFilter::~KeyEventFilter()
void KeyEventFilter::OnKeyEvent(MMI::KeyEvent &event)
{
HILOG_DEBUG();
HILOG_INFO();
bool whetherIntercept = IsWantedKeyEvent(event);
if (whetherIntercept) {
@ -73,7 +73,7 @@ void KeyEventFilter::OnKeyEvent(MMI::KeyEvent &event)
void KeyEventFilter::SetServiceOnKeyEventResult(AccessibleAbilityConnection &connection, bool isHandled,
uint32_t sequenceNum)
{
HILOG_DEBUG("isHandled[%{public}d], sequenceNum[%{public}u].", isHandled, sequenceNum);
HILOG_INFO("isHandled[%{public}d], sequenceNum[%{public}u].", isHandled, sequenceNum);
std::shared_ptr<ProcessingEvent> processingEvent = FindProcessingEvent(connection, sequenceNum);
if (!processingEvent) {
@ -94,7 +94,7 @@ void KeyEventFilter::SetServiceOnKeyEventResult(AccessibleAbilityConnection &con
void KeyEventFilter::ClearServiceKeyEvents(AccessibleAbilityConnection &connection)
{
HILOG_DEBUG();
HILOG_INFO();
for (auto iter = eventMaps_.begin(); iter != eventMaps_.end(); iter++) {
if (iter->first.GetRefPtr() != &connection) {
@ -114,7 +114,7 @@ void KeyEventFilter::ClearServiceKeyEvents(AccessibleAbilityConnection &connecti
void KeyEventFilter::DispatchKeyEvent(MMI::KeyEvent &event)
{
HILOG_DEBUG();
HILOG_INFO();
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
@ -153,7 +153,7 @@ void KeyEventFilter::DispatchKeyEvent(MMI::KeyEvent &event)
bool KeyEventFilter::RemoveProcessingEvent(std::shared_ptr<ProcessingEvent> event)
{
HILOG_DEBUG();
HILOG_INFO();
bool haveEvent = false;
for (auto iter = eventMaps_.begin(); iter != eventMaps_.end(); iter++) {
@ -174,7 +174,7 @@ bool KeyEventFilter::RemoveProcessingEvent(std::shared_ptr<ProcessingEvent> even
std::shared_ptr<KeyEventFilter::ProcessingEvent> KeyEventFilter::FindProcessingEvent(
AccessibleAbilityConnection &connection, uint32_t sequenceNum)
{
HILOG_DEBUG();
HILOG_INFO();
std::shared_ptr<ProcessingEvent> processingEvent = nullptr;
@ -200,15 +200,15 @@ std::shared_ptr<KeyEventFilter::ProcessingEvent> KeyEventFilter::FindProcessingE
void KeyEventFilter::DestroyEvents()
{
HILOG_DEBUG();
HILOG_INFO();
timeouthandler_->RemoveAllEvents();
eventMaps_.clear();
}
void KeyEventFilter::SendEventToParent(MMI::KeyEvent &event)
void KeyEventFilter::SendEventToNext(MMI::KeyEvent &event)
{
HILOG_DEBUG();
HILOG_INFO();
EventTransmission::OnKeyEvent(event);
}
@ -216,12 +216,12 @@ KeyEventFilterEventHandler::KeyEventFilterEventHandler(
const std::shared_ptr<AppExecFwk::EventRunner> &runner, KeyEventFilter &keyEventFilter)
: AppExecFwk::EventHandler(runner), keyEventFilter_(keyEventFilter)
{
HILOG_DEBUG("KeyEventFilterEventHandler is created");
HILOG_INFO("KeyEventFilterEventHandler is created");
}
void KeyEventFilterEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
{
HILOG_DEBUG();
HILOG_INFO();
if (!event) {
HILOG_ERROR("event is null.");
@ -236,7 +236,7 @@ void KeyEventFilterEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Poin
bool haveEvent = keyEventFilter_.RemoveProcessingEvent(processingEvent);
if (haveEvent) {
keyEventFilter_.SendEventToParent(*processingEvent->event_);
keyEventFilter_.SendEventToNext(*processingEvent->event_);
}
}
} // namespace Accessibility

View File

@ -164,7 +164,7 @@ void AccessibilitySettingsConfig::SetContentTimeout(const uint32_t time)
pref_->Flush();
}
void AccessibilitySettingsConfig:: SetBrightnessDiscount(const float discount)
void AccessibilitySettingsConfig::SetBrightnessDiscount(const float discount)
{
HILOG_DEBUG("start.");
brightnessDiscount_ = discount;
@ -199,25 +199,20 @@ void AccessibilitySettingsConfig::SetCaptionProperty(const AccessibilityConfig::
HILOG_ERROR("pref_ is null!");
return;
}
HILOG_DEBUG("GetFontFamily.");
const std::string FONTFAMILY = captionProperty_.GetFontFamily();
HILOG_DEBUG("GetFontScale.");
int32_t FONTSCALE = captionProperty_.GetFontScale();
uint32_t FONTCOLOR = captionProperty_.GetFontColor();
const std::string FONTEDGETYPE = captionProperty_.GetFontEdgeType();
uint32_t BACKGROUNDCOLOR = captionProperty_.GetBackgroundColor();
uint32_t WINDOWCOLOR = captionProperty_.GetWindowColor();
HILOG_DEBUG("PutString.");
pref_->PutString("fontFamily", FONTFAMILY);
HILOG_DEBUG("PutInt.");
pref_->PutInt("fontColor", static_cast<int32_t>(FONTCOLOR));
pref_->PutString("fontEdgeType", FONTEDGETYPE);
pref_->PutInt("backgroundColor", static_cast<int32_t>(BACKGROUNDCOLOR));
pref_->PutInt("windowColor", static_cast<int32_t>(WINDOWCOLOR));
pref_->PutInt("fontScale", FONTSCALE);
HILOG_DEBUG("fontScale.");
pref_->Flush();
HILOG_DEBUG("Flush.");
}
bool AccessibilitySettingsConfig::SetStatePref(int32_t type)
@ -265,19 +260,19 @@ bool AccessibilitySettingsConfig::SetStatePref(int32_t type)
case STATE::HIGHCONTRASTTEXT:
strValue = StateChange(highContrastTextState_);
pref_->PutString("highContrastText", strValue);
break;
break;
case STATE::INVERTCOLORSTATE:
strValue = StateChange(invertColorState_);
pref_->PutString("invertColor", strValue);
break;
break;
case STATE::ANIMATIONOFF:
strValue = StateChange(animationOffState_);
pref_->PutString("animationOff", strValue);
break;
break;
case STATE::AUDIOMONO:
strValue = StateChange(audioMonoState_);
pref_->PutString("audioMono", strValue);
break;
break;
default:
HILOG_ERROR("Invalid parameter.");
return false;
@ -482,61 +477,28 @@ void AccessibilitySettingsConfig::SettingInit()
}
std::string strValue = pref_->GetString("ScreenMagnification", "");
HILOG_DEBUG(" pref_->GetString() = %{public}s.", strValue.c_str());
if (!std::strcmp(strValue.c_str(), "on")) {
isScreenMagnificationState_ = true;
} else {
isScreenMagnificationState_ = false;
}
isScreenMagnificationState_ = std::strcmp(strValue.c_str(), "on") ? false : true;
strValue = pref_->GetString("MouseKey", "");
if (!std::strcmp(strValue.c_str(), "on")) {
isMouseKeyState_ = true;
} else {
isMouseKeyState_ = false;
}
isMouseKeyState_ = std::strcmp(strValue.c_str(), "on") ? false : true;
strValue = pref_->GetString("ShortKey", "");
if (!std::strcmp(strValue.c_str(), "on")) {
isShortKeyState_ = true;
} else {
isShortKeyState_ = false;
}
isShortKeyState_ = std::strcmp(strValue.c_str(), "on") ? false : true;
strValue = pref_->GetString("animationOff", "");
if (!std::strcmp(strValue.c_str(), "on")) {
animationOffState_ = true;
} else {
animationOffState_ = false;
}
animationOffState_ = std::strcmp(strValue.c_str(), "on") ? false : true;
strValue = pref_->GetString("invertColor", "");
if (!std::strcmp(strValue.c_str(), "on")) {
invertColorState_ = true;
} else {
invertColorState_ = false;
}
invertColorState_ = std::strcmp(strValue.c_str(), "on") ? false : true;
strValue = pref_->GetString("highContrastText", "");
if (!std::strcmp(strValue.c_str(), "on")) {
highContrastTextState_ = true;
} else {
highContrastTextState_ = false;
}
highContrastTextState_ = std::strcmp(strValue.c_str(), "on") ? false : true;
strValue = pref_->GetString("audioMono", "");
if (!std::strcmp(strValue.c_str(), "on")) {
audioMonoState_ = true;
} else {
audioMonoState_ = false;
}
audioMonoState_ = std::strcmp(strValue.c_str(), "on") ? false : true;
shortkeyTarget_ = pref_->GetString("ShortkeyTarget", "none");
HILOG_DEBUG(" pref_->GetString() = 0x%{public}s.", shortkeyTarget_.c_str());
mouseAutoClick_ = static_cast<int32_t>(pref_->GetInt("MouseAutoClick", -1));
HILOG_DEBUG(" pref_->GetInt() = 0x%{public}x.", mouseAutoClick_);
daltonizationColorFilter_ = static_cast<uint32_t>(pref_->GetInt("daltonizationColorFilter", 0));
contentTimeout_ = static_cast<uint32_t>(pref_->GetInt("contentTimeout", 0));
brightnessDiscount_ = static_cast<uint32_t>(pref_->GetFloat("brightnessDiscount", 0));
@ -605,7 +567,8 @@ void AccessibilitySettingsConfig::Init()
HILOG_DEBUG("start.");
int errCode = -1;
pref_ = NativePreferences::PreferencesHelper::GetPreferences(PREF_PATH + std::to_string(accountId_) + ".xml", errCode);
pref_ = NativePreferences::PreferencesHelper::GetPreferences(PREF_PATH + std::to_string(accountId_) + ".xml",
errCode);
if (errCode) {
HILOG_ERROR("GetPreferences failed! account id (%{public}d), errCode(%{public}d).", accountId_, errCode);
return;

View File

@ -1605,7 +1605,6 @@ void AccessibleAbilityManagerService::SetHighContrastTextState(const bool state)
accountData->GetCurrentConfig()->SetHighContrastTextState(state);
UpdateConfigState();
}), "TASK_SET_HIGHCONTRASTTEXT_STATE");
}
void AccessibleAbilityManagerService::SetInvertColorState(const bool state)

View File

@ -58,7 +58,8 @@ public:
return true;
}
static bool GetStringVecFromJson(const nlohmann::json &json, const std::string &key, std::vector<std::string> &value)
static bool GetStringVecFromJson(const nlohmann::json &json, const std::string &key,
std::vector<std::string> &value)
{
HILOG_DEBUG("start.");
if (!json.is_object()) {

View File

@ -27,7 +27,7 @@ public:
virtual ~MockKeyEventFilter();
MOCK_METHOD1(OnKeyEvent, void(MMI::KeyEvent& event));
MOCK_METHOD1(SendEventToParent, void(MMI::KeyEvent& event));
MOCK_METHOD1(SendEventToNext, void(MMI::KeyEvent& event));
MOCK_METHOD3(SetServiceOnKeyEventResult,
void(AccessibleAbilityConnection& connection, bool isHandled, uint32_t sequenceNum));
MOCK_METHOD1(ClearServiceKeyEvents, void(AccessibleAbilityConnection& connection));

View File

@ -314,8 +314,6 @@ void AccessibilityAccountData::Init()
if (!config_) {
config_ = std::make_shared<AccessibilitySettingsConfig>(id_);
}
}
bool AccessibilityAccountData::DisableAbility(const std::string &name)

View File

@ -66,7 +66,7 @@ std::shared_ptr<KeyEventFilter::ProcessingEvent> KeyEventFilter::FindProcessingE
void KeyEventFilter::DestroyEvents()
{}
void KeyEventFilter::SendEventToParent(MMI::KeyEvent& event)
void KeyEventFilter::SendEventToNext(MMI::KeyEvent& event)
{
(void)event;
}

View File

@ -326,8 +326,8 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_AddEnab
/* add */
AccessibilityAbilityInitParams initParams;
initParams.name = "bbb";
std::shared_ptr<AccessibilityAbilityInfo> abilityInfo = std::make_shared<AccessibilityAbilityInfo>(initParams);
abilityInfo->SetCapabilityValues(1);
std::shared_ptr<AccessibilityAbilityInfo> abilityInfo = std::make_shared<AccessibilityAbilityInfo>(initParams);
abilityInfo->SetCapabilityValues(1);
accountData->AddInstalledAbility(*abilityInfo);
accountData->AddEnabledAbility(bundleName);
EXPECT_EQ(1, (int)accountData->GetCurrentConfig()->GetEnabledAbilityInfos().size());
@ -350,8 +350,8 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_RemoveE
/* add */
AccessibilityAbilityInitParams initParams;
initParams.name = "bbb";
std::shared_ptr<AccessibilityAbilityInfo> abilityInfo = std::make_shared<AccessibilityAbilityInfo>(initParams);
abilityInfo->SetCapabilityValues(1);
std::shared_ptr<AccessibilityAbilityInfo> abilityInfo = std::make_shared<AccessibilityAbilityInfo>(initParams);
abilityInfo->SetCapabilityValues(1);
accountData->AddInstalledAbility(*abilityInfo);
accountData->AddEnabledAbility(bundleName);