视检问题修正

Signed-off-by: Mupceet <laiguizhong@huawei.com>
This commit is contained in:
Mupceet 2022-03-22 11:05:59 +08:00
parent 3d9dfab539
commit 4279fada9b
53 changed files with 740 additions and 633 deletions

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2022 Huawei Device Co., Ltd. <!-- Copyright (C) 2022 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

View File

@ -81,6 +81,17 @@ public:
virtual void OnGestureSimulateResult(const int sequence, const bool completedSuccessfully) override; virtual void OnGestureSimulateResult(const int sequence, const bool completedSuccessfully) override;
private: private:
/**
* @brief Send the command data from proxy to stub in IPC mechanism.
* @param code The code matched the function called.
* @param data Serializable data
* @param reply The response of IPC
* @param option The option parameter of IPC,such as: async,sync
* @return true: Write the descriptor successfully; otherwise is not.
*/
bool SendTransactCmd(IAccessibleAbilityClient::Message code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
bool WriteInterfaceToken(MessageParcel &data); bool WriteInterfaceToken(MessageParcel &data);
static inline BrokerDelegator<AccessibleAbilityClientProxy> delegator; static inline BrokerDelegator<AccessibleAbilityClientProxy> delegator;

View File

@ -29,7 +29,7 @@ bool AccessibilityExtensionContext::GetFocusElementInfo(
{ {
HILOG_DEBUG("start."); HILOG_DEBUG("start.");
if ((focusType != FOCUS_TYPE_INPUT) && (focusType != FOCUS_TYPE_ACCESSIBILITY)) { if ((focusType != FOCUS_TYPE_INPUT) && (focusType != FOCUS_TYPE_ACCESSIBILITY)) {
HILOG_DEBUG("focusType is not allowed."); HILOG_ERROR("focusType is not allowed.");
return false; return false;
} }

View File

@ -34,9 +34,26 @@ bool AccessibleAbilityClientProxy::WriteInterfaceToken(MessageParcel &data)
return true; return true;
} }
bool AccessibleAbilityClientProxy::SendTransactCmd(IAccessibleAbilityClient::Message code, MessageParcel &data,
MessageParcel &reply, MessageOption &option)
{
HILOG_DEBUG("start.");
sptr<IRemoteObject> remote = Remote();
if (!remote) {
HILOG_ERROR("fail to send transact cmd %{public}d due to remote object", code);
return false;
}
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
if (result != NO_ERROR) {
HILOG_ERROR("receive error transact code %{public}d in transact cmd %{public}d", result, code);
return false;
}
return true;
}
void AccessibleAbilityClientProxy::Init(const sptr<IAccessibleAbilityChannel> &channel, const int channelId) void AccessibleAbilityClientProxy::Init(const sptr<IAccessibleAbilityChannel> &channel, const int channelId)
{ {
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC); MessageOption option(MessageOption::TF_ASYNC);
@ -60,15 +77,14 @@ void AccessibleAbilityClientProxy::Init(const sptr<IAccessibleAbilityChannel> &c
return; return;
} }
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::INIT), data, reply, option); if (!SendTransactCmd(IAccessibleAbilityClient::Message::INIT, data, reply, option)) {
if (error != NO_ERROR) { HILOG_ERROR("Init fail");
HILOG_ERROR("Init fail, error: %d", error); return;
} }
} }
void AccessibleAbilityClientProxy::Disconnect(const int channelId) void AccessibleAbilityClientProxy::Disconnect(const int channelId)
{ {
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC); MessageOption option(MessageOption::TF_ASYNC);
@ -84,16 +100,14 @@ void AccessibleAbilityClientProxy::Disconnect(const int channelId)
return; return;
} }
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::DISCONNECT), if (!SendTransactCmd(IAccessibleAbilityClient::Message::DISCONNECT, data, reply, option)) {
data, reply, option); HILOG_ERROR("Disconnect fail");
if (error != NO_ERROR) { return;
HILOG_ERROR("Disconnect fail, error: %d", error);
} }
} }
void AccessibleAbilityClientProxy::OnAccessibilityEvent(const AccessibilityEventInfo &eventInfo) void AccessibleAbilityClientProxy::OnAccessibilityEvent(const AccessibilityEventInfo &eventInfo)
{ {
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC); MessageOption option(MessageOption::TF_ASYNC);
@ -107,16 +121,14 @@ void AccessibleAbilityClientProxy::OnAccessibilityEvent(const AccessibilityEvent
HILOG_ERROR("fail, eventInfo write parcelable error"); HILOG_ERROR("fail, eventInfo write parcelable error");
return; return;
} }
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_ACCESSIBILITY_EVENT), if (!SendTransactCmd(IAccessibleAbilityClient::Message::ON_ACCESSIBILITY_EVENT, data, reply, option)) {
data, reply, option); HILOG_ERROR("OnAccessibilityEvent fail");
if (error != NO_ERROR) { return;
HILOG_ERROR("OnAccessibilityEvent fail, error: %d", error);
} }
} }
void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int sequence) void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int sequence)
{ {
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC); MessageOption option(MessageOption::TF_ASYNC);
@ -136,17 +148,15 @@ void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent &keyEvent
return; return;
} }
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_KEY_PRESS_EVENT), if (!SendTransactCmd(IAccessibleAbilityClient::Message::ON_KEY_PRESS_EVENT, data, reply, option)) {
data, reply, option); HILOG_ERROR("OnKeyPressEvent fail");
if (error != NO_ERROR) { return;
HILOG_ERROR("OnKeyPressEvent fail, error: %d", error);
} }
} }
void AccessibleAbilityClientProxy::OnDisplayResized(const int displayId, const Rect &rect, const float scale, void AccessibleAbilityClientProxy::OnDisplayResized(const int displayId, const Rect &rect, const float scale,
const float centerX, const float centerY) const float centerX, const float centerY)
{ {
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC); MessageOption option(MessageOption::TF_ASYNC);
@ -177,16 +187,14 @@ void AccessibleAbilityClientProxy::OnDisplayResized(const int displayId, const R
return; return;
} }
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_DISPALYRESIZE_CHANGED), if (!SendTransactCmd(IAccessibleAbilityClient::Message::ON_DISPALYRESIZE_CHANGED, data, reply, option)) {
data, reply, option); HILOG_ERROR("OnDisplayResized fail");
if (error != NO_ERROR) { return;
HILOG_ERROR("OnDisplayResized fail, error: %d", error);
} }
} }
void AccessibleAbilityClientProxy::OnGestureSimulateResult(const int sequence, const bool completedSuccessfully) void AccessibleAbilityClientProxy::OnGestureSimulateResult(const int sequence, const bool completedSuccessfully)
{ {
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC); MessageOption option(MessageOption::TF_ASYNC);
@ -204,10 +212,10 @@ void AccessibleAbilityClientProxy::OnGestureSimulateResult(const int sequence, c
HILOG_ERROR("fail, completedSuccessfully write bool error"); HILOG_ERROR("fail, completedSuccessfully write bool error");
return; return;
} }
error = Remote()->SendRequest(static_cast<uint32_t>(IAccessibleAbilityClient::Message::ON_GESTURE_SIMULATE_RESULT),
data, reply, option); if (!SendTransactCmd(IAccessibleAbilityClient::Message::ON_GESTURE_SIMULATE_RESULT, data, reply, option)) {
if (error != NO_ERROR) { HILOG_ERROR("OnGestureSimulateResult fail");
HILOG_ERROR("OnGestureSimulateResult fail, error: %d", error); return;
} }
} }
} // namespace Accessibility } // namespace Accessibility

View File

@ -48,7 +48,7 @@ int AccessibleAbilityClientStub::OnRemoteRequest(uint32_t code,
std::u16string descriptor = AccessibleAbilityClientStub::GetDescriptor(); std::u16string descriptor = AccessibleAbilityClientStub::GetDescriptor();
std::u16string remoteDescriptor = data.ReadInterfaceToken(); std::u16string remoteDescriptor = data.ReadInterfaceToken();
if (descriptor != remoteDescriptor) { if (descriptor != remoteDescriptor) {
HILOG_INFO("local descriptor is not equal to remote"); HILOG_ERROR("local descriptor is not equal to remote");
return ERR_INVALID_STATE; return ERR_INVALID_STATE;
} }

View File

@ -102,10 +102,10 @@ void AccessibleAbilityClientStubImpl::Init(const sptr<IAccessibleAbilityChannel>
deathRecipient_ = new AccessibleAbilityDeathRecipient(channelId_, channel_); deathRecipient_ = new AccessibleAbilityDeathRecipient(channelId_, channel_);
} }
auto object = channel_->AsObject(); auto uiTestObject = channel_->AsObject();
if (object) { if (uiTestObject) {
HILOG_DEBUG("Add death recipient"); HILOG_DEBUG("Add death recipient");
object->AddDeathRecipient(deathRecipient_); uiTestObject->AddDeathRecipient(deathRecipient_);
} }
uiTestListener_->OnAbilityConnected(); uiTestListener_->OnAbilityConnected();
@ -134,8 +134,10 @@ void AccessibleAbilityClientStubImpl::Disconnect(const int channelId)
} }
} else { } else {
AccessibilityUITestAbility::GetInstance()->SetChannelId(channelId_); AccessibilityUITestAbility::GetInstance()->SetChannelId(channelId_);
uiTestListener_->OnAbilityDisconnected(); if (uiTestListener_) {
uiTestListener_ = nullptr; uiTestListener_->OnAbilityDisconnected();
uiTestListener_ = nullptr;
}
} }
} }
@ -163,8 +165,8 @@ void AccessibleAbilityClientStubImpl::OnKeyPressEvent(const MMI::KeyEvent &keyEv
if (uiTestListener_) { if (uiTestListener_) {
std::shared_ptr<MMI::KeyEvent> tmp = std::make_shared<MMI::KeyEvent>(keyEvent); std::shared_ptr<MMI::KeyEvent> tmp = std::make_shared<MMI::KeyEvent>(keyEvent);
bool handled = uiTestListener_->OnKeyPressEvent(tmp, sequence); bool uiTestHandled = uiTestListener_->OnKeyPressEvent(tmp, sequence);
AccessibilityOperator::GetInstance().SetOnKeyPressEventResult(channelId_, handled, sequence); AccessibilityOperator::GetInstance().SetOnKeyPressEventResult(channelId_, uiTestHandled, sequence);
} }
} }
@ -214,7 +216,7 @@ void AccessibleAbilityClientStubImpl::AccessibleAbilityDeathRecipient::OnRemoteD
return; return;
} }
if (!recipientchannel_ && (recipientchannel_->AsObject() != remote)) { if (!recipientchannel_ || (recipientchannel_->AsObject() != remote)) {
HILOG_ERROR("recipientchannel_ is nullptr or remote is wrong."); HILOG_ERROR("recipientchannel_ is nullptr or remote is wrong.");
return; return;
} }

View File

@ -109,7 +109,9 @@ void DisplayResizeController::DispatchOnDisplayResized(const Rect& rect,
{ {
HILOG_DEBUG("start."); HILOG_DEBUG("start.");
for (auto listener : displayResizeListeners_) { for (auto listener : displayResizeListeners_) {
listener->OnDisplayResized(*this, rect, scale, centerX, centerY); if (listener) {
listener->OnDisplayResized(*this, rect, scale, centerX, centerY);
}
} }
} }
} // namespace Accessibility } // namespace Accessibility

View File

