Function:1、using Preference for user setting; 2、read capbility from BMS

Signed-off-by: yichengzhao <yichengzhao1@huawei.com>
This commit is contained in:
yichengzhao 2022-03-02 17:45:32 +08:00
parent fcb357925a
commit 3330661b7f
30 changed files with 416 additions and 452 deletions

View File

@ -137,8 +137,8 @@ void JsAccessibilityExtension::OnAccessibilityEvent(const AccessibilityEventInfo
HandleScope handleScope(jsRuntime_);
NativeEngine* nativeEngine = &jsRuntime_.GetNativeEngine();
napi_get_reference_value(reinterpret_cast<napi_env>(&nativeEngine), NAccessibilityEventInfo::consRef_,
&NAccessibilityEventInfo::cons_);
napi_get_reference_value(reinterpret_cast<napi_env>(nativeEngine), NAccessibilityEventInfo::consRef_,
&NAccessibilityEventInfo::cons_);
napi_value napiEventInfo = nullptr;
napi_new_instance(
reinterpret_cast<napi_env>(nativeEngine), NAccessibilityEventInfo::cons_, 0, nullptr, &napiEventInfo);

View File

@ -66,7 +66,7 @@ void AccessibilityExtensionContextUnitTest::TearDown()
* @tc.desc: Test function GetFocusElementInfo
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_GetFocusElementInfo_001, TestSize.Level1)
AccessibilityExtensionContext_Unittest_GetFocusElementInfo_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_GetFocusElementInfo_001 start";
@ -85,7 +85,7 @@ HWTEST_F(AccessibilityExtensionContextUnitTest,
* Get focus elementInfo when focusType is not allowed.
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_GetFocusElementInfo_002, TestSize.Level1)
AccessibilityExtensionContext_Unittest_GetFocusElementInfo_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_GetFocusElementInfo_002 start";
@ -104,7 +104,7 @@ HWTEST_F(AccessibilityExtensionContextUnitTest,
* Send a gesture without any path.
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_GestureSimulate_001, TestSize.Level1)
AccessibilityExtensionContext_Unittest_GestureSimulate_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_GestureSimulate_001 start";
@ -122,7 +122,7 @@ HWTEST_F(AccessibilityExtensionContextUnitTest,
* Send a gesture whose total duration time is not allowed.
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_GestureSimulate_002, TestSize.Level1)
AccessibilityExtensionContext_Unittest_GestureSimulate_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_GestureSimulate_002 start";
@ -144,7 +144,7 @@ HWTEST_F(AccessibilityExtensionContextUnitTest,
* Send a gesture with one path.
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_GestureSimulate_003, TestSize.Level1)
AccessibilityExtensionContext_Unittest_GestureSimulate_003, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_GestureSimulate_003 start";
@ -165,7 +165,7 @@ HWTEST_F(AccessibilityExtensionContextUnitTest,
* Get a default displayResize controller.
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_GetDisplayResizeController_001, TestSize.Level1)
AccessibilityExtensionContext_Unittest_GetDisplayResizeController_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_GetDisplayResizeController_001 start";
@ -181,7 +181,7 @@ HWTEST_F(AccessibilityExtensionContextUnitTest,
* Get an informal displayResize controller.
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_GetDisplayResizeController_002, TestSize.Level1)
AccessibilityExtensionContext_Unittest_GetDisplayResizeController_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_GetDisplayResizeController_002 start";
@ -198,7 +198,7 @@ HWTEST_F(AccessibilityExtensionContextUnitTest,
* @tc.desc: Test function GetRootElementInfo
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_GetRootElementInfo_001, TestSize.Level1)
AccessibilityExtensionContext_Unittest_GetRootElementInfo_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_GetRootElementInfo_001 start";
@ -229,7 +229,7 @@ HWTEST_F(AccessibilityExtensionContextUnitTest, AccessibilityExtensionContext_Un
* @tc.desc: Test function ExecuteCommonAction
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_PerformCommonAction_001, TestSize.Level1)
AccessibilityExtensionContext_Unittest_PerformCommonAction_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_PerformCommonAction_001 start";
@ -245,7 +245,7 @@ HWTEST_F(AccessibilityExtensionContextUnitTest,
* Perform common action which is not allowed.
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_PerformCommonAction_002, TestSize.Level1)
AccessibilityExtensionContext_Unittest_PerformCommonAction_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_PerformCommonAction_002 start";
@ -261,7 +261,7 @@ HWTEST_F(AccessibilityExtensionContextUnitTest,
* Dispatch simulation gesture's result without listener.
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_DispatchOnSimulationGestureResult_001, TestSize.Level1)
AccessibilityExtensionContext_Unittest_DispatchOnSimulationGestureResult_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_DispatchOnSimulationGestureResult_001 start";
@ -277,7 +277,7 @@ HWTEST_F(AccessibilityExtensionContextUnitTest,
* Dispatch simulation gesture's result with listener and the result is completed.
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_DispatchOnSimulationGestureResult_002, TestSize.Level1)
AccessibilityExtensionContext_Unittest_DispatchOnSimulationGestureResult_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_DispatchOnSimulationGestureResult_002 start";
@ -299,7 +299,7 @@ HWTEST_F(AccessibilityExtensionContextUnitTest,
* @tc.desc: Test function SetChannelId
*/
HWTEST_F(AccessibilityExtensionContextUnitTest,
AccessibilityExtensionContext_Unittest_SetChannelId_001, TestSize.Level1)
AccessibilityExtensionContext_Unittest_SetChannelId_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityExtensionContext_Unittest_SetChannelId_001 start";

View File

@ -128,7 +128,7 @@ void AccessibleAbilityClientStubImplUnitTest::InitToSetChannelId()
* Register a listener which is already exist.
*/
HWTEST_F(AccessibleAbilityClientStubImplUnitTest,
AccessibleAbilityClientStubImpl_Unittest_RegisterListenerImpl_001, TestSize.Level1)
AccessibleAbilityClientStubImpl_Unittest_RegisterListenerImpl_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibleAbilityClientStubImpl_Unittest_RegisterListenerImpl_001 start";
@ -193,7 +193,7 @@ HWTEST_F(AccessibleAbilityClientStubImplUnitTest, AccessibleAbilityClientStubImp
* @tc.desc: Test function Disconnect
*/
HWTEST_F(AccessibleAbilityClientStubImplUnitTest,
AccessibleAbilityClientStubImpl_Unittest_Disconnect_001, TestSize.Level1)
AccessibleAbilityClientStubImpl_Unittest_Disconnect_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibleAbilityClientStubImpl_Unittest_Disconnect_001 start";
@ -211,7 +211,7 @@ HWTEST_F(AccessibleAbilityClientStubImplUnitTest,
* @tc.desc: Test function OnAccessibilityEvent
*/
HWTEST_F(AccessibleAbilityClientStubImplUnitTest,
AccessibleAbilityClientStubImpl_Unittest_OnAccessibilityEvent_001, TestSize.Level1)
AccessibleAbilityClientStubImpl_Unittest_OnAccessibilityEvent_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibleAbilityClientStubImpl_Unittest_OnAccessibilityEvent_001 start";
@ -230,7 +230,7 @@ HWTEST_F(AccessibleAbilityClientStubImplUnitTest,
* @tc.desc: Test function OnKeyPressEvent
*/
HWTEST_F(AccessibleAbilityClientStubImplUnitTest,
AccessibleAbilityClientStubImpl_Unittest_OnKeyPressEvent_001, TestSize.Level1)
AccessibleAbilityClientStubImpl_Unittest_OnKeyPressEvent_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibleAbilityClientStubImpl_Unittest_OnKeyPressEvent_001 start";
@ -250,7 +250,7 @@ HWTEST_F(AccessibleAbilityClientStubImplUnitTest,
* @tc.desc: Test function OnDisplayResized
*/
HWTEST_F(AccessibleAbilityClientStubImplUnitTest,
AccessibleAbilityClientStubImpl_Unittest_OnDisplayResized_001, TestSize.Level1)
AccessibleAbilityClientStubImpl_Unittest_OnDisplayResized_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibleAbilityClientStubImpl_Unittest_OnDisplayResized_001 start";
@ -273,7 +273,7 @@ HWTEST_F(AccessibleAbilityClientStubImplUnitTest,
* @tc.desc: Test function OnGestureSimulateResult
*/
HWTEST_F(AccessibleAbilityClientStubImplUnitTest,
AccessibleAbilityClientStubImpl_Unittest_OnGestureSimulateResult_001, TestSize.Level1)
AccessibleAbilityClientStubImpl_Unittest_OnGestureSimulateResult_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibleAbilityClientStubImpl_Unittest_OnGestureSimulateResult_001 start";

View File

@ -231,7 +231,7 @@ HWTEST_F(DisplayResizeControllerUnitTest, DisplayResizeController_Unittest_SetSc
* @tc.desc: Test function DispatchOnDisplayResized
*/
HWTEST_F(DisplayResizeControllerUnitTest,
DisplayResizeController_Unittest_DispatchOnDisplayResized_001, TestSize.Level1)
DisplayResizeController_Unittest_DispatchOnDisplayResized_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "DisplayResizeController_Unittest_DispatchOnDisplayResized_001 start";

View File

@ -53,7 +53,7 @@ public:
*/
AccessibilityOperator();
/**
/**
* @brief destruct function
* @param object The object of IPC
* @return

View File

@ -31,6 +31,7 @@ AccessibilityAbilityInfo::AccessibilityAbilityInfo(AppExecFwk::ExtensionAbilityI
bundleName_ = abilityInfo.bundleName;
moduleName_ = abilityInfo.moduleName;
name_ = abilityInfo.name;
eventTypes_ = EventType::TYPES_ALL_MASK;
HILOG_DEBUG("bundle name is [%{public}s].", bundleName_.c_str());
HILOG_DEBUG("moudle name is [%{public}s].", moduleName_.c_str());
HILOG_DEBUG("ability name is [%{public}s]].", name_.c_str());

View File

@ -172,7 +172,7 @@ uint32_t AccessibleAbilityManagerServiceClientProxy::RegisterStateCallback(
int error = NO_ERROR;
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC);
MessageOption option(MessageOption::TF_SYNC);
if (client == nullptr) {
HILOG_ERROR("%{public}s fail, Input client is null", __func__);

View File

@ -61,8 +61,8 @@ void AccessibilityAbilityInfoUnitTest::WritefileAll(const char* fname, const cha
void AccessibilityAbilityInfoUnitTest::CreateAccessibilityConfig()
{
std::ostringstream os;
Json::Value object1, targetBundleNames;
Json::Value accessibilityAbilityTypes, accessibilityEventTypes, accessibilityCapabilities;
Json::Value object1, targetBundleNames;
Json::Value accessibilityAbilityTypes, accessibilityEventTypes, accessibilityCapabilities;
string jsonStr;
if (remove("/system/app/dummy_accessibility_ability_config.json") == 0) {

View File

@ -53,6 +53,7 @@ ohos_shared_library("accessibilityclient") {
deps = [
"//base/miscservices/time/services:time_service",
"//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native",
"//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_preferences:native_preferences",
"//utils/native/base:utils",
]

View File

@ -43,7 +43,7 @@ void NAccessibilityEventInfo::DefineJSAccessibilityEventInfo(napi_env env)
sizeof(descForAccessibilityEventInfo) / sizeof(descForAccessibilityEventInfo[0]),
descForAccessibilityEventInfo,
&NAccessibilityEventInfo::cons_));
napi_create_reference(env, NAccessibilityWindowInfo::cons_, 1, &NAccessibilityWindowInfo::consRef_);
napi_create_reference(env, NAccessibilityEventInfo::cons_, 1, &NAccessibilityEventInfo::consRef_);
}
napi_value NAccessibilityEventInfo::JSConstructor(napi_env env, napi_callback_info info)

View File

@ -112,7 +112,7 @@ napi_value NAccessibilityClient::IsOpenTouchExploration(napi_env env, napi_callb
// execute async to call c++ function
[](napi_env env, void* data) {
NAccessibilitySystemAbilityClient* callbackInfo = (NAccessibilitySystemAbilityClient*)data;
callbackInfo->enabled_ = AccessibilitySystemAbilityClient::GetInstance()->IsEnabled();
callbackInfo->touchEnabled_ = AccessibilitySystemAbilityClient::GetInstance()->IsTouchExplorationEnabled();
HILOG_INFO("IsOpenTouchExploration Executing touchEnabled[%{public}d]", callbackInfo->touchEnabled_);
},
// execute the complete function
@ -123,7 +123,7 @@ napi_value NAccessibilityClient::IsOpenTouchExploration(napi_env env, napi_callb
napi_value undefined = 0;
napi_get_undefined(env, &undefined);
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, callbackInfo->enabled_, &result[PARAM1]));
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, callbackInfo->touchEnabled_, &result[PARAM1]));
HILOG_INFO("IsOpenTouchExploration completed touchEnabled_[%{public}d]", callbackInfo->touchEnabled_);
if (callbackInfo->callback_) {
@ -1539,10 +1539,9 @@ napi_value NAccessibilityClient::RegisterCaptionStateCallback(napi_env env, napi
} else {
HILOG_ERROR("SubscribeState eventType[%{public}s] is error", eventType.c_str());
}
bool result = AccessibilitySystemAbilityClient::GetInstance()->AddCaptionListener(captionListener, type);
napi_value ret = {0};
napi_get_boolean(env, result, &ret);
return ret;
AccessibilitySystemAbilityClient::GetInstance()->AddCaptionListener(captionListener, type);
return nullptr;
}
napi_value NAccessibilityClient::DeregisterCaptionStateCallback(napi_env env, napi_callback_info info)
@ -1591,7 +1590,15 @@ napi_value NAccessibilityClient::DeregisterCaptionStateCallback(napi_env env, na
napi_get_undefined(env, &undefined);
napi_get_boolean(env, callbackInfo->result_, &result[PARAM1]);
if (callbackInfo->callback_) {
napi_get_boolean(env, callbackInfo->result_, &result[PARAM0]); // maby rework
if (type == CaptionObserverType::CAPTION_ENABLE) {
napi_get_boolean(env, callbackInfo->result_, &result[PARAM0]); // maby rework
} else {
napi_create_object(env, &result[PARAM0]); // maby rework
OHOS::Accessibility::CaptionProperty captionProperty {};
captionProperty = AccessibilitySystemAbilityClient::GetInstance()->GetCaptionProperty();
ConvertCaptionPropertyToJS(env, result[PARAM0], captionProperty);
}
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_value returnVal;
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
@ -1622,9 +1629,8 @@ napi_value NAccessibilityClient::DeregisterCaptionStateCallback(napi_env env, na
i++;
}
}
napi_value ret = 0;
napi_get_boolean(env, retValue, &ret);
return ret;
return nullptr;
}
CaptionListener::CaptionListener()

View File

@ -42,6 +42,7 @@ config("aams_service_config") {
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
"//base/accessibility/common/log/include",
"//utils/system/safwk/native/include",
"//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_preferences/include",
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include",
"//foundation/multimodalinput/input/interfaces/native/innerkits/event/include",
"//foundation/multimodalinput/input/interfaces/native/innerkits/proxy/include",
@ -91,6 +92,7 @@ ohos_shared_library("accessibleabilityms") {
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
"//foundation/windowmanager/dm:libdm",
"//foundation/windowmanager/wm:libwm",
"//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_preferences:native_preferences",
"//utils/native/base:utils",
]

View File

@ -19,6 +19,7 @@
#include <set>
#include <string>
#include <vector>
#include "accessibility_caption.h"
#include "accessibility_state_event.h"
#include "accessibility_system_ability_client.h"
@ -27,6 +28,7 @@
#include "accessible_ability_manager_service_caption_property_interface.h"
#include "accessible_ability_manager_service_state_interface.h"
#include "element_name.h"
#include "preferences_helper.h"
#include "refbase.h"
namespace OHOS {
@ -362,9 +364,12 @@ private:
* @return
*/
void UpdateMagnificationCapability();
void CaptionInit(nlohmann::json jsonObj);
void CapbilityInit(nlohmann::json jsonObj);
void EnabledListInit(nlohmann::json jsonObj);
void CaptionInit(const std::shared_ptr<NativePreferences::Preferences> &pref);
void CapbilityInit(const std::shared_ptr<NativePreferences::Preferences> &pref);
void EnabledListInit(const std::shared_ptr<NativePreferences::Preferences> &pref);
void StringToVector(std::string &stringIn, std::vector<std::string> &vectorResult);
void VectorToString(std::vector<std::string> &vectorVal,std::string &stringOut);
int id_;
bool isEnabled_ = false;

View File

@ -18,10 +18,12 @@
#include "accessible_ability_manager_service.h"
#include "extension_ability_info.h"
#include "hilog_wrapper.h"
#include "json_utils.h"
namespace OHOS {
namespace Accessibility {
const static std::string PREF_TEST_PATH =
"/data/service/el1/public/barrierfree/accessibility_ability_manager_service/";
AccessibilityAccountData::AccessibilityAccountData(int accountId)
{
id_ = accountId;
@ -96,7 +98,7 @@ void AccessibilityAccountData::OnAccountSwitched()
// add connect ability.
void AccessibilityAccountData::AddConnectedAbility(sptr<AccessibleAbilityConnection>& connection)
{
HILOG_DEBUG("%{public}s start. URI is %{public}s", __func__, connection->GetElementName().GetURI().c_str());
HILOG_DEBUG("URI is %{public}s", connection->GetElementName().GetURI().c_str());
if (!connectedA11yAbilities_.count(connection->GetElementName().GetURI())) {
connectedA11yAbilities_.insert(make_pair(connection->GetElementName().GetURI(), connection));
}
@ -107,7 +109,7 @@ void AccessibilityAccountData::AddConnectedAbility(sptr<AccessibleAbilityConnect
// remove connect ability.
void AccessibilityAccountData::RemoveConnectedAbility(sptr<AccessibleAbilityConnection>& connection)
{
HILOG_DEBUG("%{public}s start. URI is %{public}s", __func__, connection->GetElementName().GetURI().c_str());
HILOG_DEBUG("URI is %{public}s", connection->GetElementName().GetURI().c_str());
std::map<std::string, sptr<AccessibleAbilityConnection>>::iterator it =
connectedA11yAbilities_.find(connection->GetElementName().GetURI());
if (it != connectedA11yAbilities_.end()) {
@ -128,7 +130,7 @@ void AccessibilityAccountData::RemoveStateCallback(const wptr<IRemoteObject>& ca
{
HILOG_DEBUG("start.");
for (auto itr = stateCallbacks_.begin(); itr != stateCallbacks_.end(); itr++) {
if (*itr == callback) {
if ((*itr)->AsObject() == callback) {
stateCallbacks_.erase(itr);
break;
}
@ -146,7 +148,7 @@ void AccessibilityAccountData::RemoveCaptionPropertyCallback(const wptr<IRemoteO
{
HILOG_DEBUG("start.");
for (auto itr = captionPropertyCallbacks_.begin(); itr != captionPropertyCallbacks_.end(); itr++) {
if (*itr == callback) {
if ((*itr)->AsObject() == callback) {
captionPropertyCallbacks_.erase(itr);
break;
}
@ -156,7 +158,7 @@ void AccessibilityAccountData::RemoveCaptionPropertyCallback(const wptr<IRemoteO
void AccessibilityAccountData::AddAccessibilityWindowConnection(
const int windowId, const sptr<AccessibilityWindowConnection>& interactionConnection)
{
HILOG_DEBUG("%{public}s start.windowId(%{public}d)", __func__, windowId);
HILOG_DEBUG("windowId(%{public}d)", windowId);
if (!asacConnections_.count(windowId)) {
asacConnections_.insert(std::make_pair(windowId, interactionConnection));
}
@ -165,7 +167,7 @@ void AccessibilityAccountData::AddAccessibilityWindowConnection(
// remove AccessibilityWindowConnection
void AccessibilityAccountData::RemoveAccessibilityWindowConnection(const int windowId)
{
HILOG_DEBUG("%{public}s start.windowId(%{public}d)", __func__, windowId);
HILOG_DEBUG("windowId(%{public}d)", windowId);
std::map<int, sptr<AccessibilityWindowConnection>>::iterator it = asacConnections_.find(windowId);
if (it != asacConnections_.end()) {
asacConnections_.erase(it);
@ -212,15 +214,33 @@ void AccessibilityAccountData::RemoveEnabledAbility(const AppExecFwk::ElementNam
if (it != enabledAbilities_.end()) {
enabledAbilities_.erase(it);
}
// temp deal: write json config
nlohmann::json jsonObj;
if (!JsonUtils::GetJsonObjFromJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH)) {
HILOG_ERROR("Get JsonObj from json failed.");
}
int errCode = 0;
std::shared_ptr<NativePreferences::Preferences> pref =
NativePreferences::PreferencesHelper::GetPreferences(PREF_TEST_PATH + "test.xml", errCode);
HILOG_DEBUG("errCode = %{public}d.", errCode);
std::string strValue = pref->GetString("BundleName", "");
HILOG_DEBUG("strValue = %{public}s", strValue.c_str());
std::vector<std::string> vecvalue;
StringToVector(strValue, vecvalue);
std::string BundleName = elementName.GetBundleName();
JsonUtils::RemoveVecValue(jsonObj, JSON_OBJECT_ENABLED, BundleName);
JsonUtils::ToJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH);
for (std::vector<std::string>::iterator val = vecvalue.begin();val != vecvalue.end();) {
if (std::strcmp(val->c_str(), BundleName.c_str()) == 0) {
val = vecvalue.erase(val);
HILOG_DEBUG("remove val = %{public}s", val->c_str());
}else{
val++;
}
}
std::string stringOut = "";
VectorToString(vecvalue,stringOut);
int err = pref->PutString("BundleName",stringOut);
HILOG_DEBUG("pref->PutString() = %{public}d.",err);
err = pref->FlushSync();
HILOG_DEBUG("pref->FlushSync() = %{public}d.",err);
HILOG_DEBUG("Remove EnabledAbility: %{public}d", enabledAbilities_.size());
@ -230,8 +250,7 @@ void AccessibilityAccountData::RemoveEnabledAbility(const AppExecFwk::ElementNam
// For UT
void AccessibilityAccountData::AddInstalledAbility(AccessibilityAbilityInfo& abilityInfo)
{
HILOG_DEBUG("%{public}s start and abilityInfo's bundle name is %{public}s",
__func__, abilityInfo.GetPackageName().c_str());
HILOG_DEBUG("abilityInfo's bundle name is %{public}s", abilityInfo.GetPackageName().c_str());
for (size_t i = 0; i < installedAbilities_.size(); i++) {
if (installedAbilities_[i].GetPackageName() == abilityInfo.GetPackageName()) {
HILOG_DEBUG("the ability is already exist.");
@ -267,7 +286,7 @@ void AccessibilityAccountData::ClearInstalledAbility()
const sptr<AccessibleAbilityConnection> AccessibilityAccountData::GetAccessibleAbilityConnection(
const std::string elementName)
{
HILOG_DEBUG("%{public}s start. URI is %{public}s", __func__, elementName.c_str());
HILOG_DEBUG("URI is %{public}s", elementName.c_str());
for (auto& connected : connectedA11yAbilities_) {
std::string::size_type idx = connected.first.find(elementName);
if (idx == std::string::npos) {
@ -346,12 +365,14 @@ const std::vector<AccessibilityAbilityInfo> AccessibilityAccountData::GetInstall
const std::vector<AccessibilityAbilityInfo> AccessibilityAccountData::GetAbilitiesByState(AbilityStateType state)
{
HILOG_DEBUG("%{public}s by state(%{public}d) start.", __func__, state);
HILOG_DEBUG("state(%{public}d) start.", state);
if (state == ABILITY_STATE_ENABLE) {
std::vector<AccessibilityAbilityInfo> enabledAbilities;
for (auto ability : connectedA11yAbilities_) {
enabledAbilities.push_back(ability.second->GetAbilityInfo());
}
HILOG_DEBUG("connectedA11yAbilities_ is (%{public}d) enabledAbilities is (%{public}d).",
connectedA11yAbilities_.size(), enabledAbilities.size());
return enabledAbilities;
} else if (state == ABILITY_STATE_DISABLE) {
std::vector<AccessibilityAbilityInfo> disabledAbilities = installedAbilities_;
@ -377,6 +398,10 @@ void AccessibilityAccountData::UpdateAccountCapabilities()
UpdateEventTouchGuideCapability();
UpdateGesturesSimulationCapability();
UpdateMagnificationCapability();
SetTouchGuideState(isEventTouchGuideState_);
SetGestureState(isGesturesSimulation_);
SetKeyEventObserverState(isFilteringKeyEvents_);
}
void AccessibilityAccountData::UpdateEventTouchGuideCapability()
@ -431,10 +456,12 @@ bool AccessibilityAccountData::SetCaptionState(const bool state)
{
HILOG_DEBUG("start.");
isCaptionState_ = state;
// temp deal: write json config
nlohmann::json jsonObj;
if (!JsonUtils::GetJsonObjFromJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH)) {
HILOG_ERROR("Get JsonObj from json failed.");
int errCode = 0;
std::shared_ptr<NativePreferences::Preferences> pref =
NativePreferences::PreferencesHelper::GetPreferences(PREF_TEST_PATH + "test.xml", errCode);
HILOG_DEBUG("errCode = %{public}d.", errCode);
if (errCode != 0) {
return false;
}
@ -446,8 +473,13 @@ bool AccessibilityAccountData::SetCaptionState(const bool state)
} else {
strValue = STATE_FALSE;
}
JsonUtils::SetStrValue(jsonObj, JSON_OBJECT_CAPTION_STATE, strValue);
JsonUtils::ToJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH);
int err = pref->PutString("CaptionState", strValue);
HILOG_DEBUG("pref->PutString() = %{public}d.", err);
err = pref->FlushSync();
HILOG_DEBUG("pref->FlushSync() = %{public}d.", err);
return true;
}
@ -455,12 +487,7 @@ bool AccessibilityAccountData::SetCaptionProperty(const CaptionProperty& caption
{
HILOG_DEBUG("start.");
captionProperty_ = caption;
// temp deal: write json config
nlohmann::json jsonObj;
if (!JsonUtils::GetJsonObjFromJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH)) {
HILOG_ERROR("Get JsonObj from json failed.");
return false;
}
std::string FONTFAMILY = captionProperty_.GetFontFamily();
int FONTSCALE = captionProperty_.GetFontScale();
std::string FONTCOLOR = captionProperty_.GetFontColor();
@ -468,13 +495,31 @@ bool AccessibilityAccountData::SetCaptionProperty(const CaptionProperty& caption
std::string BACKGROUNDCOLOR = captionProperty_.GetBackgroundColor();
std::string WINDOWCOLOR = captionProperty_.GetWindowColor();
JsonUtils::SetStrValue(jsonObj, JSON_OBJECT_CAPTION_STYLE, CAPTION_JSON_VALUE_FONTFAMILY, FONTFAMILY);
JsonUtils::SetIntValue(jsonObj, JSON_OBJECT_CAPTION_STYLE, CAPTION_JSON_VALUE_FONTSCALE, FONTSCALE);
JsonUtils::SetStrValue(jsonObj, JSON_OBJECT_CAPTION_STYLE, CAPTION_JSON_VALUE_FONTCOLOR, FONTCOLOR);
JsonUtils::SetStrValue(jsonObj, JSON_OBJECT_CAPTION_STYLE, CAPTION_JSON_VALUE_FONTEDGETYPE, FONTEDGETYPE);
JsonUtils::SetStrValue(jsonObj, JSON_OBJECT_CAPTION_STYLE, CAPTION_JSON_VALUE_BACKGROUNDCOLOR, BACKGROUNDCOLOR);
JsonUtils::SetStrValue(jsonObj, JSON_OBJECT_CAPTION_STYLE, CAPTION_JSON_VALUE_WINDOWCOLOR, WINDOWCOLOR);
JsonUtils::ToJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH);
int errCode = 0;
std::shared_ptr<NativePreferences::Preferences> pref =
NativePreferences::PreferencesHelper::GetPreferences(PREF_TEST_PATH + "test.xml", errCode);
HILOG_DEBUG("errCode = %{public}d.", errCode);
int err = pref->PutString("fontFamily", FONTFAMILY);
HILOG_DEBUG("pref->PutString() = %{public}d.", err);
err = pref->PutString("fontColor", FONTCOLOR);
HILOG_DEBUG("pref->PutString() = %{public}d.", err);
err = pref->PutString("fontEdgeType", FONTEDGETYPE);
HILOG_DEBUG("pref->PutString() = %{public}d.", err);
err = pref->PutString("backgroundColor", BACKGROUNDCOLOR);
HILOG_DEBUG("pref->PutString() = %{public}d.", err);
err = pref->PutString("windowColor", WINDOWCOLOR);
HILOG_DEBUG("pref->PutString() = %{public}d.", err);
err = pref->PutInt("fontScale", FONTSCALE);
HILOG_DEBUG("pref->PutInt() = %{public}d.", err);
err = pref->FlushSync();
HILOG_DEBUG("pref->FlushSync() = %{public}d.", err);
return true;
}
@ -483,10 +528,12 @@ bool AccessibilityAccountData::SetEnabled(const bool state)
{
HILOG_DEBUG("start.");
isEnabled_ = state;
// temp deal: write json config
nlohmann::json jsonObj;
if (!JsonUtils::GetJsonObjFromJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH)) {
HILOG_ERROR("Get JsonObj from json failed.");
int errCode = 0;
std::shared_ptr<NativePreferences::Preferences> pref =
NativePreferences::PreferencesHelper::GetPreferences(PREF_TEST_PATH + "test.xml", errCode);
HILOG_DEBUG("errCode = %{public}d.", errCode);
if (errCode != 0) {
return false;
}
@ -499,9 +546,11 @@ bool AccessibilityAccountData::SetEnabled(const bool state)
} else {
strValue = STATE_FALSE;
}
HILOG_DEBUG("strValue = %{public}s", strValue.c_str());
JsonUtils::SetStrValue(jsonObj, JSON_OBJECT_CAPABILITY, CAPABILITY_JSON_VALUE_ACCESSIBLE, strValue);
JsonUtils::ToJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH);
int err = pref->PutString("accessible", strValue);
HILOG_DEBUG("pref->PutString() = %{public}d.", err);
err = pref->FlushSync();
HILOG_DEBUG("pref->FlushSync() = %{public}d.", err);
return true;
}
@ -509,10 +558,12 @@ bool AccessibilityAccountData::SetTouchGuideState(const bool state)
{
HILOG_DEBUG("start.");
isEventTouchGuideState_ = state;
// temp deal: write json config
nlohmann::json jsonObj;
if (!JsonUtils::GetJsonObjFromJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH)) {
HILOG_ERROR("Get JsonObj from json failed.");
int errCode = 0;
std::shared_ptr<NativePreferences::Preferences> pref =
NativePreferences::PreferencesHelper::GetPreferences(PREF_TEST_PATH + "test.xml", errCode);
HILOG_DEBUG("errCode = %{public}d.", errCode);
if (errCode != 0) {
return false;
}
@ -524,8 +575,12 @@ bool AccessibilityAccountData::SetTouchGuideState(const bool state)
} else {
strValue = STATE_FALSE;
}
JsonUtils::SetStrValue(jsonObj, JSON_OBJECT_CAPABILITY, CAPABILITY_JSON_VALUE_TOUCH_GUIDE, strValue);
JsonUtils::ToJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH);
int err = pref->PutString("touchGuide", strValue);
HILOG_DEBUG("pref->PutString() = %{public}d.", err);
err = pref->FlushSync();
HILOG_DEBUG("pref->FlushSync() = %{public}d.", err);
return true;
}
@ -533,10 +588,12 @@ bool AccessibilityAccountData::SetGestureState(const bool state)
{
HILOG_DEBUG("start.");
isGesturesSimulation_ = state;
// temp deal: write json config
nlohmann::json jsonObj;
if (!JsonUtils::GetJsonObjFromJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH)) {
HILOG_ERROR("Get JsonObj from json failed.");
int errCode = 0;
std::shared_ptr<NativePreferences::Preferences> pref =
NativePreferences::PreferencesHelper::GetPreferences(PREF_TEST_PATH + "test.xml", errCode);
HILOG_DEBUG("errCode = %{public}d.", errCode);
if (errCode != 0) {
return false;
}
@ -548,8 +605,12 @@ bool AccessibilityAccountData::SetGestureState(const bool state)
} else {
strValue = STATE_FALSE;
}
JsonUtils::SetStrValue(jsonObj, JSON_OBJECT_CAPABILITY, CAPABILITY_JSON_VALUE_GESTURE, strValue);
JsonUtils::ToJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH);
int err = pref->PutString("gesture", strValue);
HILOG_DEBUG("pref->PutString() = %{public}d.", err);
err = pref->FlushSync();
HILOG_DEBUG("pref->FlushSync() = %{public}d.", err);
return true;
}
@ -557,10 +618,12 @@ bool AccessibilityAccountData::SetKeyEventObserverState(const bool state)
{
HILOG_DEBUG("start.");
isFilteringKeyEvents_ = state;
// temp deal: write json config
nlohmann::json jsonObj;
if (!JsonUtils::GetJsonObjFromJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH)) {
HILOG_ERROR("Get JsonObj from json failed.");
int errCode = 0;
std::shared_ptr<NativePreferences::Preferences> pref =
NativePreferences::PreferencesHelper::GetPreferences(PREF_TEST_PATH + "test.xml", errCode);
HILOG_DEBUG("errCode = %{public}d.", errCode);
if (errCode != 0) {
return false;
}
@ -572,8 +635,12 @@ bool AccessibilityAccountData::SetKeyEventObserverState(const bool state)
} else {
strValue = STATE_FALSE;
}
JsonUtils::SetStrValue(jsonObj, JSON_OBJECT_CAPABILITY, CAPABILITY_JSON_VALUE_KEY_EVENT_BOSERVER, strValue);
JsonUtils::ToJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH);
int err = pref->PutString("keyEventObserver", strValue);
HILOG_DEBUG("pref->PutString() = %{public}d.", err);
err = pref->FlushSync();
HILOG_DEBUG("pref->FlushSync() = %{public}d.", err);
return true;
}
@ -584,6 +651,7 @@ bool AccessibilityAccountData::GetEnabledState()
bool AccessibilityAccountData::GetTouchGuideState()
{
HILOG_DEBUG("start. isEventTouchGuideState_ = %{public}s", isEventTouchGuideState_ ? "true" : "false");
return isEventTouchGuideState_;
}
@ -611,25 +679,29 @@ bool AccessibilityAccountData::SetEnabledObj(std::map<std::string, AppExecFwk::E
enabledAbilities_.insert(std::pair<std::string, AppExecFwk::ElementName>(ability.first, ability.second));
}
for (auto& abilitie : enabledAbilities_) {
std::string bundleName = abilitie.second.GetBundleName();
HILOG_DEBUG("bundleName = %{public}s ", bundleName.c_str());
}
// temp deal: write json config
nlohmann::json jsonObj;
if (!JsonUtils::GetJsonObjFromJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH)) {
HILOG_ERROR("Get JsonObj from json failed.");
return false;
}
std::string BundleName = "";
for (auto& enableAbility : it) {
BundleName = enableAbility.second.GetBundleName();
JsonUtils::SetVecValue(jsonObj, JSON_OBJECT_ENABLED, BundleName);
std::vector<std::string> vecvalue;
for (auto& abilitie : enabledAbilities_) {
BundleName = abilitie.second.GetBundleName();
vecvalue.push_back(BundleName);
HILOG_DEBUG("bundleName = %{public}s ", BundleName.c_str());
}
JsonUtils::ToJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH);
std::string stringOut = "";
VectorToString(vecvalue, stringOut);
int errCode = 0;
std::shared_ptr<NativePreferences::Preferences> pref =
NativePreferences::PreferencesHelper::GetPreferences(PREF_TEST_PATH + "test.xml", errCode);
HILOG_DEBUG("errCode = %{public}d.", errCode);
int err = pref->PutString("BundleName", stringOut);
HILOG_DEBUG("pref->PutString() = %{public}d.", err);
err = pref->FlushSync();
HILOG_DEBUG("pref->FlushSync() = %{public}d.", err);
return true;
}
@ -662,17 +734,35 @@ bool AccessibilityAccountData::GetInstalledAbilitiesFromBMS()
return true;
}
void AccessibilityAccountData::CaptionInit(nlohmann::json jsonObj)
void AccessibilityAccountData::CaptionInit(const std::shared_ptr<NativePreferences::Preferences> &pref)
{
std::string FONTFAMILY = JsonUtils::GetStrValue(jsonObj, JSON_OBJECT_CAPTION_STYLE, CAPTION_JSON_VALUE_FONTFAMILY);
int FONTSCALE = JsonUtils::GetIntValue(jsonObj, JSON_OBJECT_CAPTION_STYLE, CAPTION_JSON_VALUE_FONTSCALE);
std::string FONTCOLOR = JsonUtils::GetStrValue(jsonObj, JSON_OBJECT_CAPTION_STYLE, CAPTION_JSON_VALUE_FONTCOLOR);
std::string FONTEDGETYPE = JsonUtils::GetStrValue(jsonObj,
JSON_OBJECT_CAPTION_STYLE, CAPTION_JSON_VALUE_FONTEDGETYPE);
std::string BACKGROUNDCOLOR = JsonUtils::GetStrValue(jsonObj,
JSON_OBJECT_CAPTION_STYLE, CAPTION_JSON_VALUE_BACKGROUNDCOLOR);
std::string WINDOWCOLOR = JsonUtils::GetStrValue(jsonObj,
JSON_OBJECT_CAPTION_STYLE, CAPTION_JSON_VALUE_WINDOWCOLOR);
HILOG_DEBUG("start.");
std::string strValue = pref->GetString("CaptionState", "");
HILOG_DEBUG(" pref->GetString() = %{public}s.", strValue.c_str());
if (std::strcmp(strValue.c_str(), "on") == 0) {
isCaptionState_ = true;
} else {
isCaptionState_ = false;
}
std::string FONTFAMILY = pref->GetString("fontFamily", "default");
HILOG_DEBUG(" pref->GetString() = %{public}s.", FONTFAMILY.c_str());
int FONTSCALE = pref->GetInt("fontScale", 0);
HILOG_DEBUG(" pref->GetString() = %{public}d.", FONTSCALE);
std::string FONTCOLOR = pref->GetString("fontColor", "");
HILOG_DEBUG(" pref->GetString() = %{public}s.", FONTCOLOR.c_str());
std::string FONTEDGETYPE = pref->GetString("fontEdgeType", "none");
HILOG_DEBUG(" pref->GetString() = %{public}s.", FONTEDGETYPE.c_str());
std::string BACKGROUNDCOLOR = pref->GetString("backgroundColor", "");
HILOG_DEBUG(" pref->GetString() = %{public}s.", BACKGROUNDCOLOR.c_str());
std::string WINDOWCOLOR = pref->GetString("windowColor", "");
HILOG_DEBUG(" pref->GetString() = %{public}s.", WINDOWCOLOR.c_str());
captionProperty_.SetFontFamily(FONTFAMILY);
captionProperty_.SetFontScale(FONTSCALE);
@ -680,19 +770,13 @@ void AccessibilityAccountData::CaptionInit(nlohmann::json jsonObj)
captionProperty_.SetFontEdgeType(FONTEDGETYPE);
captionProperty_.SetBackgroundColor(BACKGROUNDCOLOR);
captionProperty_.SetWindowColor(WINDOWCOLOR);
std::string strValue = JsonUtils::GetStrValue(jsonObj, JSON_OBJECT_CAPTION_STATE);
HILOG_DEBUG("strValue = %{public}s", strValue.c_str());
if (std::strcmp(strValue.c_str(), "on") == 0) {
isCaptionState_ = true;
} else {
isCaptionState_ = false;
}
}
void AccessibilityAccountData::CapbilityInit(nlohmann::json jsonObj)
void AccessibilityAccountData::CapbilityInit(const std::shared_ptr<NativePreferences::Preferences> &pref)
{
std::string strValue = JsonUtils::GetStrValue(jsonObj, JSON_OBJECT_CAPABILITY, CAPABILITY_JSON_VALUE_ACCESSIBLE);
HILOG_DEBUG("start.");
std::string strValue = pref->GetString("accessible", "");
HILOG_DEBUG("strValue = %{public}s", strValue.c_str());
if (std::strcmp(strValue.c_str(), "on") == 0) {
isEnabled_ = true;
@ -700,15 +784,17 @@ void AccessibilityAccountData::CapbilityInit(nlohmann::json jsonObj)
isEnabled_ = false;
}
strValue = JsonUtils::GetStrValue(jsonObj, JSON_OBJECT_CAPABILITY, CAPABILITY_JSON_VALUE_TOUCH_GUIDE);
strValue = pref->GetString("touchGuide", "");
HILOG_DEBUG("strValue = %{public}s", strValue.c_str());
if (std::strcmp(strValue.c_str(), "on") == 0) {
HILOG_DEBUG("isEventTouchGuideState_ = true");
isEventTouchGuideState_ = true;
} else {
HILOG_DEBUG("isEventTouchGuideState_ = false");
isEventTouchGuideState_ = false;
}
strValue = JsonUtils::GetStrValue(jsonObj, JSON_OBJECT_CAPABILITY, CAPABILITY_JSON_VALUE_KEY_EVENT_BOSERVER);
strValue = pref->GetString("gesture", "");
HILOG_DEBUG("strValue = %{public}s", strValue.c_str());
if (std::strcmp(strValue.c_str(), "on") == 0) {
isFilteringKeyEvents_ = true;
@ -716,7 +802,7 @@ void AccessibilityAccountData::CapbilityInit(nlohmann::json jsonObj)
isFilteringKeyEvents_ = false;
}
strValue = JsonUtils::GetStrValue(jsonObj, JSON_OBJECT_CAPABILITY, CAPABILITY_JSON_VALUE_GESTURE);
strValue = pref->GetString("keyEventObserver", "");
HILOG_DEBUG("strValue = %{public}s", strValue.c_str());
if (std::strcmp(strValue.c_str(), "on") == 0) {
isGesturesSimulation_ = true;
@ -725,12 +811,17 @@ void AccessibilityAccountData::CapbilityInit(nlohmann::json jsonObj)
}
}
void AccessibilityAccountData::EnabledListInit(nlohmann::json jsonObj)
void AccessibilityAccountData::EnabledListInit(const std::shared_ptr<NativePreferences::Preferences> &pref)
{
HILOG_DEBUG("start.");
std::string BundleName = "";
AccessibilityAbilityInfo abilityInfo;
std::vector<std::string> vecvalue = JsonUtils::GetVecValue(jsonObj, JSON_OBJECT_ENABLED);
std::string strValue = pref->GetString("BundleName", "");
HILOG_DEBUG("strValue = %{public}s", strValue.c_str());
std::vector<std::string> vecvalue;
StringToVector(strValue, vecvalue);
for (auto i = vecvalue.begin(); i != vecvalue.end(); i++) {
BundleName = *i;
HILOG_DEBUG("BundleName = %{public}s", BundleName.c_str());
@ -739,15 +830,63 @@ void AccessibilityAccountData::EnabledListInit(nlohmann::json jsonObj)
}
}
void AccessibilityAccountData::StringToVector(std::string &stringIn, std::vector<std::string> &vectorResult)
{
HILOG_DEBUG("start.");
int strLength = stringIn.size();
std::vector<int> position;
int wrodCount = 0;
if (strLength == 0) {
return;
}
for (int i = 0; i < strLength; i++) {
if (stringIn[i] == ',') {
position.push_back(i);
}
}
wrodCount = position.size();
if ((wrodCount == 0) && (strLength > 0)) {
vectorResult.push_back(stringIn);
} else {
int startWrod = 0;
int length = 0;
for (int i = 0; i <= wrodCount; i++) {
if (i == 0) {
startWrod = 0;
length = position[i];
vectorResult.push_back(stringIn.substr(startWrod, length)); // first string
} else if (i < wrodCount) {
startWrod = position[i - 1] + 1;
length = position[i] - position[i - 1] - 1;
vectorResult.push_back(stringIn.substr(startWrod, length)); // second string to last-1 string
} else {
startWrod = position[i - 1] + 1;
length = strLength - position[i - 1] - 1;
vectorResult.push_back(stringIn.substr(startWrod, length)); // last string
}
}
}
HILOG_DEBUG("strLength = %{public}d, wrodCount = %{public}d, stringIn : %{public}s",
strLength, wrodCount, stringIn.c_str());
for(auto& var : vectorResult) {
HILOG_DEBUG("vectorResult = %{public}s ", var.c_str());
}
HILOG_DEBUG("end.");
}
void AccessibilityAccountData::init()
{
nlohmann::json jsonObj;
if (!JsonUtils::GetJsonObjFromJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH)) {
HILOG_ERROR("Get JsonObj from json failed.");
}
CaptionInit(jsonObj);
CapbilityInit(jsonObj);
EnabledListInit(jsonObj);
int errCode = 0;
std::shared_ptr<NativePreferences::Preferences> pref =
NativePreferences::PreferencesHelper::GetPreferences(PREF_TEST_PATH + "test.xml", errCode);
HILOG_DEBUG("errCode = %{public}d.", errCode);
CaptionInit(pref);
CapbilityInit(pref);
EnabledListInit(pref);
}
bool AccessibilityAccountData::DisableAbilities(std::map<std::string, AppExecFwk::ElementName> it)
@ -757,19 +896,37 @@ bool AccessibilityAccountData::DisableAbilities(std::map<std::string, AppExecFwk
enabledAbilities_.erase(disAbilities.first);
}
// temp deal: write json config
nlohmann::json jsonObj;
if (!JsonUtils::GetJsonObjFromJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH)) {
HILOG_ERROR("Get JsonObj from json failed.");
return false;
}
int errCode = 0;
std::shared_ptr<NativePreferences::Preferences> pref =
NativePreferences::PreferencesHelper::GetPreferences(PREF_TEST_PATH + "test.xml", errCode);
HILOG_DEBUG("errCode = %{public}d.", errCode);
std::string strValue = pref->GetString("BundleName","");
HILOG_DEBUG("strValue = %{public}s", strValue.c_str());
std::vector<std::string> vecvalue;
StringToVector(strValue, vecvalue);
std::string BundleName = "";
for (auto& disableAbility : it) {
BundleName = disableAbility.second.GetBundleName();
HILOG_DEBUG("BundleName = %{public}s", BundleName.c_str());
JsonUtils::RemoveVecValue(jsonObj, JSON_OBJECT_ENABLED, BundleName);
for (std::vector<std::string>::iterator val = vecvalue.begin(); val != vecvalue.end();) {
if (std::strcmp(val->c_str(), BundleName.c_str()) == 0) {
val = vecvalue.erase(val);
HILOG_DEBUG("remove val = %{public}s", val->c_str());
} else {
val++;
}
}
}
JsonUtils::ToJson(jsonObj, AccessibleAbility_Config_JSON_FILE_PATH);
std::string stringOut = "";
VectorToString(vecvalue, stringOut);
int err = pref->PutString("BundleName", stringOut);
HILOG_DEBUG("pref->PutString() = %{public}d.", err);
err = pref->FlushSync();
HILOG_DEBUG("pref->FlushSync() = %{public}d.", err);
DelayedSingleton<AccessibleAbilityManagerService>::GetInstance()->UpdateAbilities();
return true;
@ -795,5 +952,19 @@ const sptr<AccessibleAbilityConnection> AccessibilityAccountData::GetUITestConne
HILOG_DEBUG("start.");
return uiTestConnectedA11yAbility_;
}
} // namespace Accessibility
} // namespace OHOS
void AccessibilityAccountData::VectorToString(std::vector<std::string> &vectorVal,std::string &stringOut)
{
HILOG_DEBUG("start.");
int i = 0;
for (auto& var : vectorVal) {
if (i > 0) {
stringOut = stringOut + ',';
}
stringOut = stringOut + var.c_str();
i++;
}
HILOG_DEBUG("end stringOUT = %{public}s .", stringOut.c_str());
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -56,7 +56,7 @@ AccessibilityInteractionBridge::AccessibilityInteractionBridge()
AccessibilityElementInfo AccessibilityInteractionBridge::FindFocusedElementInfo()
{
HILOG_DEBUG("[%{public}s without window]", __func__);
HILOG_DEBUG("[without window]");
return FindFocusedElementInfo(ANY_WINDOW_ID);
}
@ -66,7 +66,7 @@ bool AccessibilityInteractionBridge::ExecuteActionOnAccessibilityFocused(const A
HILOG_DEBUG("start");
auto focus = FindFocusedElementInfo();
std::map<std::string, std::string> actionArguments {};
HILOG_DEBUG("[%{public}s ExecuteAction]", __func__);
HILOG_DEBUG("[ExecuteAction]");
return focus.ExecuteAction(action, actionArguments);
}
@ -138,7 +138,7 @@ bool AccessibilityInteractionBridge::GetPointerItermOfAccessibilityFocusClick(MM
AccessibilityElementInfo AccessibilityInteractionBridge::FindFocusedElementInfo(const int &windowId)
{
HILOG_DEBUG("[%{public}s with window]", __func__);
HILOG_DEBUG("[windowId %{public}d]", windowId);
AccessibilityElementInfo info {};
AccessibilityOperator::GetInstance().FindFocusedElementInfo(INTERACTION_BRIDGE_CHANNEL_ID,
windowId, NONE_ID, FOCUS_TYPE_ACCESSIBILITY, info);

View File

@ -21,7 +21,7 @@ namespace Accessibility {
void AccessibilityWindowListener::OnWindowUpdate(const sptr<Rosen::WindowInfo>& windowInfo,
Rosen::WindowUpdateType type)
{
HILOG_DEBUG("%{public}s: windowId[%{public}d] type[%{public}d]", __func__, windowInfo->wid_, type);
HILOG_DEBUG("windowId[%{public}d] type[%{public}d]", windowInfo->wid_, type);
auto aams = DelayedSingleton<AccessibleAbilityManagerService>::GetInstance();
auto accountData = aams->GetCurrentAccountData();
if (accountData->GetAccessibilityWindowConnection(windowInfo->wid_) == nullptr) {
@ -84,7 +84,7 @@ void AccessibilityWindowListener::OnWindowUpdate(const sptr<Rosen::WindowInfo>&
default:
break;
}
HILOG_DEBUG("%{public}s: winMgr.a11yWindows[%{public}d]", __func__, winMgr.a11yWindows_.size());
HILOG_DEBUG("winMgr.a11yWindows[%{public}d]", winMgr.a11yWindows_.size());
}
AccessibilityWindowInfoManager &AccessibilityWindowInfoManager::GetInstance()
@ -123,7 +123,7 @@ WindowType ConvertWindowType(Rosen::WindowType type)
} else if ((type >= Rosen::WindowType::SYSTEM_WINDOW_BASE) && (type <= Rosen::WindowType::SYSTEM_WINDOW_END)) {
winType = TYPE_SYSTEM;
} else {
HILOG_ERROR("%{public}s: Unknown windowType[%{public}d]", __func__, type);
HILOG_ERROR("Unknown windowType[%{public}d]", type);
}
return winType;
}
@ -162,7 +162,7 @@ void AccessibilityWindowInfoManager::DeregisterWindowChangeListener()
void AccessibilityWindowInfoManager::SetActiveWindow(int windowId)
{
HILOG_DEBUG("%{public}s start windowId(%{public}d)", __func__, windowId);
HILOG_DEBUG("windowId(%{public}d)", windowId);
if (windowId == INVALID_WINDOW_ID) {
if (a11yWindows_.count(activeWindowId_)) {
a11yWindows_[activeWindowId_].SetActive(false);
@ -186,12 +186,12 @@ void AccessibilityWindowInfoManager::SetActiveWindow(int windowId)
AccessibilityEventInfo evtInf(activeWindowId_, WINDOW_UPDATE_ACTIVE);
aams->SendEvent(evtInf, aams->GetCurrentAccountId());
}
HILOG_DEBUG("%{public}s %{public}d", __func__, activeWindowId_);
HILOG_DEBUG("activeWindowId is %{public}d", activeWindowId_);
}
void AccessibilityWindowInfoManager::SetAccessibilityFocusedWindow(int windowId)
{
HILOG_DEBUG("%{public}s start", __func__);
HILOG_DEBUG("start");
if (windowId == INVALID_WINDOW_ID) {
if (a11yWindows_.count(a11yFocusedWindowId_)) {
a11yWindows_[a11yFocusedWindowId_].SetAccessibilityFocused(false);
@ -212,7 +212,7 @@ void AccessibilityWindowInfoManager::SetAccessibilityFocusedWindow(int windowId)
a11yFocusedWindowId_ = windowId;
a11yWindows_[a11yFocusedWindowId_].SetAccessibilityFocused(true);
}
HILOG_DEBUG("%{public}s %{public}d", __func__, a11yFocusedWindowId_);
HILOG_DEBUG("a11yFocusedWindowId_ is %{public}d", a11yFocusedWindowId_);
}
void AccessibilityWindowInfoManager::SetInputFocusedWindow(int windowId)

View File

@ -14,7 +14,7 @@
*/
#include "accessibility_zoom_gesture.h"
#include <cmath>
#include <complex>
namespace OHOS {
namespace Accessibility {

View File

@ -324,7 +324,7 @@ void AccessibleAbilityConnection::OnAbilityConnectDone(const AppExecFwk::Element
HILOG_ERROR("AccessibleAbilityConnection::OnAbilityConnectDone get AccessibleAbilityClientProxy failed");
return;
}
HILOG_ERROR("AccessibleAbilityConnection::OnAbilityConnectDone get AccessibleAbilityClientProxy successfully");
HILOG_DEBUG("AccessibleAbilityConnection::OnAbilityConnectDone get AccessibleAbilityClientProxy successfully");
if (!deathRecipient_) {
wptr<AccessibilityAccountData> data(accountData_);
@ -336,12 +336,12 @@ void AccessibleAbilityConnection::OnAbilityConnectDone(const AppExecFwk::Element
}
sptr<AccessibleAbilityConnection> pointer = this;
stub_ = new AccessibleAbilityChannelStubImpl(*pointer);
proxy_->Init(stub_, connectionId_);
accountData_->AddConnectedAbility(pointer);
accountData_->RemoveConnectingA11yAbility(elementName_);
DelayedSingleton<AccessibleAbilityManagerService>::GetInstance()->UpdateAccessibilityManagerService();
stub_ = new AccessibleAbilityChannelStubImpl(*pointer);
proxy_->Init(stub_, connectionId_);
}
void AccessibleAbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode)
@ -470,6 +470,7 @@ bool AccessibleAbilityConnection::IsWantedEvent(int eventType)
{
uint32_t type = static_cast<uint32_t>(eventType);
if ((type & abilityInfo_.GetEventTypes()) != type) {
HILOG_DEBUG("EventType(%{public}d) is not wanted", type);
return false;
}
return true;
@ -485,7 +486,7 @@ AAFwk::Want CreateWant(AppExecFwk::ElementName& element)
void AccessibleAbilityConnection::Disconnect()
{
HILOG_DEBUG(" %{public}s start", __func__);
HILOG_DEBUG("start");
// temp deal:
#if 1
if (AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(this) != ERR_OK) {
@ -499,7 +500,7 @@ void AccessibleAbilityConnection::Disconnect()
void AccessibleAbilityConnection::Connect(const AppExecFwk::ElementName &element)
{
HILOG_DEBUG(" %{public}s start", __func__);
HILOG_DEBUG("start");
elementName_ = element;
AAFwk::Want want = CreateWant(elementName_);
HILOG_DEBUG("GetBundleName is %{public}s ", elementName_.GetBundleName().c_str());
@ -521,7 +522,7 @@ void AccessibleAbilityConnection::Connect(const AppExecFwk::ElementName &element
int AccessibleAbilityConnection::GetChannelId()
{
HILOG_DEBUG(" %{public}s connectionId_ is %{public}d", __func__, connectionId_);
HILOG_DEBUG("connectionId_ is %{public}d", connectionId_);
return connectionId_;
}
@ -532,6 +533,7 @@ void AccessibleAbilityConnection::AccessibleAbilityConnectionDeathRecipient::OnR
if (!recipientAccountData_.promote()) {
HILOG_ERROR("recipientAccountData_ is null.");
return;
}
sptr<AccessibleAbilityConnection> connection = recipientAccountData_->

View File

@ -153,7 +153,7 @@ void AccessibleAbilityManagerService::SendEvent(const AccessibilityEventInfo& ui
HILOG_INFO("eventType[%{public}d]", (int)uiEvent.GetEventType());
HILOG_INFO("gestureId[%{public}d]", (int)uiEvent.GetGestureType());
if (accountId != currentAccountId_) {
HILOG_ERROR(" %{public}s accountId[%{public}d] is not matched", __func__, accountId);
HILOG_ERROR("accountId[%{public}d] is not matched", accountId);
return;
}
AccessibilityEventInfo& event = const_cast<AccessibilityEventInfo&>(uiEvent);
@ -179,7 +179,7 @@ uint32_t AccessibleAbilityManagerService::RegisterCaptionPropertyCallback(
{
HILOG_DEBUG("start");
if (accountId != currentAccountId_) {
HILOG_ERROR(" %{public}s accountId[%{public}d] is not matched", __func__, accountId);
HILOG_ERROR("accountId[%{public}d] is not matched", accountId);
return ERR_INVALID_VALUE;
}
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
@ -205,7 +205,7 @@ uint32_t AccessibleAbilityManagerService::RegisterStateCallback(
{
HILOG_DEBUG("start");
if (accountId != currentAccountId_) {
HILOG_ERROR(" %{public}s accountId[%{public}d] is not matched", __func__, accountId);
HILOG_ERROR("accountId[%{public}d] is not matched", accountId);
return 0;
}
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
@ -228,8 +228,7 @@ uint32_t AccessibleAbilityManagerService::RegisterStateCallback(
vector<AccessibilityAbilityInfo> AccessibleAbilityManagerService::GetAbilityList(
const int abilityTypes, const int stateType)
{
HILOG_DEBUG(" %{public}s abilityTypes(%{public}d) stateType(%{public}d)",
__func__, abilityTypes, stateType);
HILOG_DEBUG("abilityTypes(%{public}d) stateType(%{public}d)", abilityTypes, stateType);
vector<AccessibilityAbilityInfo> infoList;
if ((stateType > ABILITY_STATE_INSTALLED) || (stateType < ABILITY_STATE_ENABLE)) {
HILOG_ERROR("stateType is out of range!!");
@ -244,14 +243,14 @@ vector<AccessibilityAbilityInfo> AccessibleAbilityManagerService::GetAbilityList
AbilityStateType state = static_cast<AbilityStateType>(stateType);
vector<AccessibilityAbilityInfo> abilities = accountData->GetAbilitiesByState(state);
HILOG_DEBUG(" %{public}s:abilityes count is %{public}d", __func__, abilities.size());
HILOG_DEBUG("abilityes count is %{public}d", abilities.size());
for (auto& ability : abilities) {
if (static_cast<uint32_t>(abilityTypes) == AccessibilityAbilityTypes::ACCESSIBILITY_ABILITY_TYPE_ALL ||
(ability.GetAccessibilityAbilityType() & static_cast<uint32_t>(abilityTypes))) {
infoList.push_back(ability);
}
}
HILOG_DEBUG(" %{public}s:infoList count is %{public}d", __func__, infoList.size());
HILOG_DEBUG("infoList count is %{public}d", infoList.size());
return infoList;
}
@ -348,7 +347,7 @@ bool AccessibleAbilityManagerService::SetEnabled(const bool state)
sptr<AccessibilityAccountData> AccessibleAbilityManagerService::GetCurrentAccountData()
{
HILOG_DEBUG(" %{public}s: currentAccoutId is %{public}d ", __func__, currentAccountId_);
HILOG_DEBUG("currentAccoutId is %{public}d ", currentAccountId_);
auto iter = a11yAccountsData_.find(currentAccountId_);
if (iter != a11yAccountsData_.end()) {
return iter->second;
@ -411,7 +410,7 @@ sptr<AppExecFwk::IBundleMgr> AccessibleAbilityManagerService::GetBundleMgrProxy(
sptr<AccessibilityWindowConnection> AccessibleAbilityManagerService::GetAccessibilityWindowConnection(
int windowId)
{
HILOG_DEBUG(" %{public}s windowId(%{public}d)", __func__, windowId);
HILOG_DEBUG("windowId(%{public}d)", windowId);
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (!accountData) {
HILOG_ERROR("Get account data failed");
@ -486,13 +485,13 @@ void AccessibleAbilityManagerService::CaptionPropertyCallbackDeathRecipient::OnR
void AccessibleAbilityManagerService::RemovedUser(int32_t accountId)
{
HILOG_DEBUG("%{public}s start", __func__);
HILOG_DEBUG("accountId(%{public}d)", accountId);
a11yAccountsData_.erase(accountId);
}
void AccessibleAbilityManagerService::PresentUser()
{
HILOG_DEBUG("%{public}s start", __func__);
HILOG_DEBUG();
GetCurrentAccountData()->ReadConfigurationForAccountData();
UpdateAbilities();
@ -621,7 +620,7 @@ void AccessibleAbilityManagerService::PackageUpdateFinished(std::string& bundleN
void AccessibleAbilityManagerService::UpdateAccessibilityWindowStateByEvent(const AccessibilityEventInfo& event)
{
EventType evtType = event.GetEventType();
HILOG_DEBUG("%{public}s start %{public}d", __func__, event.GetWindowId());
HILOG_DEBUG("windowId is %{public}d", event.GetWindowId());
switch (evtType) {
case TYPE_VIEW_HOVER_ENTER_EVENT:
case TYPE_VIEW_ACCESSIBILITY_FOCUSED_EVENT:
@ -677,10 +676,6 @@ void AccessibleAbilityManagerService::UpdateAbilities()
sptr<AccessibleAbilityConnection> connection = accountData->GetAccessibleAbilityConnection(elementName);
if (accountData->GetEnabledAbilities().count(elementName)) {
if (!connection) {
// this is a temp deal for ace test
installAbility.SetCapabilityValues(Capability::CAPABILITY_RETRIEVE |
Capability::CAPABILITY_KEY_EVENT_OBSERVER |
Capability::CAPABILITY_GESTURE);
connection = new AccessibleAbilityConnection(accountData, connectCounter_++, installAbility);
connection->Connect(element);
}
@ -802,10 +797,10 @@ void AccessibleAbilityManagerService::UpdateWindowChangeListener()
}
}
if (isWindowRetrieve) {
HILOG_INFO("%{public}s RegisterWindowChangeListener.", __func__);
HILOG_INFO("RegisterWindowChangeListener.");
AccessibilityWindowInfoManager::GetInstance().RegisterWindowChangeListener();
} else {
HILOG_INFO("%{public}s DeregisterWindowChangeListener.", __func__);
HILOG_INFO("DeregisterWindowChangeListener.");
AccessibilityWindowInfoManager::GetInstance().DeregisterWindowChangeListener();
AccessibilityWindowInfoManager::GetInstance().GetAccessibilityWindows().clear();
}
@ -918,7 +913,7 @@ bool AccessibleAbilityManagerService::RegisterUITestAbilityConnectionClient(cons
sptr<AccessibleAbilityConnection> connection = GetCurrentAccountData()->GetUITestConnectedAbilityConnection();
if (connection) {
HILOG_ERROR(" %{public}s connection is existed!!", __func__);
HILOG_ERROR("connection is existed!!");
return false;
}
@ -958,7 +953,7 @@ bool AccessibleAbilityManagerService::DeregisterUITestAbilityConnectionClient()
sptr<AccessibleAbilityConnection> connection = GetCurrentAccountData()->GetUITestConnectedAbilityConnection();
if (connection == nullptr) {
HILOG_ERROR(" %{public}s connection is not existed!!", __func__);
HILOG_ERROR("connection is not existed!!");
return false;
}
std::function<void()> removeUITestClientFunc =

View File

@ -12,6 +12,7 @@
# limitations under the License.
import("//build/test.gni")
import("//base/accessibility/services/test/aamstestmock.gni")
module_output_path = "accessibility/framework_test"
@ -29,6 +30,7 @@ config("module_private_config") {
"//utils/native/base/include",
"//utils/system/safwk/native/include",
"//base/accessibility/services/aams/include",
"//base/accessibility/services/test/mock/distributeddatamgr/include",
"//base/accessibility/frameworks/asacfwk/include",
"//base/accessibility/frameworks/aafwk/include",
"//base/accessibility/interfaces/innerkits/asacfwk/include",
@ -52,6 +54,7 @@ config("module_private_config") {
"//base/powermgr/power_manager/interfaces/innerkits/native/include",
"//foundation/appexecfwk/standard/kits/appkit/native/app/include",
"//base/global/resmgr_standard/interfaces/innerkits/include",
"//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_preferences/include",
"//foundation/distributedschedule/samgr/services/samgr/native/include",
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include",
"//foundation/distributedschedule/samgr/interfaces/innerkits/common/include",
@ -120,6 +123,7 @@ ohos_unittest("accessibility_account_data_test") {
"mock/mock_display_manager.cpp",
"unittest/accessibility_account_data_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
configs = [ ":module_private_config" ]
@ -211,6 +215,7 @@ ohos_unittest("accessible_ability_manager_service_test") {
"mock/system_ability_mock.cpp",
"unittest/accessible_ability_manager_service_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
configs = [
":module_private_config",
@ -294,6 +299,7 @@ ohos_unittest("accessibility_touch_guider_test") {
"mock/system_ability_mock.cpp",
"unittest/accessibility_touch_guider_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
configs = [
":module_private_config",
@ -379,6 +385,7 @@ ohos_unittest("accessibility_common_event_registry_test") {
"mock/system_ability_mock.cpp",
"unittest/accessibility_common_event_registry_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
configs = [
":module_private_config",
@ -461,6 +468,7 @@ ohos_unittest("accessibility_input_interceptor_test") {
"mock/mock_input_manager.cpp",
"unittest/accessibility_input_interceptor_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
configs = [ ":module_private_config" ]
@ -538,6 +546,7 @@ ohos_unittest("accessibility_window_manager_test") {
"mock/mock_display_manager.cpp",
"unittest/accessibility_window_manager_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
configs = [ ":module_private_config" ]
@ -625,6 +634,7 @@ ohos_unittest("accessibility_keyevent_filter_test") {
"mock/system_ability_mock.cpp",
"unittest/accessibility_keyevent_filter_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
configs = [
":module_private_config",
@ -720,6 +730,7 @@ ohos_unittest("accessible_ability_connection_test") {
"mock/system_ability_mock.cpp",
"unittest/accessible_ability_connection_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
configs = [
":module_private_config",
@ -806,6 +817,7 @@ ohos_unittest("accessibility_display_manager_test") {
"mock/system_ability_mock.cpp",
"unittest/accessibility_display_manager_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
configs = [
":module_private_config",
@ -889,6 +901,7 @@ ohos_unittest("accessibility_touchEvent_injector_test") {
"mock/system_ability_mock.cpp",
"unittest/accessibility_touchEvent_injector_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
configs = [
":module_private_config",
@ -978,6 +991,7 @@ ohos_unittest("accessibility_interaction_bridge_test") {
"mock/system_ability_mock.cpp",
"unittest/accessibility_interaction_bridge_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
configs = [
":module_private_config",

View File

@ -50,7 +50,7 @@ sptr<IAccessibleAbilityChannel> AccessibilityOperator::GetChannel(int channelId)
void AccessibilityOperator::AddChannel(const int channelId, const sptr<IAccessibleAbilityChannel> &channel)
{
HILOG_DEBUG("[%{public}s] Add connection to aams [channelId:%{public}d]", __func__, channelId);
HILOG_DEBUG("[Add connection to aams [channelId:%{public}d]", channelId);
int tempId = *(const_cast<int *>(&channelId));
for (auto iter = channels_.begin(); iter != channels_.end(); iter++) {
if (iter->first == tempId) {
@ -64,7 +64,7 @@ void AccessibilityOperator::AddChannel(const int channelId, const sptr<IAccessib
void AccessibilityOperator::RemoveChannel(int channelId)
{
HILOG_DEBUG("[%{public}s] Remove connection to aams [channelId:%{public}d]", __func__, channelId);
HILOG_DEBUG("Remove connection to aams [channelId:%{public}d]", channelId);
auto iter = channels_.find(channelId);
if (iter != channels_.end()) {
channels_.erase(iter);

View File

@ -69,12 +69,9 @@ void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent &keyEvent
MessageParcel data;
MessageParcel reply;
HILOG_DEBUG();
HILOG_DEBUG("%{public}s start.-------------------------zjx mock Proxy Start ", __func__);
HILOG_DEBUG("%{public}s start.-----sequence--%{public}d ----------zjx mock Proxy Start ", __func__, sequence);
HILOG_DEBUG("start.-----sequence--%{public}d ----------mock Proxy Start ", sequence);
g_testKeyPressEvent = sequence;
HILOG_DEBUG("%{public}s mock AccessibleAbilityClientProxy -------mock -----mock------------- end.", __func__);
HILOG_DEBUG("%{public}s start.-----------------------------zjx mock Proxy end ", __func__);
HILOG_DEBUG("start.-----------------------------mock Proxy end ");
}
void AccessibleAbilityClientProxy::OnDisplayResized(const int displayId, const Rect &rect, const float scale,

View File

@ -543,7 +543,7 @@ uint32_t AccessibleAbilityManagerService::RegisterCaptionPropertyCallback(
{
HILOG_DEBUG("start");
if (accountId != currentAccountId_) {
HILOG_ERROR(" %{public}s accountId[%{public}d] is not matched", __func__, accountId);
HILOG_ERROR("accountId[%{public}d] is not matched", accountId);
return ERR_INVALID_VALUE;
}
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();

View File

@ -12,6 +12,7 @@
# limitations under the License.
import("//build/test.gni")
import("//base/accessibility/services/test/aamstestmock.gni")
module_output_path = "accessibility/framework_test"
@ -30,6 +31,7 @@ config("module_private_config") {
"mock/multimodalinput/include",
"mock/powermanager/include",
"mock/aafwk/include",
"mock/distributeddatamgr/include",
"../aams/test/mock/",
"//third_party/json/include",
"//utils/native/base/include",
@ -42,6 +44,7 @@ config("module_private_config") {
"//foundation/aafwk/standard/interfaces/innerkits/base/include",
"//foundation/aafwk/standard/interfaces/innerkits/want/include/ohos/aafwk/content",
"//foundation/aafwk/standard/interfaces/innerkits/want/include",
"//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_preferences/include",
"//foundation/distributedschedule/dmsfwk/services/dtbschedmgr/include",
"//base/notification/ces_standard/interfaces/innerkits/native/include",
"//base/accessibility/dummyData",
@ -144,6 +147,7 @@ ohos_moduletest("aams_accessibility_touch_guider_test") {
"moduletest/aamstest/aams_accessibility_touch_guider_test/mock/accessibility_window_info_mock.cpp",
]
sources += aams_mock_distributeddatamgr_src
sources += MockMultiModalInputSrc
sources += MockPowerManagerSrc
sources += MockAafwkSrc
@ -229,6 +233,7 @@ ohos_moduletest("aams_accessibility_touchEvent_injector_test") {
"moduletest/aamstest/aams_accessibility_touchEvent_injector_test/mock/accessibility_window_info_mock.cpp",
]
sources += aams_mock_distributeddatamgr_src
sources += MockMultiModalInputSrc
sources += MockPowerManagerSrc
sources += MockAafwkSrc
@ -326,6 +331,7 @@ ohos_moduletest("aams_accessible_ability_channel_test") {
"moduletest/aamstest/aams_accessible_ability_channel_test/aams_accessible_ability_channel_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
sources += MockMultiModalInputSrc
sources += MockPowerManagerSrc
sources += MockAafwkSrc
@ -425,6 +431,7 @@ ohos_moduletest("aams_server_test") {
"moduletest/aamstest/aams_server_test/aams_server_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
sources += MockMultiModalInputSrc
sources += MockPowerManagerSrc
sources += MockAafwkSrc
@ -512,6 +519,7 @@ ohos_moduletest("aams_accessibility_keyevent_filter_test") {
"moduletest/aamstest/aams_accessibility_keyevent_filter_test/aams_accessibility_keyevent_filter_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
sources += MockMultiModalInputSrc
sources += MockPowerManagerSrc
sources += MockAafwkSrc
@ -608,6 +616,7 @@ ohos_moduletest("aams_common_event_registry_test") {
"moduletest/aamstest/aams_common_event_registry_test/aams_common_event_registry_test.cpp",
]
sources += aams_mock_distributeddatamgr_src
sources += MockMultiModalInputSrc
sources += MockPowerManagerSrc
sources += MockAafwkSrc

View File

@ -53,7 +53,7 @@ sptr<IAccessibleAbilityChannel> AccessibilityOperator::GetChannel(int channelId)
void AccessibilityOperator::AddChannel(const int channelId, const sptr<IAccessibleAbilityChannel> &channel)
{
HILOG_DEBUG("[%{public}s] Add connection to aams [channelId:%{public}d]", __func__, channelId);
HILOG_DEBUG("Add connection to aams [channelId:%{public}d]", channelId);
int tempId = *(const_cast<int *>(&channelId));
for (auto iter = channels_.begin(); iter != channels_.end(); iter++) {
if (iter->first == tempId) {
@ -67,7 +67,7 @@ void AccessibilityOperator::AddChannel(const int channelId, const sptr<IAccessib
void AccessibilityOperator::RemoveChannel(int channelId)
{
HILOG_DEBUG("[%{public}s] Remove connection to aams [channelId:%{public}d]", __func__, channelId);
HILOG_DEBUG("Remove connection to aams [channelId:%{public}d]", channelId);
auto iter = channels_.find(channelId);
if (iter != channels_.end()) {
channels_.erase(iter);

View File

@ -74,8 +74,8 @@ ErrCode AccessibleAbilityChannelStub::HandleExecuteCommonAction(MessageParcel &d
ErrCode AccessibleAbilityChannelStub::HandleSetOnKeyPressEventResult(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG("%{public}s mock AccessibleAbilityChannelStub mock ------------------ start.", __func__);
HILOG_DEBUG("%{public}s mock AccessibleAbilityChannelStub -------mock -----mock------------- end.", __func__);
HILOG_DEBUG("mock AccessibleAbilityChannelStub mock ------------------ start.");
HILOG_DEBUG("mock AccessibleAbilityChannelStub mock ------------------ end.");
return NO_ERROR;
}

View File

@ -87,11 +87,9 @@ void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent &keyEvent
MessageParcel data;
MessageParcel reply;
HILOG_DEBUG();
HILOG_DEBUG("%{public}s start.-----------------------------mock Proxy Start ", __func__);
HILOG_DEBUG("%{public}s start.----------sequence--%{public}d ----------mock Proxy Start ", __func__, sequence);
HILOG_DEBUG("start.----------sequence--%{public}d ----------mock Proxy Start ", sequence);
g_testKeyPressEvent = sequence;
HILOG_DEBUG("%{public}s mock AccessibleAbilityClientProxy-----mock------------- end.", __func__);
HILOG_DEBUG("%{public}s start.-----------------------------mock Proxy end ", __func__);
HILOG_DEBUG("start.-----------------------------mock Proxy end ");
}
void AccessibleAbilityClientProxy::OnDisplayResized(const int displayId, const Rect &rect, const float scale,

View File

@ -86,4 +86,4 @@ private:
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // _AMS_ST_PAGE_ABILITY_EVENT_H_
#endif // _AMS_ST_PAGE_ABILITY_EVENT_H_

View File

@ -79,25 +79,6 @@ const static std::string CAPABILITIES_JSON_VALUE_KEY_EVENT_OBSERVER = "keyEventO
const static std::string CAPABILITIES_JSON_VALUE_ZOOM = "zoom";
const static std::string CAPABILITIES_JSON_VALUE_GESTURE = "gesture";
// The json object
const static std::string JSON_OBJECT_CAPABILITY = "Capability";
const static std::string JSON_OBJECT_ENABLED = "Enabled";
const static std::string JSON_OBJECT_CAPTION_STATE = "CaptionState";
const static std::string JSON_OBJECT_CAPTION_STYLE = "CaptionsStyle";
// The json value of Capability
const static std::string CAPABILITY_JSON_VALUE_ACCESSIBLE = "accessible";
const static std::string CAPABILITY_JSON_VALUE_TOUCH_GUIDE = "touchGuide";
const static std::string CAPABILITY_JSON_VALUE_GESTURE = "gesture";
const static std::string CAPABILITY_JSON_VALUE_KEY_EVENT_BOSERVER = "keyEventObserver";
// The json value of Caption
const static std::string CAPTION_JSON_VALUE_FONTFAMILY = "fontFamily";
const static std::string CAPTION_JSON_VALUE_FONTSCALE = "fontScale";
const static std::string CAPTION_JSON_VALUE_FONTCOLOR = "fontColor";
const static std::string CAPTION_JSON_VALUE_FONTEDGETYPE = "fontEdgeType";
const static std::string CAPTION_JSON_VALUE_BACKGROUNDCOLOR = "backgroundColor";
const static std::string CAPTION_JSON_VALUE_WINDOWCOLOR = "windowColor";
class JsonUtils {
public:
@ -108,19 +89,6 @@ public:
const nlohmann::json& json, const std::string& key, std::vector<std::string>& value);
static bool ParseObjVecFromJson(
const nlohmann::json& json, const std::string& key, std::vector<nlohmann::json>& value);
static bool SetStrValue(
nlohmann::json& json, const std::string& key, const std::string& subkey, const std::string& value);
static bool SetStrValue(nlohmann::json& json, const std::string& key, const std::string& value);
static bool SetIntValue(nlohmann::json& json, const std::string& key, const std::string& subkey, int& value);
static bool SetVecValue(nlohmann::json& json, const std::string& key, std::string& value);
static bool ClearVecValue(nlohmann::json& json, const std::string& key);
static bool RemoveVecValue(nlohmann::json& json, const std::string& key, const std::string& value);
static bool CheckEnabledValue(nlohmann::json& json, const std::string& Enakey, const std::string& Inskey);
static bool ToJson(const nlohmann::json& jsonObj, const std::string& jsonPath);
static int GetIntValue(nlohmann::json& json, const std::string& key, const std::string& subkey);
static std::string GetStrValue(nlohmann::json& json, const std::string& key, const std::string& subkey);
static std::string GetStrValue(nlohmann::json& json, const std::string& key);
static std::vector<std::string> GetVecValue(nlohmann::json& json, const std::string& key);
};
class PraseVecUtils {

View File

@ -24,7 +24,6 @@ using namespace std;
namespace OHOS {
namespace Accessibility {
const int NUM_4 = 4;
bool JsonUtils::GetJsonObjFromJson(nlohmann::json &jsonObj, const std::string &jsonPath)
{
HILOG_DEBUG("start.");
@ -108,134 +107,6 @@ bool JsonUtils::ParseObjVecFromJson(const nlohmann::json &json, const std::strin
return true;
}
bool JsonUtils::SetStrValue(
nlohmann::json& json, const std::string& key, const std::string& subkey, const std::string& value)
{
HILOG_DEBUG("start.");
if (!json.is_object()) {
HILOG_ERROR("json is not object.");
return false;
}
if (json.find(key) != json.end() && json.at(key).is_object()) {
HILOG_DEBUG("Find key[%{public}s] successful.", key.c_str());
if (json[key].find(subkey) != json[key].end()) {
json[key][subkey] = value;
HILOG_DEBUG("value = %{public}s .", value.c_str());
}
}
return true;
}
bool JsonUtils::SetStrValue(nlohmann::json& json, const std::string& key, const std::string& value)
{
HILOG_DEBUG("start.");
if (!json.is_object()) {
HILOG_ERROR("json is not object.");
return false;
}
if (json.find(key) != json.end()) {
HILOG_DEBUG("Find key[%{public}s] successful.", key.c_str());
HILOG_DEBUG("value [%{public}s] successful.", value.c_str());
json[key] = value;
}
return true;
}
bool JsonUtils::SetIntValue(nlohmann::json& json, const std::string& key, const std::string& subkey, int& value)
{
HILOG_DEBUG("start.");
if (!json.is_object()) {
HILOG_ERROR("json is not object.");
return false;
}
if (json.find(key) != json.end() && json.at(key).is_object()) {
HILOG_DEBUG("Find key[%{public}s] successful.", key.c_str());
if (json[key].find(subkey) != json[key].end()) {
HILOG_DEBUG("value = %{public}d.", value);
json[key][subkey] = value;
}
}
return true;
}
bool JsonUtils::SetVecValue(nlohmann::json& json, const std::string& key, std::string& value)
{
HILOG_DEBUG("start.");
if (!json.is_object()) {
HILOG_ERROR("json is not object.");
return false;
}
if (json.find(key) != json.end() && json.at(key).is_array()) {
HILOG_DEBUG("Find key[%{public}s] successful.", key.c_str());
std::string str1 = "{\"BundleName\":\"";
std::string str2 = "\"}";
std::string jsonStr = str1.append(value);
jsonStr = jsonStr.append(str2);
HILOG_DEBUG("jsonStr = %{public}s .", jsonStr.c_str());
nlohmann::json jsonobj = json.parse(jsonStr);
json[key].push_back(jsonobj);
}
return true;
}
bool JsonUtils::ClearVecValue(nlohmann::json& json, const std::string& key)
{
HILOG_DEBUG("start.");
if (!json.is_object()) {
HILOG_ERROR("json is not object.");
return false;
}
if (json.find(key) != json.end() && json.at(key).is_array()) {
HILOG_DEBUG("Find key[%{public}s] successful.", key.c_str());
for (unsigned int i = 0; i < json[key].size(); i++) {
HILOG_DEBUG("Find Size = %{public}d\n", json[key].size());
json[key].erase(i);
}
}
return true;
}
bool JsonUtils::RemoveVecValue(nlohmann::json& json, const std::string& key, const std::string& value)
{
HILOG_DEBUG("start.");
if (!json.is_object()) {
HILOG_ERROR("json is not object.");
return false;
}
if (json.find(key) != json.end() && json.at(key).is_array()) {
HILOG_DEBUG("Find key[%{public}s] successful.", key.c_str());
for (unsigned int i = 0; i < json[key].size(); i++) {
HILOG_DEBUG("Find Size = %{public}d\n", json[key].size());
std::string val = std::string(json[key][i]["BundleName"]);
HILOG_DEBUG("Find key[%{public}s] successful.", val.c_str());
if (strcmp(value.c_str(), val.c_str()) == 0) {
json[key].erase(i);
HILOG_DEBUG("erase successful");
}
}
}
return true;
}
bool JsonUtils::CheckEnabledValue(nlohmann::json& json, const std::string& Enakey, const std::string& Inskey)
{
HILOG_DEBUG("start.");
if (!json.is_object()) {
HILOG_ERROR("json is not object.");
return false;
}
for (unsigned int i = 0; i < json[Enakey].size(); i++) {
for (unsigned int j = 0; j < json[Inskey].size(); j++) {
if (json[Enakey][i] == json[Inskey][j]) {
json[Enakey].erase(i);
j = json[Inskey].size();
}
}
}
return true;
}
void PraseVecUtils::ParseEventTypesFromVec(const vector<string>& events, uint32_t& eventTypes)
{
HILOG_DEBUG("start.");
@ -337,81 +208,5 @@ void PraseVecUtils::ParseCapabilitiesFromVec(const vector<string>& capabilities,
}
}
bool JsonUtils::ToJson(const nlohmann::json& jsonObj, const std::string& jsonPath)
{
HILOG_DEBUG("start.");
std::ofstream ofs(jsonPath);
ofs << jsonObj.dump(NUM_4) << std::endl;
return true;
}
int JsonUtils::GetIntValue(nlohmann::json& json, const std::string& key, const std::string& subkey)
{
HILOG_DEBUG("start.");
if (!json.is_object()) {
HILOG_ERROR("json is not object.");
}
int value = 0;
if (json.find(key) != json.end() && json.at(key).is_object()) {
HILOG_DEBUG("Find key[%{public}s] successful.", key.c_str());
if (json[key].find(subkey) != json[key].end()) {
value = json[key][subkey] ;
HILOG_DEBUG("value = %{public}d.", value);
}
}
return value;
}
string JsonUtils::GetStrValue(nlohmann::json& json, const std::string& key, const std::string& subkey)
{
HILOG_DEBUG("start.");
if (!json.is_object()) {
HILOG_ERROR("json is not object.");
}
std::string value = "";
if (json.find(key) != json.end() && json.at(key).is_object()) {
HILOG_DEBUG("Find key[%{public}s] successful.", key.c_str());
if (json[key].find(subkey) != json[key].end()) {
value = json[key][subkey] ;
HILOG_DEBUG("value = %{public}s.", value.c_str());
}
}
return value;
}
string JsonUtils::GetStrValue(nlohmann::json& json, const std::string& key)
{
HILOG_DEBUG("start.");
if (!json.is_object()) {
HILOG_ERROR("json is not object.");
}
std::string value = "";
if (json.find(key) != json.end()) {
HILOG_DEBUG("Find key[%{public}s] successful.", key.c_str());
value = json[key];
HILOG_DEBUG("value = %{public}s.", value.c_str());
}
return value;
}
vector<std::string> JsonUtils::GetVecValue(nlohmann::json& json, const std::string& key)
{
HILOG_DEBUG("start.");
if (!json.is_object()) {
HILOG_ERROR("json is not object.");
}
std::vector<std::string> vecvalue;
std::string value = "";
if (json.find(key) != json.end() && json.at(key).is_array()) {
HILOG_DEBUG("Find key[%{public}s] successful.", key.c_str());
for (unsigned int i = 0; i < json[key].size(); i++) {
value = std::string(json[key][i]["BundleName"]);
HILOG_DEBUG("BundleName[%{public}d] = %{public}s.", i, value.c_str());
vecvalue.push_back(value);
}
}
return vecvalue;
}
} // namespace Accessibility
} // namespace OHOS