@ -41,8 +41,7 @@ JsAccessibilityExtension::~JsAccessibilityExtension() = default;
void JsAccessibilityExtension::Init(const std::shared_ptr<AppExecFwk::AbilityLocalRecord> &record, void JsAccessibilityExtension::Init(const std::shared_ptr<AppExecFwk::AbilityLocalRecord> &record,
const std::shared_ptr<AppExecFwk::OHOSApplication> &application, const std::shared_ptr<AppExecFwk::OHOSApplication> &application,
std::shared_ptr<AppExecFwk::AbilityHandler> &handler, std::shared_ptr<AppExecFwk::AbilityHandler> &handler, const sptr<IRemoteObject> &token)
const sptr<IRemoteObject> &token)
{ {
HILOG_INFO("JsAccessibilityExtension::Init begin."); HILOG_INFO("JsAccessibilityExtension::Init begin.");
AccessibilityExtension::Init(record, application, handler, token); AccessibilityExtension::Init(record, application, handler, token);
@ -53,10 +52,13 @@ void JsAccessibilityExtension::Init(const std::shared_ptr<AppExecFwk::AbilityLoc
return; return;
} }
if (!abilityInfo_) {
HILOG_ERROR("abilityInfo_ is nullptr.");
return;
}
std::string moduleName(Extension::abilityInfo_->moduleName); std::string moduleName(Extension::abilityInfo_->moduleName);
moduleName.append("::").append(abilityInfo_->name); moduleName.append("::").append(abilityInfo_->name);
HILOG_INFO("JsAccessibilityExtension::Init moduleName:%{public}s, srcPath:%{public}s.", HILOG_INFO("moduleName:%{public}s, srcPath:%{public}s.", moduleName.c_str(), srcPath.c_str());
moduleName.c_str(), srcPath.c_str());
HandleScope handleScope(jsRuntime_); HandleScope handleScope(jsRuntime_);
auto& engine = jsRuntime_.GetNativeEngine(); auto& engine = jsRuntime_.GetNativeEngine();
@ -65,7 +67,6 @@ void JsAccessibilityExtension::Init(const std::shared_ptr<AppExecFwk::AbilityLoc
HILOG_ERROR("Failed to get jsObj_"); HILOG_ERROR("Failed to get jsObj_");
return; return;
} }
HILOG_INFO("JsAccessibilityExtension::Init ConvertNativeValueTo.");
NativeObject* obj = ConvertNativeValueTo<NativeObject>(jsObj_->Get()); NativeObject* obj = ConvertNativeValueTo<NativeObject>(jsObj_->Get());
if (!obj) { if (!obj) {
HILOG_ERROR("Failed to get JsAccessibilityExtension object"); HILOG_ERROR("Failed to get JsAccessibilityExtension object");
@ -77,13 +78,14 @@ void JsAccessibilityExtension::Init(const std::shared_ptr<AppExecFwk::AbilityLoc
HILOG_ERROR("Failed to get context"); HILOG_ERROR("Failed to get context");
return; return;
} }
HILOG_INFO("JsAccessibilityExtension::Init CreateJsAccessibilityExtensionContext.");
NativeValue* contextObj = CreateJsAccessibilityExtensionContext(engine, context); NativeValue* contextObj = CreateJsAccessibilityExtensionContext(engine, context);
auto shellContextRef = jsRuntime_.LoadSystemModule("application.AccessibilityExtensionContext", &contextObj, 1); auto shellContextRef = jsRuntime_.LoadSystemModule("application.AccessibilityExtensionContext", &contextObj, 1);
if (!shellContextRef) {
HILOG_ERROR("shellContextRef is nullptr.");
return;
}
contextObj = shellContextRef->Get(); contextObj = shellContextRef->Get();
HILOG_INFO("JsAccessibilityExtension::Init Bind.");
context->Bind(jsRuntime_, shellContextRef.release()); context->Bind(jsRuntime_, shellContextRef.release());
HILOG_INFO("JsAccessibilityExtension::SetProperty.");
obj->SetProperty("context", contextObj); obj->SetProperty("context", contextObj);
auto nativeObj = ConvertNativeValueTo<NativeObject>(contextObj); auto nativeObj = ConvertNativeValueTo<NativeObject>(contextObj);
@ -91,16 +93,10 @@ void JsAccessibilityExtension::Init(const std::shared_ptr<AppExecFwk::AbilityLoc
HILOG_ERROR("Failed to get accessibility extension native object"); HILOG_ERROR("Failed to get accessibility extension native object");
return; return;
} }
HILOG_INFO("Set accessibility extension context pointer: %{public}p", context.get());
nativeObj->SetNativePointer(new std::weak_ptr<AbilityRuntime::Context>(context), nativeObj->SetNativePointer(new std::weak_ptr<AbilityRuntime::Context>(context),
[](NativeEngine*, void* data, void*) { [](NativeEngine*, void* data, void*) {
HILOG_INFO("Finalizer for weak_ptr accessibility extension context is called");
delete static_cast<std::weak_ptr<AbilityRuntime::Context>*>(data); delete static_cast<std::weak_ptr<AbilityRuntime::Context>*>(data);
}, nullptr); }, nullptr);
HILOG_INFO("JsAccessibilityExtension::Init end.");
} }
sptr<IRemoteObject> JsAccessibilityExtension::OnConnect(const AAFwk::Want &want) sptr<IRemoteObject> JsAccessibilityExtension::OnConnect(const AAFwk::Want &want)
@ -182,7 +178,7 @@ NativeValue* JsAccessibilityExtension::CallObjectMethod(const char* name, Native
{ {
HILOG_INFO("JsAccessibilityExtension::CallObjectMethod(%{public}s), begin", name); HILOG_INFO("JsAccessibilityExtension::CallObjectMethod(%{public}s), begin", name);
if (!jsObj_) { if (!jsObj_) {
HILOG_WARN("jsObj_ is nullptr"); HILOG_ERROR("jsObj_ is nullptr");
return nullptr; return nullptr;
} }
@ -207,6 +203,10 @@ NativeValue* JsAccessibilityExtension::CallObjectMethod(const char* name, Native
void JsAccessibilityExtension::GetSrcPath(std::string &srcPath) void JsAccessibilityExtension::GetSrcPath(std::string &srcPath)
{ {
if (!Extension::abilityInfo_) {
HILOG_ERROR("abilityInfo_ is nullptr");
return;
}
if (!Extension::abilityInfo_->isModuleJson) { if (!Extension::abilityInfo_->isModuleJson) {
/* temporary compatibility api8 + config.json */ /* temporary compatibility api8 + config.json */
srcPath.append(Extension::abilityInfo_->package); srcPath.append(Extension::abilityInfo_->package);

View File

@ -104,7 +104,7 @@ private:
HILOG_INFO("GetFocusElementInfo begin"); HILOG_INFO("GetFocusElementInfo begin");
auto context = weak.lock(); auto context = weak.lock();
if (!context) { if (!context) {
HILOG_WARN("context is released"); HILOG_ERROR("context is released");
task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "Context is released")); task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "Context is released"));
return; return;
} }
@ -121,8 +121,8 @@ private:
NativeValue* nativeElementInfo = reinterpret_cast<NativeValue*>(napiElementInfo); NativeValue* nativeElementInfo = reinterpret_cast<NativeValue*>(napiElementInfo);
task.Resolve(engine, nativeElementInfo); task.Resolve(engine, nativeElementInfo);
} else { } else {
HILOG_ERROR("Get focus elementInfo failed.\ HILOG_ERROR("Get focus elementInfo failed. ret: %{public}d, elementInfo.has_value(): %{public}d",
ret: %{public}d, elementInfo.has_value(): %{public}d", ret, elementInfo.has_value()); ret, elementInfo.has_value());
task.Reject(engine, CreateJsError(engine, false, "Get focus elementInfo failed.")); task.Reject(engine, CreateJsError(engine, false, "Get focus elementInfo failed."));
} }
}; };
@ -148,7 +148,7 @@ private:
HILOG_INFO("GetRootElementInfo begin"); HILOG_INFO("GetRootElementInfo begin");
auto context = weak.lock(); auto context = weak.lock();
if (!context) { if (!context) {
HILOG_WARN("context is released"); HILOG_ERROR("context is released");
task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "Context is released")); task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "Context is released"));
return; return;
} }
@ -193,7 +193,7 @@ private:
HILOG_INFO("GetWindows begin"); HILOG_INFO("GetWindows begin");
auto context = weak.lock(); auto context = weak.lock();
if (!context) { if (!context) {
HILOG_WARN("context is released"); HILOG_ERROR("context is released");
task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "Context is released")); task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "Context is released"));
return; return;
} }
@ -247,7 +247,7 @@ private:
HILOG_INFO("ExecuteCommonAction begin"); HILOG_INFO("ExecuteCommonAction begin");
auto context = weak.lock(); auto context = weak.lock();
if (!context) { if (!context) {
HILOG_WARN("context is released"); HILOG_ERROR("context is released");
task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "Context is released")); task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "Context is released"));
return; return;
} }
@ -304,7 +304,7 @@ private:
HILOG_INFO("GestureSimulate begin"); HILOG_INFO("GestureSimulate begin");
auto context = weak.lock(); auto context = weak.lock();
if (!context) { if (!context) {
HILOG_WARN("context is released"); HILOG_ERROR("context is released");
task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "Context is released")); task.Reject(engine, CreateJsError(engine, ERROR_CODE_ONE, "Context is released"));
return; return;
} }
@ -336,6 +336,10 @@ NativeValue* CreateJsAccessibilityExtensionContext(
std::unique_ptr<JsAccessibilityExtensionContext> jsContext = std::unique_ptr<JsAccessibilityExtensionContext> jsContext =
std::make_unique<JsAccessibilityExtensionContext>(context); std::make_unique<JsAccessibilityExtensionContext>(context);
if (!object) {
HILOG_ERROR("object is nullptr.");
return nullptr;
}
object->SetNativePointer(jsContext.release(), JsAccessibilityExtensionContext::Finalizer, nullptr); object->SetNativePointer(jsContext.release(), JsAccessibilityExtensionContext::Finalizer, nullptr);
BindNativeFunction(engine, *object, "getFocusElementInfo", JsAccessibilityExtensionContext::GetFocusElementInfo); BindNativeFunction(engine, *object, "getFocusElementInfo", JsAccessibilityExtensionContext::GetFocusElementInfo);

View File

@ -74,7 +74,9 @@ bool AccessibilityWindowInfo::GetRootAccessibilityInfo(AccessibilityElementInfo
} }
void AccessibilityWindowInfo::SetAnchorId(const int anchorId) void AccessibilityWindowInfo::SetAnchorId(const int anchorId)
{} {
(void)anchorId;
}
bool AccessibilityWindowInfo::GetAnchor(AccessibilityElementInfo &elementInfo) bool AccessibilityWindowInfo::GetAnchor(AccessibilityElementInfo &elementInfo)
{ {

View File

@ -36,6 +36,11 @@ public:
const long elementId, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback, const long elementId, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback,
const int mode) const int mode)
{ {
(void)accessibilityWindowId;
(void)elementId;
(void)requestId;
(void)callback;
(void)mode;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock SearchElementInfoByAccessibilityId"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock SearchElementInfoByAccessibilityId";
return true; return true;
} }
@ -43,6 +48,11 @@ public:
virtual bool SearchElementInfosByText(const int accessibilityWindowId, const long elementId, virtual bool SearchElementInfosByText(const int accessibilityWindowId, const long elementId,
const std::string &text, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) const std::string &text, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
{ {
(void)accessibilityWindowId;
(void)elementId;
(void)text;
(void)requestId;
(void)callback;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock SearchElementInfosByText"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock SearchElementInfosByText";
return true; return true;
} }
@ -50,6 +60,11 @@ public:
virtual bool FindFocusedElementInfo(const int accessibilityWindowId, const long elementId, virtual bool FindFocusedElementInfo(const int accessibilityWindowId, const long elementId,
const int focusType, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) const int focusType, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
{ {
(void)accessibilityWindowId;
(void)elementId;
(void)focusType;
(void)requestId;
(void)callback;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock FindFocusedElementInfo"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock FindFocusedElementInfo";
return true; return true;
} }
@ -57,6 +72,11 @@ public:
virtual bool FocusMoveSearch(const int accessibilityWindowId, const long elementId, virtual bool FocusMoveSearch(const int accessibilityWindowId, const long elementId,
const int direction, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) const int direction, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
{ {
(void)accessibilityWindowId;
(void)elementId;
(void)direction;
(void)requestId;
(void)callback;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock FocusMoveSearch"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock FocusMoveSearch";
return true; return true;
} }
@ -65,6 +85,12 @@ public:
std::map<std::string, std::string> &actionArguments, const int requestId, std::map<std::string, std::string> &actionArguments, const int requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback) const sptr<IAccessibilityElementOperatorCallback> &callback)
{ {
(void)accessibilityWindowId;
(void)elementId;
(void)action;
(void)actionArguments;
(void)requestId;
(void)callback;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock ExecuteAction"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock ExecuteAction";
return true; return true;
} }
@ -78,35 +104,42 @@ public:
virtual bool ExecuteCommonAction(const int action) virtual bool ExecuteCommonAction(const int action)
{ {
(void)action;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock ExecuteCommonAction"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock ExecuteCommonAction";
return true; return true;
} }
virtual void SetOnKeyPressEventResult(const bool handled, const int sequence) virtual void SetOnKeyPressEventResult(const bool handled, const int sequence)
{ {
(void)handled;
(void)sequence;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock SetOnKeyPressEventResult"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock SetOnKeyPressEventResult";
} }
virtual float GetDisplayResizeScale(const int displayId) virtual float GetDisplayResizeScale(const int displayId)
{ {
(void)displayId;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock GetDisplayResizeScale"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock GetDisplayResizeScale";
return 0; return 0;
} }
virtual float GetDisplayResizeCenterX(const int displayId) virtual float GetDisplayResizeCenterX(const int displayId)
{ {
(void)displayId;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock GetDisplayResizeCenterX"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock GetDisplayResizeCenterX";
return 0; return 0;
} }
virtual float GetDisplayResizeCenterY(const int displayId) virtual float GetDisplayResizeCenterY(const int displayId)
{ {
(void)displayId;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock GetDisplayResizeCenterY"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock GetDisplayResizeCenterY";
return 0; return 0;
} }
virtual Rect GetDisplayResizeRect(const int displayId) virtual Rect GetDisplayResizeRect(const int displayId)
{ {
(void)displayId;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock GetDisplayResizeRect"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock GetDisplayResizeRect";
Rect rect {}; Rect rect {};
return rect; return rect;
@ -114,6 +147,8 @@ public:
virtual bool ResetDisplayResize(const int displayId, const bool animate) virtual bool ResetDisplayResize(const int displayId, const bool animate)
{ {
(void)displayId;
(void)animate;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock ResetDisplayResize"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock ResetDisplayResize";
return true; return true;
} }
@ -121,12 +156,19 @@ public:
virtual bool SetDisplayResizeScaleAndCenter(const int displayId, const float scale, const float centerX, virtual bool SetDisplayResizeScaleAndCenter(const int displayId, const float scale, const float centerX,
const float centerY, const bool animate) const float centerY, const bool animate)
{ {
(void)displayId;
(void)scale;
(void)centerX;
(void)centerY;
(void)animate;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock SetDisplayResizeScaleAndCenter"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock SetDisplayResizeScaleAndCenter";
return true; return true;
} }
virtual void SendSimulateGesture(const int requestId, const std::vector<GesturePathDefine> &gestureSteps) virtual void SendSimulateGesture(const int requestId, const std::vector<GesturePathDefine> &gestureSteps)
{ {
(void)requestId;
(void)gestureSteps;
GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock SendSimulateGesture"; GTEST_LOG_(INFO) << "MOCK AccessibleAbilityChannelStubMock SendSimulateGesture";
} }
}; };

View File

@ -94,6 +94,17 @@ private:
*/ */
bool WriteInterfaceToken(MessageParcel &data); bool WriteInterfaceToken(MessageParcel &data);
/**
* @brief Send the command data from proxy to stub in IPC mechanism.
* @param code The code matched the function called.
* @param data Serializable data
* @param reply The response of IPC
* @param option The option parameter of IPC,such as: async,sync
* @return true: Write the descriptor successfully; otherwise is not.
*/
bool SendTransactCmd(IAccessibilityElementOperatorCallback::Message code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
/** /**
* @brief Write the serializable data * @brief Write the serializable data
* @param parcelableVector The communication data of IPC * @param parcelableVector The communication data of IPC

View File

@ -145,6 +145,17 @@ private:
* @return true: Write the descriptor successfully; otherwise is not. * @return true: Write the descriptor successfully; otherwise is not.
*/ */
bool WriteInterfaceToken(MessageParcel &data); bool WriteInterfaceToken(MessageParcel &data);
/**
* @brief Send the command data from proxy to stub in IPC mechanism.
* @param code The code matched the function called.
* @param data Serializable data
* @param reply The response of IPC
* @param option The option parameter of IPC,such as: async,sync
* @return true: Write the descriptor successfully; otherwise is not.
*/
bool SendTransactCmd(IAccessibilityElementOperator::Message code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
static inline BrokerDelegator<AccessibilityElementOperatorProxy> delegator; static inline BrokerDelegator<AccessibilityElementOperatorProxy> delegator;
}; };
} // namespace Accessibility } // namespace Accessibility

View File

@ -132,6 +132,17 @@ private:
* @return true: Write the descriptor successfully; otherwise is not. * @return true: Write the descriptor successfully; otherwise is not.
*/ */
bool WriteInterfaceToken(MessageParcel& data); bool WriteInterfaceToken(MessageParcel& data);
/**
* @brief Send the command data from proxy to stub in IPC mechanism.
* @param code The code matched the function called.
* @param data Serializable data
* @param reply The response of IPC
* @param option The option parameter of IPC,such as: async,sync
* @return true: Write the descriptor successfully; otherwise is not.
*/
bool SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
static inline BrokerDelegator<AccessibleAbilityManagerServiceClientProxy> delegator; static inline BrokerDelegator<AccessibleAbilityManagerServiceClientProxy> delegator;
}; };
} // namespace Accessibility } // namespace Accessibility

View File

@ -216,8 +216,8 @@ void AccessibilityElementInfo::SetComponentId(const int componentId)
bool AccessibilityElementInfo::GetFocus(const int focus, AccessibilityElementInfo &elementInfo) bool AccessibilityElementInfo::GetFocus(const int focus, AccessibilityElementInfo &elementInfo)
{ {
HILOG_INFO("channelId_[%{public}d], windowId_[%{public}d],\ HILOG_INFO("channelId_[%{public}d], windowId_[%{public}d], elementId_[%{public}d], focus[%{public}d]",
elementId_[%{public}d], focus[%{public}d]", channelId_, windowId_, elementId_, focus); channelId_, windowId_, elementId_, focus);
AccessibilityOperator *instance = &AccessibilityOperator::GetInstance(); AccessibilityOperator *instance = &AccessibilityOperator::GetInstance();
bool result = false; bool result = false;
if (instance != nullptr) { if (instance != nullptr) {
@ -230,8 +230,8 @@ bool AccessibilityElementInfo::GetFocus(const int focus, AccessibilityElementInf
bool AccessibilityElementInfo::GetNext(const FocusMoveDirection direction, AccessibilityElementInfo &elementInfo) bool AccessibilityElementInfo::GetNext(const FocusMoveDirection direction, AccessibilityElementInfo &elementInfo)
{ {
HILOG_INFO("channelId_[%{public}d], windowId_[%{public}d],\ HILOG_INFO("channelId_[%{public}d], windowId_[%{public}d], elementId_[%{public}d], direction[%{public}d]",
elementId_[%{public}d], direction[%{public}d]", channelId_, windowId_, elementId_, direction); channelId_, windowId_, elementId_, direction);
AccessibilityOperator *instance = &AccessibilityOperator::GetInstance(); AccessibilityOperator *instance = &AccessibilityOperator::GetInstance();
bool result = false; bool result = false;
if (instance != nullptr) { if (instance != nullptr) {
@ -383,7 +383,7 @@ bool AccessibilityElementInfo::ExecuteAction(const ActionType &action,
return instance->ExecuteAction(channelId_, windowId_, elementId_, action, return instance->ExecuteAction(channelId_, windowId_, elementId_, action,
const_cast<std::map<std::string, std::string> &>(actionArguments)); const_cast<std::map<std::string, std::string> &>(actionArguments));
} else { } else {
HILOG_INFO("Can't get AccessibilityOperator instance"); HILOG_ERROR("Can't get AccessibilityOperator instance");
return false; return false;
} }
} }
@ -391,8 +391,8 @@ bool AccessibilityElementInfo::ExecuteAction(const ActionType &action,
bool AccessibilityElementInfo::GetByContent(const std::string &text, bool AccessibilityElementInfo::GetByContent(const std::string &text,
std::vector<AccessibilityElementInfo> &elementInfos) std::vector<AccessibilityElementInfo> &elementInfos)
{ {
HILOG_INFO("called channelId_[%{public}d], windowId_[%{public}d],\ HILOG_INFO("called channelId_[%{public}d], windowId_[%{public}d], elementId_[%{public}d], text[%{public}s]",
elementId_[%{public}d], text[%{public}s]", channelId_, windowId_, elementId_, text.c_str()); channelId_, windowId_, elementId_, text.c_str());
AccessibilityOperator *instance = &AccessibilityOperator::GetInstance(); AccessibilityOperator *instance = &AccessibilityOperator::GetInstance();
bool result = false; bool result = false;
if (instance != nullptr) { if (instance != nullptr) {
@ -447,7 +447,7 @@ bool AccessibilityElementInfo::GetParent(AccessibilityElementInfo &elementInfo)
elementInfo = elementInfos.front(); elementInfo = elementInfos.front();
} }
} else { } else {
HILOG_INFO("Can't get AccessibilityOperator instance"); HILOG_ERROR("Can't get AccessibilityOperator instance");
} }
return result; return result;
} }

View File

@ -38,6 +38,10 @@ bool AccessibilityElementAsyncOperatorMng::SearchElementResultTimer(const int se
} }
gettimeofday(&getTime, NULL); gettimeofday(&getTime, NULL);
uint64_t endTime = (uint64_t)(getTime.tv_sec * SECOND_TO_MILLIS + getTime.tv_usec); uint64_t endTime = (uint64_t)(getTime.tv_sec * SECOND_TO_MILLIS + getTime.tv_usec);
if (endTime < startTime) {
HILOG_ERROR("timer is wrong.");
return false;
}
uint64_t waitTime = (uint64_t)(endTime - startTime); uint64_t waitTime = (uint64_t)(endTime - startTime);
if (TIMEOUT_OPERATOR_MILLIS < waitTime) { if (TIMEOUT_OPERATOR_MILLIS < waitTime) {
completed_ = true; completed_ = true;

View File

@ -37,12 +37,28 @@ bool AccessibilityElementOperatorCallbackProxy::WriteInterfaceToken(MessageParce
return true; return true;
} }
bool AccessibilityElementOperatorCallbackProxy::SendTransactCmd(IAccessibilityElementOperatorCallback::Message code,
MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
HILOG_DEBUG("start.");
sptr<IRemoteObject> remote = Remote();
if (!remote) {
HILOG_ERROR("fail to send transact cmd %{public}d due to remote object", code);
return false;
}
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
if (result != NO_ERROR) {
HILOG_ERROR("receive error transact code %{public}d in transact cmd %{public}d", result, code);
return false;
}
return true;
}
void AccessibilityElementOperatorCallbackProxy::SetSearchElementInfoByAccessibilityIdResult( void AccessibilityElementOperatorCallbackProxy::SetSearchElementInfoByAccessibilityIdResult(
const std::vector<AccessibilityElementInfo> &infos, const int requestId) const std::vector<AccessibilityElementInfo> &infos, const int requestId)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -62,11 +78,10 @@ void AccessibilityElementOperatorCallbackProxy::SetSearchElementInfoByAccessibil
return; return;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibilityElementOperatorCallback::Message::SET_RESULT_BY_ACCESSIBILITY_ID,
static_cast<uint32_t>(IAccessibilityElementOperatorCallback::Message::SET_RESULT_BY_ACCESSIBILITY_ID), data, reply, option)) {
data, reply, option); HILOG_ERROR("SetSearchElementInfoByAccessibilityIdResult failed");
if (error != NO_ERROR) { return;
HILOG_ERROR("SearchAccessibilityInfoByAccessibility fail, error: %d", error);
} }
} }
@ -74,8 +89,6 @@ void AccessibilityElementOperatorCallbackProxy::SetSearchElementInfoByTextResult
const std::vector<AccessibilityElementInfo> &infos, const int requestId) const std::vector<AccessibilityElementInfo> &infos, const int requestId)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -95,11 +108,10 @@ void AccessibilityElementOperatorCallbackProxy::SetSearchElementInfoByTextResult
return; return;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibilityElementOperatorCallback::Message::SET_RESULT_BY_TEXT,
static_cast<uint32_t>(IAccessibilityElementOperatorCallback::Message::SET_RESULT_BY_TEXT), data, reply, option)) {
data, reply, option); HILOG_ERROR("SetSearchElementInfoByTextResult failed");
if (error != NO_ERROR) { return;
HILOG_ERROR("SearchAccessibilityInfoByAccessibility fail, error: %d", error);
} }
} }
@ -107,8 +119,6 @@ void AccessibilityElementOperatorCallbackProxy::SetFindFocusedElementInfoResult(
const AccessibilityElementInfo &info, const int requestId) const AccessibilityElementInfo &info, const int requestId)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -127,11 +137,10 @@ void AccessibilityElementOperatorCallbackProxy::SetFindFocusedElementInfoResult(
return; return;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibilityElementOperatorCallback::Message::SET_RESULT_FOCUSED_INFO,
static_cast<uint32_t>(IAccessibilityElementOperatorCallback::Message::SET_RESULT_FOCUSED_INFO), data, reply, option)) {
data, reply, option); HILOG_ERROR("SetFindFocusedElementInfoResult failed");
if (error != NO_ERROR) { return;
HILOG_ERROR("SetFindFocusedElementInfo fail, error: %d", error);
} }
} }
@ -139,8 +148,6 @@ void AccessibilityElementOperatorCallbackProxy::SetFocusMoveSearchResult(const A
const int requestId) const int requestId)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -160,19 +167,16 @@ void AccessibilityElementOperatorCallbackProxy::SetFocusMoveSearchResult(const A
return; return;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibilityElementOperatorCallback::Message::SET_RESULT_FOCUS_MOVE,
static_cast<uint32_t>(IAccessibilityElementOperatorCallback::Message::SET_RESULT_FOCUS_MOVE), data, reply, option)) {
data, reply, option); HILOG_ERROR("SetFocusMoveSearchResult failed");
if (error != NO_ERROR) { return;
HILOG_ERROR("SetFocusMoveSearchResult fail, error: %d", error);
} }
} }
void AccessibilityElementOperatorCallbackProxy::SetExecuteActionResult(const bool succeeded, const int requestId) void AccessibilityElementOperatorCallbackProxy::SetExecuteActionResult(const bool succeeded, const int requestId)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -192,11 +196,10 @@ void AccessibilityElementOperatorCallbackProxy::SetExecuteActionResult(const boo
return; return;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibilityElementOperatorCallback::Message::SET_RESULT_PERFORM_ACTION,
static_cast<uint32_t>(IAccessibilityElementOperatorCallback::Message::SET_RESULT_PERFORM_ACTION), data, reply, option)) {
data, reply, option); HILOG_ERROR("SetExecuteActionResult failed");
if (error != NO_ERROR) { return;
HILOG_ERROR("SetExecuteActionResult fail, error: %d", error);
} }
} }

View File

@ -49,12 +49,12 @@ AccessibilityElementOperatorCallbackStub::~AccessibilityElementOperatorCallbackS
int AccessibilityElementOperatorCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, int AccessibilityElementOperatorCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option) MessageParcel &reply, MessageOption &option)
{ {
HILOG_DEBUG("AccessibilityElementOperatorCallbackStub::OnRemoteRequest, cmd = %d, flags= %d", HILOG_DEBUG("AccessibilityElementOperatorCallbackStub::OnRemoteRequest, cmd = %{public}u, flags= %{public}d",
code, option.GetFlags()); code, option.GetFlags());
std::u16string descriptor = AccessibilityElementOperatorCallbackStub::GetDescriptor(); std::u16string descriptor = AccessibilityElementOperatorCallbackStub::GetDescriptor();
std::u16string remoteDescriptor = data.ReadInterfaceToken(); std::u16string remoteDescriptor = data.ReadInterfaceToken();
if (descriptor != remoteDescriptor) { if (descriptor != remoteDescriptor) {
HILOG_INFO("local descriptor is not equal to remote"); HILOG_ERROR("local descriptor is not equal to remote");
return ERR_INVALID_STATE; return ERR_INVALID_STATE;
} }

View File

@ -38,12 +38,27 @@ bool AccessibilityElementOperatorProxy::WriteInterfaceToken(MessageParcel &data)
return true; return true;
} }
bool AccessibilityElementOperatorProxy::SendTransactCmd(IAccessibilityElementOperator::Message code,
MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
HILOG_DEBUG("start.");
sptr<IRemoteObject> remote = Remote();
if (!remote) {
HILOG_ERROR("fail to send transact cmd %{public}d due to remote object", code);
return false;
}
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
if (result != NO_ERROR) {
HILOG_ERROR("receive error transact code %{public}d in transact cmd %{public}d", result, code);
return false;
}
return true;
}
void AccessibilityElementOperatorProxy::SearchElementInfoByAccessibilityId(const long elementId, void AccessibilityElementOperatorProxy::SearchElementInfoByAccessibilityId(const long elementId,
const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback, const int mode) const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback, const int mode)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC); MessageOption option(MessageOption::TF_ASYNC);
@ -63,6 +78,10 @@ void AccessibilityElementOperatorProxy::SearchElementInfoByAccessibilityId(const
return; return;
} }
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return;
}
if (!data.WriteRemoteObject(callback->AsObject())) { if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("fail, connection write parcelable callback error"); HILOG_ERROR("fail, connection write parcelable callback error");
return; return;
@ -73,11 +92,9 @@ void AccessibilityElementOperatorProxy::SearchElementInfoByAccessibilityId(const
return; return;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(AccessibilityElementOperatorProxy::Message::SEARCH_BY_ACCESSIBILITY_ID,
static_cast<uint32_t>(AccessibilityElementOperatorProxy::Message::SEARCH_BY_ACCESSIBILITY_ID), data, reply, option)) {
data, reply, option); HILOG_ERROR("SearchElementInfoByAccessibilityId failed");
if (error != NO_ERROR) {
HILOG_ERROR("SearchAccessibilityInfo fail, error: %d", error);
return; return;
} }
} }
@ -87,8 +104,6 @@ void AccessibilityElementOperatorProxy::SearchElementInfosByText(const long elem
const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC); MessageOption option(MessageOption::TF_ASYNC);
@ -112,16 +127,17 @@ void AccessibilityElementOperatorProxy::SearchElementInfosByText(const long elem
return; return;
} }
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return;
}
if (!data.WriteRemoteObject(callback->AsObject())) { if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("fail, connection write callback error"); HILOG_ERROR("fail, connection write callback error");
return; return;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(AccessibilityElementOperatorProxy::Message::SEARCH_BY_TEXT, data, reply, option)) {
static_cast<uint32_t>(AccessibilityElementOperatorProxy::Message::SEARCH_BY_TEXT), HILOG_ERROR("SearchElementInfosByText failed");
data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("SearchElementInfosByText fail, error: %d", error);
return; return;
} }
} }
@ -130,8 +146,6 @@ void AccessibilityElementOperatorProxy::FindFocusedElementInfo(const long elemen
const int focusType, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) const int focusType, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC); MessageOption option(MessageOption::TF_ASYNC);
@ -156,16 +170,17 @@ void AccessibilityElementOperatorProxy::FindFocusedElementInfo(const long elemen
return; return;
} }
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return;
}
if (!data.WriteRemoteObject(callback->AsObject())) { if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("fail, connection write callback error"); HILOG_ERROR("fail, connection write callback error");
return; return;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(AccessibilityElementOperatorProxy::Message::FIND_FOCUSED_INFO, data, reply, option)) {
static_cast<uint32_t>(AccessibilityElementOperatorProxy::Message::FIND_FOCUSED_INFO), HILOG_ERROR("FindFocusedElementInfo failed");
data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("FindFocusedElementInfo fail, error: %d", error);
return; return;
} }
} }
@ -174,8 +189,6 @@ void AccessibilityElementOperatorProxy::FocusMoveSearch(const long elementId,
const int direction, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) const int direction, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC); MessageOption option(MessageOption::TF_ASYNC);
@ -200,15 +213,17 @@ void AccessibilityElementOperatorProxy::FocusMoveSearch(const long elementId,
return; return;
} }
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return;
}
if (!data.WriteRemoteObject(callback->AsObject())) { if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("fail, connection write callback error"); HILOG_ERROR("fail, connection write callback error");
return; return;
} }
error = Remote()->SendRequest(static_cast<uint32_t>(AccessibilityElementOperatorProxy::Message::FOCUS_FIND), if (!SendTransactCmd(AccessibilityElementOperatorProxy::Message::FOCUS_FIND, data, reply, option)) {
data, reply, option); HILOG_ERROR("FocusMoveSearch failed");
if (error != NO_ERROR) {
HILOG_ERROR("FindFocusedElementInfo fail, error: %d", error);
return; return;
} }
} }
@ -218,8 +233,6 @@ void AccessibilityElementOperatorProxy::ExecuteAction(const long elementId, cons
const sptr<IAccessibilityElementOperatorCallback> &callback) const sptr<IAccessibilityElementOperatorCallback> &callback)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC); MessageOption option(MessageOption::TF_ASYNC);
@ -263,16 +276,17 @@ void AccessibilityElementOperatorProxy::ExecuteAction(const long elementId, cons
return; return;
} }
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return;
}
if (!data.WriteRemoteObject(callback->AsObject())) { if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("fail, connection write callback error"); HILOG_ERROR("fail, connection write callback error");
return; return;
} }
error = Remote()->SendRequest(static_cast<uint32_t>( if (!SendTransactCmd(AccessibilityElementOperatorProxy::Message::PERFORM_ACTION, data, reply, option)) {
AccessibilityElementOperatorProxy::Message::PERFORM_ACTION), HILOG_ERROR("ExecuteAction failed");
data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("ExecuteAction fail, error: %d", error);
return; return;
} }
} }
@ -280,8 +294,6 @@ void AccessibilityElementOperatorProxy::ExecuteAction(const long elementId, cons
void AccessibilityElementOperatorProxy::ClearFocus() void AccessibilityElementOperatorProxy::ClearFocus()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -290,10 +302,8 @@ void AccessibilityElementOperatorProxy::ClearFocus()
return; return;
} }
error = Remote()->SendRequest(static_cast<uint32_t>(AccessibilityElementOperatorProxy::Message::CLEAR_FOCUS), if (!SendTransactCmd(AccessibilityElementOperatorProxy::Message::CLEAR_FOCUS, data, reply, option)) {
data, reply, option); HILOG_ERROR("ClearFocus failed");
if (error != NO_ERROR) {
HILOG_ERROR("ExecuteAction fail, error: %d", error);
return; return;
} }
} }
@ -301,8 +311,6 @@ void AccessibilityElementOperatorProxy::ClearFocus()
void AccessibilityElementOperatorProxy::OutsideTouch() void AccessibilityElementOperatorProxy::OutsideTouch()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -311,11 +319,8 @@ void AccessibilityElementOperatorProxy::OutsideTouch()
return; return;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(AccessibilityElementOperatorProxy::Message::OUTSIDE_TOUCH, data, reply, option)) {
static_cast<uint32_t>(AccessibilityElementOperatorProxy::Message::OUTSIDE_TOUCH), HILOG_ERROR("OutsideTouch failed");
data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("ExecuteAction fail, error: %d", error);
return; return;
} }
} }

View File

@ -57,7 +57,8 @@ AccessibilityElementOperatorStub::~AccessibilityElementOperatorStub()
int AccessibilityElementOperatorStub::OnRemoteRequest(uint32_t code, MessageParcel &data, int AccessibilityElementOperatorStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option) MessageParcel &reply, MessageOption &option)
{ {
HILOG_DEBUG("AccessibilityElementOperatorStub::OnRemoteRequest,cmd = %d,flags= %d", code, option.GetFlags()); HILOG_DEBUG("AccessibilityElementOperatorStub::OnRemoteRequest,cmd = %{public}u, flags = %{public}d",
code, option.GetFlags());
std::u16string descriptor = AccessibilityElementOperatorStub::GetDescriptor(); std::u16string descriptor = AccessibilityElementOperatorStub::GetDescriptor();
std::u16string remoteDescriptor = data.ReadInterfaceToken(); std::u16string remoteDescriptor = data.ReadInterfaceToken();
if (descriptor != remoteDescriptor) { if (descriptor != remoteDescriptor) {
@ -200,7 +201,7 @@ void AccessibilityElementOperatorStub::SearchElementInfoByAccessibilityId(const
if (obj != nullptr) { if (obj != nullptr) {
obj->SearchElementInfoByAccessibilityId(elementId, requestId, *tempCallback, mode); obj->SearchElementInfoByAccessibilityId(elementId, requestId, *tempCallback, mode);
} else { } else {
HILOG_DEBUG("Can not find interaction object"); HILOG_ERROR("Can not find interaction object");
} }
} }

View File

@ -100,15 +100,14 @@ bool AccessibilityMemo::GetSource(AccessibilityElementInfo &elementInfo) const
bool result = false; bool result = false;
if (instance != nullptr) { if (instance != nullptr) {
result = instance->SearchElementInfosByAccessibilityId(channelId_, windowId_, elementId_, 0, elementInfos); result = instance->SearchElementInfosByAccessibilityId(channelId_, windowId_, elementId_, 0, elementInfos);
for (auto& info : elementInfos) { HILOG_DEBUG("elementInfos' size is [%{public}d]", elementInfos.size());
if (!elementInfos.empty()) {
HILOG_INFO("called] GetSource OK"); HILOG_INFO("called] GetSource OK");
result = true; result = true;
elementInfo = info; elementInfo = elementInfos[0];
break;
} }
HILOG_INFO("called] GetSource is null");
} else { } else {
HILOG_INFO("called] Can't get AccessibilityOperator instance"); HILOG_ERROR("called] Can't get AccessibilityOperator instance");
} }
return result; return result;
} }
@ -304,7 +303,7 @@ bool AccessibilityEventInfo::ReadFromParcel(Parcel &parcel)
int32_t contentSize = 0; int32_t contentSize = 0;
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, contentSize); READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, contentSize);
std::string content; std::string content;
for (auto i = 0 ; i < contentSize; i++) { for (auto j = 0 ; j < contentSize; j++) {
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, content); READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, content);
AddContent(content); AddContent(content);
} }

View File

@ -99,10 +99,9 @@ bool AccessibilityOperator::GetRoot(int channelId, AccessibilityElementInfo &ele
int activeWindow = AccessibilitySystemAbilityClient::GetInstance()->GetActiveWindow(); int activeWindow = AccessibilitySystemAbilityClient::GetInstance()->GetActiveWindow();
HILOG_DEBUG("activeWindow is %{public}d", activeWindow); HILOG_DEBUG("activeWindow is %{public}d", activeWindow);
bool result = SearchElementInfosByAccessibilityId(channelId, activeWindow, NONE_ID, 0, elementInfos); bool result = SearchElementInfosByAccessibilityId(channelId, activeWindow, NONE_ID, 0, elementInfos);
for (auto& info : elementInfos) { HILOG_DEBUG("element [elementSize:%{public}d]", elementInfos.size());
HILOG_DEBUG("element [elementSize:%{public}d]", elementInfosResult_.size()); if (!elementInfos.empty()) {
elementInfo = info; elementInfo = elementInfos[0];
break;
} }
return result; return result;
} }
@ -198,9 +197,7 @@ bool AccessibilityOperator::FindFocusedElementInfo(int channelId, int accessibil
if (!result) { if (!result) {
return result; return result;
} }
HILOG_DEBUG("channelId[%{public}d], elementId[%{public}d], focusType[%{public}d], sequenceNum[%{public}d]",
HILOG_DEBUG("FindFocusedElementInfo channelId[%{public}d] elementId[%{public}d],\
focusType[%{public}d] sequenceNum[%{public}d]",
channelId, accessibilityWindowId, elementId, focusType); channelId, accessibilityWindowId, elementId, focusType);
if (!asyncElementOperatorMng_.SearchElementResultTimer(sequenceNum)) { if (!asyncElementOperatorMng_.SearchElementResultTimer(sequenceNum)) {
HILOG_ERROR("Failed to wait result"); HILOG_ERROR("Failed to wait result");

View File

@ -208,7 +208,7 @@ shared_ptr<AccessibilityElementOperator> AccessibilitySystemAbilityClient::GetOp
return it->second; return it->second;
} }
} }
HILOG_DEBUG("Failed to get interaction"); HILOG_ERROR("Failed to get interaction");
return nullptr; return nullptr;
} }
@ -518,33 +518,36 @@ bool AccessibilitySystemAbilityClient::UnsubscribeStateObserver(const shared_ptr
return false; return false;
} }
bool result = false; bool result = false;
for (auto it = observersAccessibilityState_.begin(); it != observersAccessibilityState_.end(); it++) { for (auto accessibilityState = observersAccessibilityState_.begin();
if (*it == observer) { accessibilityState != observersAccessibilityState_.end(); accessibilityState++) {
observersAccessibilityState_.erase(it); if (*accessibilityState == observer) {
observersAccessibilityState_.erase(accessibilityState);
result = true; result = true;
break; break;
} }
} }
for (auto it = observersTouchState_.begin(); it != observersTouchState_.end(); it++) { for (auto touchState = observersTouchState_.begin(); touchState != observersTouchState_.end(); touchState++) {
if (*it == observer) { if (*touchState == observer) {
observersTouchState_.erase(it); observersTouchState_.erase(touchState);
result = true; result = true;
break; break;
} }
} }
for (auto it = observersKeyEventState_.begin(); it != observersKeyEventState_.end(); it++) { for (auto keyEventState = observersKeyEventState_.begin(); keyEventState != observersKeyEventState_.end();
if (*it == observer) { keyEventState++) {
observersKeyEventState_.erase(it); if (*keyEventState == observer) {
observersKeyEventState_.erase(keyEventState);
result = true; result = true;
break; break;
} }
} }
for (auto it = observersGestureState_.begin(); it != observersGestureState_.end(); it++) { for (auto gestureState = observersGestureState_.begin(); gestureState != observersGestureState_.end();
if (*it == observer) { gestureState++) {
observersGestureState_.erase(it); if (*gestureState == observer) {
observersGestureState_.erase(gestureState);
result = true; result = true;
break; break;
} }
@ -663,17 +666,18 @@ bool AccessibilitySystemAbilityClient::DeleteCaptionListener(
HILOG_DEBUG("start"); HILOG_DEBUG("start");
bool result = false; bool result = false;
if (type == CaptionObserverType::CAPTION_ENABLE) { if (type == CaptionObserverType::CAPTION_ENABLE) {
for (auto it = observersCaptionEnable_.begin(); it != observersCaptionEnable_.end(); ++it) { for (auto enable = observersCaptionEnable_.begin(); enable != observersCaptionEnable_.end(); ++enable) {
if (*it == ob) { if (*enable == ob) {
observersCaptionEnable_.erase(it); observersCaptionEnable_.erase(enable);
result = true; result = true;
break; break;
} }
} }
} else if (type == CaptionObserverType::CAPTION_PROPERTY) { } else if (type == CaptionObserverType::CAPTION_PROPERTY) {
for (auto it = observersCaptionProperty_.begin(); it != observersCaptionProperty_.end(); ++it) { for (auto property = observersCaptionProperty_.begin(); property != observersCaptionProperty_.end();
if (*it == ob) { ++property) {
observersCaptionProperty_.erase(it); if (*property == ob) {
observersCaptionProperty_.erase(property);
result = true; result = true;
break; break;
} }

View File

@ -80,6 +80,10 @@ bool AccessibleAbilityChannelProxy::SearchElementInfoByAccessibilityId(const int
HILOG_ERROR("requestId write error: %{public}d, ", requestId); HILOG_ERROR("requestId write error: %{public}d, ", requestId);
return false; return false;
} }
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return false;
}
if (!data.WriteRemoteObject(callback->AsObject())) { if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("callback write error"); HILOG_ERROR("callback write error");
return false; return false;
@ -126,6 +130,10 @@ bool AccessibleAbilityChannelProxy::SearchElementInfosByText(const int accessibi
HILOG_ERROR("requestId write error: %{public}d, ", requestId); HILOG_ERROR("requestId write error: %{public}d, ", requestId);
return false; return false;
} }
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return false;
}
if (!data.WriteRemoteObject(callback->AsObject())) { if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("callback write error"); HILOG_ERROR("callback write error");
return false; return false;
@ -168,6 +176,10 @@ bool AccessibleAbilityChannelProxy::FindFocusedElementInfo(const int accessibili
HILOG_ERROR("requestId write error: %{public}d, ", requestId); HILOG_ERROR("requestId write error: %{public}d, ", requestId);
return false; return false;
} }
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return false;
}
if (!data.WriteRemoteObject(callback->AsObject())) { if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("callback write error"); HILOG_ERROR("callback write error");
return false; return false;
@ -208,6 +220,10 @@ bool AccessibleAbilityChannelProxy::FocusMoveSearch(const int accessibilityWindo
HILOG_ERROR("requestId write error: %{public}d, ", requestId); HILOG_ERROR("requestId write error: %{public}d, ", requestId);
return false; return false;
} }
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return false;
}
if (!data.WriteRemoteObject(callback->AsObject())) { if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("callback write error"); HILOG_ERROR("callback write error");
return false; return false;
@ -265,7 +281,7 @@ bool AccessibleAbilityChannelProxy::ExecuteAction(const int accessibilityWindowI
HILOG_ERROR("requestId write error: %{public}d, ", requestId); HILOG_ERROR("requestId write error: %{public}d, ", requestId);
return false; return false;
} }
if (!data.WriteRemoteObject(callback->AsObject())) { if (!callback || !data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("callback write error"); HILOG_ERROR("callback write error");
return false; return false;
} }

View File

@ -55,7 +55,13 @@ void AccessibleAbilityManagerServiceCaptionPropertyProxy::OnCaptionPropertyChang
return; return;
} }
error = Remote()->SendRequest( sptr<IRemoteObject> remote = Remote();
if (!remote) {
HILOG_ERROR("fail to send transact cmd due to remote object");
return;
}
error = remote->SendRequest(
static_cast<uint32_t>(IAccessibleAbilityManagerServiceCaptionProperty::Message::ON_CAPTION_PROPERTY_CHANGED), static_cast<uint32_t>(IAccessibleAbilityManagerServiceCaptionProperty::Message::ON_CAPTION_PROPERTY_CHANGED),
data, reply, option); data, reply, option);
if (error != NO_ERROR) { if (error != NO_ERROR) {

View File

@ -64,7 +64,7 @@ void AccessibleAbilityManagerServiceCaptionPropertyStub::OnCaptionPropertyChange
HILOG_DEBUG("start"); HILOG_DEBUG("start");
std::shared_ptr<AccessibilitySystemAbilityClient> instance = AccessibilitySystemAbilityClient::GetInstance(); std::shared_ptr<AccessibilitySystemAbilityClient> instance = AccessibilitySystemAbilityClient::GetInstance();
if (!instance) { if (!instance) {
HILOG_DEBUG("Can't get asac instance"); HILOG_ERROR("Can't get asac instance");
return; return;
} }
instance->UpdatecaptionProperty(caption); instance->UpdatecaptionProperty(caption);

View File

@ -39,11 +39,27 @@ bool AccessibleAbilityManagerServiceClientProxy::WriteInterfaceToken(MessageParc
return true; return true;
} }
bool AccessibleAbilityManagerServiceClientProxy::SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message code,
MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
HILOG_DEBUG("start.");
sptr<IRemoteObject> remote = Remote();
if (!remote) {
HILOG_ERROR("fail to send transact cmd %{public}d due to remote object", code);
return false;
}
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
if (result != NO_ERROR) {
HILOG_ERROR("receive error transact code %{public}d in transact cmd %{public}d", result, code);
return false;
}
return true;
}
void AccessibleAbilityManagerServiceClientProxy::SendEvent(const AccessibilityEventInfo& uiEvent, const int userId) void AccessibleAbilityManagerServiceClientProxy::SendEvent(const AccessibilityEventInfo& uiEvent, const int userId)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -63,10 +79,8 @@ void AccessibleAbilityManagerServiceClientProxy::SendEvent(const AccessibilityEv
return; return;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::SEND_EVENT, data, reply, option)) {
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::SEND_EVENT), data, reply, option); HILOG_ERROR("SendEvent fail");
if (error != NO_ERROR) {
HILOG_ERROR("SendEvent fail, error: %{public}d", error);
return; return;
} }
} }
@ -74,8 +88,6 @@ void AccessibleAbilityManagerServiceClientProxy::SendEvent(const AccessibilityEv
bool AccessibleAbilityManagerServiceClientProxy::SetCaptionProperty(const CaptionProperty& caption) bool AccessibleAbilityManagerServiceClientProxy::SetCaptionProperty(const CaptionProperty& caption)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -90,13 +102,8 @@ bool AccessibleAbilityManagerServiceClientProxy::SetCaptionProperty(const Captio
return false; return false;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::SET_CAPTION_PROPERTY, data, reply, option)) {
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::SET_CAPTION_PROPERTY), HILOG_ERROR("SetCaptionProperty fail");
data,
reply,
option);
if (error != NO_ERROR) {
HILOG_ERROR("SetCaptionProperty fail, error: %{public}d", error);
return false; return false;
} }
return true; return true;
@ -105,8 +112,6 @@ bool AccessibleAbilityManagerServiceClientProxy::SetCaptionProperty(const Captio
bool AccessibleAbilityManagerServiceClientProxy::SetCaptionState(const bool state) bool AccessibleAbilityManagerServiceClientProxy::SetCaptionState(const bool state)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -121,10 +126,8 @@ bool AccessibleAbilityManagerServiceClientProxy::SetCaptionState(const bool stat
return false; return false;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::SET_CAPTION_STATE, data, reply, option)) {
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::SET_CAPTION_STATE), data, reply, option); HILOG_ERROR("SetCaptionState fail");
if (error != NO_ERROR) {
HILOG_ERROR("SetCaptionState fail, error: %{public}d", error);
return false; return false;
} }
return true; return true;
@ -133,8 +136,6 @@ bool AccessibleAbilityManagerServiceClientProxy::SetCaptionState(const bool stat
bool AccessibleAbilityManagerServiceClientProxy::SetEnabled(const bool state) bool AccessibleAbilityManagerServiceClientProxy::SetEnabled(const bool state)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -149,10 +150,8 @@ bool AccessibleAbilityManagerServiceClientProxy::SetEnabled(const bool state)
return false; return false;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::SET_ENABLED, data, reply, option)) {
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::SET_ENABLED), data, reply, option); HILOG_ERROR("SetEnabled fail");
if (error != NO_ERROR) {
HILOG_ERROR("SetEnabled fail, error: %{public}d", error);
return false; return false;
} }
return true; return true;
@ -162,8 +161,6 @@ uint32_t AccessibleAbilityManagerServiceClientProxy::RegisterStateCallback(
const sptr<IAccessibleAbilityManagerServiceState>& client, const int userId) const sptr<IAccessibleAbilityManagerServiceState>& client, const int userId)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_SYNC); MessageOption option(MessageOption::TF_SYNC);
@ -188,16 +185,11 @@ uint32_t AccessibleAbilityManagerServiceClientProxy::RegisterStateCallback(
return ErrCode::ERROR; return ErrCode::ERROR;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::REGISTER_STATE_CALLBACK,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::REGISTER_STATE_CALLBACK), data, reply, option)) {
data, HILOG_ERROR("RegisterStateCallback fail");
reply,
option);
if (error != NO_ERROR) {
HILOG_ERROR("SendEvent fail, error: %{public}d", error);
return ErrCode::ERROR; return ErrCode::ERROR;
} }
return reply.ReadUint32(); return reply.ReadUint32();
} }
@ -205,8 +197,6 @@ std::vector<AccessibilityAbilityInfo> AccessibleAbilityManagerServiceClientProxy
const uint32_t abilityTypes, const int32_t stateType) const uint32_t abilityTypes, const int32_t stateType)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -227,10 +217,9 @@ std::vector<AccessibilityAbilityInfo> AccessibleAbilityManagerServiceClientProxy
return errorList; return errorList;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::GET_ABILITYLIST,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::GET_ABILITYLIST), data, reply, option); data, reply, option)) {
if (error != NO_ERROR) { HILOG_ERROR("GetAbilityList fail");
HILOG_ERROR("SendEvent fail, error: %d", error);
return errorList; return errorList;
} }
// read result // read result
@ -251,8 +240,6 @@ void AccessibleAbilityManagerServiceClientProxy::RegisterElementOperator(
int windowId, const sptr<IAccessibilityElementOperator>& operation, const int userId) int windowId, const sptr<IAccessibilityElementOperator>& operation, const int userId)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -282,13 +269,9 @@ void AccessibleAbilityManagerServiceClientProxy::RegisterElementOperator(
return; return;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::REGISTER_INTERACTION_CONNECTION,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::REGISTER_INTERACTION_CONNECTION), data, reply, option)) {
data, HILOG_ERROR("RegisterElementOperator fail");
reply,
option);
if (error != NO_ERROR) {
HILOG_ERROR("Register fail, error: %{public}d", error);
return; return;
} }
} }
@ -296,8 +279,6 @@ void AccessibleAbilityManagerServiceClientProxy::RegisterElementOperator(
void AccessibleAbilityManagerServiceClientProxy::DeregisterElementOperator(const int windowId) void AccessibleAbilityManagerServiceClientProxy::DeregisterElementOperator(const int windowId)
{ {
HILOG_DEBUG("windowId(%{public}d)", windowId); HILOG_DEBUG("windowId(%{public}d)", windowId);
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -312,13 +293,9 @@ void AccessibleAbilityManagerServiceClientProxy::DeregisterElementOperator(const
return; return;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::DEREGISTER_INTERACTION_CONNECTION,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::DEREGISTER_INTERACTION_CONNECTION), data, reply, option)) {
data, HILOG_ERROR("DeregisterElementOperator fail");
reply,
option);
if (error != NO_ERROR) {
HILOG_ERROR("Deregister fail, error: %{public}d", error);
return; return;
} }
} }
@ -326,8 +303,6 @@ void AccessibleAbilityManagerServiceClientProxy::DeregisterElementOperator(const
CaptionProperty AccessibleAbilityManagerServiceClientProxy::GetCaptionProperty() CaptionProperty AccessibleAbilityManagerServiceClientProxy::GetCaptionProperty()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -336,24 +311,25 @@ CaptionProperty AccessibleAbilityManagerServiceClientProxy::GetCaptionProperty()
HILOG_ERROR("fail, connection write Token error"); HILOG_ERROR("fail, connection write Token error");
return property; return property;
} }
error = Remote()->SendRequest(
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::GET_CAPTION_PROPERTY), if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::GET_CAPTION_PROPERTY,
data, data, reply, option)) {
reply, HILOG_ERROR("GetCaptionProperty fail");
option);
if (error != NO_ERROR) {
HILOG_ERROR("Interrupt fail, error: %{public}d", error);
return property; return property;
} }
return *reply.ReadParcelable<CaptionProperty>();
std::unique_ptr<CaptionProperty> captionProperty(reply.ReadParcelable<CaptionProperty>());
if (!captionProperty) {
HILOG_ERROR("ReadParcelable<CaptionProperty> failed");
return property;
}
return *captionProperty;
} }
uint32_t AccessibleAbilityManagerServiceClientProxy::RegisterCaptionPropertyCallback( uint32_t AccessibleAbilityManagerServiceClientProxy::RegisterCaptionPropertyCallback(
const sptr<IAccessibleAbilityManagerServiceCaptionProperty>& client, const int userId) const sptr<IAccessibleAbilityManagerServiceCaptionProperty>& client, const int userId)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC); MessageOption option(MessageOption::TF_ASYNC);
@ -378,16 +354,11 @@ uint32_t AccessibleAbilityManagerServiceClientProxy::RegisterCaptionPropertyCall
return ErrCode::ERROR; return ErrCode::ERROR;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::REGISTER_CAPTION_PROPERTY_CALLBACK,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::REGISTER_CAPTION_PROPERTY_CALLBACK), data, reply, option)) {
data, HILOG_ERROR("RegisterCaptionPropertyCallback fail");
reply,
option);
if (error != NO_ERROR) {
HILOG_ERROR("SendEvent fail, error: %{public}d", error);
return ErrCode::ERROR; return ErrCode::ERROR;
} }
return reply.ReadUint32(); return reply.ReadUint32();
} }
@ -399,8 +370,6 @@ sptr<IRemoteObject> AccessibleAbilityManagerServiceClientProxy::GetObject()
bool AccessibleAbilityManagerServiceClientProxy::GetEnabledState() bool AccessibleAbilityManagerServiceClientProxy::GetEnabledState()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -409,10 +378,9 @@ bool AccessibleAbilityManagerServiceClientProxy::GetEnabledState()
HILOG_ERROR("fail, connection write Token"); HILOG_ERROR("fail, connection write Token");
return false; return false;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::GET_ENABLED,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::GET_ENABLED), data, reply, option); data, reply, option)) {
if (error != NO_ERROR) { HILOG_ERROR("GetEnabledState fail");
HILOG_ERROR("GetEnabled fail, error: %{public}d", error);
return false; return false;
} }
return reply.ReadBool(); return reply.ReadBool();
@ -421,8 +389,6 @@ bool AccessibleAbilityManagerServiceClientProxy::GetEnabledState()
bool AccessibleAbilityManagerServiceClientProxy::GetCaptionState() bool AccessibleAbilityManagerServiceClientProxy::GetCaptionState()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -431,10 +397,9 @@ bool AccessibleAbilityManagerServiceClientProxy::GetCaptionState()
HILOG_ERROR("fail, connection write Token"); HILOG_ERROR("fail, connection write Token");
return false; return false;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::GET_CAPTION_STATE,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::GET_CAPTION_STATE), data, reply, option); data, reply, option)) {
if (error != NO_ERROR) { HILOG_ERROR("GetCaptionState fail");
HILOG_ERROR("GetCaptionState fail, error: %{public}d", error);
return false; return false;
} }
return reply.ReadBool(); return reply.ReadBool();
@ -443,8 +408,6 @@ bool AccessibleAbilityManagerServiceClientProxy::GetCaptionState()
bool AccessibleAbilityManagerServiceClientProxy::GetTouchGuideState() bool AccessibleAbilityManagerServiceClientProxy::GetTouchGuideState()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -453,13 +416,9 @@ bool AccessibleAbilityManagerServiceClientProxy::GetTouchGuideState()
HILOG_ERROR("fail, connection write Token"); HILOG_ERROR("fail, connection write Token");
return false; return false;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::GET_TOUCH_GUIDE_STATE,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::GET_TOUCH_GUIDE_STATE), data, reply, option)) {
data, HILOG_ERROR("GetTouchGuideState fail");
reply,
option);
if (error != NO_ERROR) {
HILOG_ERROR("GetTouchGuideState fail, error: %{public}d", error);
return false; return false;
} }
return reply.ReadBool(); return reply.ReadBool();
@ -468,8 +427,6 @@ bool AccessibleAbilityManagerServiceClientProxy::GetTouchGuideState()
bool AccessibleAbilityManagerServiceClientProxy::GetGestureState() bool AccessibleAbilityManagerServiceClientProxy::GetGestureState()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -478,10 +435,9 @@ bool AccessibleAbilityManagerServiceClientProxy::GetGestureState()
HILOG_ERROR("fail, connection write Token"); HILOG_ERROR("fail, connection write Token");
return false; return false;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::GET_GESTURE_STATE,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::GET_GESTURE_STATE), data, reply, option); data, reply, option)) {
if (error != NO_ERROR) { HILOG_ERROR("GetGestureState fail");
HILOG_ERROR("GetGestureState fail, error: %{public}d", error);
return false; return false;
} }
return reply.ReadBool(); return reply.ReadBool();
@ -490,8 +446,6 @@ bool AccessibleAbilityManagerServiceClientProxy::GetGestureState()
bool AccessibleAbilityManagerServiceClientProxy::GetKeyEventObserverState() bool AccessibleAbilityManagerServiceClientProxy::GetKeyEventObserverState()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -500,13 +454,9 @@ bool AccessibleAbilityManagerServiceClientProxy::GetKeyEventObserverState()
HILOG_ERROR("fail, connection write Token"); HILOG_ERROR("fail, connection write Token");
return false; return false;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::GET_KEY_EVENT_OBSERVE_STATE,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::GET_KEY_EVENT_OBSERVE_STATE), data, reply, option)) {
data, HILOG_ERROR("GetKeyEventObserverState fail");
reply,
option);
if (error != NO_ERROR) {
HILOG_ERROR("GetKeyEventObserverState fail, error: %{public}d", error);
return false; return false;
} }
return reply.ReadBool(); return reply.ReadBool();
@ -515,8 +465,6 @@ bool AccessibleAbilityManagerServiceClientProxy::GetKeyEventObserverState()
bool AccessibleAbilityManagerServiceClientProxy::SetTouchGuideState(const bool state) bool AccessibleAbilityManagerServiceClientProxy::SetTouchGuideState(const bool state)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -531,13 +479,9 @@ bool AccessibleAbilityManagerServiceClientProxy::SetTouchGuideState(const bool s
return false; return false;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::SET_TOUCH_GUIDE_STATE,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::SET_TOUCH_GUIDE_STATE), data, reply, option)) {
data, HILOG_ERROR("SetTouchGuideState fail");
reply,
option);
if (error != NO_ERROR) {
HILOG_ERROR("SetTouchGuideState fail, error: %{public}d", error);
return false; return false;
} }
return true; return true;
@ -546,8 +490,6 @@ bool AccessibleAbilityManagerServiceClientProxy::SetTouchGuideState(const bool s
bool AccessibleAbilityManagerServiceClientProxy::SetGestureState(const bool state) bool AccessibleAbilityManagerServiceClientProxy::SetGestureState(const bool state)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -562,10 +504,9 @@ bool AccessibleAbilityManagerServiceClientProxy::SetGestureState(const bool stat
return false; return false;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::SET_GESTURE_STATE,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::SET_GESTURE_STATE), data, reply, option); data, reply, option)) {
if (error != NO_ERROR) { HILOG_ERROR("SetGestureState fail");
HILOG_ERROR("SetGestureState fail, error: %{public}d", error);
return false; return false;
} }
return true; return true;
@ -574,8 +515,6 @@ bool AccessibleAbilityManagerServiceClientProxy::SetGestureState(const bool stat
bool AccessibleAbilityManagerServiceClientProxy::SetKeyEventObserverState(const bool state) bool AccessibleAbilityManagerServiceClientProxy::SetKeyEventObserverState(const bool state)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -590,13 +529,9 @@ bool AccessibleAbilityManagerServiceClientProxy::SetKeyEventObserverState(const
return false; return false;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::SET_KEY_EVENT_OBSERVE_STATE,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::SET_KEY_EVENT_OBSERVE_STATE), data, reply, option)) {
data, HILOG_ERROR("SetKeyEventObserverState fail");
reply,
option);
if (error != NO_ERROR) {
HILOG_ERROR("SetKeyEventObserverState fail, error: %{public}d", error);
return false; return false;
} }
return true; return true;
@ -605,8 +540,6 @@ bool AccessibleAbilityManagerServiceClientProxy::SetKeyEventObserverState(const
bool AccessibleAbilityManagerServiceClientProxy::SetEnabledObj(std::map<std::string, AppExecFwk::ElementName> it) bool AccessibleAbilityManagerServiceClientProxy::SetEnabledObj(std::map<std::string, AppExecFwk::ElementName> it)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -626,13 +559,9 @@ bool AccessibleAbilityManagerServiceClientProxy::SetEnabledObj(std::map<std::str
} }
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::SET_ENABLED_OBJECT,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::SET_ENABLED_OBJECT), data, reply, option)) {
data, HILOG_ERROR("SetEnabledObj fail");
reply,
option);
if (error != NO_ERROR) {
HILOG_ERROR("SetEnabledObj fail, error: %{public}d", error);
return false; return false;
} }
return true; return true;
@ -641,8 +570,6 @@ bool AccessibleAbilityManagerServiceClientProxy::SetEnabledObj(std::map<std::str
std::map<std::string, AppExecFwk::ElementName> AccessibleAbilityManagerServiceClientProxy::GetEnabledAbilities() std::map<std::string, AppExecFwk::ElementName> AccessibleAbilityManagerServiceClientProxy::GetEnabledAbilities()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -652,13 +579,9 @@ std::map<std::string, AppExecFwk::ElementName> AccessibleAbilityManagerServiceCl
HILOG_ERROR("fail, connection write Token error"); HILOG_ERROR("fail, connection write Token error");
return it; return it;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::GET_ENABLED_OBJECT,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::GET_ENABLED_OBJECT), data, reply, option)) {
data, HILOG_ERROR("GetEnabledAbilities fail");
reply,
option);
if (error != NO_ERROR) {
HILOG_ERROR("Interrupt fail, error: %{public}d", error);
return it; return it;
} }
@ -673,8 +596,8 @@ std::map<std::string, AppExecFwk::ElementName> AccessibleAbilityManagerServiceCl
temp.push_back(*iter); temp.push_back(*iter);
} }
for (int i = 0; i < dev_num; i++) { for (int j = 0; j < dev_num; j++) {
it.insert(make_pair(temp[i].GetURI(), temp[i])); it.insert(make_pair(temp[j].GetURI(), temp[j]));
} }
return it; return it;
} }
@ -682,8 +605,6 @@ std::map<std::string, AppExecFwk::ElementName> AccessibleAbilityManagerServiceCl
std::vector<AccessibilityAbilityInfo> AccessibleAbilityManagerServiceClientProxy::GetInstalledAbilities() std::vector<AccessibilityAbilityInfo> AccessibleAbilityManagerServiceClientProxy::GetInstalledAbilities()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -693,12 +614,12 @@ std::vector<AccessibilityAbilityInfo> AccessibleAbilityManagerServiceClientProxy
HILOG_ERROR("fail, connection write Token error"); HILOG_ERROR("fail, connection write Token error");
return it; return it;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::GET_INSTALLED,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::GET_INSTALLED), data, reply, option); data, reply, option)) {
if (error != NO_ERROR) { HILOG_ERROR("GetInstalledAbilities fail");
HILOG_ERROR("Interrupt fail, error: %{public}d", error);
return it; return it;
} }
int dev_num = reply.ReadInt32(); int dev_num = reply.ReadInt32();
for (int i = dev_num; i > 0; i--) { for (int i = dev_num; i > 0; i--) {
std::unique_ptr<AccessibilityAbilityInfo> dev(reply.ReadParcelable<AccessibilityAbilityInfo>()); std::unique_ptr<AccessibilityAbilityInfo> dev(reply.ReadParcelable<AccessibilityAbilityInfo>());
@ -714,8 +635,6 @@ std::vector<AccessibilityAbilityInfo> AccessibleAbilityManagerServiceClientProxy
bool AccessibleAbilityManagerServiceClientProxy::DisableAbilities(std::map<std::string, AppExecFwk::ElementName> it) bool AccessibleAbilityManagerServiceClientProxy::DisableAbilities(std::map<std::string, AppExecFwk::ElementName> it)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -733,11 +652,9 @@ bool AccessibleAbilityManagerServiceClientProxy::DisableAbilities(std::map<std::
return false; return false;
} }
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::DISABLE_ABILITIES,
static_cast<uint32_t>(IAccessibleAbilityManagerServiceClient::Message::DISABLE_ABILITIES), data, reply, option)) {
data, reply, option); HILOG_ERROR("DisableAbilities fail");
if (error != NO_ERROR) {
HILOG_ERROR("SetEnabledObj fail, error: %{public}d", error);
return false; return false;
} }
return true; return true;
@ -746,8 +663,6 @@ bool AccessibleAbilityManagerServiceClientProxy::DisableAbilities(std::map<std::
int AccessibleAbilityManagerServiceClientProxy::GetActiveWindow() int AccessibleAbilityManagerServiceClientProxy::GetActiveWindow()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -757,12 +672,9 @@ int AccessibleAbilityManagerServiceClientProxy::GetActiveWindow()
return false; return false;
} }
error = Remote()->SendRequest( if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::GET_ACTIVE_WINDOW,
static_cast<uint32_t>( data, reply, option)) {
IAccessibleAbilityManagerServiceClient::Message::GET_ACTIVE_WINDOW), HILOG_ERROR("GetActiveWindow fail");
data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("GetActiveWindow fail, error: %{public}d", error);
return false; return false;
} }
return reply.ReadInt32(); return reply.ReadInt32();
@ -771,8 +683,6 @@ int AccessibleAbilityManagerServiceClientProxy::GetActiveWindow()
bool AccessibleAbilityManagerServiceClientProxy::RegisterUITestAbilityConnectionClient(const sptr<IRemoteObject>& obj) bool AccessibleAbilityManagerServiceClientProxy::RegisterUITestAbilityConnectionClient(const sptr<IRemoteObject>& obj)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -787,11 +697,9 @@ bool AccessibleAbilityManagerServiceClientProxy::RegisterUITestAbilityConnection
return false; return false;
} }
error = Remote()->SendRequest(static_cast<uint32_t> if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::REGISTER_UITEST_ABILITY_CONNECTION_CLIENT,
(IAccessibleAbilityManagerServiceClient::Message::REGISTER_UITEST_ABILITY_CONNECTION_CLIENT), data, reply, option)) {
data, reply, option); HILOG_ERROR("RegisterUITestAbilityConnectionClient fail");
if (error != NO_ERROR) {
HILOG_ERROR("Interrupt fail, error: %{public}d", error);
return false; return false;
} }
return reply.ReadBool(); return reply.ReadBool();
@ -800,8 +708,6 @@ bool AccessibleAbilityManagerServiceClientProxy::RegisterUITestAbilityConnection
bool AccessibleAbilityManagerServiceClientProxy::DeregisterUITestAbilityConnectionClient() bool AccessibleAbilityManagerServiceClientProxy::DeregisterUITestAbilityConnectionClient()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
int error = NO_ERROR;
MessageParcel data; MessageParcel data;
MessageParcel reply; MessageParcel reply;
MessageOption option; MessageOption option;
@ -811,11 +717,9 @@ bool AccessibleAbilityManagerServiceClientProxy::DeregisterUITestAbilityConnecti
return false; return false;
} }
error = Remote()->SendRequest(static_cast<uint32_t> if (!SendTransactCmd(IAccessibleAbilityManagerServiceClient::Message::DEREGISTER_UITEST_ABILITY_CONNECTION_CLIENT,
(IAccessibleAbilityManagerServiceClient::Message::DEREGISTER_UITEST_ABILITY_CONNECTION_CLIENT), data, reply, option)) {
data, reply, option); HILOG_ERROR("DeregisterUITestAbilityConnectionClient fail");
if (error != NO_ERROR) {
HILOG_ERROR("Interrupt fail, error: %{public}d", error);
return false; return false;
} }
return reply.ReadBool(); return reply.ReadBool();

View File

@ -56,7 +56,13 @@ void AccessibleAbilityManagerServiceStateProxy::OnStateChanged(const uint32_t st
return; return;
} }
error = Remote()->SendRequest( sptr<IRemoteObject> remote = Remote();
if (!remote) {
HILOG_ERROR("fail to send transact cmd due to remote object");
return;
}
error = remote->SendRequest(
static_cast<uint32_t>(IAccessibleAbilityManagerServiceState::Message::ON_STATE_CHANGED), static_cast<uint32_t>(IAccessibleAbilityManagerServiceState::Message::ON_STATE_CHANGED),
data, reply, option); data, reply, option);
if (error != NO_ERROR) { if (error != NO_ERROR) {

View File

@ -30,7 +30,7 @@ AccessibleAbilityManagerServiceStateStub::AccessibleAbilityManagerServiceStateSt
int AccessibleAbilityManagerServiceStateStub::OnRemoteRequest(uint32_t code, MessageParcel &data, int AccessibleAbilityManagerServiceStateStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option) MessageParcel &reply, MessageOption &option)
{ {
HILOG_DEBUG("AccessibleAbilityManagerServiceStateStub::OnRemoteRequest, cmd = %{public}d, flags= %{public}d", HILOG_DEBUG("AccessibleAbilityManagerServiceStateStub::OnRemoteRequest, cmd = %{public}u, flags= %{public}d",
code, option.GetFlags()); code, option.GetFlags());
std::u16string descriptor = AccessibleAbilityManagerServiceStateStub::GetDescriptor(); std::u16string descriptor = AccessibleAbilityManagerServiceStateStub::GetDescriptor();
std::u16string remoteDescriptor = data.ReadInterfaceToken(); std::u16string remoteDescriptor = data.ReadInterfaceToken();

View File

@ -97,13 +97,13 @@ AccessibleAbilityManagerServiceClientStub::~AccessibleAbilityManagerServiceClien
int AccessibleAbilityManagerServiceClientStub::OnRemoteRequest( int AccessibleAbilityManagerServiceClientStub::OnRemoteRequest(
uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
{ {
HILOG_DEBUG("AccessibleAbilityManagerServiceClientStub::OnRemoteRequest, cmd = %{public}d, flags= %{public}d", HILOG_DEBUG("AccessibleAbilityManagerServiceClientStub::OnRemoteRequest, cmd = %{public}u, flags= %{public}d",
code, code,
option.GetFlags()); option.GetFlags());
std::u16string descriptor = AccessibleAbilityManagerServiceClientStub::GetDescriptor(); std::u16string descriptor = AccessibleAbilityManagerServiceClientStub::GetDescriptor();
std::u16string remoteDescriptor = data.ReadInterfaceToken(); std::u16string remoteDescriptor = data.ReadInterfaceToken();
if (descriptor != remoteDescriptor) { if (descriptor != remoteDescriptor) {
HILOG_INFO("local descriptor is not equal to remote"); HILOG_ERROR("local descriptor is not equal to remote");
return ERR_INVALID_STATE; return ERR_INVALID_STATE;
} }
@ -354,8 +354,8 @@ ErrCode AccessibleAbilityManagerServiceClientStub::HandleSetEnabledObj(MessagePa
} }
temp.push_back(*iter); temp.push_back(*iter);
} }
for (int i = 0; i < dev_num; i++) { for (int j = 0; j < dev_num; j++) {
it.insert(make_pair(temp[i].GetURI(), temp[i])); it.insert(make_pair(temp[j].GetURI(), temp[j]));
} }
SetEnabledObj(it); SetEnabledObj(it);
@ -417,8 +417,8 @@ ErrCode AccessibleAbilityManagerServiceClientStub::HandleDisableAbilities(Messag
} }
temp.push_back(*iter); temp.push_back(*iter);
} }
for (int i = 0; i < dev_num; i++) { for (int j = 0; j < dev_num; j++) {
it.insert(make_pair(temp[i].GetURI(), temp[i])); it.insert(make_pair(temp[j].GetURI(), temp[j]));
} }
DisableAbilities(it); DisableAbilities(it);

View File

@ -44,7 +44,7 @@ napi_value NGesturePos::JSPosConstructor(napi_env env, napi_callback_info info)
uint32_t x = 0, y = 0; uint32_t x = 0, y = 0;
ParseUint32(env, x, argv[PARAM0]); ParseUint32(env, x, argv[PARAM0]);
ParseUint32(env, y, argv[PARAM1]); ParseUint32(env, y, argv[PARAM1]);
HILOG_INFO("JSPosConstructor, x:%{public}d, y:%{public}d", x, y); HILOG_INFO("JSPosConstructor, x:%{public}u, y:%{public}u", x, y);
napi_set_named_property(env, jsthis, "posX", argv[PARAM0]); napi_set_named_property(env, jsthis, "posX", argv[PARAM0]);
napi_set_named_property(env, jsthis, "posY", argv[PARAM1]); napi_set_named_property(env, jsthis, "posY", argv[PARAM1]);

View File

@ -127,6 +127,7 @@ napi_value NElementInfo::ExecuteAction(napi_env env, napi_callback_info info)
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -208,6 +209,7 @@ napi_value NElementInfo::GetByContent(napi_env env, napi_callback_info info)
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -297,6 +299,7 @@ napi_value NElementInfo::GetFocus(napi_env env, napi_callback_info info)
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -403,6 +406,7 @@ napi_value NElementInfo::GetNext(napi_env env, napi_callback_info info)
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -484,6 +488,7 @@ napi_value NElementInfo::GetChild(napi_env env, napi_callback_info info)
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -562,6 +567,7 @@ napi_value NElementInfo::GetParent(napi_env env, napi_callback_info info)
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);

View File

@ -79,6 +79,7 @@ napi_value NAccessibilityClient::IsOpenAccessibility(napi_env env, napi_callback
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -106,10 +107,7 @@ napi_value NAccessibilityClient::IsOpenTouchExploration(napi_env env, napi_callb
napi_value resource = nullptr; napi_value resource = nullptr;
napi_create_string_utf8(env, "IsOpenTouchExploration", NAPI_AUTO_LENGTH, &resource); napi_create_string_utf8(env, "IsOpenTouchExploration", NAPI_AUTO_LENGTH, &resource);
napi_create_async_work( napi_create_async_work(env, nullptr, resource,
env,
nullptr,
resource,
// execute async to call c++ function // execute async to call c++ function
[](napi_env env, void* data) { [](napi_env env, void* data) {
NAccessibilitySystemAbilityClient* callbackInfo = (NAccessibilitySystemAbilityClient*)data; NAccessibilitySystemAbilityClient* callbackInfo = (NAccessibilitySystemAbilityClient*)data;
@ -138,6 +136,7 @@ napi_value NAccessibilityClient::IsOpenTouchExploration(napi_env env, napi_callb
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -200,6 +199,7 @@ napi_value NAccessibilityClient::GetAbilityList(napi_env env, napi_callback_info
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -269,6 +269,7 @@ napi_value NAccessibilityClient::SendEvent(napi_env env, napi_callback_info info
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -443,6 +444,7 @@ napi_value NAccessibilityClient::GetCaptionProperty(napi_env env, napi_callback_
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -502,6 +504,7 @@ napi_value NAccessibilityClient::SetCaptionProperty(napi_env env, napi_callback_
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -561,6 +564,7 @@ napi_value NAccessibilityClient::GetCaptionState(napi_env env, napi_callback_inf
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -589,10 +593,7 @@ napi_value NAccessibilityClient::SetCaptionState(napi_env env, napi_callback_inf
napi_value resource = nullptr; napi_value resource = nullptr;
napi_create_string_utf8(env, "SetCaptionState", NAPI_AUTO_LENGTH, &resource); napi_create_string_utf8(env, "SetCaptionState", NAPI_AUTO_LENGTH, &resource);
napi_create_async_work( napi_create_async_work(env, nullptr, resource,
env,
nullptr,
resource,
// execute async to call c++ function // execute async to call c++ function
[](napi_env env, void* data) { [](napi_env env, void* data) {
NAccessibilitySystemAbilityClient* callbackInfo = (NAccessibilitySystemAbilityClient*)data; NAccessibilitySystemAbilityClient* callbackInfo = (NAccessibilitySystemAbilityClient*)data;
@ -621,6 +622,7 @@ napi_value NAccessibilityClient::SetCaptionState(napi_env env, napi_callback_inf
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -680,6 +682,7 @@ napi_value NAccessibilityClient::GetEnabled(napi_env env, napi_callback_info inf
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -739,6 +742,7 @@ napi_value NAccessibilityClient::SetEnabled(napi_env env, napi_callback_info inf
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -798,6 +802,7 @@ napi_value NAccessibilityClient::GetTouchGuideState(napi_env env, napi_callback_
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -857,6 +862,7 @@ napi_value NAccessibilityClient::SetTouchGuideState(napi_env env, napi_callback_
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -916,6 +922,7 @@ napi_value NAccessibilityClient::GetGestureState(napi_env env, napi_callback_inf
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -975,6 +982,7 @@ napi_value NAccessibilityClient::SetGestureState(napi_env env, napi_callback_inf
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -1035,6 +1043,7 @@ napi_value NAccessibilityClient::GetKeyEventObserverState(napi_env env, napi_cal
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -1094,6 +1103,7 @@ napi_value NAccessibilityClient::SetKeyEventObserverState(napi_env env, napi_cal
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -1123,10 +1133,7 @@ napi_value NAccessibilityClient::GetInstalled(napi_env env, napi_callback_info i
napi_value resource = nullptr; napi_value resource = nullptr;
napi_create_string_utf8(env, "GetInstalled", NAPI_AUTO_LENGTH, &resource); napi_create_string_utf8(env, "GetInstalled", NAPI_AUTO_LENGTH, &resource);
napi_create_async_work( napi_create_async_work(env, nullptr, resource,
env,
nullptr,
resource,
// execute async to call c++ function // execute async to call c++ function
[](napi_env env, void* data) { [](napi_env env, void* data) {
NAccessibilitySystemAbilityClient* callbackInfo = (NAccessibilitySystemAbilityClient*)data; NAccessibilitySystemAbilityClient* callbackInfo = (NAccessibilitySystemAbilityClient*)data;
@ -1155,6 +1162,7 @@ napi_value NAccessibilityClient::GetInstalled(napi_env env, napi_callback_info i
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -1215,6 +1223,7 @@ napi_value NAccessibilityClient::GetExtensionEnabled(napi_env env, napi_callback
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -1274,6 +1283,7 @@ napi_value NAccessibilityClient::ExtensionEnabled(napi_env env, napi_callback_in
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -1333,6 +1343,7 @@ napi_value NAccessibilityClient::ExtensionDisabled(napi_env env, napi_callback_i
} }
napi_delete_async_work(env, callbackInfo->work_); napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
}, },
(void*)callbackInfo, (void*)callbackInfo,
&callbackInfo->work_); &callbackInfo->work_);
@ -1391,6 +1402,7 @@ napi_value NAccessibilityClient::GetCaptionsManager(napi_env env, napi_callback_
napi_set_named_property(env, result, "style", keyCode); napi_set_named_property(env, result, "style", keyCode);
delete callbackInfo; delete callbackInfo;
callbackInfo = nullptr;
return result; return result;
} }

View File

@ -69,7 +69,7 @@ bool ParseUint32(napi_env env, uint32_t& param, napi_value args)
napi_valuetype valuetype; napi_valuetype valuetype;
status = napi_typeof(env, args, &valuetype); status = napi_typeof(env, args, &valuetype);
if (status != napi_ok) { if (status != napi_ok) {
HILOG_INFO("napi_typeof error and status is %{public}d", status); HILOG_ERROR("napi_typeof error and status is %{public}d", status);
return false; return false;
} }
HILOG_INFO("param=%{public}d.", valuetype); HILOG_INFO("param=%{public}d.", valuetype);
@ -258,10 +258,11 @@ static void ConvertAccessibleAbilityInfoToJS(napi_env env, napi_value& result, A
NAPI_CALL_RETURN_VOID(env, napi_create_array(env, &nAbilityType)); NAPI_CALL_RETURN_VOID(env, napi_create_array(env, &nAbilityType));
uint32_t abilityTypesValue = info.GetAccessibilityAbilityType(); uint32_t abilityTypesValue = info.GetAccessibilityAbilityType();
std::vector<std::string> abilityTypes = ParseAbilityTypesToVec(abilityTypesValue); std::vector<std::string> abilityTypes = ParseAbilityTypesToVec(abilityTypesValue);
for (size_t idx = 0; idx < abilityTypes.size(); idx++) { for (size_t idxType = 0; idxType < abilityTypes.size(); idxType++) {
napi_value nType; napi_value nType;
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, abilityTypes[idx].c_str(), NAPI_AUTO_LENGTH, &nType)); NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, abilityTypes[idxType].c_str(),
NAPI_CALL_RETURN_VOID(env, napi_set_element(env, nAbilityType, idx, nType)); NAPI_AUTO_LENGTH, &nType));
NAPI_CALL_RETURN_VOID(env, napi_set_element(env, nAbilityType, idxType, nType));
} }
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "abilityTypes", nAbilityType)); NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "abilityTypes", nAbilityType));
@ -269,10 +270,11 @@ static void ConvertAccessibleAbilityInfoToJS(napi_env env, napi_value& result, A
NAPI_CALL_RETURN_VOID(env, napi_create_array(env, &nCapabilities)); NAPI_CALL_RETURN_VOID(env, napi_create_array(env, &nCapabilities));
uint32_t capabilitiesValue = info.GetCapabilityValues(); uint32_t capabilitiesValue = info.GetCapabilityValues();
std::vector<std::string> capabilities = ParseCapabilitiesToVec(capabilitiesValue); std::vector<std::string> capabilities = ParseCapabilitiesToVec(capabilitiesValue);
for (size_t idx = 0; idx < capabilities.size(); idx++) { for (size_t idxCap = 0; idxCap < capabilities.size(); idxCap++) {
napi_value nType; napi_value nCap;
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, capabilities[idx].c_str(), NAPI_AUTO_LENGTH, &nType)); NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, capabilities[idxCap].c_str(),
NAPI_CALL_RETURN_VOID(env, napi_set_element(env, nCapabilities, idx, nType)); NAPI_AUTO_LENGTH, &nCap));
NAPI_CALL_RETURN_VOID(env, napi_set_element(env, nCapabilities, idxCap, nCap));
} }
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "capabilities", nCapabilities)); NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "capabilities", nCapabilities));
@ -285,10 +287,10 @@ static void ConvertAccessibleAbilityInfoToJS(napi_env env, napi_value& result, A
NAPI_CALL_RETURN_VOID(env, napi_create_array(env, &nEventTypes)); NAPI_CALL_RETURN_VOID(env, napi_create_array(env, &nEventTypes));
uint32_t eventTypesValue = info.GetEventTypes(); uint32_t eventTypesValue = info.GetEventTypes();
std::vector<std::string> eventTypes = ParseEventTypesToVec(eventTypesValue); std::vector<std::string> eventTypes = ParseEventTypesToVec(eventTypesValue);
for (size_t idx = 0; idx < eventTypes.size(); idx++) { for (size_t idxEve = 0; idxEve < eventTypes.size(); idxEve++) {
napi_value nType; napi_value nEve;
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, eventTypes[idx].c_str(), NAPI_AUTO_LENGTH, &nType)); NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, eventTypes[idxEve].c_str(), NAPI_AUTO_LENGTH, &nEve));
NAPI_CALL_RETURN_VOID(env, napi_set_element(env, nEventTypes, idx, nType)); NAPI_CALL_RETURN_VOID(env, napi_set_element(env, nEventTypes, idxEve, nEve));
} }
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "eventTypes", nEventTypes)); NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "eventTypes", nEventTypes));
@ -847,11 +849,11 @@ void ConvertElementInfoToJS(napi_env env, napi_value result, const Accessibility
NAPI_CALL_RETURN_VOID(env, napi_create_array(env, &nOperations)); NAPI_CALL_RETURN_VOID(env, napi_create_array(env, &nOperations));
std::vector<AccessibleAction> operations = elementInfo.GetActionList(); std::vector<AccessibleAction> operations = elementInfo.GetActionList();
size_t operationCount = operations.size(); size_t operationCount = operations.size();
for (size_t idx = 0; idx < operationCount; idx++) { for (size_t i = 0; i < operationCount; i++) {
napi_value nOp; napi_value nOp;
napi_create_object(env, &nOp); napi_create_object(env, &nOp);
ConvertOperationToJS(env, nOp, operations[idx]); ConvertOperationToJS(env, nOp, operations[i]);
NAPI_CALL_RETURN_VOID(env, napi_set_element(env, nOperations, idx, nOp)); NAPI_CALL_RETURN_VOID(env, napi_set_element(env, nOperations, i, nOp));
} }
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "operations", nOperations)); NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "operations", nOperations));
@ -1238,9 +1240,9 @@ void ConvertActionArgsJSToNAPI(
napi_create_string_utf8(env, "htmlItem", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "htmlItem", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value htmlItemValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &htmlItemValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, htmlItemValue);
args.insert(std::pair<std::string, std::string>("htmlItem", str.c_str())); args.insert(std::pair<std::string, std::string>("htmlItem", str.c_str()));
} }
break; break;
@ -1249,9 +1251,9 @@ void ConvertActionArgsJSToNAPI(
napi_create_string_utf8(env, "textMoveUnit", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "textMoveUnit", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value textMoveUnitValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &textMoveUnitValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, textMoveUnitValue);
args.insert(std::pair<std::string, std::string>("textMoveUnit", str.c_str())); args.insert(std::pair<std::string, std::string>("textMoveUnit", str.c_str()));
} }
break; break;
@ -1259,17 +1261,17 @@ void ConvertActionArgsJSToNAPI(
napi_create_string_utf8(env, "selectTextBegin", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "selectTextBegin", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value selectTextBeginValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &selectTextBeginValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, selectTextBeginValue);
args.insert(std::pair<std::string, std::string>("selectTextBegin", str.c_str())); args.insert(std::pair<std::string, std::string>("selectTextBegin", str.c_str()));
} }
napi_create_string_utf8(env, "selectTextEnd", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "selectTextEnd", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value selectTextEndValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &selectTextEndValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, selectTextEndValue);
args.insert(std::pair<std::string, std::string>("selectTextEnd", str.c_str())); args.insert(std::pair<std::string, std::string>("selectTextEnd", str.c_str()));
} }
break; break;
@ -1277,9 +1279,9 @@ void ConvertActionArgsJSToNAPI(
napi_create_string_utf8(env, "setText", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "setText", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value setTextValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &setTextValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, setTextValue);
args.insert(std::pair<std::string, std::string>("setText", str.c_str())); args.insert(std::pair<std::string, std::string>("setText", str.c_str()));
} }
break; break;
@ -1311,18 +1313,18 @@ bool ConvertEventInfoJSToNAPI(napi_env env, napi_value object, AccessibilityEven
napi_create_string_utf8(env, "windowUpdateType", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "windowUpdateType", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value windowUpdateTypeValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &windowUpdateTypeValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, windowUpdateTypeValue);
eventInfo.SetWindowChangeTypes(ConvertStringToWindowUpdateTypes(str)); eventInfo.SetWindowChangeTypes(ConvertStringToWindowUpdateTypes(str));
} }
napi_create_string_utf8(env, "bundleName", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "bundleName", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value bundleNameValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &bundleNameValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, bundleNameValue);
if (str == "") { if (str == "") {
return false; return false;
} }
@ -1334,9 +1336,9 @@ bool ConvertEventInfoJSToNAPI(napi_env env, napi_value object, AccessibilityEven
napi_create_string_utf8(env, "componentType", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "componentType", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value componentTypeValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &componentTypeValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, componentTypeValue);
eventInfo.SetComponentType(str); eventInfo.SetComponentType(str);
} }
@ -1344,54 +1346,54 @@ bool ConvertEventInfoJSToNAPI(napi_env env, napi_value object, AccessibilityEven
napi_create_string_utf8(env, "timeStamp", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "timeStamp", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value timeStampValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &timeStampValue);
napi_get_value_int64(env, value, &timestamp); napi_get_value_int64(env, timeStampValue, &timestamp);
eventInfo.SetTimeStamp(timestamp); eventInfo.SetTimeStamp(timestamp);
} }
napi_create_string_utf8(env, "windowId", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "windowId", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value windowIdValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &windowIdValue);
napi_get_value_int32(env, value, &dataValue); napi_get_value_int32(env, windowIdValue, &dataValue);
eventInfo.SetWindowId(dataValue); eventInfo.SetWindowId(dataValue);
} }
napi_create_string_utf8(env, "pageId", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "pageId", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value pageIdValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &pageIdValue);
napi_get_value_int32(env, value, &dataValue); napi_get_value_int32(env, pageIdValue, &dataValue);
eventInfo.SetPageId(dataValue); eventInfo.SetPageId(dataValue);
} }
napi_create_string_utf8(env, "componentId", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "componentId", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value componentIdValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &componentIdValue);
napi_get_value_int32(env, value, &dataValue); napi_get_value_int32(env, componentIdValue, &dataValue);
eventInfo.SetSource(dataValue); eventInfo.SetSource(dataValue);
} }
napi_create_string_utf8(env, "description", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "description", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value descriptionValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &descriptionValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, descriptionValue);
eventInfo.SetDescription(str); eventInfo.SetDescription(str);
} }
napi_create_string_utf8(env, "triggerAction", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "triggerAction", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value triggerActionValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &triggerActionValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, triggerActionValue);
eventInfo.SetTriggerAction(ConvertStringToAccessibleOperationType(str)); eventInfo.SetTriggerAction(ConvertStringToAccessibleOperationType(str));
if (eventInfo.GetTriggerAction() == ACCESSIBILITY_ACTION_INVALID) { if (eventInfo.GetTriggerAction() == ACCESSIBILITY_ACTION_INVALID) {
return false; return false;
@ -1403,22 +1405,22 @@ bool ConvertEventInfoJSToNAPI(napi_env env, napi_value object, AccessibilityEven
napi_create_string_utf8(env, "textMoveUnit", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "textMoveUnit", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value textMoveUnitValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &textMoveUnitValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, textMoveUnitValue);
eventInfo.SetTextMovementStep(ConvertStringToTextMoveStep(str)); eventInfo.SetTextMovementStep(ConvertStringToTextMoveStep(str));
} }
napi_create_string_utf8(env, "contents", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "contents", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value contentsValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &contentsValue);
napi_value data = nullptr; napi_value data = nullptr;
size_t dataLen = 0; size_t dataLen = 0;
napi_get_array_length(env, value, &dataLen); napi_get_array_length(env, contentsValue, &dataLen);
for (int i = 0; i < int(dataLen); i++) { for (int i = 0; i < int(dataLen); i++) {
napi_get_element(env, value, i, &data); napi_get_element(env, contentsValue, i, &data);
str = GetStringFromNAPI(env, data); str = GetStringFromNAPI(env, data);
eventInfo.AddContent(str); eventInfo.AddContent(str);
} }
@ -1427,63 +1429,63 @@ bool ConvertEventInfoJSToNAPI(napi_env env, napi_value object, AccessibilityEven
napi_create_string_utf8(env, "lastContent", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "lastContent", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value lastContentValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &lastContentValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, lastContentValue);
eventInfo.SetLatestContent(str); eventInfo.SetLatestContent(str);
} }
napi_create_string_utf8(env, "beginIndex", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "beginIndex", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value beginIndexValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &beginIndexValue);
napi_get_value_int32(env, value, &dataValue); napi_get_value_int32(env, beginIndexValue, &dataValue);
eventInfo.SetBeginIndex(dataValue); eventInfo.SetBeginIndex(dataValue);
} }
napi_create_string_utf8(env, "currentIndex", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "currentIndex", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value currentIndexValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &currentIndexValue);
napi_get_value_int32(env, value, &dataValue); napi_get_value_int32(env, currentIndexValue, &dataValue);
eventInfo.SetCurrentIndex(dataValue); eventInfo.SetCurrentIndex(dataValue);
} }
napi_create_string_utf8(env, "endIndex", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "endIndex", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value endIndexValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &endIndexValue);
napi_get_value_int32(env, value, &dataValue); napi_get_value_int32(env, endIndexValue, &dataValue);
eventInfo.SetEndIndex(dataValue); eventInfo.SetEndIndex(dataValue);
} }
napi_create_string_utf8(env, "itemCount", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "itemCount", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value itemCountValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &itemCountValue);
napi_get_value_int32(env, value, &dataValue); napi_get_value_int32(env, itemCountValue, &dataValue);
eventInfo.SetItemCounts(dataValue); eventInfo.SetItemCounts(dataValue);
} }
napi_create_string_utf8(env, "categoryNotification", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "categoryNotification", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value categoryNotificationValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &categoryNotificationValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, categoryNotificationValue);
eventInfo.SetNotificationInfo(ConvertStringToNotificationCategory(str)); eventInfo.SetNotificationInfo(ConvertStringToNotificationCategory(str));
} }
napi_create_string_utf8(env, "gestureType", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "gestureType", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value gestureTypeValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &gestureTypeValue);
str = GetStringFromNAPI(env, value); str = GetStringFromNAPI(env, gestureTypeValue);
eventInfo.SetGestureType(ConvertStringToGestureType(str)); eventInfo.SetGestureType(ConvertStringToGestureType(str));
} }
return true; return true;
@ -1499,18 +1501,18 @@ static void ConvertGesturePathPositionJSToNAPI(
napi_create_string_utf8(env, "posX", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "posX", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value valueX = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &valueX);
napi_get_value_double(env, value, &position); napi_get_value_double(env, valueX, &position);
gesturePathPosition.SetPositionX((float)position); gesturePathPosition.SetPositionX((float)position);
} }
napi_create_string_utf8(env, "posY", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "posY", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value valueY = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &valueY);
napi_get_value_double(env, value, &position); napi_get_value_double(env, valueY, &position);
gesturePathPosition.SetPositionY((float)position); gesturePathPosition.SetPositionY((float)position);
} }
} }
@ -1524,18 +1526,18 @@ static void ConvertGesturePathJSToNAPI(napi_env env, napi_value object, GestureP
napi_create_string_utf8(env, "startPos", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "startPos", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value startValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &startValue);
ConvertGesturePathPositionJSToNAPI(env, value, gesturePathPosition); ConvertGesturePathPositionJSToNAPI(env, startValue, gesturePathPosition);
gesturePath.SetStartPosition(gesturePathPosition); gesturePath.SetStartPosition(gesturePathPosition);
} }
napi_create_string_utf8(env, "endPos", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "endPos", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value endValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &endValue);
ConvertGesturePathPositionJSToNAPI(env, value, gesturePathPosition); ConvertGesturePathPositionJSToNAPI(env, endValue, gesturePathPosition);
gesturePath.SetEndPosition(gesturePathPosition); gesturePath.SetEndPosition(gesturePathPosition);
} }
@ -1543,9 +1545,9 @@ static void ConvertGesturePathJSToNAPI(napi_env env, napi_value object, GestureP
napi_create_string_utf8(env, "durationTime", NAPI_AUTO_LENGTH, &propertyNameValue); napi_create_string_utf8(env, "durationTime", NAPI_AUTO_LENGTH, &propertyNameValue);
napi_has_property(env, object, propertyNameValue, &hasProperty); napi_has_property(env, object, propertyNameValue, &hasProperty);
if (hasProperty) { if (hasProperty) {
napi_value value = nullptr; napi_value timeValue = nullptr;
napi_get_property(env, object, propertyNameValue, &value); napi_get_property(env, object, propertyNameValue, &timeValue);
napi_get_value_int64(env, value, &durationTime); napi_get_value_int64(env, timeValue, &durationTime);
gesturePath.SetDurationTime(durationTime); gesturePath.SetDurationTime(durationTime);
} }
} }
@ -1610,9 +1612,9 @@ void ConvertKeyEventToJS(napi_env env, napi_value result, OHOS::MMI::KeyEvent& k
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, key.GetDeviceId(), &deviceId)); NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, key.GetDeviceId(), &deviceId));
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, keyItem, "deviceId", deviceId)); NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, keyItem, "deviceId", deviceId));
napi_value keyCode; napi_value itemKeyCode;
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, key.GetKeyCode(), &keyCode)); NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, key.GetKeyCode(), &itemKeyCode));
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, keyItem, "keyCode", keyCode)); NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, keyItem, "keyCode", itemKeyCode));
NAPI_CALL_RETURN_VOID(env, napi_set_element(env, keys, idx, keyItem)); NAPI_CALL_RETURN_VOID(env, napi_set_element(env, keys, idx, keyItem));
idx++; idx++;
@ -1710,16 +1712,16 @@ uint32_t ConvertColorStringToNumer(std::string colorStr)
newColorStr += c; newColorStr += c;
newColorStr += c; newColorStr += c;
} }
auto value = stoul(newColorStr, nullptr, COLOR_STRING_BASE); auto valueMini = stoul(newColorStr, nullptr, COLOR_STRING_BASE);
if (newColorStr.length() < COLOR_STRING_SIZE_STANDARD) { if (newColorStr.length() < COLOR_STRING_SIZE_STANDARD) {
// no alpha specified, set alpha to 0xff // no alpha specified, set alpha to 0xff
value |= COLOR_ALPHA_MASK; valueMini |= COLOR_ALPHA_MASK;
} else { } else {
auto alpha = value << ALPHA_MOVE; auto alphaMini = valueMini << ALPHA_MOVE;
auto rgb = value >> COLOR_MOVE; auto rgbMini = valueMini >> COLOR_MOVE;
value = alpha | rgb; valueMini = alphaMini | rgbMini;
} }
color = value; color = valueMini;
return color; return color;
} }

View File

@ -63,12 +63,9 @@ config("aams_service_config") {
if (target_cpu == "arm") { if (target_cpu == "arm") {
cflags = [ "-DBINDER_IPC_32BIT" ] cflags = [ "-DBINDER_IPC_32BIT" ]
# cflags_cc = ["-frtti"]
} }
} }
# remove_configs = [ "//build/config/compiler:no_rtti" ]
ohos_shared_library("accessibleabilityms") { ohos_shared_library("accessibleabilityms") {
install_enable = true install_enable = true

View File

@ -214,6 +214,12 @@ public:
*/ */
const std::vector<AccessibilityAbilityInfo> GetAbilitiesByState(AbilityStateType state); const std::vector<AccessibilityAbilityInfo> GetAbilitiesByState(AbilityStateType state);
/**
* @brief Get the accessibility ability info of the disabled ability.
* @return
*/
const std::vector<AccessibilityAbilityInfo> GetDisableAbilities();
/** /**
* @brief Get enable accessibility list. * @brief Get enable accessibility list.
* @param * @param

View File

@ -29,6 +29,7 @@ using EventHandle = std::function<void(const OHOS::AAFwk::Want&)>;
namespace OHOS { namespace OHOS {
namespace Accessibility { namespace Accessibility {
#define RETRY_SUBSCRIBER 3
class AccessibilityCommonEventSubscriber : public EventFwk::CommonEventSubscriber { class AccessibilityCommonEventSubscriber : public EventFwk::CommonEventSubscriber {
public: public:
AccessibilityCommonEventSubscriber(const EventFwk::CommonEventSubscribeInfo &subscriberInfo, AccessibilityCommonEventSubscriber(const EventFwk::CommonEventSubscribeInfo &subscriberInfo,

View File

@ -376,22 +376,30 @@ const std::vector<AccessibilityAbilityInfo> AccessibilityAccountData::GetAbiliti
connectedA11yAbilities_.size(), enabledAbilities.size()); connectedA11yAbilities_.size(), enabledAbilities.size());
return enabledAbilities; return enabledAbilities;
} else if (state == ABILITY_STATE_DISABLE) { } else if (state == ABILITY_STATE_DISABLE) {
std::vector<AccessibilityAbilityInfo> disabledAbilities = installedAbilities_; std::vector<AccessibilityAbilityInfo> disabledAbilities = GetDisableAbilities();
for (auto enabledAbility : connectedA11yAbilities_) { HILOG_DEBUG("the size of disable abilities is %{public}d", disabledAbilities.size());
for (auto itr = disabledAbilities.begin(); itr != disabledAbilities.end();) {
if (itr->GetId() == enabledAbility.second->GetAbilityInfo().GetId()) {
disabledAbilities.erase(itr);
} else {
itr++;
}
}
}
return disabledAbilities; return disabledAbilities;
} else { } else {
return installedAbilities_; return installedAbilities_;
} }
} }
const std::vector<AccessibilityAbilityInfo> AccessibilityAccountData::GetDisableAbilities()
{
HILOG_DEBUG("start.");
std::vector<AccessibilityAbilityInfo> disabledAbilities = installedAbilities_;
for (auto enabledAbility : connectedA11yAbilities_) {
for (auto itr = disabledAbilities.begin(); itr != disabledAbilities.end();) {
if (itr->GetId() == enabledAbility.second->GetAbilityInfo().GetId()) {
disabledAbilities.erase(itr);
} else {
itr++;
}
}
}
return disabledAbilities;
}
void AccessibilityAccountData::UpdateAccountCapabilities() void AccessibilityAccountData::UpdateAccountCapabilities()
{ {
HILOG_DEBUG("start."); HILOG_DEBUG("start.");
@ -774,19 +782,18 @@ void AccessibilityAccountData::StringToVector(std::string &stringIn, std::vector
HILOG_DEBUG("start."); HILOG_DEBUG("start.");
int strLength = (int)stringIn.size(); int strLength = (int)stringIn.size();
std::vector<int> position; std::vector<int> position;
int wrodCount = 0;
if (strLength == 0) { if (strLength == 0) {
return; return;
} }
for (int i = 0; i < strLength; i++) { for (int j = 0; j < strLength; j++) {
if (stringIn[i] == ',') { if (stringIn[j] == ',') {
position.push_back(i); position.push_back(j);
} }
} }
wrodCount = (int)position.size(); int wrodCount = (int)position.size();
if ((wrodCount == 0) && (strLength > 0)) { if ((wrodCount == 0) && (strLength > 0)) {
vectorResult.push_back(stringIn); vectorResult.push_back(stringIn);
} else { } else {
@ -794,7 +801,6 @@ void AccessibilityAccountData::StringToVector(std::string &stringIn, std::vector
int length = 0; int length = 0;
for (int i = 0; i <= wrodCount; i++) { for (int i = 0; i <= wrodCount; i++) {
if (i == 0) { if (i == 0) {
startWrod = 0;
length = position[i]; length = position[i];
vectorResult.push_back(stringIn.substr(startWrod, length)); // first string vectorResult.push_back(stringIn.substr(startWrod, length)); // first string
} else if (i < wrodCount) { } else if (i < wrodCount) {

View File

@ -74,7 +74,7 @@ bool AccessibilityCommonEventRegistry::RegisterSubscriber()
accessibilityCommonEventSubscriber_ = accessibilityCommonEventSubscriber_ =
std::make_shared<AccessibilityCommonEventSubscriber>(subscribeInfo, eventHandles_); std::make_shared<AccessibilityCommonEventSubscriber>(subscribeInfo, eventHandles_);
int retry = 3; int retry = RETRY_SUBSCRIBER;
do { do {
subscribeResult = CommonEventManager::SubscribeCommonEvent(accessibilityCommonEventSubscriber_); subscribeResult = CommonEventManager::SubscribeCommonEvent(accessibilityCommonEventSubscriber_);
if (subscribeResult) { if (subscribeResult) {

View File

@ -57,6 +57,7 @@ void AccessibilityDisplayManager::OnCreate(Rosen::DisplayId did)
void AccessibilityDisplayManager::OnDestroy(Rosen::DisplayId did) void AccessibilityDisplayManager::OnDestroy(Rosen::DisplayId did)
{ {
} }
void AccessibilityDisplayManager::OnChange(Rosen::DisplayId dId) void AccessibilityDisplayManager::OnChange(Rosen::DisplayId dId)
{ {
} }

View File

@ -29,6 +29,10 @@ GestureHandler::GestureHandler(const std::shared_ptr<AppExecFwk::EventRunner> &r
void GestureHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) void GestureHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
{ {
HILOG_DEBUG(); HILOG_DEBUG();
if (!event) {
HILOG_ERROR("event is null");
return;
}
switch (event->GetInnerEventId()) { switch (event->GetInnerEventId()) {
case AccessibilityGestureRecognizer::LONG_PRESS_MSG: case AccessibilityGestureRecognizer::LONG_PRESS_MSG:
@ -179,7 +183,8 @@ bool AccessibilityGestureRecognizer::HandleTouchMoveEvent(MMI::PointerEvent &eve
isDoubleTap_ = false; isDoubleTap_ = false;
if (!isGestureStarted_) { if (!isGestureStarted_) {
isGestureStarted_ = true; isGestureStarted_ = true;
return listener_->OnStarted(); listener_->OnStarted();
return false;
} }
} else if (!isFirstTapUp_) { } else if (!isFirstTapUp_) {
int64_t durationTime = eventTime - startTime_; int64_t durationTime = eventTime - startTime_;

View File

@ -49,7 +49,8 @@ AccessibilityInputInterceptor::AccessibilityInputInterceptor()
keyEventTransmitters_ = nullptr; keyEventTransmitters_ = nullptr;
aams_ = DelayedSingleton<AccessibleAbilityManagerService>::GetInstance(); aams_ = DelayedSingleton<AccessibleAbilityManagerService>::GetInstance();
if (!aams_) { if (!aams_) {
HILOG_DEBUG("aams_ is null."); HILOG_ERROR("aams_ is null.");
return;
} }
inputManager_ = MMI::InputManager::GetInstance(); inputManager_ = MMI::InputManager::GetInstance();
eventHandler_ = std::make_shared<AppExecFwk::EventHandler>(aams_->GetMainRunner()); eventHandler_ = std::make_shared<AppExecFwk::EventHandler>(aams_->GetMainRunner());
@ -113,7 +114,7 @@ void AccessibilityInputInterceptor::SetAvailableFunctions(uint32_t availableFunc
void AccessibilityInputInterceptor::CreateTransmitters() void AccessibilityInputInterceptor::CreateTransmitters()
{ {
HILOG_DEBUG("function[%{public}d].", availableFunctions_); HILOG_DEBUG("function[%{public}u].", availableFunctions_);
if (!availableFunctions_) { if (!availableFunctions_) {
DestroyInterceptor(); DestroyInterceptor();
@ -201,6 +202,7 @@ void AccessibilityInputInterceptor::InterceptKeyEventCallback(std::shared_ptr<MM
if (!instance_ || !instance_->eventHandler_) { if (!instance_ || !instance_->eventHandler_) {
HILOG_ERROR("eventHandler is nullptr."); HILOG_ERROR("eventHandler is nullptr.");
return;
} }
auto task = std::bind(&AccessibilityInputInterceptor::ProcessKeyEvent, instance_, keyEvent); auto task = std::bind(&AccessibilityInputInterceptor::ProcessKeyEvent, instance_, keyEvent);
instance_->eventHandler_->PostTask(task, AppExecFwk::EventQueue::Priority::LOW); instance_->eventHandler_->PostTask(task, AppExecFwk::EventQueue::Priority::LOW);

View File

@ -92,7 +92,7 @@ bool Intersect(Rect& focus, Rect source)
int maxx = std::min(focus.GetRightBottomXScreenPostion(), source.GetRightBottomXScreenPostion()); int maxx = std::min(focus.GetRightBottomXScreenPostion(), source.GetRightBottomXScreenPostion());
int maxy = std::min(focus.GetRightBottomYScreenPostion(), source.GetRightBottomYScreenPostion()); int maxy = std::min(focus.GetRightBottomYScreenPostion(), source.GetRightBottomYScreenPostion());
if ((minx > maxx) || (miny > maxy)) { if ((minx > maxx) || (miny > maxy)) {
HILOG_DEBUG("The two Rects do not intersect"); HILOG_ERROR("The two Rects do not intersect");
return false; return false;
} }
focus.SetLeftTopScreenPostion(minx, miny); focus.SetLeftTopScreenPostion(minx, miny);
@ -125,7 +125,7 @@ bool AccessibilityInteractionBridge::GetPointerItermOfAccessibilityFocusClick(MM
auto focus = FindFocusedElementInfo(); auto focus = FindFocusedElementInfo();
auto focusRect = focus.GetRectInScreen(); auto focusRect = focus.GetRectInScreen();
float denominator = 2.0; float denominator = 2.0;
/* Apply magnification if needed. */ // Apply magnification if needed.
// Intersect with window // Intersect with window
auto& windowManager = AccessibilityWindowInfoManager::GetInstance(); auto& windowManager = AccessibilityWindowInfoManager::GetInstance();

View File

@ -18,9 +18,9 @@
namespace OHOS { namespace OHOS {
namespace Accessibility { namespace Accessibility {
const int value_1000 = 1000; const int g_value_1000 = 1000;
const int value_1000000 = 1000000; const int g_value_1000000 = 1000000;
const int MS_TO_US = 1000; const int g_msToUs = 1000;
TouchInjectHandler::TouchInjectHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner, TouchInjectHandler::TouchInjectHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
TouchEventInjector &server) : AppExecFwk::EventHandler(runner), server_(server) TouchEventInjector &server) : AppExecFwk::EventHandler(runner), server_(server)
{ {
@ -96,7 +96,7 @@ void TouchEventInjector::GetTapsEvents(int64_t startTime)
float py = gesturePath_[i].GetStartPosition().GetPositionY(); float py = gesturePath_[i].GetStartPosition().GetPositionY();
pointer.SetGlobalX(px); pointer.SetGlobalX(px);
pointer.SetGlobalY(py); pointer.SetGlobalY(py);
pointer.SetDownTime(downTime * MS_TO_US); pointer.SetDownTime(downTime * g_msToUs);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pointer, downTime); event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pointer, downTime);
HILOG_INFO("append down event"); HILOG_INFO("append down event");
injectedEvents_.push_back(event); injectedEvents_.push_back(event);
@ -107,7 +107,7 @@ void TouchEventInjector::GetTapsEvents(int64_t startTime)
py = gesturePath_[i].GetEndPosition().GetPositionY(); py = gesturePath_[i].GetEndPosition().GetPositionY();
pointer.SetGlobalX(px); pointer.SetGlobalX(px);
pointer.SetGlobalY(py); pointer.SetGlobalY(py);
pointer.SetDownTime(downTime * MS_TO_US); pointer.SetDownTime(downTime * g_msToUs);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pointer, nowTime); event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pointer, nowTime);
HILOG_INFO("append up event"); HILOG_INFO("append up event");
injectedEvents_.push_back(event); injectedEvents_.push_back(event);
@ -118,7 +118,7 @@ void TouchEventInjector::GetTapsEvents(int64_t startTime)
void TouchEventInjector::GetMovesEvents(int64_t startTime) void TouchEventInjector::GetMovesEvents(int64_t startTime)
{ {
HILOG_INFO("TouchEventInjector::GetTapsEvents: start"); HILOG_INFO("TouchEventInjector::GetMovesEvents: start");
std::shared_ptr<MMI::PointerEvent> event; std::shared_ptr<MMI::PointerEvent> event;
MMI::PointerEvent::PointerItem pointer = {}; MMI::PointerEvent::PointerItem pointer = {};
int64_t downTime = startTime; int64_t downTime = startTime;
@ -129,7 +129,7 @@ void TouchEventInjector::GetMovesEvents(int64_t startTime)
pointer.SetPointerId(1); pointer.SetPointerId(1);
pointer.SetGlobalX(px); pointer.SetGlobalX(px);
pointer.SetGlobalY(py); pointer.SetGlobalY(py);
pointer.SetDownTime(downTime * MS_TO_US); pointer.SetDownTime(downTime * g_msToUs);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pointer, downTime); event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pointer, downTime);
HILOG_INFO("append down event"); HILOG_INFO("append down event");
injectedEvents_.push_back(event); injectedEvents_.push_back(event);
@ -138,7 +138,7 @@ void TouchEventInjector::GetMovesEvents(int64_t startTime)
py = gesturePath_[i].GetEndPosition().GetPositionY(); py = gesturePath_[i].GetEndPosition().GetPositionY();
pointer.SetGlobalX(px); pointer.SetGlobalX(px);
pointer.SetGlobalY(py); pointer.SetGlobalY(py);
pointer.SetDownTime(downTime * MS_TO_US); pointer.SetDownTime(downTime * g_msToUs);
HILOG_INFO("append move event"); HILOG_INFO("append move event");
nowTime += gesturePath_[i].GetDurationTime(); nowTime += gesturePath_[i].GetDurationTime();
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, pointer, nowTime); event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, pointer, nowTime);
@ -149,7 +149,7 @@ void TouchEventInjector::GetMovesEvents(int64_t startTime)
py = gesturePath_[gesturePath_.size() - 1].GetEndPosition().GetPositionY(); py = gesturePath_[gesturePath_.size() - 1].GetEndPosition().GetPositionY();
pointer.SetGlobalX(px); pointer.SetGlobalX(px);
pointer.SetGlobalY(py); pointer.SetGlobalY(py);
pointer.SetDownTime(downTime * MS_TO_US); pointer.SetDownTime(downTime * g_msToUs);
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pointer, nowTime); event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pointer, nowTime);
HILOG_INFO("append up event"); HILOG_INFO("append up event");
injectedEvents_.push_back(event); injectedEvents_.push_back(event);
@ -186,9 +186,10 @@ void TouchEventInjector::InjectEventsInner()
std::shared_ptr<SendEventArgs> parameters = std::make_shared<SendEventArgs>(); std::shared_ptr<SendEventArgs> parameters = std::make_shared<SendEventArgs>();
parameters->isLastEvent_ = (i == injectedEvents_.size() - 1) ? true : false; parameters->isLastEvent_ = (i == injectedEvents_.size() - 1) ? true : false;
parameters->event_ = injectedEvents_[i]; parameters->event_ = injectedEvents_[i];
int64_t timeout = injectedEvents_[i]->GetActionTime() / MS_TO_US - curTime; if (g_msToUs - curTime != 0) {
int64_t timeout = injectedEvents_[i]->GetActionTime() / g_msToUs - curTime;
handler_->SendEvent(SEND_TOUCH_EVENT_MSG, parameters, timeout); handler_->SendEvent(SEND_TOUCH_EVENT_MSG, parameters, timeout);
}
} }
injectedEvents_.clear(); injectedEvents_.clear();
} }
@ -214,7 +215,7 @@ void TouchEventInjector::CancelGesture()
MMI::PointerEvent::PointerItem pointer = {}; MMI::PointerEvent::PointerItem pointer = {};
pointer.SetPointerId(1); pointer.SetPointerId(1);
int64_t time = getSystemTime(); int64_t time = getSystemTime();
pointer.SetDownTime(time * MS_TO_US); pointer.SetDownTime(time * g_msToUs);
pointer.SetPointerId(1); pointer.SetPointerId(1);
if (GetNext() != nullptr && isGestureUnderway_) { if (GetNext() != nullptr && isGestureUnderway_) {
event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_CANCEL, pointer, time); event = obtainTouchEvent(MMI::PointerEvent::POINTER_ACTION_CANCEL, pointer, time);
@ -251,7 +252,7 @@ std::shared_ptr<MMI::PointerEvent> TouchEventInjector::obtainTouchEvent(int acti
std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create(); std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
pointerEvent->SetPointerId(point.GetPointerId()); pointerEvent->SetPointerId(point.GetPointerId());
pointerEvent->SetPointerAction(action); pointerEvent->SetPointerAction(action);
pointerEvent->SetActionTime(actionTime * MS_TO_US); pointerEvent->SetActionTime(actionTime * g_msToUs);
pointerEvent->SetActionStartTime(point.GetDownTime()); pointerEvent->SetActionStartTime(point.GetDownTime());
pointerEvent->AddPointerItem(point); pointerEvent->AddPointerItem(point);
pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN); pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
@ -263,7 +264,7 @@ int64_t TouchEventInjector::getSystemTime()
HILOG_INFO("TouchEventInjector::getSystemTime: start"); HILOG_INFO("TouchEventInjector::getSystemTime: start");
struct timespec times = {0, 0}; struct timespec times = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &times); clock_gettime(CLOCK_MONOTONIC, &times);
int64_t millisecond = (int64_t)(times.tv_sec * value_1000 + times.tv_nsec / value_1000000); int64_t millisecond = (int64_t)(times.tv_sec * g_value_1000 + times.tv_nsec / g_value_1000000);
return millisecond; return millisecond;
} }

View File

@ -276,7 +276,7 @@ bool TouchGuider::TouchGuideListener::OnStarted()
server_.CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); server_.CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG);
server_.PostGestureRecognizeExit(); server_.PostGestureRecognizeExit();
server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
return false; return true;
} }
bool TouchGuider::TouchGuideListener::OnCompleted(GestureType gestureId) bool TouchGuider::TouchGuideListener::OnCompleted(GestureType gestureId)
@ -590,7 +590,7 @@ void TouchGuider::HandleDraggingStateInnerMove(MMI::PointerEvent &event)
if (pointCount == POINTER_COUNT_1) { if (pointCount == POINTER_COUNT_1) {
HILOG_INFO("Only two pointers can be received in the dragging state"); HILOG_INFO("Only two pointers can be received in the dragging state");
} else if (pointCount == POINTER_COUNT_2 && IsDragGestureAccept(event)) { } else if (pointCount == POINTER_COUNT_2 && IsDragGestureAccept(event)) {
/* get densityPixels from WMS */ // get densityPixels from WMS
AccessibilityDisplayManager &displayMgr = AccessibilityDisplayManager::GetInstance(); AccessibilityDisplayManager &displayMgr = AccessibilityDisplayManager::GetInstance();
auto display = displayMgr.GetDefaultDisplay(); auto display = displayMgr.GetDefaultDisplay();
float densityPixels = display->GetVirtualPixelRatio(); float densityPixels = display->GetVirtualPixelRatio();
@ -629,7 +629,7 @@ float TouchGuider::GetAngleCos(float offsetX, float offsetY, bool isGetX)
float ret = isGetX ? offsetX : offsetY; float ret = isGetX ? offsetX : offsetY;
double duration = hypot(offsetX, offsetY); double duration = hypot(offsetX, offsetY);
if (duration == 0) { if ((int)duration == 0) {
return ret; return ret;
} }
ret = ret / duration; ret = ret / duration;
@ -733,9 +733,9 @@ void TouchGuider::ClearReceivedEventRecorder()
{ {
HILOG_DEBUG(); HILOG_DEBUG();
memset_s(receivedRecorder_.pointerDownX, sizeof(receivedRecorder_.pointerDownX), (void)memset_s(receivedRecorder_.pointerDownX, sizeof(receivedRecorder_.pointerDownX),
0, sizeof(receivedRecorder_.pointerDownX)); 0, sizeof(receivedRecorder_.pointerDownX));
memset_s(receivedRecorder_.pointerDownY, sizeof(receivedRecorder_.pointerDownY), (void)memset_s(receivedRecorder_.pointerDownY, sizeof(receivedRecorder_.pointerDownY),
0, sizeof(receivedRecorder_.pointerDownY)); 0, sizeof(receivedRecorder_.pointerDownY));
receivedRecorder_.lastEvent = nullptr; receivedRecorder_.lastEvent = nullptr;
} }

View File

@ -28,11 +28,11 @@ void AccessibilityWindowListener::OnWindowUpdate(const sptr<Rosen::Accessibility
auto& winMgr = AccessibilityWindowInfoManager::GetInstance(); auto& winMgr = AccessibilityWindowInfoManager::GetInstance();
switch (type) { switch (type) {
case Rosen::WindowUpdateType::WINDOW_UPDATE_ADDED: { case Rosen::WindowUpdateType::WINDOW_UPDATE_ADDED: {
auto a11yWindowInfo = winMgr.CreateAccessibilityWindowInfo(*windowInfo); auto a11yWindowInfoAdded = winMgr.CreateAccessibilityWindowInfo(*windowInfo);
winMgr.a11yWindows_.emplace(windowInfo->currentWindowInfo_->wid_, a11yWindowInfo); winMgr.a11yWindows_.emplace(windowInfo->currentWindowInfo_->wid_, a11yWindowInfoAdded);
AccessibilityEventInfo evtInf(windowInfo->currentWindowInfo_->wid_, WINDOW_UPDATE_ADDED); AccessibilityEventInfo evtInfAdded(windowInfo->currentWindowInfo_->wid_, WINDOW_UPDATE_ADDED);
aams->SendEvent(evtInf, aams->GetCurrentAccountId()); aams->SendEvent(evtInfAdded, aams->GetCurrentAccountId());
if (a11yWindowInfo.IsFocused()) { if (a11yWindowInfoAdded.IsFocused()) {
winMgr.SetActiveWindow(windowInfo->currentWindowInfo_->wid_); winMgr.SetActiveWindow(windowInfo->currentWindowInfo_->wid_);
} }
break; break;
@ -51,30 +51,30 @@ void AccessibilityWindowListener::OnWindowUpdate(const sptr<Rosen::Accessibility
winMgr.SetInputFocusedWindow(INVALID_WINDOW_ID); winMgr.SetInputFocusedWindow(INVALID_WINDOW_ID);
} }
winMgr.a11yWindows_.erase(windowInfo->currentWindowInfo_->wid_); winMgr.a11yWindows_.erase(windowInfo->currentWindowInfo_->wid_);
AccessibilityEventInfo evtInf(windowInfo->currentWindowInfo_->wid_, WINDOW_UPDATE_REMOVED); AccessibilityEventInfo evtInfRemoved(windowInfo->currentWindowInfo_->wid_, WINDOW_UPDATE_REMOVED);
aams->SendEvent(evtInf, aams->GetCurrentAccountId()); aams->SendEvent(evtInfRemoved, aams->GetCurrentAccountId());
break; break;
} }
case Rosen::WindowUpdateType::WINDOW_UPDATE_BOUNDS: { case Rosen::WindowUpdateType::WINDOW_UPDATE_BOUNDS: {
AccessibilityEventInfo evtInf(windowInfo->currentWindowInfo_->wid_, WINDOW_UPDATE_BOUNDS); AccessibilityEventInfo evtInfBounds(windowInfo->currentWindowInfo_->wid_, WINDOW_UPDATE_BOUNDS);
aams->SendEvent(evtInf, aams->GetCurrentAccountId()); aams->SendEvent(evtInfBounds, aams->GetCurrentAccountId());
break; break;
} }
case Rosen::WindowUpdateType::WINDOW_UPDATE_ACTIVE: case Rosen::WindowUpdateType::WINDOW_UPDATE_ACTIVE:
if (!winMgr.a11yWindows_.count(windowInfo->currentWindowInfo_->wid_)) { if (!winMgr.a11yWindows_.count(windowInfo->currentWindowInfo_->wid_)) {
auto a11yWindowInfo = winMgr.CreateAccessibilityWindowInfo(*windowInfo); auto a11yWindowInfoActive = winMgr.CreateAccessibilityWindowInfo(*windowInfo);
winMgr.a11yWindows_.emplace(windowInfo->currentWindowInfo_->wid_, a11yWindowInfo); winMgr.a11yWindows_.emplace(windowInfo->currentWindowInfo_->wid_, a11yWindowInfoActive);
} }
winMgr.SetActiveWindow(windowInfo->currentWindowInfo_->wid_); winMgr.SetActiveWindow(windowInfo->currentWindowInfo_->wid_);
break; break;
case Rosen::WindowUpdateType::WINDOW_UPDATE_FOCUSED: { case Rosen::WindowUpdateType::WINDOW_UPDATE_FOCUSED: {
if (!winMgr.a11yWindows_.count(windowInfo->currentWindowInfo_->wid_)) { if (!winMgr.a11yWindows_.count(windowInfo->currentWindowInfo_->wid_)) {
auto a11yWindowInfo = winMgr.CreateAccessibilityWindowInfo(*windowInfo); auto a11yWindowInfoFocused = winMgr.CreateAccessibilityWindowInfo(*windowInfo);
winMgr.a11yWindows_.emplace(windowInfo->currentWindowInfo_->wid_, a11yWindowInfo); winMgr.a11yWindows_.emplace(windowInfo->currentWindowInfo_->wid_, a11yWindowInfoFocused);
} }
winMgr.SetActiveWindow(windowInfo->currentWindowInfo_->wid_); winMgr.SetActiveWindow(windowInfo->currentWindowInfo_->wid_);
AccessibilityEventInfo evtInf(windowInfo->currentWindowInfo_->wid_, WINDOW_UPDATE_FOCUSED); AccessibilityEventInfo evtInfFocused(windowInfo->currentWindowInfo_->wid_, WINDOW_UPDATE_FOCUSED);
aams->SendEvent(evtInf, aams->GetCurrentAccountId()); aams->SendEvent(evtInfFocused, aams->GetCurrentAccountId());
break; break;
} }
default: default:
@ -208,7 +208,7 @@ void AccessibilityWindowInfoManager::SetAccessibilityFocusedWindow(int windowId)
} }
if (!a11yWindows_.count(windowId)) { if (!a11yWindows_.count(windowId)) {
HILOG_WARN("Window id is not found"); HILOG_ERROR("Window id is not found");
return; return;
} }

View File

@ -62,7 +62,7 @@ bool AccessibleAbilityChannelStubImpl::SearchElementInfoByAccessibilityId(const
return false; return false;
} }
connection->GetProxy()->SearchElementInfoByAccessibilityId(elementId, requestId, callback, mode); connection->GetProxy()->SearchElementInfoByAccessibilityId(elementId, requestId, callback, mode);
HILOG_ERROR("AccessibleAbilityChannelStubImpl::SearchElementInfoByAccessibilityId successfully"); HILOG_DEBUG("AccessibleAbilityChannelStubImpl::SearchElementInfoByAccessibilityId successfully");
return true; return true;
} }
@ -84,6 +84,10 @@ bool AccessibleAbilityChannelStubImpl::SearchElementInfosByText(const int access
HILOG_ERROR("AccessibleAbilityChannelStubImpl::SearchElementInfosByText failed: no capability"); HILOG_ERROR("AccessibleAbilityChannelStubImpl::SearchElementInfosByText failed: no capability");
return false; return false;
} }
if (!connection->GetProxy()) {
HILOG_ERROR("get proxy failed");
return false;
}
connection->GetProxy()->SearchElementInfosByText(elementId, text, requestId, callback); connection->GetProxy()->SearchElementInfosByText(elementId, text, requestId, callback);
return true; return true;
} }
@ -106,6 +110,10 @@ bool AccessibleAbilityChannelStubImpl::FindFocusedElementInfo(const int accessib
HILOG_ERROR("AccessibleAbilityChannelStubImpl::FindFocusedElementInfo failed: no capability"); HILOG_ERROR("AccessibleAbilityChannelStubImpl::FindFocusedElementInfo failed: no capability");
return false; return false;
} }
if (!connection->GetProxy()) {
HILOG_ERROR("get proxy failed");
return false;
}
connection->GetProxy()->FindFocusedElementInfo(elementId, focusType, requestId, callback); connection->GetProxy()->FindFocusedElementInfo(elementId, focusType, requestId, callback);
return true; return true;
} }
@ -303,7 +311,7 @@ void AccessibleAbilityConnection::OnAbilityConnectDone(const AppExecFwk::Element
elementName_ = element; elementName_ = element;
if (resultCode != NO_ERROR) { if (resultCode != NO_ERROR) {
HILOG_DEBUG("Connect failed!"); HILOG_ERROR("Connect failed!");
accountData_->RemoveEnabledAbility(elementName_); accountData_->RemoveEnabledAbility(elementName_);
accountData_->RemoveConnectingA11yAbility(elementName_); accountData_->RemoveConnectingA11yAbility(elementName_);
DelayedSingleton<AccessibleAbilityManagerService>::GetInstance()->UpdateAbilities(); DelayedSingleton<AccessibleAbilityManagerService>::GetInstance()->UpdateAbilities();
@ -499,15 +507,10 @@ AAFwk::Want CreateWant(AppExecFwk::ElementName& element)
void AccessibleAbilityConnection::Disconnect() void AccessibleAbilityConnection::Disconnect()
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
// temp deal:
#if 1
if (AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(this) != ERR_OK) { if (AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(this) != ERR_OK) {
HILOG_ERROR("Disconnect failed!"); HILOG_ERROR("Disconnect failed!");
return; return;
} }
#else
OnAbilityDisconnectDone(elementName_, 0);
#endif
} }
void AccessibleAbilityConnection::Connect(const AppExecFwk::ElementName &element) void AccessibleAbilityConnection::Connect(const AppExecFwk::ElementName &element)

View File

@ -200,11 +200,18 @@ uint32_t AccessibleAbilityManagerService::RegisterCaptionPropertyCallback(
} }
} }
if (!callback) {
HILOG_ERROR("callback is null");
return 0;
}
if (!callback->AsObject()) {
HILOG_ERROR("object is null");
return 0;
}
callback->AsObject()->AddDeathRecipient(captionPropertyCallbackDeathRecipient_); callback->AsObject()->AddDeathRecipient(captionPropertyCallbackDeathRecipient_);
accountData->AddCaptionPropertyCallback(callback); accountData->AddCaptionPropertyCallback(callback);
printf("accountData AddCaptionPropertyCallback %d\n", accountData->GetCaptionPropertyCallbacks().size()); HILOG_DEBUG("the size of caption property callbacks is %{public}d",
HILOG_INFO("AccessibleAbilityManagerService::RegisterCaptionPropertyCallback successfully"); accountData->GetCaptionPropertyCallbacks().size());
return NO_ERROR; return NO_ERROR;
} }
@ -230,6 +237,14 @@ uint32_t AccessibleAbilityManagerService::RegisterStateCallback(
} }
} }
if (!callback) {
HILOG_ERROR("callback is null");
return 0;
}
if (!callback->AsObject()) {
HILOG_ERROR("object is null");
return 0;
}
callback->AsObject()->AddDeathRecipient(stateCallbackDeathRecipient_); callback->AsObject()->AddDeathRecipient(stateCallbackDeathRecipient_);
accountData->AddStateCallback(callback); accountData->AddStateCallback(callback);
HILOG_INFO("AccessibleAbilityManagerService::RegisterStateCallback successfully"); HILOG_INFO("AccessibleAbilityManagerService::RegisterStateCallback successfully");
@ -449,14 +464,18 @@ void AccessibleAbilityManagerService::ClearFocus(int windowId)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
sptr<AccessibilityWindowConnection> connection = GetAccessibilityWindowConnection(windowId); sptr<AccessibilityWindowConnection> connection = GetAccessibilityWindowConnection(windowId);
connection->GetProxy()->ClearFocus(); if (connection && connection->GetProxy()) {
connection->GetProxy()->ClearFocus();
}
} }
void AccessibleAbilityManagerService::OutsideTouch(int windowId) void AccessibleAbilityManagerService::OutsideTouch(int windowId)
{ {
HILOG_DEBUG("start"); HILOG_DEBUG("start");
sptr<AccessibilityWindowConnection> connection = GetAccessibilityWindowConnection(windowId); sptr<AccessibilityWindowConnection> connection = GetAccessibilityWindowConnection(windowId);
connection->GetProxy()->OutsideTouch(); if (connection && connection->GetProxy()) {
connection->GetProxy()->OutsideTouch();
}
} }
void AccessibleAbilityManagerService::OnChanging(bool selfChange, Uri& uri) void AccessibleAbilityManagerService::OnChanging(bool selfChange, Uri& uri)
@ -569,6 +588,10 @@ void AccessibleAbilityManagerService::PackageRemoved(std::string& bundleName)
for (auto& connectedAbility : connectedAbilities) { for (auto& connectedAbility : connectedAbilities) {
std::size_t firstPos = connectedAbility.first.find_first_of('/') + 1; std::size_t firstPos = connectedAbility.first.find_first_of('/') + 1;
std::size_t endPos = connectedAbility.first.find_last_of('/'); std::size_t endPos = connectedAbility.first.find_last_of('/');
if (endPos <= firstPos) {
HILOG_ERROR("it's a wrong ability and the uri is %{public}s", connectedAbility.first.c_str());
continue;
}
std::string connectedBundleName = connectedAbility.first.substr(firstPos, endPos - firstPos); std::string connectedBundleName = connectedAbility.first.substr(firstPos, endPos - firstPos);
if (connectedBundleName == bundleName) { if (connectedBundleName == bundleName) {
HILOG_DEBUG("Remove connected ability and it's bundle name is %{public}s", connectedBundleName.c_str()); HILOG_DEBUG("Remove connected ability and it's bundle name is %{public}s", connectedBundleName.c_str());
@ -734,10 +757,9 @@ void AccessibleAbilityManagerService::UpdateAbilities()
if (!connection) { if (!connection) {
connection = new(std::nothrow) AccessibleAbilityConnection(accountData, connection = new(std::nothrow) AccessibleAbilityConnection(accountData,
connectCounter_++, installAbility); connectCounter_++, installAbility);
if (!connection) { if (connection) {
HILOG_ERROR("connection is null"); connection->Connect(element);
} }
connection->Connect(element);
} }
} else { } else {
HILOG_DEBUG("not in enabledAbilites list ."); HILOG_DEBUG("not in enabledAbilites list .");
@ -804,15 +826,12 @@ void AccessibleAbilityManagerService::UpdateInputFilter()
} }
HILOG_DEBUG("InputInterceptor flag is %{public}d", flag); HILOG_DEBUG("InputInterceptor flag is %{public}d", flag);
if (flag) { inputInterceptor_ = AccessibilityInputInterceptor::GetInstance();
inputInterceptor_ = AccessibilityInputInterceptor::GetInstance(); if (!inputInterceptor_) {
inputInterceptor_->SetAvailableFunctions(flag); HILOG_ERROR("inputInterceptor_ is null.");
} else if (inputInterceptor_ != nullptr) { return;
HILOG_DEBUG("Has InputInterceptor before.");
inputInterceptor_->SetAvailableFunctions(0);
} else {
HILOG_DEBUG("InputInterceptor is null.");
} }
inputInterceptor_->SetAvailableFunctions(flag);
} }
void AccessibleAbilityManagerService::UpdateMagnification() void AccessibleAbilityManagerService::UpdateMagnification()
@ -828,12 +847,12 @@ void AccessibleAbilityManagerService::UpdateMagnification()
std::vector<sptr<Rosen::Display>> displays = AccessibilityDisplayManager::GetInstance().GetDisplays(); std::vector<sptr<Rosen::Display>> displays = AccessibilityDisplayManager::GetInstance().GetDisplays();
if (accountData->GetScreenMagnificationFlag()) { if (accountData->GetScreenMagnificationFlag()) {
for (sptr<Rosen::Display> display : displays) { for (sptr<Rosen::Display> displayReg : displays) {
AccessibilityZoomProxy::GetInstance().Register(display->GetId()); AccessibilityZoomProxy::GetInstance().Register(displayReg->GetId());
} }
} else { } else {
for (sptr<Rosen::Display> display : displays) { for (sptr<Rosen::Display> displayUnreg : displays) {
AccessibilityZoomProxy::GetInstance().Unregister(display->GetId()); AccessibilityZoomProxy::GetInstance().Unregister(displayUnreg->GetId());
} }
} }
} }

View File

@ -29,6 +29,10 @@ AAMSEventHandler::~AAMSEventHandler()
void AAMSEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) void AAMSEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
{ {
if (!event) {
HILOG_ERROR("event is null");
return;
}
HILOG_DEBUG("the eventId is %{public}d", event->GetInnerEventId()); HILOG_DEBUG("the eventId is %{public}d", event->GetInnerEventId());
} }
} // namespace Accessibility } // namespace Accessibility

View File

@ -339,15 +339,12 @@ void AccessibleAbilityManagerService::UpdateInputFilter()
} }
HILOG_DEBUG("InputFilter flag is %{public}d", flag); HILOG_DEBUG("InputFilter flag is %{public}d", flag);
if (flag) { inputInterceptor_ = AccessibilityInputInterceptor::GetInstance();
inputInterceptor_ = AccessibilityInputInterceptor::GetInstance(); if (!inputInterceptor_) {
inputInterceptor_->SetAvailableFunctions(flag); HILOG_ERROR("inputInterceptor_ is null.");
} else if (inputInterceptor_ != nullptr) { return;
HILOG_DEBUG("Has InputInterceptor before.");
inputInterceptor_->SetAvailableFunctions(0);
} else {
HILOG_DEBUG("InputInterceptor is null.");
} }
inputInterceptor_->SetAvailableFunctions(flag);
} }
void AccessibleAbilityManagerService::UpdateMagnification() void AccessibleAbilityManagerService::UpdateMagnification()
@ -363,12 +360,12 @@ void AccessibleAbilityManagerService::UpdateMagnification()
std::vector<sptr<Rosen::Display>> displays = AccessibilityDisplayManager::GetInstance().GetDisplays(); std::vector<sptr<Rosen::Display>> displays = AccessibilityDisplayManager::GetInstance().GetDisplays();
if (accountData->GetScreenMagnificationFlag()) { if (accountData->GetScreenMagnificationFlag()) {
for (sptr<Rosen::Display> display : displays) { for (sptr<Rosen::Display> displayReg : displays) {
AccessibilityZoomProxy::GetInstance().Register(display->GetId()); AccessibilityZoomProxy::GetInstance().Register(displayReg->GetId());
} }
} else { } else {
for (sptr<Rosen::Display> display : displays) { for (sptr<Rosen::Display> displayUnreg : displays) {
AccessibilityZoomProxy::GetInstance().Unregister(display->GetId()); AccessibilityZoomProxy::GetInstance().Unregister(displayUnreg->GetId());
} }
} }
} }

View File

@ -320,15 +320,12 @@ void AccessibleAbilityManagerService::UpdateInputFilter()
} }
HILOG_DEBUG("InputFilter flag is %{public}d", flag); HILOG_DEBUG("InputFilter flag is %{public}d", flag);
if (flag) { inputInterceptor_ = AccessibilityInputInterceptor::GetInstance();
inputInterceptor_ = AccessibilityInputInterceptor::GetInstance(); if (!inputInterceptor_) {
inputInterceptor_->SetAvailableFunctions(flag); HILOG_ERROR("inputInterceptor_ is null.");
} else if (inputInterceptor_ != nullptr) { return;
HILOG_DEBUG("Has InputInterceptor before.");
inputInterceptor_->SetAvailableFunctions(0);
} else {
HILOG_DEBUG("InputInterceptor is null.");
} }
inputInterceptor_->SetAvailableFunctions(flag);
} }
void AccessibleAbilityManagerService::UpdateMagnification() void AccessibleAbilityManagerService::UpdateMagnification()
@ -344,12 +341,12 @@ void AccessibleAbilityManagerService::UpdateMagnification()
std::vector<sptr<Rosen::Display>> displays = AccessibilityDisplayManager::GetInstance().GetDisplays(); std::vector<sptr<Rosen::Display>> displays = AccessibilityDisplayManager::GetInstance().GetDisplays();
if (accountData->GetScreenMagnificationFlag()) { if (accountData->GetScreenMagnificationFlag()) {
for (sptr<Rosen::Display> display : displays) { for (sptr<Rosen::Display> displayReg : displays) {
AccessibilityZoomProxy::GetInstance().Register(display->GetId()); AccessibilityZoomProxy::GetInstance().Register(displayReg->GetId());
} }
} else { } else {
for (sptr<Rosen::Display> display : displays) { for (sptr<Rosen::Display> displayUnreg : displays) {
AccessibilityZoomProxy::GetInstance().Unregister(display->GetId()); AccessibilityZoomProxy::GetInstance().Unregister(displayUnreg->GetId());
} }
} }
} }

View File

@ -299,7 +299,7 @@ const std::string CommonEventSupport::COMMON_EVENT_HWID_LOGOUT = "common.event.H
const std::string CommonEventSupport::COMMON_EVENT_HWID_TOKEN_INVALID = "common.event.HWID_TOKEN_INVALID"; const std::string CommonEventSupport::COMMON_EVENT_HWID_TOKEN_INVALID = "common.event.HWID_TOKEN_INVALID";
/** /**
* Indicate the action of a common event about a logoff of a account ID. * Indicate the action of a common event about a logoff of an account ID.
* This is a protected common event, which can be sent only by the system. * This is a protected common event, which can be sent only by the system.
*/ */
const std::string CommonEventSupport::COMMON_EVENT_HWID_LOGOFF = "common.event.HWID_LOGOFF"; const std::string CommonEventSupport::COMMON_EVENT_HWID_LOGOFF = "common.event.HWID_LOGOFF";

View File

@ -39,7 +39,7 @@ void AccessibleAbilityListenerTest::OnAbilityConnected()
void AccessibleAbilityListenerTest::OnAccessibilityEvent(const AccessibilityEventInfo& eventInfo) void AccessibleAbilityListenerTest::OnAccessibilityEvent(const AccessibilityEventInfo& eventInfo)
{ {
HILOG_INFO("##############AamsStAbilityB1: An Accessibility event is received and eventType is %{public}d", HILOG_INFO("##############AamsStAbilityB1: An Accessibility event is received and eventType is %{public}u",
eventInfo.GetEventType()); eventInfo.GetEventType());
std::optional<AccessibilityElementInfo> elementInfo; std::optional<AccessibilityElementInfo> elementInfo;
Accessibility::AccessibleAbility::GetInstance().GetRootElementInfo(elementInfo); Accessibility::AccessibleAbility::GetInstance().GetRootElementInfo(elementInfo);