回退 'Pull Request !425 : 无障碍添加ErrorCode'

This commit is contained in:
openharmony_ci
2022-10-18 09:49:19 +00:00
committed by Gitee
parent 5841ac57bf
commit 9f2e9ebfd5
85 changed files with 2285 additions and 3140 deletions
@@ -44,9 +44,9 @@ public:
* PREFETCH_SIBLINGS: Need to make the sister/brothers element info also.
* PREFETCH_CHILDREN: Need to make the child element info also.
* otherwise: Make the element information by elementId only.
* @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if search elementInfo successfully, else return false.
*/
virtual RetError SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
virtual bool SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
const int32_t elementId, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback,
const int32_t mode) override;
@@ -58,9 +58,9 @@ public:
* @param text Filter for the child components to matched with the text
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
* @param callback To transfer the element info to ASAC and it defined by ASAC.
* @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if search elementInfo successfully, else return false.
*/
virtual RetError SearchElementInfosByText(const int32_t accessibilityWindowId, const int32_t elementId,
virtual bool SearchElementInfosByText(const int32_t accessibilityWindowId, const int32_t elementId,
const std::string &text, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback) override;
@@ -73,9 +73,9 @@ public:
* FOCUS_TYPE_INPUT: text input focus
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
* @param callback To transfer the element info to ASAC and it defined by ASAC.
* @return Return RET_OK if find elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if find elementInfo successfully, else return false.
*/
virtual RetError FindFocusedElementInfo(const int32_t accessibilityWindowId, const int32_t elementId,
virtual bool FindFocusedElementInfo(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t focusType, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback) override;
@@ -86,9 +86,9 @@ public:
* @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
* @param callback To transfer the element info to ASAC and it defined by ASAC.
* @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if search elementInfo successfully, else return false.
*/
virtual RetError FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
virtual bool FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t direction, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback) override;
@@ -100,9 +100,9 @@ public:
* @param actionArguments The parameter for action type.
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
* @param callback To transfer the node info to ASAC and it defined by ASAC.
* @return Return RET_OK if perform action successfully, otherwise refer to the RetError for the failure.
* @return Return true if perform action successfully, else return false.
*/
virtual RetError ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t action,
virtual bool ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t action,
const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback) override;
@@ -110,24 +110,24 @@ public:
* @brief Get the window information related with the event
* @param windowId The window id.
* @param windowInfo The window information.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
virtual bool GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
virtual bool GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param displayId the id of display
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindowsByDisplayId(const uint64_t displayId,
virtual bool GetWindowsByDisplayId(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows) override;
/**
@@ -140,16 +140,16 @@ public:
/**
* @brief Send simulation gesture through the proxy object.
* @param gesturePath The gesture path to send.
* @return Return RET_OK if gesture injection is successfully, otherwise refer to the RetError for the failure.
* @return Return true if gesture injection is successfully, otherwise return false.
*/
virtual RetError SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
virtual bool SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
/**
* @brief Set target bundle names.
* @param targetBundleNames The target bundle name
* @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure.
* @return Return true if sets target bundle names successfully, else return false.
*/
virtual RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
virtual bool SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
private:
/**
@@ -40,9 +40,9 @@ public:
/**
* @brief Sends information about an accessibility event.
* @param uiEvent Indicates the accessibility event information specified by AccessibilityEventInfo.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: send ok; otherwise is refused.
*/
virtual RetError SendEvent(const AccessibilityEventInfo &uiEvent) override;
virtual void SendEvent(const AccessibilityEventInfo &uiEvent) override;
/**
* @brief Register the state observer of AAMS.
@@ -64,26 +64,25 @@ public:
* 2 indicates that the ability is disabled;
* 3 indicates that the ability has been installed.
* @param infos accessibility ability infos by specified types.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return Return true if get ability lists successfully, else return false.
*/
virtual RetError GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
virtual bool GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
std::vector<AccessibilityAbilityInfo> &infos) override;
/**
* @brief Register the element operator, so the AA can get node info from ACE.
* @param windowId Window ID
* @param operation The callback object.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return 0: Succeed ; otherwise is failed.
*/
virtual RetError RegisterElementOperator(const int32_t windowId,
virtual void RegisterElementOperator(const int32_t windowId,
const sptr<IAccessibilityElementOperator> &operation) override;
/**
* @brief Deregister the element operator.
* @param windowId Window ID
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
virtual RetError DeregisterElementOperator(const int32_t windowId) override;
virtual void DeregisterElementOperator(const int32_t windowId) override;
virtual RetError GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption) override;
virtual RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption) override;
@@ -95,13 +94,14 @@ public:
virtual bool GetGestureState() override;
virtual bool GetKeyEventObserverState() override;
virtual RetError EnableAbility(const std::string &name, const uint32_t capabilities) override;
virtual RetError GetEnabledAbilities(std::vector<std::string> &enabledAbilities) override;
virtual RetError DisableAbility(const std::string &name) override;
virtual bool EnableAbility(const std::string &name, const uint32_t capabilities) override;
virtual bool GetEnabledAbilities(std::vector<std::string> &enabledAbilities) override;
virtual bool DisableAbility(const std::string &name) override;
virtual int32_t GetActiveWindow() override;
virtual RetError EnableUITestAbility(const sptr<IRemoteObject> &obj) override;
virtual RetError DisableUITestAbility() override;
virtual bool DisableUITestAbility() override;
virtual RetError SetScreenMagnificationState(const bool state) override;
virtual RetError SetShortKeyState(const bool state) override;
@@ -107,6 +107,7 @@ private:
ErrCode HandleEnableAbility(MessageParcel &data, MessageParcel &reply);
ErrCode HandleGetEnabledAbilities(MessageParcel &data, MessageParcel &reply);
ErrCode HandleDisableAbility(MessageParcel &data, MessageParcel &reply);
ErrCode HandleEnableUITestAbility(MessageParcel &data, MessageParcel &reply);
ErrCode HandleDisableUITestAbility(MessageParcel &data, MessageParcel &reply);
@@ -41,9 +41,9 @@ public:
* PREFETCH_SIBLINGS: Need to make the sister/brothers element info also.
* PREFETCH_CHILDREN: Need to make the child element info also.
* otherwise: Make the element information by elementId only.
* @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if search elementInfo successfully, else return false.
*/
virtual RetError SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
virtual bool SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
const int32_t elementId, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback,
const int32_t mode) = 0;
@@ -55,9 +55,9 @@ public:
* @param text Filter for the child components to matched with the text
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
* @param callback To transfer the element info to ASAC and it defined by ASAC.
* @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if search elementInfo successfully, else return false.
*/
virtual RetError SearchElementInfosByText(const int32_t accessibilityWindowId, const int32_t elementId,
virtual bool SearchElementInfosByText(const int32_t accessibilityWindowId, const int32_t elementId,
const std::string &text, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback) = 0;
@@ -69,9 +69,9 @@ public:
* FOCUS_TYPE_INPUT: text input focus
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
* @param callback To transfer the element info to ASAC and it defined by ASAC.
* @return Return RET_OK if find elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if find elementInfo successfully, else return false.
*/
virtual RetError FindFocusedElementInfo(const int32_t accessibilityWindowId, const int32_t elementId,
virtual bool FindFocusedElementInfo(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t focusType, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback) = 0;
@@ -82,9 +82,9 @@ public:
* @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
* @param callback To transfer the element info to ASAC and it defined by ASAC.
* @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if search elementInfo successfully, else return false.
*/
virtual RetError FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
virtual bool FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t direction, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback) = 0;
@@ -96,9 +96,9 @@ public:
* @param actionArguments The parameter for action type.
* @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
* @param callback To transfer the node info to ASAC and it defined by ASAC.
* @return Return RET_OK if perform action successfully, otherwise refer to the RetError for the failure.
* @return Return true if perform action successfully, else return false.
*/
virtual RetError ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t action,
virtual bool ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t action,
const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback) = 0;
@@ -106,24 +106,24 @@ public:
* @brief Get the window information related with the event
* @param windowId The window id.
* @param windowInfo The window information.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) = 0;
virtual bool GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) = 0;
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows) = 0;
virtual bool GetWindows(std::vector<AccessibilityWindowInfo> &windows) = 0;
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param displayId the id of display
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindowsByDisplayId(const uint64_t displayId,
virtual bool GetWindowsByDisplayId(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows) = 0;
/**
@@ -136,16 +136,16 @@ public:
/**
* @brief Send simulation gesture.
* @param gesturePath The gesture path to send.
* @return Return RET_OK if gesture injection is successfully, otherwise refer to the RetError for the failure.
* @return Return true if gesture injection is successfully, otherwise return false.
*/
virtual RetError SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) = 0;
virtual bool SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) = 0;
/**
* @brief Set target bundle names.
* @param targetBundleNames The target bundle name
* @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure.
* @return Return true if sets target bundle names successfully, else return false.
*/
virtual RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) = 0;
virtual bool SetTargetBundleName(const std::vector<std::string> &targetBundleNames) = 0;
enum class Message {
SEARCH_ELEMENTINFO_BY_ACCESSIBILITY_ID = 0,
@@ -58,9 +58,9 @@ public:
/**
* @brief Sends information about an accessibility event.
* @param uiEvent Indicates the accessibility event information specified by AccessibilityEventInfo.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: send ok; otherwise is refused.
*/
virtual RetError SendEvent(const AccessibilityEventInfo &uiEvent) = 0;
virtual void SendEvent(const AccessibilityEventInfo &uiEvent) = 0;
/**
* @brief Register the state observer of AAMS.
@@ -82,26 +82,25 @@ public:
* 2 indicates that the ability is disabled;
* 3 indicates that the ability has been installed.
* @param infos accessibility ability infos by specified types.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return Return true if get ability lists successfully, else return false.
*/
virtual RetError GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
virtual bool GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
std::vector<AccessibilityAbilityInfo> &infos) = 0;
/**
* @brief Register the element operator, so the AA can get node info from ACE.
* @param windowId Window ID
* @param operation The callback object.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return 0: Succeed ; otherwise is failed.
*/
virtual RetError RegisterElementOperator(const int32_t windowId,
const sptr<IAccessibilityElementOperator> &operation) = 0;
virtual void RegisterElementOperator(
const int32_t windowId, const sptr<IAccessibilityElementOperator> &operation) = 0;
/**
* @brief Deregister the element operator.
* @param windowId Window ID
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
virtual RetError DeregisterElementOperator(const int32_t windowId) = 0;
virtual void DeregisterElementOperator(const int32_t windowId) = 0;
virtual RetError GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption) = 0;
virtual bool GetEnabledState() = 0;
@@ -113,13 +112,14 @@ public:
virtual RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption) = 0;
virtual RetError SetCaptionState(const bool state) = 0;
virtual RetError EnableAbility(const std::string &name, const uint32_t capabilities) = 0;
virtual RetError GetEnabledAbilities(std::vector<std::string> &enabledAbilities) = 0;
virtual RetError DisableAbility(const std::string &name) = 0;
virtual bool EnableAbility(const std::string &name, const uint32_t capabilities) = 0;
virtual bool GetEnabledAbilities(std::vector<std::string> &enabledAbilities) = 0;
virtual bool DisableAbility(const std::string &name) = 0;
virtual int32_t GetActiveWindow() = 0;
virtual RetError EnableUITestAbility(const sptr<IRemoteObject> &obj) = 0;
virtual RetError DisableUITestAbility() = 0;
virtual bool DisableUITestAbility() = 0;
virtual RetError SetScreenMagnificationState(const bool state) = 0;
virtual RetError SetShortKeyState(const bool state) = 0;
@@ -58,189 +58,188 @@ bool AccessibleAbilityChannelProxy::SendTransactCmd(IAccessibleAbilityChannel::M
return true;
}
RetError AccessibleAbilityChannelProxy::SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannelProxy::SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
const int32_t elementId, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback,
const int32_t mode)
{
HILOG_DEBUG();
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return RET_ERR_INVALID_PARAM;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!WriteInterfaceToken(data)) {
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(accessibilityWindowId)) {
HILOG_ERROR("accessibilityWindowId write error: %{public}d, ", accessibilityWindowId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(elementId)) {
HILOG_ERROR("elementId write error: %{public}d, ", elementId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(requestId)) {
HILOG_ERROR("requestId write error: %{public}d, ", requestId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return false;
}
if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("callback write error");
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(mode)) {
HILOG_ERROR("mode write error: %{public}d, ", mode);
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SEARCH_ELEMENTINFO_BY_ACCESSIBILITY_ID,
data, reply, option)) {
HILOG_ERROR("fail to find elementInfo by elementId");
return RET_ERR_IPC_FAILED;
return false;
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
RetError AccessibleAbilityChannelProxy::SearchElementInfosByText(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannelProxy::SearchElementInfosByText(const int32_t accessibilityWindowId,
const int32_t elementId, const std::string &text, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback)
{
HILOG_DEBUG();
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return RET_ERR_INVALID_PARAM;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!WriteInterfaceToken(data)) {
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(accessibilityWindowId)) {
HILOG_ERROR("accessibilityWindowId write error: %{public}d, ", accessibilityWindowId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(elementId)) {
HILOG_ERROR("elementId write error: %{public}d, ", elementId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteString(text)) {
HILOG_ERROR("text write error: %{public}s, ", text.c_str());
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(requestId)) {
HILOG_ERROR("requestId write error: %{public}d, ", requestId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return false;
}
if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("callback write error");
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SEARCH_ELEMENTINFOS_BY_TEXT,
data, reply, option)) {
HILOG_ERROR("fail to find elementInfo by text");
return RET_ERR_IPC_FAILED;
return false;
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
RetError AccessibleAbilityChannelProxy::FindFocusedElementInfo(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannelProxy::FindFocusedElementInfo(const int32_t accessibilityWindowId,
const int32_t elementId, const int32_t focusType, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback)
{
HILOG_DEBUG();
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return RET_ERR_INVALID_PARAM;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!WriteInterfaceToken(data)) {
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(accessibilityWindowId)) {
HILOG_ERROR("accessibilityWindowId write error: %{public}d, ", accessibilityWindowId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(elementId)) {
HILOG_ERROR("elementId write error: %{public}d, ", elementId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(focusType)) {
HILOG_ERROR("focusType write error: %{public}d, ", focusType);
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(requestId)) {
HILOG_ERROR("requestId write error: %{public}d, ", requestId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return false;
}
if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("callback write error");
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::FIND_FOCUSED_ELEMENTINFO, data, reply, option)) {
HILOG_ERROR("fail to gain focus");
return RET_ERR_IPC_FAILED;
return false;
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
RetError AccessibleAbilityChannelProxy::FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
bool AccessibleAbilityChannelProxy::FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t direction, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
{
HILOG_DEBUG();
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return RET_ERR_INVALID_PARAM;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!WriteInterfaceToken(data)) {
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(accessibilityWindowId)) {
HILOG_ERROR("accessibilityWindowId write error: %{public}d, ", accessibilityWindowId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(elementId)) {
HILOG_ERROR("elementId write error: %{public}d, ", elementId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(direction)) {
HILOG_ERROR("direction write error: %{public}d, ", direction);
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(requestId)) {
HILOG_ERROR("requestId write error: %{public}d, ", requestId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!callback) {
HILOG_ERROR("callback is nullptr.");
return false;
}
if (!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("callback write error");
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::FOCUS_MOVE_SEARCH, data, reply, option)) {
HILOG_ERROR("fail to search focus");
return RET_ERR_IPC_FAILED;
return false;
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
RetError AccessibleAbilityChannelProxy::ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId,
bool AccessibleAbilityChannelProxy::ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t action, const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback)
{
@@ -251,19 +250,19 @@ RetError AccessibleAbilityChannelProxy::ExecuteAction(const int32_t accessibilit
MessageOption option;
if (!WriteInterfaceToken(data)) {
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(accessibilityWindowId)) {
HILOG_ERROR("accessibilityWindowId write error: %{public}d, ", accessibilityWindowId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(elementId)) {
HILOG_ERROR("elementId write error: %{public}d, ", elementId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(action)) {
HILOG_ERROR("action write error: %{public}d, ", action);
return RET_ERR_IPC_FAILED;
return false;
}
std::vector<std::string> actionArgumentsKey {};
@@ -274,31 +273,31 @@ RetError AccessibleAbilityChannelProxy::ExecuteAction(const int32_t accessibilit
}
if (!data.WriteStringVector(actionArgumentsKey)) {
HILOG_ERROR("actionArgumentsKey write error");
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteStringVector(actionArgumentsValue)) {
HILOG_ERROR("actionArgumentsValue write error");
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(requestId)) {
HILOG_ERROR("requestId write error: %{public}d, ", requestId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!callback || !data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("callback write error");
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::PERFORM_ACTION,
data, reply, option)) {
HILOG_ERROR("fail to perform accessibility action");
return RET_ERR_IPC_FAILED;
return false;
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
RetError AccessibleAbilityChannelProxy::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
bool AccessibleAbilityChannelProxy::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
{
HILOG_DEBUG();
@@ -307,30 +306,30 @@ RetError AccessibleAbilityChannelProxy::GetWindow(const int32_t windowId, Access
MessageOption option;
if (!WriteInterfaceToken(data)) {
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(windowId)) {
HILOG_ERROR("windowId write error: %{public}d, ", windowId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::GET_WINDOW, data, reply, option)) {
HILOG_ERROR("fail to get window");
return RET_ERR_IPC_FAILED;
return false;
}
sptr<AccessibilityWindowInfoParcel> windowInfoParcel = reply.ReadStrongParcelable<AccessibilityWindowInfoParcel>();
if (!windowInfoParcel) {
HILOG_ERROR("ReadStrongParcelable<AccessibilityWindowInfoParcel> failed");
return RET_ERR_IPC_FAILED;
return false;
}
windowInfo = *windowInfoParcel;
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
RetError AccessibleAbilityChannelProxy::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
bool AccessibleAbilityChannelProxy::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_DEBUG();
MessageParcel data;
@@ -338,12 +337,12 @@ RetError AccessibleAbilityChannelProxy::GetWindows(std::vector<AccessibilityWind
MessageOption option;
if (!WriteInterfaceToken(data)) {
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::GET_WINDOWS, data, reply, option)) {
HILOG_ERROR("fail to get windows");
return RET_ERR_IPC_FAILED;
return false;
}
int32_t windowsSize = reply.ReadInt32();
@@ -351,15 +350,15 @@ RetError AccessibleAbilityChannelProxy::GetWindows(std::vector<AccessibilityWind
sptr<AccessibilityWindowInfoParcel> window = reply.ReadStrongParcelable<AccessibilityWindowInfoParcel>();
if (!window) {
HILOG_ERROR("ReadStrongParcelable<AccessibilityWindowInfoParcel> failed");
return RET_ERR_IPC_FAILED;
return false;
}
windows.emplace_back(*window);
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
RetError AccessibleAbilityChannelProxy::GetWindowsByDisplayId(const uint64_t displayId,
bool AccessibleAbilityChannelProxy::GetWindowsByDisplayId(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_DEBUG();
@@ -369,17 +368,17 @@ RetError AccessibleAbilityChannelProxy::GetWindowsByDisplayId(const uint64_t dis
MessageOption option;
if (!WriteInterfaceToken(data)) {
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteUint64(displayId)) {
HILOG_ERROR("displayId write error: %{public}" PRIu64 ", ", displayId);
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::GET_WINDOWS_BY_DISPLAY_ID, data, reply, option)) {
HILOG_ERROR("fail to get windows");
return RET_ERR_IPC_FAILED;
return false;
}
int32_t windowsSize = reply.ReadInt32();
@@ -387,12 +386,12 @@ RetError AccessibleAbilityChannelProxy::GetWindowsByDisplayId(const uint64_t dis
sptr<AccessibilityWindowInfoParcel> window = reply.ReadStrongParcelable<AccessibilityWindowInfoParcel>();
if (!window) {
HILOG_ERROR("ReadStrongParcelable<AccessibilityWindowInfoParcel> failed");
return RET_ERR_IPC_FAILED;
return false;
}
windows.emplace_back(*window);
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
void AccessibleAbilityChannelProxy::SetOnKeyPressEventResult(const bool handled, const int32_t sequence)
@@ -420,7 +419,7 @@ void AccessibleAbilityChannelProxy::SetOnKeyPressEventResult(const bool handled,
}
}
RetError AccessibleAbilityChannelProxy::SendSimulateGesture(
bool AccessibleAbilityChannelProxy::SendSimulateGesture(
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
{
HILOG_DEBUG();
@@ -428,7 +427,7 @@ RetError AccessibleAbilityChannelProxy::SendSimulateGesture(
new(std::nothrow) AccessibilityGestureInjectPathParcel(*gesturePath);
if (!path) {
HILOG_ERROR("Failed to create path.");
return RET_ERR_NULLPTR;
return false;
}
MessageParcel data;
@@ -436,22 +435,22 @@ RetError AccessibleAbilityChannelProxy::SendSimulateGesture(
MessageOption option(MessageOption::TF_SYNC);
if (!WriteInterfaceToken(data)) {
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteStrongParcelable(path)) {
HILOG_ERROR("WriteStrongParcelable<AccessibilityGestureInjectPathParcel> failed");
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SEND_SIMULATE_GESTURE_PATH, data, reply, option)) {
HILOG_ERROR("fail to send simulation gesture path");
return RET_ERR_IPC_FAILED;
return false;
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
RetError AccessibleAbilityChannelProxy::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
bool AccessibleAbilityChannelProxy::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
{
HILOG_DEBUG();
@@ -460,23 +459,23 @@ RetError AccessibleAbilityChannelProxy::SetTargetBundleName(const std::vector<st
MessageOption option(MessageOption::TF_SYNC);
if (!WriteInterfaceToken(data)) {
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(targetBundleNames.size())) {
HILOG_ERROR("targetBundleNames.size() write error: %{public}zu, ", targetBundleNames.size());
return RET_ERR_IPC_FAILED;
return false;
}
for (auto &targetBundleName : targetBundleNames) {
if (!data.WriteString(targetBundleName)) {
HILOG_ERROR("targetBundleName write error: %{public}s, ", targetBundleName.c_str());
return RET_ERR_IPC_FAILED;
return false;
}
}
if (!SendTransactCmd(IAccessibleAbilityChannel::Message::SET_TARGET_BUNDLE_NAME, data, reply, option)) {
HILOG_ERROR("fail to set target bundle name filter");
return RET_ERR_IPC_FAILED;
return false;
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
} // namespace Accessibility
} // namespace OHOS
@@ -99,9 +99,9 @@ ErrCode AccessibleAbilityChannelStub::HandleSearchElementInfoByAccessibilityId(M
}
int32_t mode = data.ReadInt32();
RetError result = SearchElementInfoByAccessibilityId(accessibilityWindowId, elementId, requestId, callback, mode);
bool result = SearchElementInfoByAccessibilityId(accessibilityWindowId, elementId, requestId, callback, mode);
HILOG_DEBUG("SearchElementInfoByAccessibilityId ret = %{public}d", result);
reply.WriteInt32(result);
reply.WriteBool(result);
return NO_ERROR;
}
@@ -120,9 +120,9 @@ ErrCode AccessibleAbilityChannelStub::HandleSearchElementInfosByText(MessageParc
sptr<IAccessibilityElementOperatorCallback> callback =
iface_cast<IAccessibilityElementOperatorCallback>(remote);
RetError result = SearchElementInfosByText(accessibilityWindowId, elementId, text, requestId, callback);
bool result = SearchElementInfosByText(accessibilityWindowId, elementId, text, requestId, callback);
HILOG_DEBUG("SearchElementInfosByText ret = %{public}d", result);
reply.WriteInt32(result);
reply.WriteBool(result);
return NO_ERROR;
}
@@ -140,9 +140,9 @@ ErrCode AccessibleAbilityChannelStub::HandleFindFocusedElementInfo(MessageParcel
sptr<IAccessibilityElementOperatorCallback> callback =
iface_cast<IAccessibilityElementOperatorCallback>(remote);
RetError result = FindFocusedElementInfo(accessibilityWindowId, elementId, focusType, requestId, callback);
bool result = FindFocusedElementInfo(accessibilityWindowId, elementId, focusType, requestId, callback);
HILOG_DEBUG("FindFocusedElementInfo ret = %{public}d", result);
reply.WriteInt32(result);
reply.WriteBool(result);
return NO_ERROR;
}
@@ -160,9 +160,9 @@ ErrCode AccessibleAbilityChannelStub::HandleFocusMoveSearch(MessageParcel &data,
sptr<IAccessibilityElementOperatorCallback> callback =
iface_cast<IAccessibilityElementOperatorCallback>(remote);
RetError result = FocusMoveSearch(accessibilityWindowId, elementId, direction, requestId, callback);
bool result = FocusMoveSearch(accessibilityWindowId, elementId, direction, requestId, callback);
HILOG_DEBUG("FocusMoveSearch ret = %{public}d", result);
reply.WriteInt32(result);
reply.WriteBool(result);
return NO_ERROR;
}
@@ -203,9 +203,9 @@ ErrCode AccessibleAbilityChannelStub::HandleExecuteAction(MessageParcel &data, M
return ERR_INVALID_VALUE;
}
RetError result = ExecuteAction(accessibilityWindowId, elementId, action, actionArguments, requestId, callback);
bool result = ExecuteAction(accessibilityWindowId, elementId, action, actionArguments, requestId, callback);
HILOG_DEBUG("ExecuteAction ret = %{public}d", result);
reply.WriteInt32(result);
reply.WriteBool(result);
return NO_ERROR;
}
@@ -220,13 +220,13 @@ ErrCode AccessibleAbilityChannelStub::HandleGetWindow(MessageParcel &data, Messa
return ERR_NULL_OBJECT;
}
RetError result = GetWindow(windowId, *windowInfoParcel);
bool result = GetWindow(windowId, *windowInfoParcel);
if (!reply.WriteStrongParcelable(windowInfoParcel)) {
HILOG_ERROR("WriteStrongParcelable windows failed");
return ERR_INVALID_VALUE;
}
reply.WriteInt32(result);
reply.WriteBool(result);
return NO_ERROR;
}
@@ -234,7 +234,7 @@ ErrCode AccessibleAbilityChannelStub::HandleGetWindows(MessageParcel &data, Mess
{
HILOG_DEBUG();
std::vector<AccessibilityWindowInfo> windows;
RetError result = GetWindows(windows);
bool result = GetWindows(windows);
if (!reply.WriteInt32(static_cast<int32_t>(windows.size()))) {
HILOG_ERROR("windows.size() write error: %{public}zu, ", windows.size());
return ERR_INVALID_VALUE;
@@ -250,7 +250,7 @@ ErrCode AccessibleAbilityChannelStub::HandleGetWindows(MessageParcel &data, Mess
return ERR_INVALID_VALUE;
}
}
reply.WriteInt32(result);
reply.WriteBool(result);
return NO_ERROR;
}
@@ -260,7 +260,7 @@ ErrCode AccessibleAbilityChannelStub::HandleGetWindowsByDisplayId(MessageParcel
uint64_t displayId = data.ReadUint64();
std::vector<AccessibilityWindowInfo> windows;
RetError result = GetWindowsByDisplayId(displayId, windows);
bool result = GetWindowsByDisplayId(displayId, windows);
if (!reply.WriteInt32(static_cast<int32_t>(windows.size()))) {
HILOG_ERROR("windows.size() write error: %{public}zu, ", windows.size());
return ERR_INVALID_VALUE;
@@ -276,7 +276,7 @@ ErrCode AccessibleAbilityChannelStub::HandleGetWindowsByDisplayId(MessageParcel
return ERR_INVALID_VALUE;
}
}
reply.WriteInt32(result);
reply.WriteBool(result);
return NO_ERROR;
}
@@ -304,8 +304,8 @@ ErrCode AccessibleAbilityChannelStub::HandleSendSimulateGesturePath(MessageParce
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath =
std::make_shared<AccessibilityGestureInjectPath>(*positions);
RetError result = SendSimulateGesture(gesturePath);
reply.WriteInt32(result);
bool result = SendSimulateGesture(gesturePath);
reply.WriteBool(result);
return NO_ERROR;
}
@@ -318,8 +318,8 @@ ErrCode AccessibleAbilityChannelStub::HandleSetTargetBundleName(MessageParcel &d
std::string temp = data.ReadString();
targetBundleNames.emplace_back(temp);
}
RetError result = SetTargetBundleName(targetBundleNames);
reply.WriteInt32(result);
bool result = SetTargetBundleName(targetBundleNames);
reply.WriteBool(result);
return NO_ERROR;
}
} // namespace Accessibility
@@ -56,7 +56,7 @@ bool AccessibleAbilityManagerServiceProxy::SendTransactCmd(IAccessibleAbilityMan
return true;
}
RetError AccessibleAbilityManagerServiceProxy::SendEvent(const AccessibilityEventInfo &uiEvent)
void AccessibleAbilityManagerServiceProxy::SendEvent(const AccessibilityEventInfo &uiEvent)
{
HILOG_DEBUG();
MessageParcel data;
@@ -66,19 +66,18 @@ RetError AccessibleAbilityManagerServiceProxy::SendEvent(const AccessibilityEven
if (!WriteInterfaceToken(data)) {
HILOG_ERROR("fail, connection write Token");
return RET_ERR_IPC_FAILED;
return;
}
if (!data.WriteParcelable(&eventInfoParcel)) {
HILOG_ERROR("fail, connection write parcelable AccessibilityEventInfo error");
return RET_ERR_IPC_FAILED;
return;
}
if (!SendTransactCmd(IAccessibleAbilityManagerService::Message::SEND_EVENT, data, reply, option)) {
HILOG_ERROR("SendEvent fail");
return RET_ERR_IPC_FAILED;
return;
}
return RET_OK;
}
RetError AccessibleAbilityManagerServiceProxy::SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption)
@@ -162,7 +161,7 @@ uint32_t AccessibleAbilityManagerServiceProxy::RegisterStateObserver(
return reply.ReadUint32();
}
RetError AccessibleAbilityManagerServiceProxy::GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
bool AccessibleAbilityManagerServiceProxy::GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
std::vector<AccessibilityAbilityInfo> &infos)
{
HILOG_DEBUG();
@@ -172,23 +171,23 @@ RetError AccessibleAbilityManagerServiceProxy::GetAbilityList(const uint32_t abi
if (!WriteInterfaceToken(data)) {
HILOG_ERROR("fail, connection write Token error");
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteUint32(abilityTypes)) {
HILOG_ERROR("fail, connection write abilityTypes error");
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteInt32(stateType)) {
HILOG_ERROR("fail, connection write stateType error");
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityManagerService::Message::GET_ABILITYLIST,
data, reply, option)) {
HILOG_ERROR("GetAbilityList fail");
return RET_ERR_IPC_FAILED;
return false;
}
// read result
int32_t abilityInfoSize = reply.ReadInt32();
@@ -196,14 +195,14 @@ RetError AccessibleAbilityManagerServiceProxy::GetAbilityList(const uint32_t abi
sptr<AccessibilityAbilityInfoParcel> info = reply.ReadStrongParcelable<AccessibilityAbilityInfoParcel>();
if (!info) {
HILOG_ERROR("ReadStrongParcelable<AccessibilityAbilityInfoParcel> failed");
return RET_ERR_IPC_FAILED;
return false;
}
infos.emplace_back(*info);
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
RetError AccessibleAbilityManagerServiceProxy::RegisterElementOperator(
void AccessibleAbilityManagerServiceProxy::RegisterElementOperator(
int32_t windowId, const sptr<IAccessibilityElementOperator> &operation)
{
HILOG_DEBUG();
@@ -213,33 +212,32 @@ RetError AccessibleAbilityManagerServiceProxy::RegisterElementOperator(
if (!operation) {
HILOG_ERROR("fail, Input operation is null");
return RET_ERR_INVALID_PARAM;
return;
}
if (!WriteInterfaceToken(data)) {
HILOG_ERROR("fail, connection write Token");
return RET_ERR_IPC_FAILED;
return;
}
if (!data.WriteInt32(windowId)) {
HILOG_ERROR("fail, connection write windowId error");
return RET_ERR_IPC_FAILED;
return;
}
if (!data.WriteRemoteObject(operation->AsObject())) {
HILOG_ERROR("fail, connection write parcelable operation error");
return RET_ERR_IPC_FAILED;
return;
}
if (!SendTransactCmd(IAccessibleAbilityManagerService::Message::REGISTER_INTERACTION_CONNECTION,
data, reply, option)) {
HILOG_ERROR("RegisterElementOperator fail");
return RET_ERR_IPC_FAILED;
return;
}
return RET_OK;
}
RetError AccessibleAbilityManagerServiceProxy::DeregisterElementOperator(const int32_t windowId)
void AccessibleAbilityManagerServiceProxy::DeregisterElementOperator(const int32_t windowId)
{
HILOG_DEBUG("windowId(%{public}d)", windowId);
MessageParcel data;
@@ -248,20 +246,19 @@ RetError AccessibleAbilityManagerServiceProxy::DeregisterElementOperator(const i
if (!WriteInterfaceToken(data)) {
HILOG_ERROR("fail, connection write Token");
return RET_ERR_IPC_FAILED;
return;
}
if (!data.WriteInt32(windowId)) {
HILOG_ERROR("fail, connection write userId error");
return RET_ERR_IPC_FAILED;
return;
}
if (!SendTransactCmd(IAccessibleAbilityManagerService::Message::DEREGISTER_INTERACTION_CONNECTION,
data, reply, option)) {
HILOG_ERROR("DeregisterElementOperator fail");
return RET_ERR_IPC_FAILED;
return;
}
return RET_OK;
}
RetError AccessibleAbilityManagerServiceProxy::GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption)
@@ -419,7 +416,7 @@ bool AccessibleAbilityManagerServiceProxy::GetKeyEventObserverState()
return reply.ReadBool();
}
RetError AccessibleAbilityManagerServiceProxy::EnableAbility(const std::string &name, const uint32_t capabilities)
bool AccessibleAbilityManagerServiceProxy::EnableAbility(const std::string &name, const uint32_t capabilities)
{
HILOG_DEBUG();
MessageParcel data;
@@ -428,28 +425,28 @@ RetError AccessibleAbilityManagerServiceProxy::EnableAbility(const std::string &
if (!WriteInterfaceToken(data)) {
HILOG_ERROR("fail, connection write Token");
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteString(name)) {
HILOG_ERROR("name write error: %{public}s, ", name.c_str());
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteUint32(capabilities)) {
HILOG_ERROR("capabilities write error: %{public}d, ", capabilities);
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityManagerService::Message::ENABLE_ABILITIES,
data, reply, option)) {
HILOG_ERROR("EnableAbility fail");
return RET_ERR_IPC_FAILED;
return false;
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
RetError AccessibleAbilityManagerServiceProxy::GetEnabledAbilities(std::vector<std::string> &enabledAbilities)
bool AccessibleAbilityManagerServiceProxy::GetEnabledAbilities(std::vector<std::string> &enabledAbilities)
{
HILOG_DEBUG();
MessageParcel data;
@@ -458,22 +455,22 @@ RetError AccessibleAbilityManagerServiceProxy::GetEnabledAbilities(std::vector<s
if (!WriteInterfaceToken(data)) {
HILOG_ERROR("fail, connection write Token error");
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityManagerService::Message::GET_ENABLED_OBJECT,
data, reply, option)) {
HILOG_ERROR("GetEnabledAbilities fail");
return RET_ERR_IPC_FAILED;
return false;
}
int32_t dev_num = reply.ReadInt32();
for (int32_t i = 0; i < dev_num; i++) {
enabledAbilities.push_back(reply.ReadString());
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
RetError AccessibleAbilityManagerServiceProxy::DisableAbility(const std::string &name)
bool AccessibleAbilityManagerServiceProxy::DisableAbility(const std::string &name)
{
HILOG_DEBUG();
MessageParcel data;
@@ -482,19 +479,19 @@ RetError AccessibleAbilityManagerServiceProxy::DisableAbility(const std::string
if (!WriteInterfaceToken(data)) {
HILOG_ERROR("fail, connection write Token");
return RET_ERR_IPC_FAILED;
return false;
}
if (!data.WriteString(name)) {
HILOG_ERROR("name write error: %{public}s, ", name.c_str());
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityManagerService::Message::DISABLE_ABILITIES,
data, reply, option)) {
HILOG_ERROR("DisableAbility fail");
return RET_ERR_IPC_FAILED;
return false;
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
int32_t AccessibleAbilityManagerServiceProxy::GetActiveWindow()
@@ -544,7 +541,7 @@ RetError AccessibleAbilityManagerServiceProxy::EnableUITestAbility(const sptr<IR
return result;
}
RetError AccessibleAbilityManagerServiceProxy::DisableUITestAbility()
bool AccessibleAbilityManagerServiceProxy::DisableUITestAbility()
{
HILOG_DEBUG();
MessageParcel data;
@@ -553,15 +550,15 @@ RetError AccessibleAbilityManagerServiceProxy::DisableUITestAbility()
if (!WriteInterfaceToken(data)) {
HILOG_ERROR("fail, connection write Token");
return RET_ERR_IPC_FAILED;
return false;
}
if (!SendTransactCmd(IAccessibleAbilityManagerService::Message::DISABLE_UI_TEST_ABILITY,
data, reply, option)) {
HILOG_ERROR("DisableUITestAbility fail");
return RET_ERR_IPC_FAILED;
return false;
}
return static_cast<RetError>(reply.ReadInt32());
return reply.ReadBool();
}
RetError AccessibleAbilityManagerServiceProxy::SetScreenMagnificationState(const bool state)
@@ -224,7 +224,7 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetAbilityList(MessageParcel
uint32_t abilityTypes = data.ReadUint32();
int32_t stateType = data.ReadInt32();
std::vector<AccessibilityAbilityInfo> abilityInfos {};
RetError result = GetAbilityList(abilityTypes, stateType, abilityInfos);
bool result = GetAbilityList(abilityTypes, stateType, abilityInfos);
int32_t abilityInfoSize = static_cast<int32_t>(abilityInfos.size());
reply.WriteInt32(abilityInfoSize);
@@ -239,7 +239,7 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetAbilityList(MessageParcel
return TRANSACTION_ERR;
}
}
reply.WriteInt32(static_cast<int32_t>(result));
reply.WriteBool(result);
return NO_ERROR;
}
@@ -285,15 +285,9 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetCaptionProperty(MessagePar
ErrCode AccessibleAbilityManagerServiceStub::HandleSetCaptionProperty(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_WRITE_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
sptr<CaptionPropertyParcel> caption = data.ReadStrongParcelable<CaptionPropertyParcel>();
if (!caption) {
HILOG_ERROR("ReadStrongParcelable<CaptionProperty> failed");
reply.WriteInt32(RET_ERR_IPC_FAILED);
HILOG_DEBUG("ReadStrongParcelable<CaptionProperty> failed");
return TRANSACTION_ERR;
}
reply.WriteInt32(SetCaptionProperty(*caption));
@@ -304,11 +298,6 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleSetCaptionProperty(MessagePar
ErrCode AccessibleAbilityManagerServiceStub::HandleSetCaptionState(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_WRITE_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
bool state = data.ReadBool();
reply.WriteInt32(SetCaptionState(state));
@@ -383,15 +372,10 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetKeyEventObserverState(
ErrCode AccessibleAbilityManagerServiceStub::HandleEnableAbility(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_WRITE_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
std::string name = data.ReadString();
uint32_t capabilities = data.ReadUint32();
RetError result = EnableAbility(name, capabilities);
reply.WriteInt32(result);
bool result = EnableAbility(name, capabilities);
reply.WriteBool(result);
return NO_ERROR;
}
@@ -400,7 +384,7 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetEnabledAbilities(MessagePa
HILOG_DEBUG();
std::vector<std::string> enabledAbilities;
RetError result = GetEnabledAbilities(enabledAbilities);
bool result = GetEnabledAbilities(enabledAbilities);
reply.WriteInt32(enabledAbilities.size());
for (auto &ability : enabledAbilities) {
if (!reply.WriteString(ability)) {
@@ -408,21 +392,16 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetEnabledAbilities(MessagePa
return TRANSACTION_ERR;
}
}
reply.WriteInt32(result);
reply.WriteBool(result);
return NO_ERROR;
}
ErrCode AccessibleAbilityManagerServiceStub::HandleDisableAbility(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_WRITE_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
std::string name = data.ReadString();
RetError result = DisableAbility(name);
reply.WriteInt32(result);
bool result = DisableAbility(name);
reply.WriteBool(result);
return NO_ERROR;
}
@@ -453,8 +432,8 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleDisableUITestAbility(
MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
int32_t result = DisableUITestAbility();
if (!reply.WriteInt32(result)) {
bool result = DisableUITestAbility();
if (!reply.WriteBool(result)) {
HILOG_ERROR("WriteBool failed");
return TRANSACTION_ERR;
}
@@ -663,6 +642,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetScreenMagnificationState(
MessageParcel& data, MessageParcel& reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
bool result = false;
RetError ret = GetScreenMagnificationState(result);
reply.WriteInt32(ret);
@@ -675,6 +659,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetScreenMagnificationState(
ErrCode AccessibleAbilityManagerServiceStub::HandleGetShortKeyState(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
bool result = false;
RetError ret = GetShortKeyState(result);
reply.WriteInt32(ret);
@@ -687,6 +676,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetShortKeyState(MessageParce
ErrCode AccessibleAbilityManagerServiceStub::HandleGetMouseKeyState(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
bool result = false;
RetError ret = GetMouseKeyState(result);
reply.WriteInt32(ret);
@@ -699,6 +693,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetMouseKeyState(MessageParce
ErrCode AccessibleAbilityManagerServiceStub::HandleGetShortkeyTarget(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
std::string result = "";
RetError ret = GetShortkeyTarget(result);
reply.WriteInt32(ret);
@@ -711,6 +710,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetShortkeyTarget(MessageParc
ErrCode AccessibleAbilityManagerServiceStub::HandleGetMouseAutoClick(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
int32_t result = 0;
RetError ret = GetMouseAutoClick(result);
reply.WriteInt32(ret);
@@ -723,6 +727,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetMouseAutoClick(MessageParc
ErrCode AccessibleAbilityManagerServiceStub::HandleGetInvertColorState(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
bool result = false;
RetError ret = GetInvertColorState(result);
reply.WriteInt32(ret);
@@ -735,6 +744,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetInvertColorState(MessagePa
ErrCode AccessibleAbilityManagerServiceStub::HandleGetHighContrastTextState(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
bool result = false;
RetError ret = GetHighContrastTextState(result);
reply.WriteInt32(ret);
@@ -747,6 +761,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetHighContrastTextState(Mess
ErrCode AccessibleAbilityManagerServiceStub::HandleGetAudioMonoState(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
bool result = false;
RetError ret = GetAudioMonoState(result);
reply.WriteInt32(ret);
@@ -759,6 +778,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetAudioMonoState(MessageParc
ErrCode AccessibleAbilityManagerServiceStub::HandleGetAnimationOffState(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
bool result = false;
RetError ret = GetAnimationOffState(result);
reply.WriteInt32(ret);
@@ -772,6 +796,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetDaltonizationColorFilter(
MessageParcel& data, MessageParcel& reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
uint32_t result = 0;
RetError ret = GetDaltonizationColorFilter(result);
reply.WriteInt32(ret);
@@ -784,6 +813,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetDaltonizationColorFilter(
ErrCode AccessibleAbilityManagerServiceStub::HandleGetContentTimeout(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
uint32_t result = 0;
RetError ret = GetContentTimeout(result);
reply.WriteInt32(ret);
@@ -796,6 +830,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetContentTimeout(MessageParc
ErrCode AccessibleAbilityManagerServiceStub::HandleGetBrightnessDiscount(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
float result = 0;
RetError ret = GetBrightnessDiscount(result);
reply.WriteInt32(ret);
@@ -808,6 +847,11 @@ ErrCode AccessibleAbilityManagerServiceStub::HandleGetBrightnessDiscount(Message
ErrCode AccessibleAbilityManagerServiceStub::HandleGetAudioBalance(MessageParcel &data, MessageParcel &reply)
{
HILOG_DEBUG();
if (!CheckPermission(OHOS_PERMISSION_READ_ACCESSIBILITY_CONFIG)) {
HILOG_WARN("Permission denied!");
reply.WriteInt32(RET_ERR_NO_PERMISSION);
return NO_ERROR;
}
float result = 0;
RetError ret = GetAudioBalance(result);
reply.WriteInt32(ret);
@@ -36,96 +36,94 @@ public:
/**
* @brief Register ability listener.
* @param listener The listener to add.
* @return Return RET_OK if registers listener successfully, otherwise refer to the RetError for the failure.
* @return Return true if registers listener successfully, else return false.
*/
virtual RetError RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener) override;
virtual bool RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener) override;
/**
* @brief Connect to AAMS. For UI test.
* @return Return RET_OK if the command of connection is sent successfully,
* otherwise refer to the RetError for the failure.
* @return Return RET_OK if the command of connection is sent successfully.
*/
virtual RetError Connect() override;
/**
* @brief disconnect to AAMS. For UI test.
* @return Return RET_OK if the command of disconnect is sent successfully,
* otherwise refer to the RetError for the failure.
* @return Return true if the command of disconnect is sent successfully, else return false.
*/
virtual RetError Disconnect() override;
virtual bool Disconnect() override;
/**
* @brief Obtains elementInfo of focus.
* @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
* @param elementInfo The accessibilityElementInfo of focus.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo) override;
virtual bool GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo) override;
/**
* @brief Obtains elementInfo of focus.
* @param sourceInfo The source info to get focus.
* @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
* @param elementInfo The accessibilityElementInfo of focus.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType,
virtual bool GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType,
AccessibilityElementInfo &elementInfo) override;
/**
* @brief Sends simulate gestures to the screen.
* @param gesturePath The gesture which need to send.
* @return Return RET_OK if the gesture sends successfully, otherwise refer to the RetError for the failure.
* @return Return true if the gesture sends successfully, else return false.
*/
virtual RetError InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
virtual bool InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
/**
* @brief Obtains elementInfo of the accessible root node.
* @param elementInfo The elementInfo of the accessible root node.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetRoot(AccessibilityElementInfo &elementInfo) override;
virtual bool GetRoot(AccessibilityElementInfo &elementInfo) override;
/**
* @brief Obtains elementInfo of the accessible root node.
* @param windowInfo The source window info to get root.
* @param elementInfo The elementInfo of the accessible root node.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
virtual bool GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
AccessibilityElementInfo &elementInfo) override;
/**
* @brief Get the window information related with the event
* @param windowId The window id.
* @param windowInfo The window information.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
virtual bool GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
virtual bool GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param displayId the id of display
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) override;
virtual bool GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) override;
/**
* @brief Gets the next focused node in the specified direction of the currently focused node.
* @param elementInfo The source info to get next info.
* @param direction Indicates the direction to obtain the next focused node. Refer to FocusMoveDirection
* @param nextElementInfo The info of next element.
* @return Return RET_OK if gets next elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets next elementInfo successfully, else return false.
*/
virtual RetError GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction,
virtual bool GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction,
AccessibilityElementInfo &nextElementInfo) override;
/**
@@ -133,18 +131,18 @@ public:
* @param index The index of the child.
* @param parent The parent info to get child.
* @param child The element info of child.
* @return Return RET_OK if gets child elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets child elementInfo successfully, else return false.
*/
virtual RetError GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
virtual bool GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
AccessibilityElementInfo &child) override;
/**
* @brief Get the child node information
* @param parent The parent info to get child.
* @param children The element info of children.
* @return Return RET_OK if gets child elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets child elementInfo successfully, else return false.
*/
virtual RetError GetChildren(const AccessibilityElementInfo &parent,
virtual bool GetChildren(const AccessibilityElementInfo &parent,
std::vector<AccessibilityElementInfo> &children) override;
/**
@@ -152,27 +150,26 @@ public:
* @param elementInfo The source info.
* @param text specified content
* @param elementInfos The element infos of specified content.
* @return Return RET_OK if gets elementInfos successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets elementInfos successfully, else return false.
*/
virtual RetError GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
virtual bool GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
std::vector<AccessibilityElementInfo> &elementInfos) override;
/**
* @brief Get the node information related with the event
* @param eventInfo The source info to get source.
* @param elementInfo The element info of source.
* @return Return RET_OK if gets elementInfos successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets elementInfos successfully, else return false.
*/
virtual RetError GetSource(const AccessibilityEventInfo &eventInfo,
AccessibilityElementInfo &elementInfo) override;
virtual bool GetSource(const AccessibilityEventInfo &eventInfo, AccessibilityElementInfo &elementInfo) override;
/**
* @brief Get Parent node information
* @param child The child element info to get parent.
* @param parent The parent element info.
* @return Return RET_OK if gets info successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets info successfully, else return false.
*/
virtual RetError GetParentElementInfo(const AccessibilityElementInfo &child,
virtual bool GetParentElementInfo(const AccessibilityElementInfo &child,
AccessibilityElementInfo &parent) override;
/**
@@ -193,17 +190,17 @@ public:
* {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
* action: ACCESSIBILITY_ACTION_SET_TEXT,
* actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
* @return Return RET_OK if performs action succeed, otherwise refer to the RetError for the failure.
* @return true Perform action succeed, otherwise is not.
*/
virtual RetError ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
virtual bool ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
const std::map<std::string, std::string> &actionArguments) override;
/**
* @brief Set target bundle names.
* @param targetBundleNames The target bundle name
* @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure.
* @return Return true if sets target bundle names successfully, else return false.
*/
virtual RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
virtual bool SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
/**
* @brief Set cache mode.
@@ -214,13 +211,12 @@ public:
* PREFETCH_SIBLINGS: cache the sister/brothers node info also.
* PREFETCH_CHILDREN: cache the child node info also.
* otherwise: no cache.
* @return Return RET_OK if sets cache mode successfully, otherwise refer to the RetError for the failure.
*/
virtual RetError SetCacheMode(const int32_t cacheMode) override;
virtual void SetCacheMode(const int32_t cacheMode) override;
private:
sptr<IAccessibleAbilityManagerService> serviceProxy_ = nullptr;
};
} // namespace Accessibility
} // namespace OHOS
#endif // ACCESSIBILITY_UI_TEST_ABILITY_IMPL_H
#endif // ACCESSIBILITY_UI_TEST_ABILITY_IMPL_H
@@ -57,17 +57,17 @@ public:
* FOCUS_TYPE_ACCESSIBILITY: accessibility focus
* FOCUS_TYPE_INPUT: text input focus
* @param elementInfo[out] The components information matched conditions searched.
* @return Return RET_OK if finds focus element info successfully, otherwise refer to the RetError for the failure.
* @return Return true if finds focus element info successfully, else return false.
*/
RetError FindFocusedElementInfo(int32_t accessibilityWindowId, int32_t elementId,
bool FindFocusedElementInfo(int32_t accessibilityWindowId, int32_t elementId,
int32_t focusType, AccessibilityElementInfo &elementInfo);
/**
* @brief Send simulate gesture to aams.
* @param gesturePath The path of gesture.
* @return Return RET_OK if gesture injection is successfully, otherwise refer to the RetError for the failure.
* @return Return true if gesture injection is successfully, otherwise return false.
*/
RetError SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath);
bool SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath);
/**
* @brief execute the action on the component.
@@ -89,9 +89,9 @@ public:
* {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
* action: ACCESSIBILITY_ACTION_SET_TEXT,
* actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
* @return RET_OK: execute action successfully; otherwise refer to the RetError for the failure.
* @return true: execute action successfully; otherwise is not.
*/
RetError ExecuteAction(int32_t accessibilityWindowId,
bool ExecuteAction(int32_t accessibilityWindowId,
int32_t elementId, int32_t action, const std::map<std::string, std::string> &actionArguments);
/**
@@ -103,33 +103,33 @@ public:
* PREFETCH_CHILDREN: Need to make the child node info also.
* otherwise: Make the node information by elementId only.
* @param elementInfos[out] The components information matched conditions searched.
* @return Return RET_OK if search element info successfully, otherwise refer to the RetError for the failure.
* @return Return true if search element info successfully, else return false.
*/
RetError SearchElementInfosByAccessibilityId(int32_t accessibilityWindowId, int32_t elementId,
bool SearchElementInfosByAccessibilityId(int32_t accessibilityWindowId, int32_t elementId,
int32_t mode, std::vector<AccessibilityElementInfo> &elementInfos);
/**
* @brief Get the window information related with the event
* @param windowId The window id.
* @param windowInfo The window information.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo);
bool GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo);
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows);
bool GetWindows(std::vector<AccessibilityWindowInfo> &windows);
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param displayId the id of display
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
RetError GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) const;
bool GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) const;
/**
* @brief Find the node information filtered by text.
@@ -137,9 +137,9 @@ public:
* @param elementId: The unique id of the component ID.
* @param text The filter text.
* @param elementInfos[out] The components information matched conditions searched.
* @return Return RET_OK if search element info successfully, otherwise refer to the RetError for the failure.
* @return Return true if search element info successfully, else return false.
*/
RetError SearchElementInfosByText(int32_t accessibilityWindowId, int32_t elementId,
bool SearchElementInfosByText(int32_t accessibilityWindowId, int32_t elementId,
const std::string &text, std::vector<AccessibilityElementInfo> &elementInfos);
/**
@@ -149,17 +149,17 @@ public:
* @param direction The direction of focus move direction.
* Refer to FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD).
* @param elementInfo[out] The components information matched conditions searched.
* @return Return RET_OK if find element info successfully, otherwise refer to the RetError for the failure.
* @return Return true if find element info successfully, else return false.
*/
RetError FocusMoveSearch(int32_t accessibilityWindowId,
bool FocusMoveSearch(int32_t accessibilityWindowId,
int32_t elementId, int32_t direction, AccessibilityElementInfo &elementInfo);
/**
* @brief Set target bundle names.
* @param targetBundleNames The target bundle name
* @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure.
* @return Return true if sets target bundle names successfully, else return false.
*/
RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames);
bool SetTargetBundleName(const std::vector<std::string> &targetBundleNames);
private:
int32_t GenerateRequestId();
@@ -46,9 +46,9 @@ public:
/**
* @brief Register ability listener.
* @param listener The listener to add.
* @return Return RET_OK if registers listener successfully, otherwise refer to the RetError for the failure.
* @return Return true if registers listener successfully, else return false.
*/
virtual RetError RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener) override;
virtual bool RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener) override;
/**
* @brief Init accessible ability.
@@ -80,74 +80,74 @@ public:
* @brief Obtains elementInfo of focus.
* @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
* @param elementInfo The accessibilityElementInfo of focus.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo) override;
virtual bool GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo) override;
/**
* @brief Obtains elementInfo of focus.
* @param sourceInfo The source info to get focus.
* @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
* @param elementInfo The accessibilityElementInfo of focus.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType,
virtual bool GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType,
AccessibilityElementInfo &elementInfo) override;
/**
* @brief Sends simulate gestures to the screen.
* @param gesturePath The gesture which need to send.
* @return Return RET_OK if the gesture sends successfully, otherwise refer to the RetError for the failure.
* @return Return true if the gesture sends successfully, else return false.
*/
virtual RetError InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath) override;
virtual bool InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath) override;
/**
* @brief Obtains elementInfo of the accessible root node.
* @param elementInfo The elementInfo of the accessible root node.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetRoot(AccessibilityElementInfo &elementInfo) override;
virtual bool GetRoot(AccessibilityElementInfo &elementInfo) override;
/**
* @brief Obtains elementInfo of the accessible root node.
* @param windowInfo The source window info to get root.
* @param elementInfo The elementInfo of the accessible root node.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
virtual bool GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
AccessibilityElementInfo &elementInfo) override;
/**
* @brief Get the window information related with the event
* @param windowId The window id.
* @param windowInfo The window information.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
virtual bool GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
virtual bool GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param displayId the id of display
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) override;
virtual bool GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) override;
/**
* @brief Gets the next focused node in the specified direction of the currently focused node.
* @param elementInfo The source info to get next info.
* @param direction Indicates the direction to obtain the next focused node. Refer to FocusMoveDirection
* @param nextElementInfo The info of next element.
* @return Return RET_OK if gets next elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets next elementInfo successfully, else return false.
*/
virtual RetError GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction,
virtual bool GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction,
AccessibilityElementInfo &nextElementInfo) override;
/**
@@ -155,18 +155,18 @@ public:
* @param index The index of the child.
* @param parent The parent info to get child.
* @param child The element info of child.
* @return Return RET_OK if gets child elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets child elementInfo successfully, else return false.
*/
virtual RetError GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
virtual bool GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
AccessibilityElementInfo &child) override;
/**
* @brief Get the child node information
* @param parent The parent info to get child.
* @param children The element info of children.
* @return Return RET_OK if gets child elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets child elementInfo successfully, else return false.
*/
virtual RetError GetChildren(const AccessibilityElementInfo &parent,
virtual bool GetChildren(const AccessibilityElementInfo &parent,
std::vector<AccessibilityElementInfo> &children) override;
/**
@@ -174,28 +174,26 @@ public:
* @param elementInfo The source info.
* @param text specified content
* @param elementInfos The element infos of specified content.
* @return Return RET_OK if gets elementInfos successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets elementInfos successfully, else return false.
*/
virtual RetError GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
virtual bool GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
std::vector<AccessibilityElementInfo> &elementInfos) override;
/**
* @brief Get the node information related with the event
* @param eventInfo The source info to get source.
* @param elementInfo The element info of source.
* @return Return RET_OK if gets elementInfos successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets elementInfos successfully, else return false.
*/
virtual RetError GetSource(const AccessibilityEventInfo &eventInfo,
AccessibilityElementInfo &elementInfo) override;
virtual bool GetSource(const AccessibilityEventInfo &eventInfo, AccessibilityElementInfo &elementInfo) override;
/**
* @brief Get Parent node information
* @param child The child element info to get parent.
* @param parent The parent element info.
* @return Return RET_OK if gets info successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets info successfully, else return false.
*/
virtual RetError GetParentElementInfo(const AccessibilityElementInfo &child,
AccessibilityElementInfo &parent) override;
virtual bool GetParentElementInfo(const AccessibilityElementInfo &child, AccessibilityElementInfo &parent) override;
/**
* @brief Executes a specified action.
@@ -215,17 +213,17 @@ public:
* {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
* action: ACCESSIBILITY_ACTION_SET_TEXT,
* actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
* @return Return RET_OK if performs action succeed, otherwise refer to the RetError for the failure.
* @return true Perform action succeed, otherwise is not.
*/
virtual RetError ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
virtual bool ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
const std::map<std::string, std::string> &actionArguments) override;
/**
* @brief Set target bundle names.
* @param targetBundleNames The target bundle name
* @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure.
* @return Return true if sets target bundle names successfully, else return false.
*/
virtual RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
virtual bool SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
/**
* @brief Set cache mode.
@@ -236,9 +234,8 @@ public:
* PREFETCH_SIBLINGS: cache the sister/brothers node info also.
* PREFETCH_CHILDREN: cache the child node info also.
* otherwise: no cache.
* @return Return RET_OK if sets cache mode successfully, otherwise refer to the RetError for the failure.
*/
virtual RetError SetCacheMode(const int32_t cacheMode) override;
virtual void SetCacheMode(const int32_t cacheMode) override;
/**
* @brief Clean data.
@@ -279,7 +276,7 @@ private:
const int32_t elementId, AccessibilityElementInfo &elementInfo) const;
void SetCacheElementInfo(const int32_t windowId,
const std::vector<OHOS::Accessibility::AccessibilityElementInfo> &elementInfos);
RetError SearchElementInfoFromAce(const int32_t windowId, const int32_t elementId,
bool SearchElementInfoFromAce(const int32_t windowId, const int32_t elementId,
const uint32_t mode, AccessibilityElementInfo &info);
sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr;
@@ -294,4 +291,4 @@ private:
};
} // namespace Accessibility
} // namespace OHOS
#endif // ACCESSIBLE_ABILITY_CLIENT_IMPL_H
#endif // ACCESSIBLE_ABILITY_CLIENT_IMPL_H
@@ -59,19 +59,18 @@ AccessibilityUITestAbilityImpl::AccessibilityUITestAbilityImpl()
}
}
RetError AccessibilityUITestAbilityImpl::RegisterAbilityListener(
const std::shared_ptr<AccessibleAbilityListener> &listener)
bool AccessibilityUITestAbilityImpl::RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener)
{
HILOG_DEBUG();
if (!listener) {
HILOG_ERROR("listener is nullptr.");
return RET_ERR_INVALID_PARAM;
return false;
}
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->RegisterAbilityListener(listener);
}
@@ -93,200 +92,199 @@ RetError AccessibilityUITestAbilityImpl::Connect()
return serviceProxy_->EnableUITestAbility(aaClient->GetRemoteObject());
}
RetError AccessibilityUITestAbilityImpl::Disconnect()
bool AccessibilityUITestAbilityImpl::Disconnect()
{
HILOG_INFO();
if (!serviceProxy_) {
HILOG_ERROR("Failed to get aams service");
return RET_ERR_SAMGR;
return false;
}
return serviceProxy_->DisableUITestAbility();
}
RetError AccessibilityUITestAbilityImpl::GetFocus(
bool AccessibilityUITestAbilityImpl::GetFocus(
const int32_t focusType, AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetFocus(focusType, elementInfo);
}
RetError AccessibilityUITestAbilityImpl::GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo,
bool AccessibilityUITestAbilityImpl::GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo,
const int32_t focusType, AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetFocusByElementInfo(sourceInfo, focusType, elementInfo);
}
RetError AccessibilityUITestAbilityImpl::InjectGesture(
const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
bool AccessibilityUITestAbilityImpl::InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->InjectGesture(gesturePath);
}
RetError AccessibilityUITestAbilityImpl::GetRoot(AccessibilityElementInfo &elementInfo)
bool AccessibilityUITestAbilityImpl::GetRoot(AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetRoot(elementInfo);
}
RetError AccessibilityUITestAbilityImpl::GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
bool AccessibilityUITestAbilityImpl::GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetRootByWindow(windowInfo, elementInfo);
}
RetError AccessibilityUITestAbilityImpl::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
bool AccessibilityUITestAbilityImpl::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetWindow(windowId, windowInfo);
}
RetError AccessibilityUITestAbilityImpl::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
bool AccessibilityUITestAbilityImpl::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetWindows(windows);
}
RetError AccessibilityUITestAbilityImpl::GetWindows(const uint64_t displayId,
bool AccessibilityUITestAbilityImpl::GetWindows(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetWindows(displayId, windows);
}
RetError AccessibilityUITestAbilityImpl::GetNext(const AccessibilityElementInfo &elementInfo,
bool AccessibilityUITestAbilityImpl::GetNext(const AccessibilityElementInfo &elementInfo,
const FocusMoveDirection direction, AccessibilityElementInfo &nextElementInfo)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetNext(elementInfo, direction, nextElementInfo);
}
RetError AccessibilityUITestAbilityImpl::GetChildElementInfo(const int32_t index,
const AccessibilityElementInfo &parent, AccessibilityElementInfo &child)
bool AccessibilityUITestAbilityImpl::GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
AccessibilityElementInfo &child)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetChildElementInfo(index, parent, child);
}
RetError AccessibilityUITestAbilityImpl::GetByContent(const AccessibilityElementInfo &elementInfo,
const std::string &text, std::vector<AccessibilityElementInfo> &elementInfos)
bool AccessibilityUITestAbilityImpl::GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
std::vector<AccessibilityElementInfo> &elementInfos)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetByContent(elementInfo, text, elementInfos);
}
RetError AccessibilityUITestAbilityImpl::GetSource(const AccessibilityEventInfo &eventInfo,
bool AccessibilityUITestAbilityImpl::GetSource(const AccessibilityEventInfo &eventInfo,
AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetSource(eventInfo, elementInfo);
}
RetError AccessibilityUITestAbilityImpl::GetParentElementInfo(const AccessibilityElementInfo &child,
bool AccessibilityUITestAbilityImpl::GetParentElementInfo(const AccessibilityElementInfo &child,
AccessibilityElementInfo &parent)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetParentElementInfo(child, parent);
}
RetError AccessibilityUITestAbilityImpl::ExecuteAction(const AccessibilityElementInfo &elementInfo,
bool AccessibilityUITestAbilityImpl::ExecuteAction(const AccessibilityElementInfo &elementInfo,
const ActionType action, const std::map<std::string, std::string> &actionArguments)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->ExecuteAction(elementInfo, action, actionArguments);
}
RetError AccessibilityUITestAbilityImpl::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
bool AccessibilityUITestAbilityImpl::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->SetTargetBundleName(targetBundleNames);
}
RetError AccessibilityUITestAbilityImpl::GetChildren(const AccessibilityElementInfo &parent,
bool AccessibilityUITestAbilityImpl::GetChildren(const AccessibilityElementInfo &parent,
std::vector<AccessibilityElementInfo> &children)
{
HILOG_DEBUG();
return AccessibleAbilityClient::GetInstance()->GetChildren(parent, children);
}
RetError AccessibilityUITestAbilityImpl::SetCacheMode(const int32_t cacheMode)
void AccessibilityUITestAbilityImpl::SetCacheMode(const int32_t cacheMode)
{
HILOG_DEBUG();
return AccessibleAbilityClient::GetInstance()->SetCacheMode(cacheMode);
@@ -51,14 +51,14 @@ void AccessibleAbilityChannelClient::SetOnKeyPressEventResult(const bool handled
}
}
RetError AccessibleAbilityChannelClient::FindFocusedElementInfo(int32_t accessibilityWindowId,
bool AccessibleAbilityChannelClient::FindFocusedElementInfo(int32_t accessibilityWindowId,
int32_t elementId, int32_t focusType, AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG("[channelId:%{public}d]", channelId_);
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "FindFocusedElement");
if (!proxy_) {
HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_);
return RET_ERR_SAMGR;
return false;
}
int32_t requestId = GenerateRequestId();
@@ -66,15 +66,12 @@ RetError AccessibleAbilityChannelClient::FindFocusedElementInfo(int32_t accessib
new(std::nothrow) AccessibilityElementOperatorCallbackImpl();
if (!elementOperator) {
HILOG_ERROR("Failed to create elementOperator.");
return RET_ERR_NULLPTR;
return false;
}
std::future<void> promiseFuture = elementOperator->promise_.get_future();
RetError ret = proxy_->FindFocusedElementInfo(accessibilityWindowId,
elementId, focusType, requestId, elementOperator);
if (ret != RET_OK) {
HILOG_ERROR("FindFocusedElementInfo failed. ret[%{public}d]", ret);
return ret;
if (!proxy_->FindFocusedElementInfo(accessibilityWindowId, elementId, focusType, requestId, elementOperator)) {
return false;
}
HILOG_DEBUG("channelId:%{public}d, accessibilityWindowId:%{public}d, elementId:%{public}d, focusType:%{public}d",
channelId_, accessibilityWindowId, elementId, focusType);
@@ -82,21 +79,21 @@ RetError AccessibleAbilityChannelClient::FindFocusedElementInfo(int32_t accessib
std::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR));
if (wait != std::future_status::ready) {
HILOG_ERROR("Failed to wait result");
return RET_ERR_TIME_OUT;
return false;
}
if (elementOperator->accessibilityInfoResult_.GetAccessibilityId() ==
AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID) {
HILOG_ERROR("The elementInfo from ace is wrong");
return RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE;
return false;
}
HILOG_INFO("Get result successfully from ace.");
elementInfo = elementOperator->accessibilityInfoResult_;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelClient::SendSimulateGesture(
bool AccessibleAbilityChannelClient::SendSimulateGesture(
const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
{
HILOG_INFO("[channelId:%{public}d]", channelId_);
@@ -104,18 +101,18 @@ RetError AccessibleAbilityChannelClient::SendSimulateGesture(
return proxy_->SendSimulateGesture(gesturePath);
} else {
HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_);
return RET_ERR_SAMGR;
return false;
}
}
RetError AccessibleAbilityChannelClient::ExecuteAction(int32_t accessibilityWindowId,
bool AccessibleAbilityChannelClient::ExecuteAction(int32_t accessibilityWindowId,
int32_t elementId, int32_t action, const std::map<std::string, std::string> &actionArguments)
{
HILOG_DEBUG("[channelId:%{public}d]", channelId_);
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "ExecuteAction");
if (!proxy_) {
HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_);
return RET_ERR_SAMGR;
return false;
}
int32_t requestId = GenerateRequestId();
@@ -123,35 +120,32 @@ RetError AccessibleAbilityChannelClient::ExecuteAction(int32_t accessibilityWind
new(std::nothrow) AccessibilityElementOperatorCallbackImpl();
if (!elementOperator) {
HILOG_ERROR("Failed to create elementOperator.");
return RET_ERR_NULLPTR;
return false;
}
std::future<void> promiseFuture = elementOperator->promise_.get_future();
RetError ret = proxy_->ExecuteAction(accessibilityWindowId,
elementId, action, actionArguments, requestId, elementOperator);
if (ret != RET_OK) {
HILOG_ERROR("ExecuteAction failed. ret[%{public}d]", ret);
return ret;
if (!proxy_->ExecuteAction(accessibilityWindowId, elementId, action, actionArguments, requestId, elementOperator)) {
return false;
}
std::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR));
if (wait != std::future_status::ready) {
HILOG_ERROR("Failed to wait result");
return RET_ERR_TIME_OUT;
return false;
}
HILOG_INFO("Get result successfully from ace. executeActionResult_[%{public}d]",
elementOperator->executeActionResult_);
return elementOperator->executeActionResult_ ? RET_OK : RET_ERR_PERFORM_ACTION_FAILED_BY_ACE;
return elementOperator->executeActionResult_;
}
RetError AccessibleAbilityChannelClient::SearchElementInfosByAccessibilityId(int32_t accessibilityWindowId,
bool AccessibleAbilityChannelClient::SearchElementInfosByAccessibilityId(int32_t accessibilityWindowId,
int32_t elementId, int32_t mode, std::vector<AccessibilityElementInfo> &elementInfos)
{
HILOG_DEBUG("[channelId:%{public}d] [windowId:%{public}d]", channelId_, accessibilityWindowId);
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SearchElementById");
if (!proxy_) {
HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_);
return RET_ERR_SAMGR;
return false;
}
int32_t requestId = GenerateRequestId();
@@ -159,46 +153,44 @@ RetError AccessibleAbilityChannelClient::SearchElementInfosByAccessibilityId(int
new(std::nothrow) AccessibilityElementOperatorCallbackImpl();
if (!elementOperator) {
HILOG_ERROR("Failed to create elementOperator.");
return RET_ERR_NULLPTR;
return false;
}
std::future<void> promiseFuture = elementOperator->promise_.get_future();
RetError ret = proxy_->SearchElementInfoByAccessibilityId(accessibilityWindowId, elementId, requestId,
elementOperator, mode);
if (ret != RET_OK) {
HILOG_ERROR("SearchElementInfosByAccessibilityId failed. ret[%{public}d]", ret);
return ret;
if (!proxy_->SearchElementInfoByAccessibilityId(accessibilityWindowId, elementId, requestId,
elementOperator, mode)) {
return false;
}
std::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR));
if (wait != std::future_status::ready) {
HILOG_ERROR("Failed to wait result");
return RET_ERR_TIME_OUT;
return false;
}
for (auto &info : elementOperator->elementInfosResult_) {
if (info.GetAccessibilityId() == AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID) {
HILOG_ERROR("The elementInfo from ace is wrong");
return RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE;
return false;
}
}
HILOG_INFO("Get result successfully from ace. size[%{public}zu]", elementOperator->elementInfosResult_.size());
elementInfos = elementOperator->elementInfosResult_;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelClient::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
bool AccessibleAbilityChannelClient::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
{
HILOG_DEBUG("[channelId:%{public}d] [windowId:%{public}d]", channelId_, windowId);
HITRACE_METER(HITRACE_TAG_ACCESSIBILITY_MANAGER);
if (!proxy_) {
HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_);
return RET_ERR_SAMGR;
return false;
}
return proxy_->GetWindow(windowId, windowInfo);
}
RetError AccessibleAbilityChannelClient::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
bool AccessibleAbilityChannelClient::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_DEBUG("[channelId:%{public}d]", channelId_);
HITRACE_METER(HITRACE_TAG_ACCESSIBILITY_MANAGER);
@@ -206,11 +198,11 @@ RetError AccessibleAbilityChannelClient::GetWindows(std::vector<AccessibilityWin
return proxy_->GetWindows(windows);
} else {
HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_);
return RET_ERR_SAMGR;
return false;
}
}
RetError AccessibleAbilityChannelClient::GetWindows(const uint64_t displayId,
bool AccessibleAbilityChannelClient::GetWindows(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows) const
{
HILOG_DEBUG("[channelId:%{public}d] [displayId:%{public}" PRIu64 "]", channelId_, displayId);
@@ -219,18 +211,18 @@ RetError AccessibleAbilityChannelClient::GetWindows(const uint64_t displayId,
return proxy_->GetWindowsByDisplayId(displayId, windows);
} else {
HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_);
return RET_ERR_SAMGR;
return false;
}
}
RetError AccessibleAbilityChannelClient::SearchElementInfosByText(int32_t accessibilityWindowId,
bool AccessibleAbilityChannelClient::SearchElementInfosByText(int32_t accessibilityWindowId,
int32_t elementId, const std::string &text, std::vector<AccessibilityElementInfo> &elementInfos)
{
HILOG_DEBUG("[channelId:%{public}d]", channelId_);
HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SearchElementByText");
if (!proxy_) {
HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_);
return RET_ERR_SAMGR;
return false;
}
int32_t requestId = GenerateRequestId();
@@ -238,41 +230,38 @@ RetError AccessibleAbilityChannelClient::SearchElementInfosByText(int32_t access
new(std::nothrow) AccessibilityElementOperatorCallbackImpl();
if (!elementOperator) {
HILOG_ERROR("Failed to create elementOperator.");
return RET_ERR_NULLPTR;
return false;
}
std::future<void> promiseFuture = elementOperator->promise_.get_future();
RetError ret = proxy_->SearchElementInfosByText(accessibilityWindowId,
elementId, text, requestId, elementOperator);
if (ret != RET_OK) {
HILOG_ERROR("SearchElementInfosByText failed. ret[%{public}d]", ret);
return ret;
if (!proxy_->SearchElementInfosByText(accessibilityWindowId, elementId, text, requestId, elementOperator)) {
return false;
}
std::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR));
if (wait != std::future_status::ready) {
HILOG_ERROR("Failed to wait result");
return RET_ERR_TIME_OUT;
return false;
}
for (auto &info : elementOperator->elementInfosResult_) {
if (info.GetAccessibilityId() == AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID) {
HILOG_ERROR("The elementInfo from ace is wrong");
return RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE;
return false;
}
}
HILOG_INFO("Get result successfully from ace. size[%{public}zu]", elementOperator->elementInfosResult_.size());
elementInfos = elementOperator->elementInfosResult_;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelClient::FocusMoveSearch(int32_t accessibilityWindowId,
bool AccessibleAbilityChannelClient::FocusMoveSearch(int32_t accessibilityWindowId,
int32_t elementId, int32_t direction, AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG("[channelId:%{public}d]", channelId_);
if (!proxy_) {
HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_);
return RET_ERR_SAMGR;
return false;
}
int32_t requestId = GenerateRequestId();
@@ -280,41 +269,39 @@ RetError AccessibleAbilityChannelClient::FocusMoveSearch(int32_t accessibilityWi
new(std::nothrow) AccessibilityElementOperatorCallbackImpl();
if (!elementOperator) {
HILOG_ERROR("Failed to create elementOperator.");
return RET_ERR_NULLPTR;
return false;
}
std::future<void> promiseFuture = elementOperator->promise_.get_future();
RetError ret = proxy_->FocusMoveSearch(accessibilityWindowId, elementId, direction, requestId, elementOperator);
if (ret != RET_OK) {
HILOG_ERROR("FocusMoveSearch failed. ret[%{public}d]", ret);
return ret;
if (!proxy_->FocusMoveSearch(accessibilityWindowId, elementId, direction, requestId, elementOperator)) {
return false;
}
std::future_status wait = promiseFuture.wait_for(std::chrono::milliseconds(TIME_OUT_OPERATOR));
if (wait != std::future_status::ready) {
HILOG_ERROR("Failed to wait result");
return RET_ERR_TIME_OUT;
return false;
}
if (elementOperator->accessibilityInfoResult_.GetAccessibilityId() ==
AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID) {
HILOG_ERROR("The elementInfo from ace is wrong");
return RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE;
return false;
}
HILOG_INFO("Get result successfully from ace");
elementInfo = elementOperator->accessibilityInfoResult_;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelClient::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
bool AccessibleAbilityChannelClient::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
{
HILOG_INFO("[channelId:%{public}d]", channelId_);
if (proxy_) {
return proxy_->SetTargetBundleName(targetBundleNames);
} else {
HILOG_ERROR("Failed to connect to aams [channelId:%{public}d]", channelId_);
return RET_ERR_SAMGR;
return false;
}
}
} // namespace Accessibility
@@ -103,18 +103,17 @@ sptr<IRemoteObject> AccessibleAbilityClientImpl::GetRemoteObject()
return g_Instance->AsObject();
}
RetError AccessibleAbilityClientImpl::RegisterAbilityListener(
const std::shared_ptr<AccessibleAbilityListener> &listener)
bool AccessibleAbilityClientImpl::RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener)
{
HILOG_INFO();
std::lock_guard<std::mutex> lock(mutex_);
if (listener_) {
HILOG_DEBUG("listener already exists.");
return RET_ERR_REGISTER_EXIST;
return false;
}
listener_ = listener;
return RET_OK;
return true;
}
void AccessibleAbilityClientImpl::Init(const sptr<IAccessibleAbilityChannel> &channel, const int32_t channelId)
@@ -220,36 +219,36 @@ void AccessibleAbilityClientImpl::OnKeyPressEvent(const MMI::KeyEvent &keyEvent,
channel->SetOnKeyPressEventResult(handled, sequence);
}
RetError AccessibleAbilityClientImpl::GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo)
bool AccessibleAbilityClientImpl::GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo)
{
HILOG_INFO("focusType[%{public}d]", focusType);
std::lock_guard<std::mutex> lock(mutex_);
if ((focusType != FOCUS_TYPE_INPUT) && (focusType != FOCUS_TYPE_ACCESSIBILITY)) {
HILOG_ERROR("focusType is not allowed.");
return RET_ERR_INVALID_PARAM;
return false;
}
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
return channelClient_->FindFocusedElementInfo(ANY_WINDOW_ID, ROOT_NODE_ID, focusType, elementInfo);
}
RetError AccessibleAbilityClientImpl::GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo,
bool AccessibleAbilityClientImpl::GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo,
const int32_t focusType, AccessibilityElementInfo &elementInfo)
{
HILOG_INFO("focusType[%{public}d]", focusType);
std::lock_guard<std::mutex> lock(mutex_);
if ((focusType != FOCUS_TYPE_INPUT) && (focusType != FOCUS_TYPE_ACCESSIBILITY)) {
HILOG_ERROR("focusType is not allowed.");
return RET_ERR_INVALID_PARAM;
return false;
}
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
int32_t windowId = sourceInfo.GetWindowId();
@@ -259,110 +258,112 @@ RetError AccessibleAbilityClientImpl::GetFocusByElementInfo(const AccessibilityE
return channelClient_->FindFocusedElementInfo(windowId, elementId, focusType, elementInfo);
}
RetError AccessibleAbilityClientImpl::InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
bool AccessibleAbilityClientImpl::InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
{
HILOG_INFO();
std::lock_guard<std::mutex> lock(mutex_);
if (!gesturePath) {
HILOG_ERROR("The gesturePath is null.");
return RET_ERR_INVALID_PARAM;
return false;
}
std::vector<AccessibilityGesturePosition> positions = gesturePath->GetPositions();
if (positions.size() == 0) {
HILOG_ERROR("The number of gesture path position is not allowed.");
return RET_ERR_INVALID_PARAM;
return false;
}
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
return channelClient_->SendSimulateGesture(gesturePath);
}
RetError AccessibleAbilityClientImpl::GetRoot(AccessibilityElementInfo &elementInfo)
bool AccessibleAbilityClientImpl::GetRoot(AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
if (!serviceProxy_) {
HILOG_ERROR("Failed to connect to aams");
return RET_ERR_SAMGR;
}
if (!channelClient_) {
if (!channelClient_ || !serviceProxy_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
int32_t activeWindow = serviceProxy_->GetActiveWindow();
HILOG_INFO("activeWindow[%{public}d]", activeWindow);
if (GetCacheElementInfo(activeWindow, ROOT_NONE_ID, elementInfo)) {
HILOG_DEBUG("get element info from cache");
return RET_OK;
return true;
}
return SearchElementInfoFromAce(activeWindow, ROOT_NONE_ID, cacheMode_, elementInfo);
if (!SearchElementInfoFromAce(activeWindow, ROOT_NONE_ID, cacheMode_, elementInfo)) {
HILOG_ERROR("Get element info from ace failed");
return false;
}
return true;
}
RetError AccessibleAbilityClientImpl::GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
bool AccessibleAbilityClientImpl::GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
int32_t windowId = windowInfo.GetWindowId();
HILOG_INFO("windowId[%{public}d]", windowId);
if (GetCacheElementInfo(windowId, ROOT_NONE_ID, elementInfo)) {
HILOG_DEBUG("get element info from cache");
return RET_OK;
return true;
}
return SearchElementInfoFromAce(windowId, ROOT_NONE_ID, cacheMode_, elementInfo);
if (!SearchElementInfoFromAce(windowId, ROOT_NONE_ID, cacheMode_, elementInfo)) {
HILOG_ERROR("Get element info from ace failed");
return false;
}
return true;
}
RetError AccessibleAbilityClientImpl::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
bool AccessibleAbilityClientImpl::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
{
HILOG_INFO("windowId[%{public}d]", windowId);
std::lock_guard<std::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
return channelClient_->GetWindow(windowId, windowInfo);
}
RetError AccessibleAbilityClientImpl::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
bool AccessibleAbilityClientImpl::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_INFO();
std::lock_guard<std::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
return channelClient_->GetWindows(windows);
}
RetError AccessibleAbilityClientImpl::GetWindows(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows)
bool AccessibleAbilityClientImpl::GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_INFO("displayId[%{public}" PRIu64 "]", displayId);
std::lock_guard<std::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
return channelClient_->GetWindows(displayId, windows);
}
RetError AccessibleAbilityClientImpl::GetNext(const AccessibilityElementInfo &elementInfo,
bool AccessibleAbilityClientImpl::GetNext(const AccessibilityElementInfo &elementInfo,
const FocusMoveDirection direction, AccessibilityElementInfo &nextElementInfo)
{
HILOG_INFO("windowId[%{public}d], elementId[%{public}d], direction[%{public}d]",
@@ -370,24 +371,24 @@ RetError AccessibleAbilityClientImpl::GetNext(const AccessibilityElementInfo &el
std::lock_guard<std::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
if (direction == DIRECTION_INVALID) {
HILOG_ERROR("direction is invalid.");
return RET_ERR_INVALID_PARAM;
return false;
}
return channelClient_->FocusMoveSearch(elementInfo.GetWindowId(),
elementInfo.GetAccessibilityId(), direction, nextElementInfo);
}
RetError AccessibleAbilityClientImpl::GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
bool AccessibleAbilityClientImpl::GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
AccessibilityElementInfo &child)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
int32_t windowId = parent.GetWindowId();
@@ -395,24 +396,28 @@ RetError AccessibleAbilityClientImpl::GetChildElementInfo(const int32_t index, c
HILOG_INFO("windowId[%{public}d], childId[%{public}d]", windowId, childId);
if (childId == -1) {
HILOG_ERROR("childId[%{public}d] is invalid", childId);
return RET_ERR_INVALID_PARAM;
return false;
}
if (GetCacheElementInfo(windowId, childId, child)) {
HILOG_DEBUG("get element info from cache");
return RET_OK;
return true;
}
return SearchElementInfoFromAce(windowId, childId, cacheMode_, child);
if (!SearchElementInfoFromAce(windowId, childId, cacheMode_, child)) {
HILOG_ERROR("Get element info from ace failed");
return false;
}
return true;
}
RetError AccessibleAbilityClientImpl::GetChildren(const AccessibilityElementInfo &parent,
bool AccessibleAbilityClientImpl::GetChildren(const AccessibilityElementInfo &parent,
std::vector<AccessibilityElementInfo> &children)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
int32_t windowId = parent.GetWindowId();
@@ -422,7 +427,7 @@ RetError AccessibleAbilityClientImpl::GetChildren(const AccessibilityElementInfo
HILOG_DEBUG("childId[%{public}d]", childId);
if (childId == -1) {
HILOG_ERROR("childId is invalid");
return RET_ERR_INVALID_PARAM;
return false;
}
AccessibilityElementInfo child;
@@ -432,24 +437,23 @@ RetError AccessibleAbilityClientImpl::GetChildren(const AccessibilityElementInfo
continue;
}
RetError ret = SearchElementInfoFromAce(windowId, childId, cacheMode_, child);
if (ret != RET_OK) {
if (!SearchElementInfoFromAce(windowId, childId, cacheMode_, child)) {
HILOG_ERROR("Get element info from ace failed");
return ret;
return false;
}
children.emplace_back(child);
}
return RET_OK;
return true;
}
RetError AccessibleAbilityClientImpl::GetByContent(const AccessibilityElementInfo &elementInfo,
const std::string &text, std::vector<AccessibilityElementInfo> &elementInfos)
bool AccessibleAbilityClientImpl::GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
std::vector<AccessibilityElementInfo> &elementInfos)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
int32_t windowId = elementInfo.GetWindowId();
int32_t elementId = elementInfo.GetAccessibilityId();
@@ -457,57 +461,66 @@ RetError AccessibleAbilityClientImpl::GetByContent(const AccessibilityElementInf
return channelClient_->SearchElementInfosByText(windowId, elementId, text, elementInfos);
}
RetError AccessibleAbilityClientImpl::GetSource(const AccessibilityEventInfo &eventInfo,
bool AccessibleAbilityClientImpl::GetSource(const AccessibilityEventInfo &eventInfo,
AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
int32_t windowId = eventInfo.GetWindowId();
int32_t elementId = eventInfo.GetAccessibilityId();
HILOG_INFO("windowId[%{public}d], elementId[%{public}d]", windowId, elementId);
if (GetCacheElementInfo(windowId, elementId, elementInfo)) {
HILOG_DEBUG("get element info from cache");
return RET_OK;
return true;
}
return SearchElementInfoFromAce(windowId, elementId, cacheMode_, elementInfo);
if (!SearchElementInfoFromAce(windowId, elementId, cacheMode_, elementInfo)) {
HILOG_ERROR("Get element info from ace failed");
return false;
}
return true;
}
RetError AccessibleAbilityClientImpl::GetParentElementInfo(const AccessibilityElementInfo &child,
bool AccessibleAbilityClientImpl::GetParentElementInfo(const AccessibilityElementInfo &child,
AccessibilityElementInfo &parent)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
int32_t windowId = child.GetWindowId();
int32_t elementId = child.GetParentNodeId();
HILOG_INFO("windowId[%{public}d], parentId[%{public}d]", windowId, elementId);
if (GetCacheElementInfo(windowId, elementId, parent)) {
HILOG_DEBUG("get element info from cache");
return RET_OK;
return true;
}
return SearchElementInfoFromAce(windowId, elementId, cacheMode_, parent);
if (!SearchElementInfoFromAce(windowId, elementId, cacheMode_, parent)) {
HILOG_ERROR("Get element info from ace failed");
return false;
}
return true;
}
RetError AccessibleAbilityClientImpl::ExecuteAction(const AccessibilityElementInfo &elementInfo,
const ActionType action, const std::map<std::string, std::string> &actionArguments)
bool AccessibleAbilityClientImpl::ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
const std::map<std::string, std::string> &actionArguments)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
if (action == ACCESSIBILITY_ACTION_INVALID) {
HILOG_ERROR("action is invalid.");
return RET_ERR_INVALID_PARAM;
return false;
}
int32_t windowId = elementInfo.GetWindowId();
int32_t elementId = elementInfo.GetAccessibilityId();
@@ -516,13 +529,13 @@ RetError AccessibleAbilityClientImpl::ExecuteAction(const AccessibilityElementIn
const_cast<std::map<std::string, std::string> &>(actionArguments));
}
RetError AccessibleAbilityClientImpl::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
bool AccessibleAbilityClientImpl::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
{
HILOG_INFO("targetBundleNames size[%{public}zu]", targetBundleNames.size());
std::lock_guard<std::mutex> lock(mutex_);
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
return channelClient_->SetTargetBundleName(targetBundleNames);
}
@@ -578,7 +591,7 @@ void AccessibleAbilityClientImpl::ResetAAClient(const wptr<IRemoteObject> &remot
}
}
RetError AccessibleAbilityClientImpl::SetCacheMode(const int32_t cacheMode)
void AccessibleAbilityClientImpl::SetCacheMode(const int32_t cacheMode)
{
HILOG_INFO("set cache mode: [%{public}d]", cacheMode);
std::lock_guard<std::mutex> lock(mutex_);
@@ -590,7 +603,6 @@ RetError AccessibleAbilityClientImpl::SetCacheMode(const int32_t cacheMode)
uint32_t mode = static_cast<uint32_t>(cacheMode);
cacheMode_ = mode & static_cast<uint32_t>(GET_SOURCE_PREFETCH_MODE);
}
return RET_OK;
}
bool AccessibleAbilityClientImpl::GetCacheElementInfo(const int32_t windowId,
@@ -623,32 +635,30 @@ void AccessibleAbilityClientImpl::SetCacheElementInfo(const int32_t windowId,
}
}
RetError AccessibleAbilityClientImpl::SearchElementInfoFromAce(const int32_t windowId, const int32_t elementId,
bool AccessibleAbilityClientImpl::SearchElementInfoFromAce(const int32_t windowId, const int32_t elementId,
const uint32_t mode, AccessibilityElementInfo &info)
{
if (!channelClient_) {
HILOG_ERROR("The channel is invalid.");
return RET_ERR_NO_CONNECTION;
return false;
}
std::vector<AccessibilityElementInfo> elementInfos {};
RetError ret = channelClient_->SearchElementInfosByAccessibilityId(
windowId, elementId, static_cast<int32_t>(mode), elementInfos);
if (ret != RET_OK) {
if (!channelClient_->SearchElementInfosByAccessibilityId(
windowId, elementId, static_cast<int32_t>(mode), elementInfos)) {
HILOG_ERROR("search element info failed. windowId[%{public}d] elementId[%{public}d] mode[%{public}d]",
windowId, elementId, mode);
return ret;
return false;
}
if (elementInfos.empty()) {
HILOG_ERROR("elementInfos from ace is empty");
return RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE;
return false;
}
HILOG_DEBUG("element [elementSize:%{public}zu]", elementInfos.size());
SetCacheElementInfo(windowId, elementInfos);
info = elementInfos.front();
return RET_OK;
return true;
}
} // namespace Accessibility
} // namespace OHOS
@@ -27,27 +27,27 @@ public:
virtual ~MockAccessibleAbilityChannelProxy() = default;
MOCK_METHOD5(SearchElementInfoByAccessibilityId,
RetError(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t requestId,
bool(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback, const int32_t mode));
MOCK_METHOD5(SearchElementInfosByText,
RetError(const int32_t accessibilityWindowId, const int32_t elementId, const std::string& text,
bool(const int32_t accessibilityWindowId, const int32_t elementId, const std::string& text,
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD5(FindFocusedElementInfo,
RetError(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t focusType,
bool(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t focusType,
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD5(FocusMoveSearch, RetError(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t direction, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD6(ExecuteAction, RetError(const int32_t accessibilityWindowId, const int32_t elementId,
MOCK_METHOD5(
FocusMoveSearch, bool(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t direction,
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD6(ExecuteAction, bool(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t action, const std::map<std::string, std::string>& actionArguments, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD2(GetWindow, RetError(const int32_t windowId, AccessibilityWindowInfo &windowInfo));
MOCK_METHOD1(GetWindows, RetError(std::vector<AccessibilityWindowInfo> &windows));
MOCK_METHOD2(GetWindowsByDisplayId, RetError(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows));
MOCK_METHOD2(GetWindow, bool(const int32_t windowId, AccessibilityWindowInfo &windowInfo));
MOCK_METHOD1(GetWindows, bool(std::vector<AccessibilityWindowInfo> &windows));
MOCK_METHOD2(GetWindowsByDisplayId, bool(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows));
MOCK_METHOD2(SetOnKeyPressEventResult, void(const bool handled, const int32_t sequence));
MOCK_METHOD1(SendSimulateGesture, RetError(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
MOCK_METHOD1(SetTargetBundleName, RetError(const std::vector<std::string> &targetBundleNames));
MOCK_METHOD1(SendSimulateGesture, bool(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
MOCK_METHOD1(SetTargetBundleName, bool(const std::vector<std::string> &targetBundleNames));
};
} // namespace Accessibility
} // namespace OHOS
@@ -26,30 +26,28 @@ public:
MockAccessibleAbilityChannelStub();
virtual ~MockAccessibleAbilityChannelStub();
MOCK_METHOD4(OnRemoteRequest, int(uint32_t code, MessageParcel& data,
MessageParcel& reply, MessageOption& option));
MOCK_METHOD4(OnRemoteRequest, int(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option));
MOCK_METHOD5(SearchElementInfoByAccessibilityId,
RetError(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t requestId,
bool(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback, const int32_t mode));
MOCK_METHOD5(SearchElementInfosByText,
RetError(const int32_t accessibilityWindowId, const int32_t elementId, const std::string& text,
bool(const int32_t accessibilityWindowId, const int32_t elementId, const std::string& text,
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD5(FindFocusedElementInfo,
RetError(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t focusType,
bool(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t focusType,
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD5(FocusMoveSearch, RetError(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t direction, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD6(ExecuteAction, RetError(const int32_t accessibilityWindowId, const int32_t elementId,
MOCK_METHOD5(
FocusMoveSearch, bool(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t direction,
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD6(ExecuteAction, bool(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t action, const std::map<std::string, std::string>& actionArguments, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD2(GetWindow, RetError(const int32_t windowId, AccessibilityWindowInfo &windowInfo));
MOCK_METHOD1(GetWindows, RetError(std::vector<AccessibilityWindowInfo> &windows));
MOCK_METHOD2(GetWindowsByDisplayId, RetError(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows));
MOCK_METHOD2(GetWindow, bool(const int32_t windowId, AccessibilityWindowInfo &windowInfo));
MOCK_METHOD1(GetWindows, bool(std::vector<AccessibilityWindowInfo> &windows));
MOCK_METHOD2(GetWindowsByDisplayId, bool(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows));
MOCK_METHOD2(SetOnKeyPressEventResult, void(const bool handled, const int32_t sequence));
MOCK_METHOD1(SendSimulateGesture, RetError(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
MOCK_METHOD1(SetTargetBundleName, RetError(const std::vector<std::string> &targetBundleNames));
MOCK_METHOD1(SendSimulateGesture, bool(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
MOCK_METHOD1(SetTargetBundleName, bool(const std::vector<std::string> &targetBundleNames));
};
} // namespace Accessibility
} // namespace OHOS
@@ -25,31 +25,29 @@ public:
MockAccessibleAbilityClient();
~MockAccessibleAbilityClient() = default;
sptr<IRemoteObject> GetRemoteObject() override;
RetError RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener) override;
RetError GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo) override;
RetError GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType,
bool RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener) override;
bool GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo) override;
bool GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType,
AccessibilityElementInfo &elementInfo) override;
RetError InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath) override;
RetError GetRoot(AccessibilityElementInfo &elementInfo) override;
RetError GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
AccessibilityElementInfo &elementInfo) override;
RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
RetError GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) override;
RetError GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction,
bool InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath) override;
bool GetRoot(AccessibilityElementInfo &elementInfo) override;
bool GetRootByWindow(const AccessibilityWindowInfo &windowInfo, AccessibilityElementInfo &elementInfo) override;
bool GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
bool GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
bool GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) override;
bool GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction,
AccessibilityElementInfo &nextElementInfo) override;
RetError GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
bool GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
AccessibilityElementInfo &child) override;
RetError GetChildren(const AccessibilityElementInfo &parent,
std::vector<AccessibilityElementInfo> &children) override;
RetError GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
bool GetChildren(const AccessibilityElementInfo &parent, std::vector<AccessibilityElementInfo> &children) override;
bool GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
std::vector<AccessibilityElementInfo> &elementInfos) override;
RetError GetSource(const AccessibilityEventInfo &eventInfo, AccessibilityElementInfo &elementInfo) override;
RetError GetParentElementInfo(const AccessibilityElementInfo &child, AccessibilityElementInfo &parent) override;
RetError ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
bool GetSource(const AccessibilityEventInfo &eventInfo, AccessibilityElementInfo &elementInfo) override;
bool GetParentElementInfo(const AccessibilityElementInfo &child, AccessibilityElementInfo &parent) override;
bool ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
const std::map<std::string, std::string> &actionArguments) override;
RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
RetError SetCacheMode(const int32_t cacheMode) override;
bool SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
void SetCacheMode(const int32_t cacheMode) override;
};
} // namespace Accessibility
} // namespace OHOS
@@ -39,7 +39,7 @@ bool AccessibleAbilityChannelProxy::SendTransactCmd(
return true;
}
RetError AccessibleAbilityChannelProxy::SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannelProxy::SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
const int32_t elementId, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback,
const int32_t mode)
{
@@ -48,10 +48,10 @@ RetError AccessibleAbilityChannelProxy::SearchElementInfoByAccessibilityId(const
(void)requestId;
(void)callback;
(void)mode;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::SearchElementInfosByText(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannelProxy::SearchElementInfosByText(const int32_t accessibilityWindowId,
const int32_t elementId, const std::string& text, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback)
{
@@ -60,22 +60,21 @@ RetError AccessibleAbilityChannelProxy::SearchElementInfosByText(const int32_t a
(void)text;
(void)requestId;
(void)callback;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::FindFocusedElementInfo(const int32_t accessibilityWindowId,
const int32_t elementId, const int32_t focusType, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback)
bool AccessibleAbilityChannelProxy::FindFocusedElementInfo(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t focusType, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback)
{
(void)accessibilityWindowId;
(void)elementId;
(void)focusType;
(void)requestId;
(void)callback;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
bool AccessibleAbilityChannelProxy::FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t direction, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback)
{
(void)accessibilityWindowId;
@@ -83,10 +82,10 @@ RetError AccessibleAbilityChannelProxy::FocusMoveSearch(const int32_t accessibil
(void)direction;
(void)requestId;
(void)callback;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId,
bool AccessibleAbilityChannelProxy::ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t action, const std::map<std::string, std::string>& actionArguments, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback)
{
@@ -96,21 +95,21 @@ RetError AccessibleAbilityChannelProxy::ExecuteAction(const int32_t accessibilit
(void)actionArguments;
(void)requestId;
(void)callback;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
bool AccessibleAbilityChannelProxy::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
{
(void)windows;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::GetWindowsByDisplayId(const uint64_t displayId,
bool AccessibleAbilityChannelProxy::GetWindowsByDisplayId(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows)
{
(void)displayId;
(void)windows;
return RET_OK;
return true;
}
void AccessibleAbilityChannelProxy::SetOnKeyPressEventResult(const bool handled, const int32_t sequence)
@@ -119,11 +118,11 @@ void AccessibleAbilityChannelProxy::SetOnKeyPressEventResult(const bool handled,
(void)sequence;
}
RetError AccessibleAbilityChannelProxy::SendSimulateGesture(
bool AccessibleAbilityChannelProxy::SendSimulateGesture(
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
{
(void)gesturePath;
return RET_OK;
return true;
}
MockAccessibleAbilityChannelProxy::MockAccessibleAbilityChannelProxy(const sptr<IRemoteObject>& object)
@@ -48,25 +48,24 @@ sptr<IRemoteObject> MockAccessibleAbilityClient::GetRemoteObject()
return nullptr;
}
RetError MockAccessibleAbilityClient::RegisterAbilityListener(
const std::shared_ptr<AccessibleAbilityListener> &listener)
bool MockAccessibleAbilityClient::RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener)
{
HILOG_DEBUG();
(void)listener;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo)
bool MockAccessibleAbilityClient::GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
(void)focusType;
(void)elementInfo;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo,
bool MockAccessibleAbilityClient::GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo,
const int32_t focusType, AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
@@ -74,63 +73,62 @@ RetError MockAccessibleAbilityClient::GetFocusByElementInfo(const AccessibilityE
(void)sourceInfo;
(void)focusType;
(void)elementInfo;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
bool MockAccessibleAbilityClient::InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
{
HILOG_INFO();
(void)gesturePath;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetRoot(AccessibilityElementInfo &elementInfo)
bool MockAccessibleAbilityClient::GetRoot(AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
(void)elementInfo;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
bool MockAccessibleAbilityClient::GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
(void)windowInfo;
(void)elementInfo;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
bool MockAccessibleAbilityClient::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
{
HILOG_DEBUG();
(void)windowId;
(void)windowInfo;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
bool MockAccessibleAbilityClient::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_DEBUG();
(void)windows;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetWindows(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows)
bool MockAccessibleAbilityClient::GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_DEBUG();
(void)displayId;
(void)windows;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetNext(const AccessibilityElementInfo &elementInfo,
bool MockAccessibleAbilityClient::GetNext(const AccessibilityElementInfo &elementInfo,
const FocusMoveDirection direction, AccessibilityElementInfo &nextElementInfo)
{
HILOG_DEBUG();
@@ -138,10 +136,10 @@ RetError MockAccessibleAbilityClient::GetNext(const AccessibilityElementInfo &el
(void)elementInfo;
(void)direction;
(void)nextElementInfo;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
bool MockAccessibleAbilityClient::GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
AccessibilityElementInfo &child)
{
HILOG_DEBUG();
@@ -149,74 +147,73 @@ RetError MockAccessibleAbilityClient::GetChildElementInfo(const int32_t index, c
(void)index;
(void)parent;
(void)child;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetChildren(const AccessibilityElementInfo &parent,
bool MockAccessibleAbilityClient::GetChildren(const AccessibilityElementInfo &parent,
std::vector<AccessibilityElementInfo> &children)
{
HILOG_DEBUG();
(void)parent;
(void)children;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetByContent(const AccessibilityElementInfo &elementInfo,
const std::string &text, std::vector<AccessibilityElementInfo> &elementInfos)
bool MockAccessibleAbilityClient::GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
std::vector<AccessibilityElementInfo> &elementInfos)
{
HILOG_DEBUG();
(void)elementInfo;
(void)text;
(void)elementInfos;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetSource(const AccessibilityEventInfo &eventInfo,
bool MockAccessibleAbilityClient::GetSource(const AccessibilityEventInfo &eventInfo,
AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
(void)eventInfo;
(void)elementInfo;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::GetParentElementInfo(const AccessibilityElementInfo &child,
bool MockAccessibleAbilityClient::GetParentElementInfo(const AccessibilityElementInfo &child,
AccessibilityElementInfo &parent)
{
HILOG_DEBUG();
(void)child;
(void)parent;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::ExecuteAction(const AccessibilityElementInfo &elementInfo,
const ActionType action, const std::map<std::string, std::string> &actionArguments)
bool MockAccessibleAbilityClient::ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
const std::map<std::string, std::string> &actionArguments)
{
HILOG_DEBUG();
(void)elementInfo;
(void)action;
(void)actionArguments;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
bool MockAccessibleAbilityClient::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
{
HILOG_DEBUG();
(void)targetBundleNames;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityClient::SetCacheMode(const int32_t cacheMode)
void MockAccessibleAbilityClient::SetCacheMode(const int32_t cacheMode)
{
HILOG_DEBUG();
AccessibilityAbilityUtHelper::GetInstance().SetCacheMode(cacheMode);
return RET_OK;
}
} // namespace Accessibility
} // namespace OHOS
@@ -85,7 +85,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, RegisterAbilityListener_001, TestSi
return;
}
std::shared_ptr<AccessibleAbilityListener> listener = nullptr;
EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_ERR_INVALID_PARAM);
EXPECT_FALSE(instance_->RegisterAbilityListener(listener));
GTEST_LOG_(INFO) << "RegisterAbilityListener_001 end";
}
@@ -105,7 +105,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, RegisterAbilityListener_002, TestSi
}
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
std::shared_ptr<AccessibleAbilityListener> listener = std::make_shared<MockAccessibleAbilityListener>();
EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->RegisterAbilityListener(listener));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "RegisterAbilityListener_002 end";
@@ -125,7 +125,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, RegisterAbilityListener_003, TestSi
return;
}
std::shared_ptr<AccessibleAbilityListener> listener = std::make_shared<MockAccessibleAbilityListener>();
EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_OK);
EXPECT_TRUE(instance_->RegisterAbilityListener(listener));
GTEST_LOG_(INFO) << "RegisterAbilityListener_003 end";
}
@@ -161,7 +161,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, Disconnect_001, TestSize.Level1)
GTEST_LOG_(INFO) << "Cann't get AccessibilityUITestAbilityImpl instance_";
return;
}
EXPECT_EQ(instance_->Disconnect(), RET_ERR_SAMGR);
EXPECT_FALSE(instance_->Disconnect());
GTEST_LOG_(INFO) << "Disconnect_001 end";
}
@@ -181,7 +181,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetFocus_001, TestSize.Level1)
}
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE, elementInfo), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->GetFocus(FOCUS_TYPE, elementInfo));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "GetFocus_001 end";
@@ -201,7 +201,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetFocus_002, TestSize.Level1)
return;
}
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE, elementInfo), RET_OK);
EXPECT_TRUE(instance_->GetFocus(FOCUS_TYPE, elementInfo));
GTEST_LOG_(INFO) << "GetFocus_002 end";
}
@@ -222,7 +222,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetFocusByElementInfo_001, TestSize
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
AccessibilityElementInfo sourceInfo {};
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE, elementInfo), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE, elementInfo));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "GetFocusByElementInfo_001 end";
@@ -243,7 +243,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetFocusByElementInfo_002, TestSize
}
AccessibilityElementInfo sourceInfo {};
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE, elementInfo), RET_OK);
EXPECT_TRUE(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE, elementInfo));
GTEST_LOG_(INFO) << "GetFocusByElementInfo_002 end";
}
@@ -263,7 +263,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, InjectGesture_001, TestSize.Level1)
}
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->InjectGesture(gesturePath));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "InjectGesture_001 end";
@@ -283,7 +283,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, InjectGesture_002, TestSize.Level1)
return;
}
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_OK);
EXPECT_TRUE(instance_->InjectGesture(gesturePath));
GTEST_LOG_(INFO) << "InjectGesture_002 end";
}
@@ -303,7 +303,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetRoot_001, TestSize.Level1)
}
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetRoot(elementInfo), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->GetRoot(elementInfo));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "GetRoot_001 end";
@@ -323,7 +323,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetRoot_002, TestSize.Level1)
return;
}
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetRoot(elementInfo), RET_OK);
EXPECT_TRUE(instance_->GetRoot(elementInfo));
GTEST_LOG_(INFO) << "GetRoot_002 end";
}
@@ -344,7 +344,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetRootByWindow_001, TestSize.Level
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
AccessibilityWindowInfo windowInfo {};
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetRootByWindow(windowInfo, elementInfo), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->GetRootByWindow(windowInfo, elementInfo));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "GetRootByWindow_001 end";
@@ -365,7 +365,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetRootByWindow_002, TestSize.Level
}
AccessibilityWindowInfo windowInfo {};
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetRootByWindow(windowInfo, elementInfo), RET_OK);
EXPECT_TRUE(instance_->GetRootByWindow(windowInfo, elementInfo));
GTEST_LOG_(INFO) << "GetRootByWindow_002 end";
}
@@ -385,7 +385,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetWindow_001, TestSize.Level1)
}
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
AccessibilityWindowInfo winInfo {};
EXPECT_EQ(instance_->GetWindow(WINDOW_ID, winInfo), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->GetWindow(WINDOW_ID, winInfo));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "GetWindow_001 end";
}
@@ -404,7 +404,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetWindow_002, TestSize.Level1)
return;
}
AccessibilityWindowInfo winInfo {};
EXPECT_EQ(instance_->GetWindow(WINDOW_ID, winInfo), RET_OK);
EXPECT_TRUE(instance_->GetWindow(WINDOW_ID, winInfo));
GTEST_LOG_(INFO) << "GetWindow_002 end";
}
@@ -423,7 +423,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetWindows_001, TestSize.Level1)
}
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
std::vector<AccessibilityWindowInfo> res {};
EXPECT_EQ(instance_->GetWindows(res), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->GetWindows(res));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "GetWindows_001 end";
}
@@ -442,7 +442,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetWindows_002, TestSize.Level1)
return;
}
std::vector<AccessibilityWindowInfo> res {};
EXPECT_EQ(instance_->GetWindows(res), RET_OK);
EXPECT_TRUE(instance_->GetWindows(res));
GTEST_LOG_(INFO) << "GetWindows_002 end";
}
@@ -461,7 +461,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetWindows_003, TestSize.Level1)
}
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
std::vector<AccessibilityWindowInfo> res {};
EXPECT_EQ(instance_->GetWindows(DISPLAY_ID, res), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->GetWindows(DISPLAY_ID, res));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "GetWindows_003 end";
}
@@ -480,7 +480,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetWindows_004, TestSize.Level1)
return;
}
std::vector<AccessibilityWindowInfo> res {};
EXPECT_EQ(instance_->GetWindows(DISPLAY_ID, res), RET_OK);
EXPECT_TRUE(instance_->GetWindows(DISPLAY_ID, res));
GTEST_LOG_(INFO) << "GetWindows_004 end";
}
@@ -501,7 +501,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetNext_001, TestSize.Level1)
AccessibilityElementInfo nextElementInfo {};
AccessibilityElementInfo elementInfo {};
FocusMoveDirection direction = DIRECTION_INVALID;
EXPECT_EQ(instance_->GetNext(elementInfo, direction, elementInfo), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->GetNext(elementInfo, direction, elementInfo));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "GetNext_001 end";
@@ -523,7 +523,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetNext_002, TestSize.Level1)
AccessibilityElementInfo nextElementInfo {};
AccessibilityElementInfo elementInfo {};
FocusMoveDirection direction = DIRECTION_INVALID;
EXPECT_EQ(instance_->GetNext(elementInfo, direction, elementInfo), RET_OK);
EXPECT_TRUE(instance_->GetNext(elementInfo, direction, elementInfo));
GTEST_LOG_(INFO) << "GetNext_002 end";
}
@@ -545,7 +545,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetChildElementInfo_001, TestSize.L
AccessibilityElementInfo parent {};
AccessibilityElementInfo child {};
int32_t index = 1;
EXPECT_EQ(instance_->GetChildElementInfo(index, parent, child), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->GetChildElementInfo(index, parent, child));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "GetChildElementInfo_001 end";
@@ -567,7 +567,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetChildElementInfo_002, TestSize.L
AccessibilityElementInfo parent {};
AccessibilityElementInfo child {};
int32_t index = 1;
EXPECT_EQ(instance_->GetChildElementInfo(index, parent, child), RET_OK);
EXPECT_TRUE(instance_->GetChildElementInfo(index, parent, child));
GTEST_LOG_(INFO) << "GetChildElementInfo_002 end";
}
@@ -588,7 +588,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetByContent_001, TestSize.Level1)
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
AccessibilityElementInfo parent {};
std::vector<AccessibilityElementInfo> elementInfos {};
EXPECT_EQ(instance_->GetByContent(parent, TEST, elementInfos), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->GetByContent(parent, TEST, elementInfos));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "GetByContent_001 end";
@@ -609,7 +609,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetByContent_002, TestSize.Level1)
}
AccessibilityElementInfo parent {};
std::vector<AccessibilityElementInfo> elementInfos {};
EXPECT_EQ(instance_->GetByContent(parent, TEST, elementInfos), RET_OK);
EXPECT_TRUE(instance_->GetByContent(parent, TEST, elementInfos));
GTEST_LOG_(INFO) << "GetByContent_002 end";
}
@@ -630,7 +630,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetSource_001, TestSize.Level1)
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
AccessibilityEventInfo eventInfo {};
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetSource(eventInfo, elementInfo), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->GetSource(eventInfo, elementInfo));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "GetSource_001 end";
@@ -651,7 +651,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetSource_002, TestSize.Level1)
}
AccessibilityEventInfo eventInfo {};
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetSource(eventInfo, elementInfo), RET_OK);
EXPECT_TRUE(instance_->GetSource(eventInfo, elementInfo));
GTEST_LOG_(INFO) << "GetSource_002 end";
}
@@ -672,7 +672,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetParentElementInfo_001, TestSize.
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
AccessibilityElementInfo child {};
AccessibilityElementInfo parent {};
EXPECT_EQ(instance_->GetParentElementInfo(child, parent), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->GetParentElementInfo(child, parent));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "GetParentElementInfo_001 end";
@@ -693,7 +693,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetParentElementInfo_002, TestSize.
}
AccessibilityElementInfo child {};
AccessibilityElementInfo parent {};
EXPECT_EQ(instance_->GetParentElementInfo(child, parent), RET_OK);
EXPECT_TRUE(instance_->GetParentElementInfo(child, parent));
GTEST_LOG_(INFO) << "GetParentElementInfo_002 end";
}
@@ -715,7 +715,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, ExecuteAction_001, TestSize.Level1)
AccessibilityElementInfo elementInfo {};
ActionType action = ACCESSIBILITY_ACTION_INVALID;
std::map<std::string, std::string> actionArguments {};
EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->ExecuteAction(elementInfo, action, actionArguments));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "ExecuteAction_001 end";
@@ -737,7 +737,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, ExecuteAction_002, TestSize.Level1)
AccessibilityElementInfo elementInfo {};
ActionType action = ACCESSIBILITY_ACTION_INVALID;
std::map<std::string, std::string> actionArguments {};
EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_OK);
EXPECT_TRUE(instance_->ExecuteAction(elementInfo, action, actionArguments));
GTEST_LOG_(INFO) << "ExecuteAction_002 end";
}
@@ -757,7 +757,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, SetTargetBundleName_001, TestSize.L
}
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(true);
std::vector<std::string> targetBundleNames;
EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_ERR_NULLPTR);
EXPECT_FALSE(instance_->SetTargetBundleName(targetBundleNames));
AccessibilityAbilityUtHelper::GetInstance().SetAbilityClientNullFlag(false);
GTEST_LOG_(INFO) << "SetTargetBundleName_001 end";
@@ -777,7 +777,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, SetTargetBundleName_002, TestSize.L
return;
}
std::vector<std::string> targetBundleNames;
EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_OK);
EXPECT_TRUE(instance_->SetTargetBundleName(targetBundleNames));
GTEST_LOG_(INFO) << "SetTargetBundleName_002 end";
}
@@ -797,7 +797,7 @@ HWTEST_F(AccessibilityUITestAbilityImplTest, GetChildren_001, TestSize.Level1)
}
AccessibilityElementInfo parent;
std::vector<AccessibilityElementInfo> children;
EXPECT_EQ(instance_->GetChildren(parent, children), RET_OK);
EXPECT_TRUE(instance_->GetChildren(parent, children));
GTEST_LOG_(INFO) << "GetChildren_001 end";
}
@@ -109,10 +109,10 @@ HWTEST_F(AccessibleAbilityChannelClientTest, SetOnKeyPressEventResult, TestSize.
HWTEST_F(AccessibleAbilityChannelClientTest, FindFocusedElementInfo_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "FindFocusedElementInfo_001 start";
EXPECT_CALL(*stub_, FindFocusedElementInfo(_, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
EXPECT_CALL(*stub_, FindFocusedElementInfo(_, _, _, _, _)).Times(1).WillOnce(Return(false));
AccessibilityElementInfo info {};
EXPECT_EQ(instance_->FindFocusedElementInfo(ACCESSIBILITY_WINDOW_ID,
ELEMENT_ID, FOCUS_TYPE_INPUT, info), RET_ERR_FAILED);
EXPECT_FALSE(instance_->FindFocusedElementInfo(ACCESSIBILITY_WINDOW_ID,
ELEMENT_ID, FOCUS_TYPE_INPUT, info));
GTEST_LOG_(INFO) << "FindFocusedElementInfo_001 end";
}
@@ -128,8 +128,7 @@ HWTEST_F(AccessibleAbilityChannelClientTest, FindFocusedElementInfo_002, TestSiz
std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
ASSERT_TRUE(client);
AccessibilityElementInfo info {};
EXPECT_EQ(client->FindFocusedElementInfo(
ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, FOCUS_TYPE_INPUT, info), RET_ERR_SAMGR);
EXPECT_FALSE(client->FindFocusedElementInfo(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, FOCUS_TYPE_INPUT, info));
GTEST_LOG_(INFO) << "FindFocusedElementInfo_002 end";
}
@@ -141,10 +140,9 @@ HWTEST_F(AccessibleAbilityChannelClientTest, FindFocusedElementInfo_002, TestSiz
HWTEST_F(AccessibleAbilityChannelClientTest, FindFocusedElementInfo_003, TestSize.Level1)
{
GTEST_LOG_(INFO) << "FindFocusedElementInfo_003 start";
EXPECT_CALL(*stub_, FindFocusedElementInfo(_, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, FindFocusedElementInfo(_, _, _, _, _)).Times(1).WillOnce(Return(true));
AccessibilityElementInfo info {};
EXPECT_EQ(instance_->FindFocusedElementInfo(
ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, FOCUS_TYPE_INPUT, info), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->FindFocusedElementInfo(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, FOCUS_TYPE_INPUT, info));
GTEST_LOG_(INFO) << "FindFocusedElementInfo_003 end";
}
@@ -156,9 +154,9 @@ HWTEST_F(AccessibleAbilityChannelClientTest, FindFocusedElementInfo_003, TestSiz
HWTEST_F(AccessibleAbilityChannelClientTest, SendSimulateGesture_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "SendSimulateGesture_001 start";
EXPECT_CALL(*stub_, SendSimulateGesture(_)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, SendSimulateGesture(_)).Times(1).WillOnce(Return(true));
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
EXPECT_EQ(instance_->SendSimulateGesture(gesturePath), RET_OK);
EXPECT_TRUE(instance_->SendSimulateGesture(gesturePath));
GTEST_LOG_(INFO) << "SendSimulateGesture_001 end";
}
@@ -174,7 +172,7 @@ HWTEST_F(AccessibleAbilityChannelClientTest, SendSimulateGesture_002, TestSize.L
std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
ASSERT_TRUE(client);
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
EXPECT_EQ(client->SendSimulateGesture(gesturePath), RET_ERR_SAMGR);
EXPECT_FALSE(client->SendSimulateGesture(gesturePath));
GTEST_LOG_(INFO) << "SendSimulateGesture_002 end";
}
@@ -186,10 +184,10 @@ HWTEST_F(AccessibleAbilityChannelClientTest, SendSimulateGesture_002, TestSize.L
HWTEST_F(AccessibleAbilityChannelClientTest, ExecuteAction_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ExecuteAction_001 start";
EXPECT_CALL(*stub_, ExecuteAction(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
EXPECT_CALL(*stub_, ExecuteAction(_, _, _, _, _, _)).Times(1).WillOnce(Return(false));
std::map<std::string, std::string> actionArguments;
EXPECT_EQ(instance_->ExecuteAction(ACCESSIBILITY_WINDOW_ID,
ELEMENT_ID, ActionType::ACCESSIBILITY_ACTION_SELECT, actionArguments), RET_ERR_FAILED);
EXPECT_FALSE(instance_->ExecuteAction(ACCESSIBILITY_WINDOW_ID,
ELEMENT_ID, ActionType::ACCESSIBILITY_ACTION_SELECT, actionArguments));
GTEST_LOG_(INFO) << "ExecuteAction_001 end";
}
@@ -205,8 +203,8 @@ HWTEST_F(AccessibleAbilityChannelClientTest, ExecuteAction_002, TestSize.Level1)
std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
ASSERT_TRUE(client);
std::map<std::string, std::string> actionArguments;
EXPECT_EQ(client->ExecuteAction(ACCESSIBILITY_WINDOW_ID,
ELEMENT_ID, ActionType::ACCESSIBILITY_ACTION_SELECT, actionArguments), RET_ERR_SAMGR);
EXPECT_FALSE(client->ExecuteAction(ACCESSIBILITY_WINDOW_ID,
ELEMENT_ID, ActionType::ACCESSIBILITY_ACTION_SELECT, actionArguments));
GTEST_LOG_(INFO) << "ExecuteAction_002 end";
}
@@ -218,10 +216,10 @@ HWTEST_F(AccessibleAbilityChannelClientTest, ExecuteAction_002, TestSize.Level1)
HWTEST_F(AccessibleAbilityChannelClientTest, ExecuteAction_003, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ExecuteAction_003 start";
EXPECT_CALL(*stub_, ExecuteAction(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, ExecuteAction(_, _, _, _, _, _)).Times(1).WillOnce(Return(true));
std::map<std::string, std::string> actionArguments;
EXPECT_EQ(instance_->ExecuteAction(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
ActionType::ACCESSIBILITY_ACTION_SELECT, actionArguments), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->ExecuteAction(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
ActionType::ACCESSIBILITY_ACTION_SELECT, actionArguments));
GTEST_LOG_(INFO) << "ExecuteAction_003 end";
}
@@ -237,7 +235,7 @@ HWTEST_F(AccessibleAbilityChannelClientTest, GetWindow_001, TestSize.Level1)
std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
ASSERT_TRUE(client);
AccessibilityWindowInfo windowInfo;
EXPECT_EQ(client->GetWindow(0, windowInfo), RET_ERR_SAMGR);
EXPECT_FALSE(client->GetWindow(0, windowInfo));
GTEST_LOG_(INFO) << "GetWindow_001 end";
}
@@ -249,9 +247,9 @@ HWTEST_F(AccessibleAbilityChannelClientTest, GetWindow_001, TestSize.Level1)
HWTEST_F(AccessibleAbilityChannelClientTest, GetWindow_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "GetWindow_002 start";
EXPECT_CALL(*stub_, GetWindow(_, _)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, GetWindow(_, _)).Times(1).WillOnce(Return(true));
AccessibilityWindowInfo windowInfo;
EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_OK);
EXPECT_TRUE(instance_->GetWindow(0, windowInfo));
GTEST_LOG_(INFO) << "GetWindow_002 end";
}
@@ -267,7 +265,7 @@ HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_001, TestSize.Level1)
std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
ASSERT_TRUE(client);
std::vector<AccessibilityWindowInfo> windowInfo {};
EXPECT_EQ(client->GetWindows(windowInfo), RET_ERR_SAMGR);
EXPECT_FALSE(client->GetWindows(windowInfo));
GTEST_LOG_(INFO) << "GetWindows_001 end";
}
@@ -279,9 +277,9 @@ HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_001, TestSize.Level1)
HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "GetWindows_002 start";
EXPECT_CALL(*stub_, GetWindows(_)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, GetWindows(_)).Times(1).WillOnce(Return(true));
std::vector<AccessibilityWindowInfo> windowInfo {};
EXPECT_EQ(instance_->GetWindows(windowInfo), RET_OK);
EXPECT_TRUE(instance_->GetWindows(windowInfo));
GTEST_LOG_(INFO) << "GetWindows_002 end";
}
@@ -297,7 +295,7 @@ HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_003, TestSize.Level1)
std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
ASSERT_TRUE(client);
std::vector<AccessibilityWindowInfo> windowInfo {};
EXPECT_EQ(client->GetWindows(0, windowInfo), RET_ERR_SAMGR);
EXPECT_FALSE(client->GetWindows(0, windowInfo));
GTEST_LOG_(INFO) << "GetWindows_003 end";
}
@@ -309,9 +307,9 @@ HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_003, TestSize.Level1)
HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_004, TestSize.Level1)
{
GTEST_LOG_(INFO) << "GetWindows_004 start";
EXPECT_CALL(*stub_, GetWindowsByDisplayId(_, _)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, GetWindowsByDisplayId(_, _)).Times(1).WillOnce(Return(true));
std::vector<AccessibilityWindowInfo> windowInfo {};
EXPECT_EQ(instance_->GetWindows(0, windowInfo), RET_OK);
EXPECT_TRUE(instance_->GetWindows(0, windowInfo));
GTEST_LOG_(INFO) << "GetWindows_004 end";
}
@@ -327,7 +325,7 @@ HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByText_001, TestS
std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
ASSERT_TRUE(client);
std::vector<AccessibilityElementInfo> infos;
EXPECT_EQ(client->SearchElementInfosByText(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, TEST, infos), RET_ERR_SAMGR);
EXPECT_FALSE(client->SearchElementInfosByText(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, TEST, infos));
GTEST_LOG_(INFO) << "SearchElementInfosByText_001 end";
}
@@ -339,9 +337,9 @@ HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByText_001, TestS
HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByText_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "SearchElementInfosByText_002 start";
EXPECT_CALL(*stub_, SearchElementInfosByText(_, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
EXPECT_CALL(*stub_, SearchElementInfosByText(_, _, _, _, _)).Times(1).WillOnce(Return(false));
std::vector<AccessibilityElementInfo> infos;
EXPECT_EQ(instance_->SearchElementInfosByText(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, TEST, infos), RET_ERR_FAILED);
EXPECT_FALSE(instance_->SearchElementInfosByText(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, TEST, infos));
GTEST_LOG_(INFO) << "SearchElementInfosByText_002 end";
}
@@ -353,9 +351,9 @@ HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByText_002, TestS
HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByText_003, TestSize.Level1)
{
GTEST_LOG_(INFO) << "SearchElementInfosByText_003 start";
EXPECT_CALL(*stub_, SearchElementInfosByText(_, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, SearchElementInfosByText(_, _, _, _, _)).Times(1).WillOnce(Return(true));
std::vector<AccessibilityElementInfo> infos;
EXPECT_EQ(instance_->SearchElementInfosByText(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, TEST, infos), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->SearchElementInfosByText(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, TEST, infos));
GTEST_LOG_(INFO) << "SearchElementInfosByText_003 end";
}
@@ -371,8 +369,7 @@ HWTEST_F(AccessibleAbilityChannelClientTest, FocusMoveSearch_001, TestSize.Level
std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
ASSERT_TRUE(client);
AccessibilityElementInfo info {};
EXPECT_EQ(client->FocusMoveSearch(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
FocusMoveDirection::DOWN, info), RET_ERR_SAMGR);
EXPECT_FALSE(client->FocusMoveSearch(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, FocusMoveDirection::DOWN, info));
GTEST_LOG_(INFO) << "FocusMoveSearch_001 end";
}
@@ -384,10 +381,9 @@ HWTEST_F(AccessibleAbilityChannelClientTest, FocusMoveSearch_001, TestSize.Level
HWTEST_F(AccessibleAbilityChannelClientTest, FocusMoveSearch_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "FocusMoveSearch_002 start";
EXPECT_CALL(*stub_, FocusMoveSearch(_, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
EXPECT_CALL(*stub_, FocusMoveSearch(_, _, _, _, _)).Times(1).WillOnce(Return(false));
AccessibilityElementInfo info {};
EXPECT_EQ(instance_->FocusMoveSearch(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
FocusMoveDirection::DOWN, info), RET_ERR_FAILED);
EXPECT_FALSE(instance_->FocusMoveSearch(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, FocusMoveDirection::DOWN, info));
GTEST_LOG_(INFO) << "FocusMoveSearch_002 end";
}
@@ -399,10 +395,9 @@ HWTEST_F(AccessibleAbilityChannelClientTest, FocusMoveSearch_002, TestSize.Level
HWTEST_F(AccessibleAbilityChannelClientTest, FocusMoveSearch_003, TestSize.Level1)
{
GTEST_LOG_(INFO) << "FocusMoveSearch_003 start";
EXPECT_CALL(*stub_, FocusMoveSearch(_, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, FocusMoveSearch(_, _, _, _, _)).Times(1).WillOnce(Return(true));
AccessibilityElementInfo info {};
EXPECT_EQ(instance_->FocusMoveSearch(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
FocusMoveDirection::DOWN, info), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->FocusMoveSearch(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, FocusMoveDirection::DOWN, info));
GTEST_LOG_(INFO) << "FocusMoveSearch_003 end";
}
@@ -418,7 +413,7 @@ HWTEST_F(AccessibleAbilityChannelClientTest, SetTargetBundleName_001, TestSize.L
std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
ASSERT_TRUE(client);
std::vector<std::string> targetBundleNames;
EXPECT_EQ(client->SetTargetBundleName(targetBundleNames), RET_ERR_SAMGR);
EXPECT_FALSE(client->SetTargetBundleName(targetBundleNames));
GTEST_LOG_(INFO) << "SetTargetBundleName_001 end";
}
@@ -430,9 +425,9 @@ HWTEST_F(AccessibleAbilityChannelClientTest, SetTargetBundleName_001, TestSize.L
HWTEST_F(AccessibleAbilityChannelClientTest, SetTargetBundleName_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "SetTargetBundleName_002 start";
EXPECT_CALL(*stub_, SetTargetBundleName(_)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, SetTargetBundleName(_)).Times(1).WillOnce(Return(true));
std::vector<std::string> targetBundleNames;
EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_OK);
EXPECT_TRUE(instance_->SetTargetBundleName(targetBundleNames));
GTEST_LOG_(INFO) << "SetTargetBundleName_002 end";
}
@@ -444,10 +439,9 @@ HWTEST_F(AccessibleAbilityChannelClientTest, SetTargetBundleName_002, TestSize.L
HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByAccessibilityId_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_001 start";
EXPECT_CALL(*stub_, SearchElementInfoByAccessibilityId(_, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
EXPECT_CALL(*stub_, SearchElementInfoByAccessibilityId(_, _, _, _, _)).Times(1).WillOnce(Return(false));
std::vector<AccessibilityElementInfo> infos;
EXPECT_EQ(instance_->SearchElementInfosByAccessibilityId(ACCESSIBILITY_WINDOW_ID,
ELEMENT_ID, MODE, infos), RET_ERR_FAILED);
EXPECT_FALSE(instance_->SearchElementInfosByAccessibilityId(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, MODE, infos));
GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_001 end";
}
@@ -463,8 +457,7 @@ HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByAccessibilityId
std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
ASSERT_TRUE(client);
std::vector<AccessibilityElementInfo> infos;
EXPECT_EQ(client->SearchElementInfosByAccessibilityId(ACCESSIBILITY_WINDOW_ID,
ELEMENT_ID, MODE, infos), RET_ERR_SAMGR);
EXPECT_FALSE(client->SearchElementInfosByAccessibilityId(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, MODE, infos));
GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_002 end";
}
@@ -476,10 +469,9 @@ HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByAccessibilityId
HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByAccessibilityId_003, TestSize.Level1)
{
GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_003 start";
EXPECT_CALL(*stub_, SearchElementInfoByAccessibilityId(_, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, SearchElementInfoByAccessibilityId(_, _, _, _, _)).Times(1).WillOnce(Return(true));
std::vector<AccessibilityElementInfo> infos;
EXPECT_EQ(instance_->SearchElementInfosByAccessibilityId(ACCESSIBILITY_WINDOW_ID,
ELEMENT_ID, MODE, infos), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->SearchElementInfosByAccessibilityId(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, MODE, infos));
GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_003 end";
}
} // namespace Accessibility
@@ -85,7 +85,7 @@ public:
void AccessibleAbilityClientImplTest::Connect()
{
EXPECT_EQ(instance_->RegisterAbilityListener(listener_), RET_OK);
EXPECT_TRUE(instance_->RegisterAbilityListener(listener_));
instance_->Init(channel_, CHANNEL_ID);
EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
}
@@ -146,7 +146,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetFocus_001, TestSize.Level1)
GTEST_LOG_(INFO) << "GetFocus_001 start";
Connect();
AccessibilityElementInfo info {};
EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE_INPUT, info), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->GetFocus(FOCUS_TYPE_INPUT, info));
GTEST_LOG_(INFO) << "GetFocus_001 end";
}
@@ -159,7 +159,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetFocus_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "GetFocus_002 start";
AccessibilityElementInfo info {};
EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE_INVALID, info), RET_ERR_INVALID_PARAM);
EXPECT_FALSE(instance_->GetFocus(FOCUS_TYPE_INVALID, info));
GTEST_LOG_(INFO) << "GetFocus_002 end";
}
@@ -172,7 +172,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetFocus_003, TestSize.Level1)
{
GTEST_LOG_(INFO) << "GetFocus_003 start";
AccessibilityElementInfo info {};
EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE_INPUT, info), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetFocus(FOCUS_TYPE_INPUT, info));
GTEST_LOG_(INFO) << "GetFocus_003 end";
}
@@ -197,8 +197,8 @@ HWTEST_F(AccessibleAbilityClientImplTest, RegisterAbilityListener_001, TestSize.
{
GTEST_LOG_(INFO) << "RegisterAbilityListener_001 start";
std::shared_ptr<AccessibleAbilityListener> listener = std::make_shared<MockAccessibleAbilityListener>();
EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_OK);
EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_ERR_REGISTER_EXIST);
EXPECT_TRUE(instance_->RegisterAbilityListener(listener));
EXPECT_FALSE(instance_->RegisterAbilityListener(listener));
GTEST_LOG_(INFO) << "RegisterAbilityListener_001 end";
}
@@ -225,7 +225,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, Init_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Init_002 start";
std::shared_ptr<AccessibleAbilityListener> listener = std::make_shared<MockAccessibleAbilityListener>();
EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_OK);
EXPECT_TRUE(instance_->RegisterAbilityListener(listener));
sptr<MockAccessibleAbilityChannelStub> stub = new MockAccessibleAbilityChannelStub();
sptr<IAccessibleAbilityChannel> channel = new MockAccessibleAbilityChannelProxy(stub->AsObject());
@@ -260,7 +260,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetFocusByElementInfo_001, TestSize.Le
Connect();
AccessibilityElementInfo sourceInfo {};
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INPUT, elementInfo), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INPUT, elementInfo));
GTEST_LOG_(INFO) << "GetFocusByElementInfo_001 end";
}
@@ -274,7 +274,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetFocusByElementInfo_002, TestSize.Le
GTEST_LOG_(INFO) << "GetFocusByElementInfo_002 start";
AccessibilityElementInfo sourceInfo {};
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INVALID, elementInfo), RET_ERR_INVALID_PARAM);
EXPECT_FALSE(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INVALID, elementInfo));
GTEST_LOG_(INFO) << "GetFocusByElementInfo_002 end";
}
@@ -288,7 +288,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetFocusByElementInfo_003, TestSize.Le
GTEST_LOG_(INFO) << "GetFocusByElementInfo_003 start";
AccessibilityElementInfo sourceInfo {};
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INPUT, elementInfo), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INPUT, elementInfo));
GTEST_LOG_(INFO) << "GetFocusByElementInfo_003 end";
}
@@ -301,7 +301,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "InjectGesture_001 start";
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_INVALID_PARAM);
EXPECT_FALSE(instance_->InjectGesture(gesturePath));
GTEST_LOG_(INFO) << "InjectGesture_001 end";
}
@@ -314,7 +314,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "InjectGesture_002 start";
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = nullptr;
EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_INVALID_PARAM);
EXPECT_FALSE(instance_->InjectGesture(gesturePath));
GTEST_LOG_(INFO) << "InjectGesture_002 end";
}
@@ -326,12 +326,12 @@ HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_002, TestSize.Level1)
HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_003, TestSize.Level1)
{
GTEST_LOG_(INFO) << "InjectGesture_003 start";
EXPECT_CALL(*stub_, SendSimulateGesture(_)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, SendSimulateGesture(_)).Times(1).WillOnce(Return(true));
Connect();
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
AccessibilityGesturePosition position;
gesturePath->AddPosition(position);
EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_OK);
EXPECT_TRUE(instance_->InjectGesture(gesturePath));
GTEST_LOG_(INFO) << "InjectGesture_003 end";
}
@@ -346,7 +346,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_004, TestSize.Level1)
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
AccessibilityGesturePosition position;
gesturePath->AddPosition(position);
EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->InjectGesture(gesturePath));
GTEST_LOG_(INFO) << "InjectGesture_004 end";
}
@@ -361,7 +361,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetRoot_001, TestSize.Level1)
Connect();
AccessibilityElementInfo info {};
instance_->SetCacheMode(0);
EXPECT_EQ(instance_->GetRoot(info), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->GetRoot(info));
GTEST_LOG_(INFO) << "GetRoot_001 end";
}
@@ -375,7 +375,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetRoot_002, TestSize.Level1)
GTEST_LOG_(INFO) << "GetRoot_002 start";
AccessibilityElementInfo info {};
instance_->SetCacheMode(INVALID_ID);
EXPECT_EQ(instance_->GetRoot(info), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetRoot(info));
GTEST_LOG_(INFO) << "GetRoot_002 end";
}
@@ -390,7 +390,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetRootByWindow_001, TestSize.Level1)
Connect();
AccessibilityElementInfo info {};
AccessibilityWindowInfo windowInfo {};
EXPECT_EQ(instance_->GetRootByWindow(windowInfo, info), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->GetRootByWindow(windowInfo, info));
GTEST_LOG_(INFO) << "GetRootByWindow_001 end";
}
@@ -405,7 +405,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetRootByWindow_002, TestSize.Level1)
GTEST_LOG_(INFO) << "GetRootByWindow_002 start";
AccessibilityElementInfo info {};
AccessibilityWindowInfo windowInfo {};
EXPECT_EQ(instance_->GetRootByWindow(windowInfo, info), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetRootByWindow(windowInfo, info));
GTEST_LOG_(INFO) << "GetRootByWindow_002 end";
}
@@ -422,7 +422,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetNext_001, TestSize.Level1)
AccessibilityElementInfo info {};
AccessibilityElementInfo nextElementInfo {};
FocusMoveDirection direction = DIRECTION_INVALID;
EXPECT_EQ(instance_->GetNext(info, direction, nextElementInfo), RET_ERR_INVALID_PARAM);
EXPECT_FALSE(instance_->GetNext(info, direction, nextElementInfo));
GTEST_LOG_(INFO) << "GetNext_001 end";
}
@@ -437,7 +437,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetNext_002, TestSize.Level1)
AccessibilityElementInfo info {};
AccessibilityElementInfo nextElementInfo {};
FocusMoveDirection direction = UP;
EXPECT_EQ(instance_->GetNext(info, direction, nextElementInfo), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetNext(info, direction, nextElementInfo));
GTEST_LOG_(INFO) << "GetNext_002 end";
}
@@ -453,7 +453,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetNext_003, TestSize.Level1)
AccessibilityElementInfo info {};
AccessibilityElementInfo nextElementInfo {};
FocusMoveDirection direction = DOWN;
EXPECT_EQ(instance_->GetNext(info, direction, nextElementInfo), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->GetNext(info, direction, nextElementInfo));
GTEST_LOG_(INFO) << "GetNext_003 end";
}
@@ -468,7 +468,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetByContent_001, TestSize.Level1)
Connect();
AccessibilityElementInfo elementInfo {};
std::vector<AccessibilityElementInfo> inelementInfosfos;
EXPECT_EQ(instance_->GetByContent(elementInfo, TEST, inelementInfosfos), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->GetByContent(elementInfo, TEST, inelementInfosfos));
GTEST_LOG_(INFO) << "GetByContent_001 end";
}
@@ -482,7 +482,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetByContent_002, TestSize.Level1)
GTEST_LOG_(INFO) << "GetByContent_002 start";
AccessibilityElementInfo elementInfo {};
std::vector<AccessibilityElementInfo> inelementInfosfos;
EXPECT_EQ(instance_->GetByContent(elementInfo, TEST, inelementInfosfos), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetByContent(elementInfo, TEST, inelementInfosfos));
GTEST_LOG_(INFO) << "GetByContent_002 end";
}
@@ -497,7 +497,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetSource_001, TestSize.Level1)
Connect();
AccessibilityEventInfo eventInfo {};
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetSource(eventInfo, elementInfo), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->GetSource(eventInfo, elementInfo));
GTEST_LOG_(INFO) << "GetSource_001 end";
}
@@ -511,7 +511,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetSource_002, TestSize.Level1)
GTEST_LOG_(INFO) << "GetSource_002 start";
AccessibilityEventInfo eventInfo {};
AccessibilityElementInfo elementInfo {};
EXPECT_EQ(instance_->GetSource(eventInfo, elementInfo), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetSource(eventInfo, elementInfo));
GTEST_LOG_(INFO) << "GetSource_002 end";
}
@@ -526,7 +526,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetParentElementInfo_001, TestSize.Lev
Connect();
AccessibilityElementInfo parent {};
AccessibilityElementInfo child {};
EXPECT_EQ(instance_->GetParentElementInfo(child, parent), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->GetParentElementInfo(child, parent));
GTEST_LOG_(INFO) << "GetParentElementInfo_001 end";
}
@@ -540,7 +540,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetParentElementInfo_002, TestSize.Lev
GTEST_LOG_(INFO) << "GetParentElementInfo_002 start";
AccessibilityElementInfo parent {};
AccessibilityElementInfo child {};
EXPECT_EQ(instance_->GetParentElementInfo(child, parent), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetParentElementInfo(child, parent));
GTEST_LOG_(INFO) << "GetParentElementInfo_002 end";
}
@@ -556,7 +556,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_001, TestSize.Level1)
AccessibilityElementInfo elementInfo {};
ActionType action = ACCESSIBILITY_ACTION_INVALID;
std::map<std::string, std::string> actionArguments {};
EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_INVALID_PARAM);
EXPECT_FALSE(instance_->ExecuteAction(elementInfo, action, actionArguments));
GTEST_LOG_(INFO) << "ExecuteAction_001 end";
}
@@ -571,7 +571,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_002, TestSize.Level1)
AccessibilityElementInfo elementInfo {};
ActionType action = ACCESSIBILITY_ACTION_SELECT;
std::map<std::string, std::string> actionArguments {};
EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->ExecuteAction(elementInfo, action, actionArguments));
GTEST_LOG_(INFO) << "ExecuteAction_002 end";
}
@@ -587,7 +587,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_003, TestSize.Level1)
AccessibilityElementInfo elementInfo {};
ActionType action = ACCESSIBILITY_ACTION_SELECT;
std::map<std::string, std::string> actionArguments {};
EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->ExecuteAction(elementInfo, action, actionArguments));
GTEST_LOG_(INFO) << "ExecuteAction_003 end";
}
@@ -599,12 +599,12 @@ HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_003, TestSize.Level1)
HWTEST_F(AccessibleAbilityClientImplTest, ResetAAClient_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ResetAAClient_001 start";
EXPECT_CALL(*stub_, GetWindows(_)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, GetWindows(_)).Times(1).WillOnce(Return(true));
Connect();
wptr<IRemoteObject> remote = nullptr;
instance_->ResetAAClient(remote);
std::vector<AccessibilityWindowInfo> infos;
EXPECT_EQ(instance_->GetWindows(infos), RET_OK);
EXPECT_TRUE(instance_->GetWindows(infos));
GTEST_LOG_(INFO) << "ResetAAClient_001 end";
}
@@ -647,10 +647,10 @@ HWTEST_F(AccessibleAbilityClientImplTest, OnKeyPressEvent_002, TestSize.Level1)
HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "GetWindows_001 start";
EXPECT_CALL(*stub_, GetWindows(_)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, GetWindows(_)).Times(1).WillOnce(Return(true));
Connect();
std::vector<AccessibilityWindowInfo> infos;
EXPECT_EQ(instance_->GetWindows(infos), RET_OK);
EXPECT_TRUE(instance_->GetWindows(infos));
GTEST_LOG_(INFO) << "GetWindows_001 end";
}
@@ -662,10 +662,10 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_001, TestSize.Level1)
HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "GetWindows_002 start";
EXPECT_CALL(*stub_, GetWindowsByDisplayId(_, _)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, GetWindowsByDisplayId(_, _)).Times(1).WillOnce(Return(true));
Connect();
std::vector<AccessibilityWindowInfo> infos;
EXPECT_EQ(instance_->GetWindows(0, infos), RET_OK);
EXPECT_TRUE(instance_->GetWindows(0, infos));
GTEST_LOG_(INFO) << "GetWindows_002 end";
}
@@ -678,7 +678,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_003, TestSize.Level1)
{
GTEST_LOG_(INFO) << "GetWindows_003 start";
std::vector<AccessibilityWindowInfo> infos;
EXPECT_EQ(instance_->GetWindows(infos), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetWindows(infos));
GTEST_LOG_(INFO) << "GetWindows_003 end";
}
@@ -691,7 +691,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_004, TestSize.Level1)
{
GTEST_LOG_(INFO) << "GetWindows_004 start";
std::vector<AccessibilityWindowInfo> infos;
EXPECT_EQ(instance_->GetWindows(0, infos), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetWindows(0, infos));
GTEST_LOG_(INFO) << "GetWindows_004 end";
}
@@ -705,7 +705,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_001, TestSize.Leve
GTEST_LOG_(INFO) << "GetChildElementInfo_001 start";
AccessibilityElementInfo parent;
AccessibilityElementInfo child;
EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetChildElementInfo(0, parent, child));
GTEST_LOG_(INFO) << "GetChildElementInfo_001 end";
}
@@ -720,7 +720,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_002, TestSize.Leve
Connect();
AccessibilityElementInfo parent;
AccessibilityElementInfo child;
EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_INVALID_PARAM);
EXPECT_FALSE(instance_->GetChildElementInfo(0, parent, child));
GTEST_LOG_(INFO) << "GetChildElementInfo_002 end";
}
@@ -737,7 +737,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_003, TestSize.Leve
AccessibilityElementInfo parent;
parent.AddChild(1);
AccessibilityElementInfo child;
EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->GetChildElementInfo(0, parent, child));
GTEST_LOG_(INFO) << "GetChildElementInfo_003 end";
}
@@ -751,7 +751,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_001, TestSize.Level1)
GTEST_LOG_(INFO) << "GetChildren_001 start";
AccessibilityElementInfo parent;
std::vector<AccessibilityElementInfo> children;
EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetChildren(parent, children));
GTEST_LOG_(INFO) << "GetChildren_001 end";
}
@@ -768,7 +768,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_002, TestSize.Level1)
AccessibilityElementInfo parent;
parent.AddChild(INVALID_CHILD_ID);
std::vector<AccessibilityElementInfo> children;
EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_INVALID_PARAM);
EXPECT_FALSE(instance_->GetChildren(parent, children));
GTEST_LOG_(INFO) << "GetChildren_002 end";
}
@@ -785,7 +785,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_003, TestSize.Level1)
AccessibilityElementInfo parent;
parent.AddChild(1);
std::vector<AccessibilityElementInfo> children;
EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_TIME_OUT);
EXPECT_FALSE(instance_->GetChildren(parent, children));
GTEST_LOG_(INFO) << "GetChildren_003 end";
}
@@ -798,7 +798,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, SetTargetBundleName_001, TestSize.Leve
{
GTEST_LOG_(INFO) << "SetTargetBundleName_001 start";
std::vector<std::string> targetBundleNames;
EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->SetTargetBundleName(targetBundleNames));
GTEST_LOG_(INFO) << "SetTargetBundleName_001 end";
}
@@ -810,10 +810,10 @@ HWTEST_F(AccessibleAbilityClientImplTest, SetTargetBundleName_001, TestSize.Leve
HWTEST_F(AccessibleAbilityClientImplTest, SetTargetBundleName_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "SetTargetBundleName_002 start";
EXPECT_CALL(*stub_, SetTargetBundleName(_)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, SetTargetBundleName(_)).Times(1).WillOnce(Return(true));
Connect();
std::vector<std::string> targetBundleNames;
EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_OK);
EXPECT_TRUE(instance_->SetTargetBundleName(targetBundleNames));
GTEST_LOG_(INFO) << "SetTargetBundleName_002 end";
}
@@ -826,7 +826,7 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetWindow_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "GetWindow_001 start";
AccessibilityWindowInfo windowInfo;
EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(instance_->GetWindow(0, windowInfo));
GTEST_LOG_(INFO) << "GetWindow_001 end";
}
@@ -838,10 +838,10 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetWindow_001, TestSize.Level1)
HWTEST_F(AccessibleAbilityClientImplTest, GetWindow_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "GetWindow_002 start";
EXPECT_CALL(*stub_, GetWindow(_, _)).Times(1).WillOnce(Return(RET_OK));
EXPECT_CALL(*stub_, GetWindow(_, _)).Times(1).WillOnce(Return(true));
Connect();
AccessibilityWindowInfo windowInfo;
EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_OK);
EXPECT_TRUE(instance_->GetWindow(0, windowInfo));
GTEST_LOG_(INFO) << "GetWindow_002 end";
}
@@ -33,18 +33,16 @@ public:
bool InitializeContext();
Accessibility::RetError SubscribeConfigObserver(const CONFIG_ID id,
const std::shared_ptr<AccessibilityConfigObserver> &observer, const bool retFlag);
Accessibility::RetError UnsubscribeConfigObserver(const CONFIG_ID id,
const std::shared_ptr<AccessibilityConfigObserver> &observer);
void SubscribeConfigObserver(const CONFIG_ID id, const std::shared_ptr<AccessibilityConfigObserver> &observer,
const bool retFlag);
void UnsubscribeConfigObserver(const CONFIG_ID id, const std::shared_ptr<AccessibilityConfigObserver> &observer);
Accessibility::RetError SubscribeEnableAbilityListsObserver(
const std::shared_ptr<AccessibilityEnableAbilityListsObserver> &observer);
Accessibility::RetError UnsubscribeEnableAbilityListsObserver(
void SubscribeEnableAbilityListsObserver(const std::shared_ptr<AccessibilityEnableAbilityListsObserver> &observer);
void UnsubscribeEnableAbilityListsObserver(
const std::shared_ptr<AccessibilityEnableAbilityListsObserver> &observer);
Accessibility::RetError EnableAbility(const std::string &name, const uint32_t capabilities);
Accessibility::RetError DisableAbility(const std::string &name);
bool EnableAbility(const std::string &name, const uint32_t capabilities);
bool DisableAbility(const std::string &name);
Accessibility::RetError SetScreenMagnificationState(const bool state);
Accessibility::RetError SetShortKeyState(const bool state);
+16 -16
View File
@@ -44,43 +44,43 @@ bool AccessibilityConfig::InitializeContext()
return pImpl_->InitializeContext();
}
Accessibility::RetError AccessibilityConfig::SubscribeConfigObserver(const CONFIG_ID id,
void AccessibilityConfig::SubscribeConfigObserver(const CONFIG_ID id,
const std::shared_ptr<AccessibilityConfigObserver> &observer, const bool retFlag)
{
CHECK_IMPL_PTR(Accessibility::RET_ERR_NULLPTR)
return pImpl_->SubscribeConfigObserver(id, observer, retFlag);
CHECK_IMPL_PTR()
pImpl_->SubscribeConfigObserver(id, observer, retFlag);
}
Accessibility::RetError AccessibilityConfig::UnsubscribeConfigObserver(const CONFIG_ID id,
void AccessibilityConfig::UnsubscribeConfigObserver(const CONFIG_ID id,
const std::shared_ptr<AccessibilityConfigObserver> &observer)
{
CHECK_IMPL_PTR(Accessibility::RET_ERR_NULLPTR)
return pImpl_->UnsubscribeConfigObserver(id, observer);
CHECK_IMPL_PTR()
pImpl_->UnsubscribeConfigObserver(id, observer);
}
Accessibility::RetError AccessibilityConfig::SubscribeEnableAbilityListsObserver(
void AccessibilityConfig::SubscribeEnableAbilityListsObserver(
const std::shared_ptr<AccessibilityEnableAbilityListsObserver> &observer)
{
CHECK_IMPL_PTR(Accessibility::RET_ERR_NULLPTR)
return pImpl_->SubscribeEnableAbilityListsObserver(observer);
CHECK_IMPL_PTR()
pImpl_->SubscribeEnableAbilityListsObserver(observer);
}
Accessibility::RetError AccessibilityConfig::UnsubscribeEnableAbilityListsObserver(
void AccessibilityConfig::UnsubscribeEnableAbilityListsObserver(
const std::shared_ptr<AccessibilityEnableAbilityListsObserver> &observer)
{
CHECK_IMPL_PTR(Accessibility::RET_ERR_NULLPTR)
return pImpl_->UnsubscribeEnableAbilityListsObserver(observer);
CHECK_IMPL_PTR()
pImpl_->UnsubscribeEnableAbilityListsObserver(observer);
}
Accessibility::RetError AccessibilityConfig::EnableAbility(const std::string &name, const uint32_t capabilities)
bool AccessibilityConfig::EnableAbility(const std::string &name, const uint32_t capabilities)
{
CHECK_IMPL_PTR(Accessibility::RET_ERR_NULLPTR)
CHECK_IMPL_PTR(false)
return pImpl_->EnableAbility(name, capabilities);
}
Accessibility::RetError AccessibilityConfig::DisableAbility(const std::string &name)
bool AccessibilityConfig::DisableAbility(const std::string &name)
{
CHECK_IMPL_PTR(Accessibility::RET_ERR_NULLPTR)
CHECK_IMPL_PTR(false)
return pImpl_->DisableAbility(name);
}
@@ -216,24 +216,24 @@ void AccessibilityConfig::Impl::ResetService(const wptr<IRemoteObject> &remote)
}
}
Accessibility::RetError AccessibilityConfig::Impl::EnableAbility(const std::string &name, const uint32_t capabilities)
bool AccessibilityConfig::Impl::EnableAbility(const std::string &name, const uint32_t capabilities)
{
HILOG_INFO("name = [%{private}s] capabilities = [%{private}u]", name.c_str(), capabilities);
std::lock_guard<std::mutex> lock(mutex_);
if (!serviceProxy_) {
HILOG_ERROR("Failed to get accessibility service");
return Accessibility::RET_ERR_SAMGR;
return false;
}
return serviceProxy_->EnableAbility(name, capabilities);
}
Accessibility::RetError AccessibilityConfig::Impl::DisableAbility(const std::string &name)
bool AccessibilityConfig::Impl::DisableAbility(const std::string &name)
{
HILOG_INFO("name = [%{private}s]", name.c_str());
std::lock_guard<std::mutex> lock(mutex_);
if (!serviceProxy_) {
HILOG_ERROR("Failed to get accessibility service");
return Accessibility::RET_ERR_SAMGR;
return false;
}
return serviceProxy_->DisableAbility(name);
}
@@ -314,7 +314,7 @@ void AccessibilityConfig::Impl::NotifyCaptionChanged(
}
}
Accessibility::RetError AccessibilityConfig::Impl::SubscribeConfigObserver(const CONFIG_ID id,
void AccessibilityConfig::Impl::SubscribeConfigObserver(const CONFIG_ID id,
const std::shared_ptr<AccessibilityConfigObserver> &observer, const bool retFlag)
{
HILOG_INFO("id = [%{public}d]", static_cast<int32_t>(id));
@@ -334,10 +334,9 @@ Accessibility::RetError AccessibilityConfig::Impl::SubscribeConfigObserver(const
if (retFlag && observer) {
NotifyImmediately(id, observer);
}
return Accessibility::RET_OK;
}
Accessibility::RetError AccessibilityConfig::Impl::UnsubscribeConfigObserver(const CONFIG_ID id,
void AccessibilityConfig::Impl::UnsubscribeConfigObserver(const CONFIG_ID id,
const std::shared_ptr<AccessibilityConfigObserver> &observer)
{
HILOG_INFO("id = [%{public}d]", static_cast<int32_t>(id));
@@ -350,13 +349,12 @@ Accessibility::RetError AccessibilityConfig::Impl::UnsubscribeConfigObserver(con
HILOG_DEBUG("erase observer");
it->second.erase(iter);
HILOG_DEBUG("observer's size is %{public}zu", it->second.size());
return Accessibility::RET_OK;
return;
}
}
} else {
HILOG_DEBUG("%{public}d has not subscribed ", id);
}
return Accessibility::RET_OK;
}
void AccessibilityConfig::Impl::OnAccessibleAbilityManagerCaptionPropertyChanged(const CaptionProperty& property)
@@ -1053,7 +1051,7 @@ Accessibility::RetError AccessibilityConfig::Impl::GetAudioBalance(float &balanc
return ret;
}
Accessibility::RetError AccessibilityConfig::Impl::SubscribeEnableAbilityListsObserver(
void AccessibilityConfig::Impl::SubscribeEnableAbilityListsObserver(
const std::shared_ptr<AccessibilityEnableAbilityListsObserver> &observer)
{
HILOG_INFO();
@@ -1063,14 +1061,13 @@ Accessibility::RetError AccessibilityConfig::Impl::SubscribeEnableAbilityListsOb
return listObserver == observer;
})) {
HILOG_ERROR("the observer is exist");
return Accessibility::RET_OK;
return;
}
enableAbilityListsObservers_.push_back(observer);
HILOG_DEBUG("observer's size is %{public}zu", enableAbilityListsObservers_.size());
return Accessibility::RET_OK;
}
Accessibility::RetError AccessibilityConfig::Impl::UnsubscribeEnableAbilityListsObserver(
void AccessibilityConfig::Impl::UnsubscribeEnableAbilityListsObserver(
const std::shared_ptr<AccessibilityEnableAbilityListsObserver> &observer)
{
HILOG_INFO();
@@ -1080,10 +1077,9 @@ Accessibility::RetError AccessibilityConfig::Impl::UnsubscribeEnableAbilityLists
HILOG_DEBUG("erase observer");
enableAbilityListsObservers_.erase(iter);
HILOG_DEBUG("observer's size is %{public}zu", enableAbilityListsObservers_.size());
return Accessibility::RET_OK;
return;
}
}
return Accessibility::RET_OK;
}
void AccessibilityConfig::Impl::OnAccessibilityEnableAbilityListsChanged()
@@ -791,6 +791,7 @@ HWTEST_F(AccessibilityConfigImplTest, UnsubscribeEnableAbilityListsObserver_001,
GTEST_LOG_(INFO) << "UnsubscribeEnableAbilityListsObserver_001 end";
}
/**
* @tc.number: EnableAbility_001
* @tc.name: EnableAbility_001
@@ -803,7 +804,7 @@ HWTEST_F(AccessibilityConfigImplTest, EnableAbility_001, TestSize.Level1)
std::string name = "test";
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
instance.InitializeContext();
EXPECT_EQ(Accessibility::RET_OK, instance.EnableAbility(name, 0));
EXPECT_TRUE(instance.EnableAbility(name, 0));
sleep(1);
GTEST_LOG_(INFO) << "EnableAbility_001 end";
}
@@ -820,7 +821,7 @@ HWTEST_F(AccessibilityConfigImplTest, DisableAbility_001, TestSize.Level1)
std::string name = "test";
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
instance.InitializeContext();
EXPECT_EQ(Accessibility::RET_OK, instance.DisableAbility(name));
EXPECT_TRUE(instance.DisableAbility(name));
GTEST_LOG_(INFO) << "DisableAbility_001 end";
}
} // namespace AccessibilityConfig
@@ -45,31 +45,28 @@ public:
* @brief Register the element operator, so the AA can get node info from ACE.
* @param windowId Window ID
* @param operation The callback object.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return 0: Succeed ; otherwise is failed.
*/
virtual RetError RegisterElementOperator(const int32_t windowId,
virtual int32_t RegisterElementOperator(const int32_t windowId,
const std::shared_ptr<AccessibilityElementOperator> &operation) override;
/**
* @brief Deregister the element operator.
* @param windowId Window ID
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
virtual RetError DeregisterElementOperator(const int32_t windowId) override;
virtual void DeregisterElementOperator(const int32_t windowId) override;
/**
* @brief Checks whether accessibility ability is enabled.
* @param isEnabled true: enabled; false: disabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: enabled; false: disabled
*/
virtual RetError IsEnabled(bool &isEnabled) override;
virtual bool IsEnabled() override;
/**
* @brief Checks whether touch exploration ability is enabled.
* @param isEnabled true: enabled; false: disabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: enabled; false: disabled
*/
virtual RetError IsTouchExplorationEnabled(bool &isEnabled) override;
virtual bool IsTouchExplorationEnabled() override;
/**
* @brief Queries the list of accessibility abilities.
@@ -79,51 +76,51 @@ public:
* 2 indicates that the ability is disabled;
* 3 indicates that the ability has been installed.
* @param infos accessibility ability infos by specified types.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return Return true if get ability lists successfully, else return false.
*/
virtual RetError GetAbilityList(const uint32_t accessibilityAbilityTypes, const AbilityStateType stateType,
virtual bool GetAbilityList(const uint32_t accessibilityAbilityTypes, const AbilityStateType stateType,
std::vector<AccessibilityAbilityInfo> &infos) override;
/**
* @brief Sends an accessibility event.
* @param eventType Identifies the accessibility event specified by AccessibilityEventInfo.
* @param componentId Indicates the ID of the component to be associated with the event.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: send ok; otherwise is refused.
*/
virtual RetError SendEvent(const EventType eventType, const int32_t componentId) override;
virtual bool SendEvent(const EventType eventType, const int32_t componentId) override;
/**
* @brief Sends information about an accessibility event.
* @param event Indicates the accessibility event information specified by AccessibilityEventInfo.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: send ok; otherwise is refused.
*/
virtual RetError SendEvent(const AccessibilityEventInfo &event) override;
virtual bool SendEvent(const AccessibilityEventInfo &event) override;
/**
* @brief Subscribes to the specified type of accessibility status change events.
* @param observer Indicates the observer for listening to status events, which is specified
* by AccessibilityStateObserver.
* @param eventType Indicates the status type, which is specified by AccessibilityStateEventType.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: send ok; otherwise is refused.
*/
virtual RetError SubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer,
virtual bool SubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer,
const uint32_t eventType) override;
/**
* @brief Unsubscribe the specified type of accessibility status change events.
* @param observer Indicates the registered accessibility status event observer.
* @param eventType Indicates the status type, which is specified by AccessibilityStateEventType.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: send ok; otherwise is refused.
*/
virtual RetError UnsubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer,
virtual bool UnsubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer,
const uint32_t eventType) override;
/**
* @brief Get enabled abilities.
* @param enabledAbilities The infos of enabled abilities.
* @return Return RET_OK if successful, otherwise refer to the RetError for the failure.
* @return Return true if get enabled abilities successfully, else return false.
*/
virtual RetError GetEnabledAbilities(std::vector<std::string> &enabledAbilities) override;
virtual bool GetEnabledAbilities(std::vector<std::string> &enabledAbilities) override;
/**
* @brief Clean the AAMS object data.
@@ -42,8 +42,6 @@ std::shared_ptr<AccessibilitySystemAbilityClient> AccessibilitySystemAbilityClie
AccessibilitySystemAbilityClientImpl::AccessibilitySystemAbilityClientImpl()
{
HILOG_DEBUG();
stateArray_.fill(false);
if (!ConnectToService()) {
HILOG_ERROR("Failed to connect to aams service");
return;
@@ -58,7 +56,6 @@ AccessibilitySystemAbilityClientImpl::~AccessibilitySystemAbilityClientImpl()
bool AccessibilitySystemAbilityClientImpl::ConnectToService()
{
HILOG_DEBUG();
if (serviceProxy_) {
HILOG_DEBUG("AAMS Service is connected");
return true;
@@ -134,73 +131,70 @@ void AccessibilitySystemAbilityClientImpl::ResetService(const wptr<IRemoteObject
}
}
RetError AccessibilitySystemAbilityClientImpl::RegisterElementOperator(
int32_t AccessibilitySystemAbilityClientImpl::RegisterElementOperator(
const int32_t windowId, const std::shared_ptr<AccessibilityElementOperator> &operation)
{
HILOG_INFO("Register windowId[%{public}d] start", windowId);
std::lock_guard<std::mutex> lock(mutex_);
if (!operation) {
HILOG_ERROR("Input operation is null");
return RET_ERR_INVALID_PARAM;
return -1;
}
if (!serviceProxy_) {
HILOG_ERROR("Failed to get aams service");
return RET_ERR_SAMGR;
return -1;
}
auto iter = elementOperators_.find(windowId);
if (iter != elementOperators_.end()) {
HILOG_ERROR("windowID[%{public}d] is exited", windowId);
return RET_ERR_CONNECTION_EXIST;
return 0;
}
sptr<AccessibilityElementOperatorImpl> aamsInteractionOperator =
new(std::nothrow) AccessibilityElementOperatorImpl(windowId, operation, *this);
if (!aamsInteractionOperator) {
HILOG_ERROR("Failed to create aamsInteractionOperator.");
return RET_ERR_NULLPTR;
return -1;
}
elementOperators_[windowId] = aamsInteractionOperator;
return serviceProxy_->RegisterElementOperator(windowId, aamsInteractionOperator);
serviceProxy_->RegisterElementOperator(windowId, aamsInteractionOperator);
return 0;
}
RetError AccessibilitySystemAbilityClientImpl::DeregisterElementOperator(const int32_t windowId)
void AccessibilitySystemAbilityClientImpl::DeregisterElementOperator(const int32_t windowId)
{
HILOG_INFO("Deregister windowId[%{public}d] start", windowId);
std::lock_guard<std::mutex> lock(mutex_);
if (!serviceProxy_) {
HILOG_ERROR("Failed to get aams service");
return RET_ERR_SAMGR;
return;
}
serviceProxy_->DeregisterElementOperator(windowId);
auto iter = elementOperators_.find(windowId);
if (iter != elementOperators_.end()) {
HILOG_DEBUG("windowID[%{public}d] is erase", windowId);
elementOperators_.erase(iter);
} else {
HILOG_WARN("Not find windowID[%{public}d]", windowId);
return RET_ERR_NO_REGISTER;
return;
}
return serviceProxy_->DeregisterElementOperator(windowId);
HILOG_DEBUG("Not find windowID[%{public}d]", windowId);
}
RetError AccessibilitySystemAbilityClientImpl::IsEnabled(bool &isEnabled)
bool AccessibilitySystemAbilityClientImpl::IsEnabled()
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
isEnabled = stateArray_[AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED];
return RET_OK;
return stateArray_[AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED];
}
RetError AccessibilitySystemAbilityClientImpl::IsTouchExplorationEnabled(bool &isEnabled)
bool AccessibilitySystemAbilityClientImpl::IsTouchExplorationEnabled()
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
isEnabled = stateArray_[AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED];
return RET_OK;
return stateArray_[AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED];
}
RetError AccessibilitySystemAbilityClientImpl::GetAbilityList(const uint32_t accessibilityAbilityTypes,
bool AccessibilitySystemAbilityClientImpl::GetAbilityList(const uint32_t accessibilityAbilityTypes,
const AbilityStateType stateType, std::vector<AccessibilityAbilityInfo> &infos)
{
HILOG_DEBUG();
@@ -219,11 +213,11 @@ RetError AccessibilitySystemAbilityClientImpl::GetAbilityList(const uint32_t acc
if (!check) {
HILOG_ERROR("Invalid params: accessibilityAbilityTypes[%{public}d] stateType[%{public}d]",
accessibilityAbilityTypes, stateType);
return RET_ERR_INVALID_PARAM;
return false;
}
if (!serviceProxy_) {
HILOG_ERROR("Failed to get aams service");
return RET_ERR_SAMGR;
return false;
}
return serviceProxy_->GetAbilityList(accessibilityAbilityTypes, stateType, infos);
}
@@ -239,85 +233,87 @@ bool AccessibilitySystemAbilityClientImpl::CheckEventType(EventType eventType)
}
}
RetError AccessibilitySystemAbilityClientImpl::SendEvent(const EventType eventType, const int32_t componentId)
bool AccessibilitySystemAbilityClientImpl::SendEvent(const EventType eventType, const int32_t componentId)
{
HILOG_DEBUG("componentId[%{public}d], eventType[%{public}d]", componentId, eventType);
std::lock_guard<std::mutex> lock(mutex_);
if (!CheckEventType(eventType)) {
return RET_ERR_INVALID_PARAM;
return false;
}
AccessibilityEventInfo event;
event.SetEventType(eventType);
event.SetSource(componentId);
if (!serviceProxy_) {
HILOG_ERROR("Failed to get aams service");
return RET_ERR_SAMGR;
return false;
}
return serviceProxy_->SendEvent(event);
serviceProxy_->SendEvent(event);
return true;
}
RetError AccessibilitySystemAbilityClientImpl::SendEvent(const AccessibilityEventInfo &event)
bool AccessibilitySystemAbilityClientImpl::SendEvent(const AccessibilityEventInfo &event)
{
HILOG_DEBUG("EventType[%{public}d]", event.GetEventType());
std::lock_guard<std::mutex> lock(mutex_);
if (!CheckEventType(event.GetEventType())) {
return RET_ERR_INVALID_PARAM;
return false;
}
if (!serviceProxy_) {
HILOG_ERROR("Failed to get aams service");
return RET_ERR_SAMGR;
return false;
}
return serviceProxy_->SendEvent(event);
serviceProxy_->SendEvent(event);
return true;
}
RetError AccessibilitySystemAbilityClientImpl::SubscribeStateObserver(
bool AccessibilitySystemAbilityClientImpl::SubscribeStateObserver(
const std::shared_ptr<AccessibilityStateObserver> &observer, const uint32_t eventType)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
if (eventType >= AccessibilityStateEventType::EVENT_TYPE_MAX) {
HILOG_ERROR("Input eventType is out of scope");
return RET_ERR_INVALID_PARAM;
return false;
}
if (!observer) {
HILOG_ERROR("Input observer is null");
return RET_ERR_INVALID_PARAM;
return false;
}
StateObserverVector &observerVector = stateObserversArray_[eventType];
for (auto iter = observerVector.begin(); iter != observerVector.end(); ++iter) {
if (*iter == observer) {
HILOG_INFO("Observer has subscribed!");
return RET_ERR_REGISTER_EXIST;
return true;
}
}
observerVector.push_back(observer);
return RET_OK;
return true;
}
RetError AccessibilitySystemAbilityClientImpl::UnsubscribeStateObserver(
bool AccessibilitySystemAbilityClientImpl::UnsubscribeStateObserver(
const std::shared_ptr<AccessibilityStateObserver> &observer, const uint32_t eventType)
{
HILOG_DEBUG("eventType is [%{public}d]", eventType);
std::lock_guard<std::mutex> lock(mutex_);
if (eventType >= AccessibilityStateEventType::EVENT_TYPE_MAX) {
HILOG_ERROR("Input eventType is out of scope");
return RET_ERR_INVALID_PARAM;
return false;
}
if (!observer) {
HILOG_ERROR("Input observer is null");
return RET_ERR_INVALID_PARAM;
return false;
}
StateObserverVector &observerVector = stateObserversArray_[eventType];
for (auto iter = observerVector.begin(); iter != observerVector.end(); ++iter) {
if (*iter == observer) {
observerVector.erase(iter);
return RET_OK;
return true;
}
}
HILOG_ERROR("The observer has not subscribed.");
return RET_ERR_NO_REGISTER;
return false;
}
void AccessibilitySystemAbilityClientImpl::NotifyStateChanged(uint32_t eventType, bool value)
@@ -345,13 +341,13 @@ void AccessibilitySystemAbilityClientImpl::NotifyStateChanged(uint32_t eventType
HILOG_DEBUG("end");
}
RetError AccessibilitySystemAbilityClientImpl::GetEnabledAbilities(std::vector<std::string> &enabledAbilities)
bool AccessibilitySystemAbilityClientImpl::GetEnabledAbilities(std::vector<std::string> &enabledAbilities)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(mutex_);
if (!serviceProxy_) {
HILOG_ERROR("Failed to get aams service");
return RET_ERR_SAMGR;
return false;
}
return serviceProxy_->GetEnabledAbilities(enabledAbilities);
}
@@ -71,7 +71,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, RegisterElementOperator_001,
GTEST_LOG_(INFO) << "Cann't get AccessibilitySystemAbilityClientImpl impl_";
return;
}
EXPECT_EQ(RET_ERR_INVALID_PARAM, impl_->RegisterElementOperator(WINDOW_ID, nullptr));
EXPECT_EQ(-1, impl_->RegisterElementOperator(WINDOW_ID, nullptr));
impl_ = nullptr;
GTEST_LOG_(INFO) << "RegisterElementOperator_001 end";
}
@@ -90,7 +90,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, RegisterElementOperator_002,
return;
}
std::shared_ptr<AccessibilityElementOperator> mockOperator = std::make_shared<MockAccessibilityElementOperator>();
EXPECT_EQ(RET_ERR_SAMGR, impl_->RegisterElementOperator(WINDOW_ID, mockOperator));
EXPECT_EQ(-1, impl_->RegisterElementOperator(WINDOW_ID, mockOperator));
impl_ = nullptr;
GTEST_LOG_(INFO) << "RegisterElementOperator_002 end";
}
@@ -111,7 +111,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, RegisterElementOperator_003,
return;
}
std::shared_ptr<AccessibilityElementOperator> mockOperator = std::make_shared<MockAccessibilityElementOperator>();
EXPECT_EQ(RET_OK, impl_->RegisterElementOperator(WINDOW_ID, mockOperator));
EXPECT_EQ(0, impl_->RegisterElementOperator(WINDOW_ID, mockOperator));
impl_ = nullptr;
GTEST_LOG_(INFO) << "RegisterElementOperator_003 end";
}
@@ -132,8 +132,8 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, RegisterElementOperator_004,
return;
}
std::shared_ptr<AccessibilityElementOperator> mockOperator = std::make_shared<MockAccessibilityElementOperator>();
EXPECT_EQ(RET_OK, impl_->RegisterElementOperator(WINDOW_ID, mockOperator));
EXPECT_EQ(RET_ERR_CONNECTION_EXIST, impl_->RegisterElementOperator(WINDOW_ID, mockOperator));
EXPECT_EQ(0, impl_->RegisterElementOperator(WINDOW_ID, mockOperator));
EXPECT_EQ(0, impl_->RegisterElementOperator(WINDOW_ID, mockOperator));
impl_ = nullptr;
GTEST_LOG_(INFO) << "RegisterElementOperator_004 end";
}
@@ -151,7 +151,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, DeregisterElementOperator_001
GTEST_LOG_(INFO) << "Cann't get AccessibilitySystemAbilityClientImpl impl_";
return;
}
EXPECT_EQ(RET_ERR_SAMGR, impl_->DeregisterElementOperator(WINDOW_ID));
impl_->DeregisterElementOperator(WINDOW_ID);
impl_ = nullptr;
GTEST_LOG_(INFO) << "DeregisterElementOperator_001 end";
}
@@ -172,8 +172,8 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, DeregisterElementOperator_002
return;
}
std::shared_ptr<AccessibilityElementOperator> mockOperator = std::make_shared<MockAccessibilityElementOperator>();
EXPECT_EQ(RET_OK, impl_->RegisterElementOperator(WINDOW_ID, mockOperator));
EXPECT_EQ(RET_OK, impl_->DeregisterElementOperator(WINDOW_ID));
EXPECT_EQ(0, impl_->RegisterElementOperator(WINDOW_ID, mockOperator));
impl_->DeregisterElementOperator(WINDOW_ID);
impl_ = nullptr;
GTEST_LOG_(INFO) << "DeregisterElementOperator_002 end";
}
@@ -193,8 +193,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, GetAbilityList_001, TestSize.
}
std::vector<AccessibilityAbilityInfo> infos {};
auto ret = impl_->GetAbilityList(ACCESSIBILITY_ABILITY_TYPE_ALL, ABILITY_STATE_INVALID, infos);
EXPECT_EQ(RET_ERR_INVALID_PARAM, ret);
EXPECT_FALSE(impl_->GetAbilityList(ACCESSIBILITY_ABILITY_TYPE_ALL, ABILITY_STATE_INVALID, infos));
impl_ = nullptr;
GTEST_LOG_(INFO) << "GetAbilityList_001 end";
}
@@ -214,8 +213,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, GetAbilityList_002, TestSize.
}
std::vector<AccessibilityAbilityInfo> infos {};
auto ret = impl_->GetAbilityList(ACCESSIBILITY_ABILITY_TYPE_ALL, ABILITY_STATE_ENABLE, infos);
EXPECT_EQ(RET_ERR_SAMGR, ret);
EXPECT_FALSE(impl_->GetAbilityList(ACCESSIBILITY_ABILITY_TYPE_ALL, ABILITY_STATE_ENABLE, infos));
impl_ = nullptr;
GTEST_LOG_(INFO) << "GetAbilityList_002 end";
}
@@ -237,8 +235,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, GetAbilityList_003, TestSize.
}
std::vector<AccessibilityAbilityInfo> infos {};
auto ret = impl_->GetAbilityList(ACCESSIBILITY_ABILITY_TYPE_ALL, ABILITY_STATE_ENABLE, infos);
EXPECT_EQ(RET_OK, ret);
EXPECT_TRUE(impl_->GetAbilityList(ACCESSIBILITY_ABILITY_TYPE_ALL, ABILITY_STATE_ENABLE, infos));
impl_ = nullptr;
GTEST_LOG_(INFO) << "GetAbilityList_003 end";
}
@@ -256,9 +253,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, IsEnabled_001, TestSize.Level
GTEST_LOG_(INFO) << "Cann't get AccessibilitySystemAbilityClientImpl impl_";
return;
}
bool isEnable = false;
impl_->IsEnabled(isEnable);
EXPECT_FALSE(isEnable);
EXPECT_FALSE(impl_->IsEnabled());
impl_ = nullptr;
GTEST_LOG_(INFO) << "IsEnabled_001 end";
}
@@ -276,9 +271,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, IsTouchExplorationEnabled_001
GTEST_LOG_(INFO) << "Cann't get AccessibilitySystemAbilityClientImpl impl_";
return;
}
bool isEnable = false;
impl_->IsTouchExplorationEnabled(isEnable);
EXPECT_FALSE(isEnable);
EXPECT_FALSE(impl_->IsTouchExplorationEnabled());
impl_ = nullptr;
GTEST_LOG_(INFO) << "IsTouchExplorationEnabled_001 end";
}
@@ -296,7 +289,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, SendEvent_001, TestSize.Level
GTEST_LOG_(INFO) << "Cann't get AccessibilitySystemAbilityClientImpl impl_";
return;
}
EXPECT_EQ(RET_ERR_SAMGR, impl_->SendEvent(TYPE_VIEW_LONG_CLICKED_EVENT, COMPONENT_ID));
EXPECT_FALSE(impl_->SendEvent(TYPE_VIEW_LONG_CLICKED_EVENT, COMPONENT_ID));
impl_ = nullptr;
GTEST_LOG_(INFO) << "SendEvent_001 end";
}
@@ -314,7 +307,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, SendEvent_002, TestSize.Level
GTEST_LOG_(INFO) << "Cann't get AccessibilitySystemAbilityClientImpl impl_";
return;
}
EXPECT_EQ(RET_ERR_INVALID_PARAM, impl_->SendEvent(TYPE_VIEW_INVALID, COMPONENT_ID));
EXPECT_FALSE(impl_->SendEvent(TYPE_VIEW_INVALID, COMPONENT_ID));
impl_ = nullptr;
GTEST_LOG_(INFO) << "SendEvent_002 end";
}
@@ -334,7 +327,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, SendEvent_003, TestSize.Level
GTEST_LOG_(INFO) << "Cann't get AccessibilitySystemAbilityClientImpl impl_";
return;
}
EXPECT_EQ(RET_OK, impl_->SendEvent(TYPE_VIEW_LONG_CLICKED_EVENT, COMPONENT_ID));
EXPECT_TRUE(impl_->SendEvent(TYPE_VIEW_LONG_CLICKED_EVENT, COMPONENT_ID));
impl_ = nullptr;
GTEST_LOG_(INFO) << "SendEvent_003 end";
}
@@ -354,7 +347,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, SendEvent_004, TestSize.Level
}
AccessibilityEventInfo event {};
event.SetEventType(TYPE_VIEW_LONG_CLICKED_EVENT);
EXPECT_EQ(RET_ERR_SAMGR, impl_->SendEvent(event));
EXPECT_FALSE(impl_->SendEvent(event));
impl_ = nullptr;
GTEST_LOG_(INFO) << "SendEvent_004 end";
}
@@ -374,7 +367,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, SendEvent_005, TestSize.Level
}
AccessibilityEventInfo event {};
event.SetEventType(TYPE_VIEW_INVALID);
EXPECT_EQ(RET_ERR_INVALID_PARAM, impl_->SendEvent(event));
EXPECT_FALSE(impl_->SendEvent(event));
impl_ = nullptr;
GTEST_LOG_(INFO) << "SendEvent_005 end";
}
@@ -396,7 +389,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, SendEvent_006, TestSize.Level
}
AccessibilityEventInfo event {};
event.SetEventType(TYPE_VIEW_LONG_CLICKED_EVENT);
EXPECT_EQ(RET_OK, impl_->SendEvent(event));
EXPECT_TRUE(impl_->SendEvent(event));
impl_ = nullptr;
GTEST_LOG_(INFO) << "SendEvent_006 end";
}
@@ -414,7 +407,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, SubscribeStateObserver_001, T
GTEST_LOG_(INFO) << "Cann't get AccessibilitySystemAbilityClientImpl impl_";
return;
}
EXPECT_EQ(RET_ERR_INVALID_PARAM, impl_->SubscribeStateObserver(nullptr, EVENT_TOUCH_GUIDE_STATE_CHANGED));
EXPECT_FALSE(impl_->SubscribeStateObserver(nullptr, EVENT_TOUCH_GUIDE_STATE_CHANGED));
impl_ = nullptr;
GTEST_LOG_(INFO) << "SubscribeStateObserver_001 end";
}
@@ -432,7 +425,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, SubscribeStateObserver_002, T
GTEST_LOG_(INFO) << "Cann't get AccessibilitySystemAbilityClientImpl impl_";
return;
}
EXPECT_EQ(RET_ERR_INVALID_PARAM, impl_->SubscribeStateObserver(nullptr, EVENT_TYPE_MAX));
EXPECT_FALSE(impl_->SubscribeStateObserver(nullptr, EVENT_TYPE_MAX));
impl_ = nullptr;
GTEST_LOG_(INFO) << "SubscribeStateObserver_002 end";
}
@@ -450,7 +443,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, UnsubscribeStateObserver_001,
GTEST_LOG_(INFO) << "Cann't get AccessibilitySystemAbilityClientImpl impl_";
return;
}
EXPECT_EQ(RET_ERR_INVALID_PARAM, impl_->UnsubscribeStateObserver(nullptr, EVENT_TYPE_MAX));
EXPECT_FALSE(impl_->UnsubscribeStateObserver(nullptr, EVENT_TYPE_MAX));
impl_ = nullptr;
GTEST_LOG_(INFO) << "UnsubscribeStateObserver_001 end";
}
@@ -468,7 +461,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, UnsubscribeStateObserver_002,
GTEST_LOG_(INFO) << "Cann't get AccessibilitySystemAbilityClientImpl impl_";
return;
}
EXPECT_EQ(RET_ERR_INVALID_PARAM, impl_->UnsubscribeStateObserver(nullptr, EVENT_KEVEVENT_STATE_CHANGED));
EXPECT_FALSE(impl_->UnsubscribeStateObserver(nullptr, EVENT_KEVEVENT_STATE_CHANGED));
impl_ = nullptr;
GTEST_LOG_(INFO) << "UnsubscribeStateObserver_002 end";
}
@@ -545,7 +538,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, GetEnabledAbilities_001, Test
return;
}
std::vector<std::string> enabledAbilities;
EXPECT_EQ(RET_ERR_SAMGR, impl_->GetEnabledAbilities(enabledAbilities));
EXPECT_FALSE(impl_->GetEnabledAbilities(enabledAbilities));
impl_ = nullptr;
GTEST_LOG_(INFO) << "GetEnabledAbilities_001 end";
}
@@ -566,7 +559,7 @@ HWTEST_F(AccessibilitySystemAbilityClientImplTest, GetEnabledAbilities_002, Test
return;
}
std::vector<std::string> enabledAbilities;
EXPECT_EQ(RET_OK, impl_->GetEnabledAbilities(enabledAbilities));
EXPECT_TRUE(impl_->GetEnabledAbilities(enabledAbilities));
impl_ = nullptr;
GTEST_LOG_(INFO) << "GetEnabledAbilities_002 end";
}
@@ -72,14 +72,14 @@ void AccessibilityWindowInfo::SetRectInScreen(const Rect &bounds)
bool AccessibilityWindowInfo::IsActive() const
{
HILOG_DEBUG("active_[%{public}d] windowId_[%{public}d]", active_, windowId_);
HILOG_DEBUG("active_[%{public}d]", active_);
return active_;
}
void AccessibilityWindowInfo::SetActive(bool active)
{
active_ = active;
HILOG_DEBUG("active_[%{public}d] windowId_[%{public}d]", active_, windowId_);
HILOG_DEBUG("active_[%{public}d]", active_);
}
bool AccessibilityWindowInfo::IsFocused() const
@@ -40,96 +40,94 @@ public:
/**
* @brief Register ability listener.
* @param listener The listener to add.
* @return Return RET_OK if registers listener successfully, otherwise refer to the RetError for the failure.
* @return Return true if registers listener successfully, else return false.
*/
virtual RetError RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener) = 0;
virtual bool RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener) = 0;
/**
* @brief Connect to AAMS. For UI test.
* @return Return RET_OK if the command of connection is sent successfully,
* otherwise refer to the RetError for the failure.
* @return Return RET_OK if the command of connection is sent successfully.
*/
virtual RetError Connect() = 0;
/**
* @brief disconnect to AAMS. For UI test.
* @return Return RET_OK if the command of disconnect is sent successfully,
* otherwise refer to the RetError for the failure.
* @return Return true if the command of disconnect is sent successfully, else return false.
*/
virtual RetError Disconnect() = 0;
virtual bool Disconnect() = 0;
/**
* @brief Obtains elementInfo of focus.
* @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
* @param elementInfo The accessibilityElementInfo of focus.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo) = 0;
virtual bool GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo) = 0;
/**
* @brief Obtains elementInfo of focus.
* @param sourceInfo The source info to get focus.
* @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
* @param elementInfo The accessibilityElementInfo of focus.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType,
virtual bool GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType,
AccessibilityElementInfo &elementInfo) = 0;
/**
* @brief Sends simulate gestures to the screen.
* @param gesturePath The gesture which need to send.
* @return Return RET_OK if the gesture sends successfully, otherwise refer to the RetError for the failure.
* @return Return true if the gesture sends successfully, else return false.
*/
virtual RetError InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath) = 0;
virtual bool InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath) = 0;
/**
* @brief Obtains elementInfo of the accessible root node.
* @param elementInfo The elementInfo of the accessible root node.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetRoot(AccessibilityElementInfo &elementInfo) = 0;
virtual bool GetRoot(AccessibilityElementInfo &elementInfo) = 0;
/**
* @brief Obtains elementInfo of the accessible root node.
* @param windowInfo The source window info to get root.
* @param elementInfo The elementInfo of the accessible root node.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
virtual bool GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
AccessibilityElementInfo &elementInfo) = 0;
/**
* @brief Get the window information related with the event
* @param windowId The window id.
* @param windowInfo The window information.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) = 0;
virtual bool GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) = 0;
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows) = 0;
virtual bool GetWindows(std::vector<AccessibilityWindowInfo> &windows) = 0;
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param displayId the id of display
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) = 0;
virtual bool GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) = 0;
/**
* @brief Gets the next focused node in the specified direction of the currently focused node.
* @param elementInfo The source info to get next info.
* @param direction Indicates the direction to obtain the next focused node. Refer to FocusMoveDirection
* @param nextElementInfo The info of next element.
* @return Return RET_OK if gets next elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets next elementInfo successfully, else return false.
*/
virtual RetError GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction,
virtual bool GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction,
AccessibilityElementInfo &nextElementInfo) = 0;
/**
@@ -137,18 +135,18 @@ public:
* @param index The index of the child.
* @param parent The parent info to get child.
* @param child The element info of child.
* @return Return RET_OK if gets child elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets child elementInfo successfully, else return false.
*/
virtual RetError GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
virtual bool GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
AccessibilityElementInfo &child) = 0;
/**
* @brief Get the children node information
* @param parent The parent info to get children.
* @param children The element info of children.
* @return Return RET_OK if gets children elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets children elementInfo successfully, else return false.
*/
virtual RetError GetChildren(const AccessibilityElementInfo &parent,
virtual bool GetChildren(const AccessibilityElementInfo &parent,
std::vector<AccessibilityElementInfo> &children) = 0;
/**
@@ -156,26 +154,26 @@ public:
* @param elementInfo The source info.
* @param text specified content
* @param elementInfos The element infos of specified content.
* @return Return RET_OK if gets elementInfos successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets elementInfos successfully, else return false.
*/
virtual RetError GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
virtual bool GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
std::vector<AccessibilityElementInfo> &elementInfos) = 0;
/**
* @brief Get the node information related with the event
* @param eventInfo The source info to get source.
* @param elementInfo The element info of source.
* @return Return RET_OK if gets elementInfos successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets elementInfos successfully, else return false.
*/
virtual RetError GetSource(const AccessibilityEventInfo &eventInfo, AccessibilityElementInfo &elementInfo) = 0;
virtual bool GetSource(const AccessibilityEventInfo &eventInfo, AccessibilityElementInfo &elementInfo) = 0;
/**
* @brief Get Parent node information
* @param child The child element info to get parent.
* @param parent The parent element info.
* @return Return RET_OK if gets info successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets info successfully, else return false.
*/
virtual RetError GetParentElementInfo(const AccessibilityElementInfo &child, AccessibilityElementInfo &parent) = 0;
virtual bool GetParentElementInfo(const AccessibilityElementInfo &child, AccessibilityElementInfo &parent) = 0;
/**
* @brief Executes a specified action.
@@ -195,17 +193,17 @@ public:
* {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
* action: ACCESSIBILITY_ACTION_SET_TEXT,
* actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
* @return Return RET_OK if performs action successfully, otherwise refer to the RetError for the failure.
* @return true Perform action succeed, otherwise is not.
*/
virtual RetError ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
virtual bool ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
const std::map<std::string, std::string> &actionArguments) = 0;
/**
* @brief Set target bundle names.
* @param targetBundleNames The target bundle name
* @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure.
* @return Return true if sets target bundle names successfully, else return false.
*/
virtual RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) = 0;
virtual bool SetTargetBundleName(const std::vector<std::string> &targetBundleNames) = 0;
/**
* @brief Set cache mode.
@@ -216,10 +214,9 @@ public:
* PREFETCH_SIBLINGS: cache the sister/brothers node info also.
* PREFETCH_CHILDREN: cache the child node info also.
* otherwise: no cache.
* @return Return RET_OK if sets cache mode successfully, otherwise refer to the RetError for the failure.
*/
virtual RetError SetCacheMode(const int32_t cacheMode) = 0;
virtual void SetCacheMode(const int32_t cacheMode) = 0;
};
} // namespace Accessibility
} // namespace OHOS
#endif // ACCESSIBILITY_UI_TEST_ABILITY_H
#endif // ACCESSIBILITY_UI_TEST_ABILITY_H
@@ -50,74 +50,74 @@ public:
* @brief Obtains elementInfo of focus.
* @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
* @param elementInfo The accessibilityElementInfo of focus.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo) = 0;
virtual bool GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo) = 0;
/**
* @brief Obtains elementInfo of focus.
* @param sourceInfo The source info to get focus.
* @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
* @param elementInfo The accessibilityElementInfo of focus.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType,
virtual bool GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType,
AccessibilityElementInfo &elementInfo) = 0;
/**
* @brief Sends simulate gestures to the screen.
* @param gesturePath The gesture which need to send.
* @return Return RET_OK if the gesture sends successfully, otherwise refer to the RetError for the failure.
* @return Return true if the gesture sends successfully, else return false.
*/
virtual RetError InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath) = 0;
virtual bool InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath) = 0;
/**
* @brief Obtains elementInfo of the accessible root node.
* @param elementInfo The elementInfo of the accessible root node.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetRoot(AccessibilityElementInfo &elementInfo) = 0;
virtual bool GetRoot(AccessibilityElementInfo &elementInfo) = 0;
/**
* @brief Obtains elementInfo of the accessible root node.
* @param windowInfo The source window info to get root.
* @param elementInfo The elementInfo of the accessible root node.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
virtual RetError GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
virtual bool GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
AccessibilityElementInfo &elementInfo) = 0;
/**
* @brief Get the window information related with the event
* @param windowId The window id.
* @param windowInfo The window information.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) = 0;
virtual bool GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) = 0;
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows) = 0;
virtual bool GetWindows(std::vector<AccessibilityWindowInfo> &windows) = 0;
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param displayId the id of display
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
virtual RetError GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) = 0;
virtual bool GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) = 0;
/**
* @brief Gets the next focused node in the specified direction of the currently focused node.
* @param elementInfo The source info to get next info.
* @param direction Indicates the direction to obtain the next focused node. Refer to FocusMoveDirection
* @param nextElementInfo The info of next element.
* @return Return RET_OK if gets next elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets next elementInfo successfully, else return false.
*/
virtual RetError GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction,
virtual bool GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction,
AccessibilityElementInfo &nextElementInfo) = 0;
/**
@@ -125,18 +125,18 @@ public:
* @param index The index of the child.
* @param parent The parent info to get child.
* @param child The element info of child.
* @return Return RET_OK if gets child elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets child elementInfo successfully, else return false.
*/
virtual RetError GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
virtual bool GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
AccessibilityElementInfo &child) = 0;
/**
* @brief Get the children node information
* @param parent The parent info to get children.
* @param children The element info of children.
* @return Return RET_OK if gets children elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets children elementInfo successfully, else return false.
*/
virtual RetError GetChildren(const AccessibilityElementInfo &parent,
virtual bool GetChildren(const AccessibilityElementInfo &parent,
std::vector<AccessibilityElementInfo> &children) = 0;
/**
@@ -144,26 +144,26 @@ public:
* @param elementInfo The source info.
* @param text specified content
* @param elementInfos The element infos of specified content.
* @return Return RET_OK if gets elementInfos successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets elementInfos successfully, else return false.
*/
virtual RetError GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
virtual bool GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
std::vector<AccessibilityElementInfo> &elementInfos) = 0;
/**
* @brief Get the node information related with the event
* @param eventInfo The source info to get source.
* @param elementInfo The element info of source.
* @return Return RET_OK if gets elementInfos successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets elementInfos successfully, else return false.
*/
virtual RetError GetSource(const AccessibilityEventInfo &eventInfo, AccessibilityElementInfo &elementInfo) = 0;
virtual bool GetSource(const AccessibilityEventInfo &eventInfo, AccessibilityElementInfo &elementInfo) = 0;
/**
* @brief Get Parent node information
* @param child The child element info to get parent.
* @param parent The parent element info.
* @return Return RET_OK if gets info successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets info successfully, else return false.
*/
virtual RetError GetParentElementInfo(const AccessibilityElementInfo &child, AccessibilityElementInfo &parent) = 0;
virtual bool GetParentElementInfo(const AccessibilityElementInfo &child, AccessibilityElementInfo &parent) = 0;
/**
* @brief Executes a specified action.
@@ -183,24 +183,24 @@ public:
* {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
* action: ACCESSIBILITY_ACTION_SET_TEXT,
* actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
* @return Return RET_OK if performs action succeed, otherwise refer to the RetError for the failure.
* @return true Perform action succeed, otherwise is not.
*/
virtual RetError ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
virtual bool ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
const std::map<std::string, std::string> &actionArguments) = 0;
/**
* @brief Register ability listener.
* @param listener The listener to add.
* @return Return RET_OK if registers listener successfully, otherwise refer to the RetError for the failure.
* @return Return true if registers listener successfully, else return false.
*/
virtual RetError RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener) = 0;
virtual bool RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener) = 0;
/**
* @brief Set target bundle names.
* @param targetBundleNames The target bundle name
* @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure.
* @return Return true if sets target bundle names successfully, else return false.
*/
virtual RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) = 0;
virtual bool SetTargetBundleName(const std::vector<std::string> &targetBundleNames) = 0;
/**
* @brief Set cache mode.
@@ -211,10 +211,9 @@ public:
* PREFETCH_SIBLINGS: cache the sister/brothers node info also.
* PREFETCH_CHILDREN: cache the child node info also.
* otherwise: no cache.
* @return Return RET_OK if sets cache mode successfully, otherwise refer to the RetError for the failure.
*/
virtual RetError SetCacheMode(const int32_t cacheMode) = 0;
virtual void SetCacheMode(const int32_t cacheMode) = 0;
};
} // namespace Accessibility
} // namespace OHOS
#endif // ACCESSIBLE_ABILITY_CLIENT_H
#endif // ACCESSIBLE_ABILITY_CLIENT_H
@@ -107,209 +107,181 @@ public:
* @brief Subscribes to accessibility config value.
* @param id the config id which is observed.
* @param observer Indicates the observer for listening to accessibility
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SubscribeConfigObserver(const CONFIG_ID id,
const std::shared_ptr<AccessibilityConfigObserver> &observer, const bool retFlag = true);
void SubscribeConfigObserver(const CONFIG_ID id, const std::shared_ptr<AccessibilityConfigObserver> &observer,
const bool retFlag = true);
/**
* @brief Unsubscribe the accessibility config value observer.
* @param id the id which is observed.
* @param observer Indicates the registered accessibility config observer.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError UnsubscribeConfigObserver(const CONFIG_ID id,
const std::shared_ptr<AccessibilityConfigObserver> &observer);
void UnsubscribeConfigObserver(const CONFIG_ID id, const std::shared_ptr<AccessibilityConfigObserver> &observer);
/**
* @brief Subscribes the observer of enable Ability lists
* @param observer Indicates the observer for listening to enable Ability lists
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SubscribeEnableAbilityListsObserver(
void SubscribeEnableAbilityListsObserver(
const std::shared_ptr<AccessibilityEnableAbilityListsObserver> &observer);
/**
* @brief Unsubscribe the observer of enable Ability lists
* @param observer Indicates the observer for listening to enable Ability lists
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError UnsubscribeEnableAbilityListsObserver(
void UnsubscribeEnableAbilityListsObserver(
const std::shared_ptr<AccessibilityEnableAbilityListsObserver> &observer);
/**
* @brief Enabled specified abilities
* @param name The string formatted by 'bundleName/abilityName'.
* @param capabilities The capabilities you permit.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return Return true if the command is sent successfully, else return false.
*/
Accessibility::RetError EnableAbility(const std::string &name, const uint32_t capabilities);
bool EnableAbility(const std::string &name, const uint32_t capabilities);
/**
* @brief Disabled specified ability
* @param name The string formatted by 'bundleName/abilityName'.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return Return true if the command is sent successfully, else return false.
*/
Accessibility::RetError DisableAbility(const std::string &name);
bool DisableAbility(const std::string &name);
/**
* @brief Set whether to enable the magnification function
* @param state true:enable magnification function; false:disable magnification function
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetScreenMagnificationState(const bool state);
/**
* @brief Set whether to enable the function of using short key to open accessibility ability
* @param state true:enable short key function; false:disable short key function
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetShortKeyState(const bool state);
/**
* @brief Set whether to enable the mouse key function
* @param state true:enable mouse key function; false:disable mouse key function
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetMouseKeyState(const bool state);
/**
* @brief Set whether to enable the caption function
* @param state true:enable caption function; false:disable caption function
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetCaptionsState(const bool state);
/**
* @brief Set caption properties
* @param caption caption properties
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetCaptionsProperty(const CaptionProperty &caption);
/**
* @brief Set the time for the cursor to stop for the mouse to automatically perform the click action
* @param time The valid time is 1000ms~5000ms, otherwise the automatic mouse click action will not be enabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetMouseAutoClick(const int32_t time);
/**
* @brief Set the name of the accessibility ability to be opened by the short key
* @param name name The string formatted by 'bundleName/abilityName'
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetShortkeyTarget(const std::string &name);
/**
* @brief Set whether to enable the high-contrast text function
* @param state true:enable high-contrast text function; false:disable high-contrast text function
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetHighContrastTextState(bool state);
/**
* @brief Set whether to enable the invert color function
* @param state true:enable invert color function; false:disable invert color function
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetInvertColorState(const bool state);
/**
* @brief Set daltonization color filter
* @param type Daltonization color filter type
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetDaltonizationColorFilter(const DALTONIZATION_TYPE type);
/**
* @brief Set content duration
* @param timer duration
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetContentTimeout(const uint32_t timer);
/**
* @brief Set whether to turn off animation
* @param state true:turn off animation; false:turn on animation
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetAnimationOffState(const bool state);
/**
* @brief Set brightness discount
* @param brightness The discount of brightness
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetBrightnessDiscount(const float brightness);
/**
* @brief Set whether to enable audio mono
* @param state true:enable audio mono; false:disable audio mono
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetAudioMonoState(const bool state);
/**
* @brief Set audio balance
* @param balance The balance of audio
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError SetAudioBalance(const float balance);
/**
* @brief Get the status of whether the magnification function is enabled
* @param state(out) true:the magnification function is enabled; false:the magnification function is disabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetScreenMagnificationState(bool &state) const;
/**
* @brief Get the status of whether the use of short key to open accessibility ability is enabled
* @param state(out) true:the short key is enabled; false:the short key is disabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetShortKeyState(bool &state) const;
/**
* @brief Get the status of whether the mouse key function is enabled
* @param state(out) true:the mouse key function is enabled; false:the mouse key function is disabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetMouseKeyState(bool &state) const;
/**
* @brief Get the status of whether the caption function is enabled
* @param state(out) true:the caption function is enabled; false:the caption function is disabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetCaptionsState(bool &state) const;
/**
* @brief Get caption properties
* @param caption(out) caption properties
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetCaptionsProperty(CaptionProperty &caption) const;
/**
* @brief Get the time for the cursor to stop for the mouse to automatically perform the click action
* @param time(out) the time for the cursor to stop for the mouse to automatically perform the click action
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetMouseAutoClick(int32_t &time) const;
/**
* @brief Get the name of the accessibility ability to be opened by the short key
* @param name(out) The string formatted by 'bundleName/abilityName'
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetShortkeyTarget(std::string &name) const;
/**
* @brief Get the status of whether the invert color function is enabled
* @param state(out) true:the invert color function is enabled; false:the invert color function is disabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetInvertColorState(bool &state) const;
@@ -317,49 +289,42 @@ public:
* @brief Get the status of whether the high-contrast text function is enabled
* @param state(out) true:the high-contrast text function is enabled;
* false:the high-contrast text function is disabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetHighContrastTextState(bool &state) const;
/**
* @brief Get daltonization color filter
* @param type(out) Daltonization color filter type
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetDaltonizationColorFilter(DALTONIZATION_TYPE &type) const;
/**
* @brief Get content duration
* @param timer(out) duration
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetContentTimeout(uint32_t &timer) const;
/**
* @brief Get the status of whether animation is disabled
* @param state(out) true:animation is disabled; false:animation is enabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetAnimationOffState(bool &state) const;
/**
* @brief Get brightness discount parameter
* @param brightness(out) The discount parameter of brightness
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetBrightnessDiscount(float &brightness) const;
/**
* @brief Get the status of whether the audio mono is enabled
* @param state(out) true:audio mono is enabled; false:audio mono is disabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetAudioMonoState(bool &state) const;
/**
* @brief Get the value of the audio balance
* @param balance(out) The value of the audio balance
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
Accessibility::RetError GetAudioBalance(float &balance) const;
@@ -55,31 +55,28 @@ public:
* @brief Register the element operator, so the AA can get node info from ACE.
* @param windowId Window ID
* @param operation The callback object.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return 0: Succeed ; otherwise is failed.
*/
virtual RetError RegisterElementOperator(const int32_t windowId,
virtual int32_t RegisterElementOperator(const int32_t windowId,
const std::shared_ptr<AccessibilityElementOperator> &operation) = 0;
/**
* @brief Deregister the element operator.
* @param windowId Window ID
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
*/
virtual RetError DeregisterElementOperator(const int32_t windowId) = 0;
virtual void DeregisterElementOperator(const int32_t windowId) = 0;
/**
* @brief Checks whether accessibility ability is enabled.
* @param isEnabled true: enabled; false: disabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: enabled; false: disabled
*/
virtual RetError IsEnabled(bool &isEnabled)= 0;
virtual bool IsEnabled() = 0;
/**
* @brief Checks whether touch exploration ability is enabled.
* @param isEnabled true: enabled; false: disabled
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: enabled; false: disabled
*/
virtual RetError IsTouchExplorationEnabled(bool &isEnabled) = 0;
virtual bool IsTouchExplorationEnabled() = 0;
/**
* @brief Queries the list of accessibility abilities.
@@ -89,51 +86,51 @@ public:
* 2 indicates that the ability is disabled;
* 3 indicates that the ability has been installed.
* @param infos accessibility ability infos by specified types.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return Return true if get ability lists successfully, else return false.
*/
virtual RetError GetAbilityList(const uint32_t accessibilityAbilityTypes, const AbilityStateType stateType,
virtual bool GetAbilityList(const uint32_t accessibilityAbilityTypes, const AbilityStateType stateType,
std::vector<AccessibilityAbilityInfo> &infos) = 0;
/**
* @brief Sends an accessibility event.
* @param eventType Identifies the accessibility event specified by AccessibilityEventInfo.
* @param componentId Indicates the ID of the component to be associated with the event.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: send ok; otherwise is refused.
*/
virtual RetError SendEvent(const EventType eventType, const int32_t componentId) = 0;
virtual bool SendEvent(const EventType eventType, const int32_t componentId) = 0;
/**
* @brief Sends information about an accessibility event.
* @param event Indicates the accessibility event information specified by AccessibilityEventInfo.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: send ok; otherwise is refused.
*/
virtual RetError SendEvent(const AccessibilityEventInfo &event) = 0;
virtual bool SendEvent(const AccessibilityEventInfo &event) = 0;
/**
* @brief Subscribes to the specified type of accessibility status change events.
* @param observer Indicates the observer for listening to status events, which is specified
* by AccessibilityStateObserver.
* @param eventType Indicates the status type, which is specified by AccessibilityStateEventType.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: send ok; otherwise is refused.
*/
virtual RetError SubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer,
virtual bool SubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer,
const uint32_t eventType) = 0;
/**
* @brief Unsubscribe the specified type of accessibility status change events.
* @param observer Indicates the registered accessibility status event observer.
* @param eventType Indicates the status type, which is specified by AccessibilityStateEventType.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return true: send ok; otherwise is refused.
*/
virtual RetError UnsubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer,
virtual bool UnsubscribeStateObserver(const std::shared_ptr<AccessibilityStateObserver> &observer,
const uint32_t eventType) = 0;
/**
* @brief Get enabled abilities.
* @param enabledAbilities The infos of enabled abilities.
* @return Returns RET_OK if successful, otherwise refer to the RetError for the failure.
* @return Return true if get enabled abilities successfully, else return false.
*/
virtual RetError GetEnabledAbilities(std::vector<std::string> &enabledAbilities) = 0;
virtual bool GetEnabledAbilities(std::vector<std::string> &enabledAbilities) = 0;
};
} // namespace Accessibility
} // namespace OHOS
@@ -23,27 +23,12 @@ namespace Accessibility {
enum RetError : int32_t {
RET_OK = 0,
RET_ERR_FAILED = -1,
RET_ERR_INVALID_PARAM = 1001,
RET_ERR_NULLPTR,
RET_ERR_IPC_FAILED,
RET_ERR_SAMGR,
RET_ERR_NO_PERMISSION,
RET_ERR_TIME_OUT,
RET_ERR_NOT_SUPPORT,
RET_ERR_REGISTER_EXIST = 4001,
RET_ERR_NO_REGISTER,
RET_ERR_CONNECTION_EXIST,
RET_ERR_NO_CONNECTION,
RET_ERR_NO_WINDOW_CONNECTION,
RET_ERR_NO_CAPABILITY,
RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE,
RET_ERR_PERFORM_ACTION_FAILED_BY_ACE,
RET_ERR_NO_INJECTOR,
RET_ERR_NOT_INSTALLED,
RET_ERR_NOT_ENABLED,
RET_ERR_PROPERTY_NOT_EXIST,
RET_ERR_ACTION_NOT_SUPPORT,
RET_ERR_INVALID_PARAM = 1,
RET_ERR_NULLPTR = 2,
RET_ERR_CONNECTION_EXIST = 3,
RET_ERR_IPC_FAILED = 4,
RET_ERR_SAMGR = 5,
RET_ERR_NO_PERMISSION = 6,
};
enum GlobalAction : uint32_t {
@@ -30,14 +30,14 @@ namespace {
if (!asaClient) {
return;
}
bool isEnable = false;
for (auto _ : state) {
/* @tc.steps: step1.call IsEnabled in loop */
(void)asaClient->IsEnabled(isEnable);
(void)asaClient->IsEnabled();
}
}
/**
/**
* @tc.name: BenchmarkTestForGetEnabledAbilities
* @tc.desc: Testcase for testing 'GetEnabledAbilities' function.
* @tc.type: FUNC
+2 -4
View File
@@ -17,19 +17,17 @@ import { GesturePoint } from "./@ohos.accessibility.GesturePoint";
/**
* Indicates the path of the gesture.
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @since 9
* @syscap SystemCapability.BarrierFree.Accessibility.Core
*/
export declare class GesturePath {
export declare class GesturePath {
constructor(durationTime: number);
/**
* Indicates the position of the points that make up the gesture.
* @type {Array<GesturePoint>}
*/
points: Array<GesturePoint>;
/**
* Indicates the duration of the gesture.
* @type {number}
*/
durationTime: number;
}
+1 -3
View File
@@ -15,19 +15,17 @@
/**
* Indicates the point of the gesture.
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @since 9
* @syscap SystemCapability.BarrierFree.Accessibility.Core
*/
export declare class GesturePoint {
constructor(positionX: number, positionY: number);
/**
* Indicates the X coordinate of point.
* @type {number}
*/
positionX: number;
/**
* Indicates the Y coordinate of point.
* @type {number}
*/
positionY: number;
}
+21 -50
View File
@@ -1,21 +1,6 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"),
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import accessibility from './@ohos.accessibility';
import { AsyncCallback, Callback } from './basic';
/**
* Configuration of the accessibility.
*
@@ -61,7 +46,7 @@ declare namespace config {
*/
var audioBalance: Config<number>;
/**
* Indicates the configuration of mouse key state.
* Indicates the configuration of monse key state.
*/
var mouseKey: Config<boolean>;
/**
@@ -69,11 +54,11 @@ declare namespace config {
*/
var mouseAutoClick: Config<number>;
/**
* Indicates the configuration of short key state.
* Indicates the configuration of shortkey state.
*/
var shortkey: Config<boolean>;
/**
* Indicates the configuration of short key target.
* Indicates the configuration of shortkey target.
*/
var shortkeyTarget: Config<string>;
/**
@@ -84,45 +69,36 @@ declare namespace config {
* Indicates the configuration of captions style.
*/
var captionsStyle: Config<accessibility.CaptionsStyle>;
/**
* Enable the accessibility extension ability.
* Enable the acceessibility extension ability.
* @param name Indicates the accessibility extension name, in "bundleName/abilityName" format.
* @param capability Indicates the ability.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Input parameter error.
* @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
* @throws { BusinessError } 9300002 - Target ability already enabled.
*/
function enableAbility(name: string, capability: Array<accessibility.Capability>): Promise<void>;
function enableAbility(name: string, capability: Array<accessibility.Capability>, callback: AsyncCallback<void>): void;
/**
* Disable the accessibility extension ability.
* Disable the acceessibility extension ability.
* @param name Indicates the accessibility extension name, in "bundleName/abilityName" format.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Input parameter error.
* @throws { BusinessError } 9300001 - Invalid bundle name or ability name.
*/
function disableAbility(name: string): Promise<void>;
function disableAbility(name: string, callback: AsyncCallback<void>): void;
/**
* Register the listener that watches for changes in the enabled status of accessibility extensions.
* @param type Indicates the type of event.
* Register the listener to listen for for changes in the enabled status of accessibility extensions.
* @param type Indicates the enableAbilityListsStateChanged type.
* @param callback Indicates the listener.
* @throws { BusinessError } 401 - Input parameter error.
*/
function on(type: 'enabledAccessibilityExtensionListChange', callback: Callback<void>): void;
function on(type: 'enableAbilityListsStateChanged', callback: Callback<void>): void;
/**
* Deregister listener that watches for changes in the enabled status of accessibility extensions.
* @param type Indicates the type of event.
* Deregister listener that watch for changes in the enabled status of accessibility extensions.
* @param type Indicates the enableAbilityListsStateChanged type.
* @param callback Indicates the listener.
* @throws { BusinessError } 401 - Input parameter error.
*/
function off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback<void>): void;
function off(type: 'enableAbilityListsStateChanged', callback?: Callback<void>): void;
/**
* Indicates setting, getting, and listening to changes in configuration.
*/
@@ -130,34 +106,29 @@ declare namespace config {
/**
* Setting configuration value.
* @param value Indicates the value.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Input parameter error.
*/
set(value: T): Promise<void>;
set(value: T, callback: AsyncCallback<void>): void;
/**
* Getting configuration value.
* @throws { BusinessError } 201 - Permission denied.
*/
get(): Promise<T>;
get(callback: AsyncCallback<T>): void;
/**
* Register the listener to listen for configuration changes.
* @param callback Indicates the listener.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Input parameter error.
*/
on(callback: Callback<T>): void;
/**
* Deregister the listener to listen for configuration changes.
* @param callback Indicates the listener.
*/
off(callback?: Callback<T>): void;
}
/**
* Indicates the type of daltonization color filter.
*/
+94 -124
View File
@@ -24,19 +24,13 @@ import { Callback } from './basic';
* @import basic,abilityInfo
*/
declare namespace accessibility {
/**
* The type of the Ability app.
* @type { 'audible' | 'generic' | 'haptic' | 'spoken' | 'visual' }
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @since 7
*/
/**
* The type of the Ability app.
* @type { 'audible' | 'generic' | 'haptic' | 'spoken' | 'visual' | 'all' }
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @since 9
*/
type AbilityType = 'audible' | 'generic' | 'haptic' | 'spoken' | 'visual' | 'all';
type AbilityType = 'audible' | 'generic' | 'haptic' | 'spoken' | 'visual';
/**
* The action that the ability can execute.
@@ -104,7 +98,7 @@ declare namespace accessibility {
* @param callback Asynchronous callback interface.
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @return Returns {@code true} if the accessibility is enabled; returns {@code false} otherwise.
*/
*/
function isOpenAccessibility(callback: AsyncCallback<boolean>): void;
function isOpenAccessibility(): Promise<boolean>;
@@ -114,19 +108,18 @@ declare namespace accessibility {
* @param callback Asynchronous callback interface.
* @syscap SystemCapability.BarrierFree.Accessibility.Vision
* @return Returns {@code true} if the touch browser is enabled; returns {@code false} otherwise.
*/
*/
function isOpenTouchGuide(callback: AsyncCallback<boolean>): void;
function isOpenTouchGuide(): Promise<boolean>;
/**
* Queries the list of accessibility abilities.
* @since 7
* @deprecated since 9
* @param abilityType The type of the accessibility ability. {@code AbilityType} eg.spoken
* @param stateType The state of the accessibility ability. {@code AbilityState} eg.installed
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @return Returns the list of abilityInfos.
*/
*/
function getAbilityLists(abilityType: AbilityType, stateType: AbilityState,
callback: AsyncCallback<Array<AccessibilityAbilityInfo>>): void;
function getAbilityLists(abilityType: AbilityType,
@@ -135,19 +128,19 @@ declare namespace accessibility {
/**
* Queries the list of accessibility abilities.
* @since 9
* @param abilityType The type of the accessibility ability. {@code AbilityType} eg.spoken
* @param abilityType The all type of the accessibility ability.
* @param stateType The state of the accessibility ability. {@code AbilityState} eg.installed
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @return Returns the list of abilityInfos.
* @throws { BusinessError } 401 - Input parameter error.
*/
function getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState): Promise<Array<AccessibilityAbilityInfo>>;
function getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState, callback: AsyncCallback<Array<AccessibilityAbilityInfo>>): void;
*/
function getAbilityLists(abilityType: 'all', stateType: AbilityState,
callback: AsyncCallback<Array<AccessibilityAbilityInfo>>): void;
function getAbilityLists(abilityType: 'all',
stateType: AbilityState): Promise<Array<AccessibilityAbilityInfo>>;
/**
* Send accessibility Event.
* @since 7
* @deprecated since 9
* @param event The object of the accessibility {@code EventInfo} .
* @param callback Asynchronous callback interface.
* @syscap SystemCapability.BarrierFree.Accessibility.Core
@@ -156,18 +149,6 @@ declare namespace accessibility {
function sendEvent(event: EventInfo, callback: AsyncCallback<void>): void;
function sendEvent(event: EventInfo): Promise<void>;
/**
* Send accessibility event.
* @since 9
* @param event The object of the accessibility {@code EventInfo} .
* @param callback Asynchronous callback interface.
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @return Returns {@code true} if success ; returns {@code false} otherwise.
* @throws { BusinessError } 401 - Input parameter error.
*/
function sendAccessibilityEvent(event: EventInfo, callback: AsyncCallback<void>): void;
function sendAccessibilityEvent(event: EventInfo): Promise<void>;
/**
* Register the observe of the accessibility state changed.
* @since 7
@@ -175,7 +156,6 @@ declare namespace accessibility {
* @param callback Asynchronous callback interface.
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @return Returns {@code true} if the register is success ; returns {@code false} otherwise.
* @throws { BusinessError } 401 - Input parameter error.
*/
function on(type: 'accessibilityStateChange', callback: Callback<boolean>): void;
@@ -186,7 +166,6 @@ declare namespace accessibility {
* @param callback Asynchronous callback interface.
* @syscap SystemCapability.BarrierFree.Accessibility.Vision
* @return Returns {@code true} if the register is success ; returns {@code false} otherwise.
* @throws { BusinessError } 401 - Input parameter error.
*/
function on(type: 'touchGuideStateChange', callback: Callback<boolean>): void;
@@ -197,7 +176,6 @@ declare namespace accessibility {
* @param callback Asynchronous callback interface.
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @return Returns {@code true} if the deregister is success ; returns {@code false} otherwise.
* @throws { BusinessError } 401 - Input parameter error.
*/
function off(type: 'accessibilityStateChange', callback?: Callback<boolean>): void;
@@ -207,9 +185,8 @@ declare namespace accessibility {
* @param type state event type
* @param callback Asynchronous callback interface.
* @return Returns {@code true} if the deregister is success ; returns {@code false} otherwise.
* @throws { BusinessError } 401 - Input parameter error.
*/
function off(type: 'touchGuideStateChange', callback?: Callback<boolean>): void;
function off(type: 'touchGuideStateChange', callback?: Callback<boolean>): void;
/**
* Get the captions manager.
@@ -217,98 +194,91 @@ declare namespace accessibility {
* @since 8
* @return Returns the captions manager.
*/
function getCaptionsManager(): CaptionsManager;
function getCaptionsManager(): CaptionsManager;
/**
* Indicates the captions manager.
* @syscap SystemCapability.BarrierFree.Accessibility.Hearing
* @since 8
*/
interface CaptionsManager {
/**
* Indicates whether captions are enabled.
*/
enabled: boolean;
/**
* Indicates the style of captions.
*/
style: CaptionsStyle;
/**
* Register the observe of the enable state.
* @throws { BusinessError } 401 - Input parameter error.
*/
on(type: 'enableChange', callback: Callback<boolean>): void;
/**
* Indicates the captions manager.
* @syscap SystemCapability.BarrierFree.Accessibility.Hearing
* @since 8
*/
interface CaptionsManager {
/**
* Indicates whether captions are enabled.
*/
enabled: boolean;
/**
* Indicates the style of captions.
*/
style: CaptionsStyle;
/**
* Register the observer of the style.
* @throws { BusinessError } 401 - Input parameter error.
*/
on(type: 'styleChange', callback: Callback<CaptionsStyle>): void;
/**
* Register the observe of the enable state.
*/
on(type: 'enableChange', callback: Callback<boolean>): void;
/**
* Register the observer of the style.
*/
on(type: 'styleChange', callback: Callback<CaptionsStyle>): void;
/**
* Deregister the observe of the enable state.
*/
off(type: 'enableChange', callback?: Callback<boolean>): void;
/**
* Deregister the observer of the style.
*/
off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void;
}
/**
* Deregister the observe of the enable state.
* @throws { BusinessError } 401 - Input parameter error.
*/
off(type: 'enableChange', callback?: Callback<boolean>): void;
/**
* Indicates the edge type of the captions font.
* @syscap SystemCapability.BarrierFree.Accessibility.Hearing
* @since 8
*/
type CaptionsFontEdgeType = 'none' | 'raised' | 'depressed' | 'uniform' | 'dropShadow';
/**
* Indicates the font family of captions.
* @syscap SystemCapability.BarrierFree.Accessibility.Hearing
* @since 8
*/
type CaptionsFontFamily = 'default' | 'monospacedSerif' | 'serif' |
'monospacedSansSerif' | 'sansSerif' | 'casual' | 'cursive' | 'smallCapitals';
/**
* Indicates the style of captions.
* @syscap SystemCapability.BarrierFree.Accessibility.Hearing
* @since 8
*/
interface CaptionsStyle {
/**
* Indicates the font family of captions.
*/
fontFamily: CaptionsFontFamily;
/**
* Indicates the font scaling of captions.
*/
fontScale: number;
/**
* Indicates the font color of captions.
*/
fontColor: number | string;
/**
* Indicates the edge type of the captions font.
*/
fontEdgeType: CaptionsFontEdgeType;
/**
* Indicates the background color of captions.
*/
backgroundColor: number | string;
/**
* Indicates the window color of captions.
*/
windowColor: number | string;
}
/**
* Deregister the observer of the style.
* @throws { BusinessError } 401 - Input parameter error.
*/
off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void;
}
/**
* Indicates the edge type of the captions font.
* @syscap SystemCapability.BarrierFree.Accessibility.Hearing
* @since 8
*/
type CaptionsFontEdgeType = 'none' | 'raised' | 'depressed' | 'uniform' | 'dropShadow';
/**
* Indicates the font family of captions.
* @syscap SystemCapability.BarrierFree.Accessibility.Hearing
* @since 8
*/
type CaptionsFontFamily = 'default' | 'monospacedSerif' | 'serif' |
'monospacedSansSerif' | 'sansSerif' | 'casual' | 'cursive' | 'smallCapitals';
/**
* Indicates the style of captions.
* @syscap SystemCapability.BarrierFree.Accessibility.Hearing
* @since 8
*/
interface CaptionsStyle {
/**
* Indicates the font family of captions.
*/
fontFamily: CaptionsFontFamily;
/**
* Indicates the font scaling of captions.
*/
fontScale: number;
/**
* Indicates the font color of captions.
*/
fontColor: number | string;
/**
* Indicates the edge type of the captions font.
*/
fontEdgeType: CaptionsFontEdgeType;
/**
* Indicates the background color of captions.
*/
backgroundColor: number | string;
/**
* Indicates the window color of captions.
*/
windowColor: number | string;
}
/**
* Indicates the info of accessibility.
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @since 7
*/
/**
* Indicates the info of accessibility.
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @since 7
*/
interface AccessibilityAbilityInfo {
/**
* The ability id.
@@ -391,7 +361,7 @@ declare namespace accessibility {
/** The page id of the event source.
* @since 7
*/
pageId ?: number;
pageId?: number;
/**
* The accessibility event description.
+3 -22
View File
@@ -28,7 +28,6 @@ export default class AccessibilityExtensionContext extends ExtensionContext {
/**
* Set the name of the bundle name that is interested in sending the event.
* @param targetNames
* @throws { BusinessError } 401 - Input parameter error.
*/
setTargetBundleName(targetNames: Array<string>): Promise<void>;
setTargetBundleName(targetNames: Array<string>, callback: AsyncCallback<void>): void;
@@ -36,8 +35,6 @@ export default class AccessibilityExtensionContext extends ExtensionContext {
/**
* Get focus element.
* @param isAccessibilityFocus Indicates whether the acquired element has an accessibility focus.
* @throws { BusinessError } 401 - Input parameter error.
* @throws { BusinessError } 9300003 - Do not have accessibility right for this operation.
*/
getFocusElement(isAccessibilityFocus?: boolean): Promise<AccessibilityElement>;
getFocusElement(callback: AsyncCallback<AccessibilityElement>): void;
@@ -46,8 +43,6 @@ export default class AccessibilityExtensionContext extends ExtensionContext {
/**
* Get window root element.
* @param windowId Indicates the window ID.
* @throws { BusinessError } 401 - Input parameter error.
* @throws { BusinessError } 9300003 - Do not have accessibility right for this operation.
*/
getWindowRootElement(windowId?: number): Promise<AccessibilityElement>;
getWindowRootElement(callback: AsyncCallback<AccessibilityElement>): void;
@@ -56,8 +51,6 @@ export default class AccessibilityExtensionContext extends ExtensionContext {
/**
* Get window list.
* @param displayId Indicates the display ID.
* @throws { BusinessError } 401 - Input parameter error.
* @throws { BusinessError } 9300003 - Do not have accessibility right for this operation.
*/
getWindows(displayId?: number): Promise<Array<AccessibilityElement>>;
getWindows(callback: AsyncCallback<Array<AccessibilityElement>>): void;
@@ -66,8 +59,6 @@ export default class AccessibilityExtensionContext extends ExtensionContext {
/**
* Inject gesture path events.
* @param gesturePath Indicates the gesture path.
* @throws { BusinessError } 401 - Input parameter error.
* @throws { BusinessError } 9300003 - Do not have accessibility right for this operation.
*/
injectGesture(gesturePath: GesturePath): Promise<void>;
injectGesture(gesturePath: GesturePath, callback: AsyncCallback<void>): void;
@@ -90,8 +81,6 @@ declare interface AccessibilityElement {
/**
* Get the value of an attribute.
* @param attributeName Indicates the attribute name.
* @throws { BusinessError } 401 - Input parameter error.
* @throws { BusinessError } 9300004 - This property does not exist.
*/
attributeValue<T extends keyof ElementAttributeValues>(attributeName: T): Promise<ElementAttributeValues[T]>;
attributeValue<T extends keyof ElementAttributeValues>(attributeName: T,
@@ -107,18 +96,15 @@ declare interface AccessibilityElement {
* Perform the specified action.
* @param actionName Indicates the action name.
* @param parameters Indicates the parameters needed to execute the action.
* @throws { BusinessError } 401 - Input parameter error.
* @throws { BusinessError } 9300005 - This action is not supported.
*/
performAction(actionName: string, parameters?: object): Promise<void>;
performAction(actionName: string, callback: AsyncCallback<void>): void;
performAction(actionName: string, parameters: object, callback: AsyncCallback<void>): void;
performAction(actionName: string, parameters?: object): Promise<boolean>;
performAction(actionName: string, callback: AsyncCallback<boolean>): void;
performAction(actionName: string, parameters: object, callback: AsyncCallback<boolean>): void;
/**
* Find elements that match the condition.
* @param type The type of query condition is content.
* @param condition Indicates the specific content to be queried.
* @throws { BusinessError } 401 - Input parameter error.
*/
findElement(type: 'content', condition: string): Promise<Array<AccessibilityElement>>;
findElement(type: 'content', condition: string, callback: AsyncCallback<Array<AccessibilityElement>>): void
@@ -127,7 +113,6 @@ declare interface AccessibilityElement {
* Find elements that match the condition.
* @param type The type of query condition is focus type.
* @param condition Indicates the type of focus to query.
* @throws { BusinessError } 401 - Input parameter error.
*/
findElement(type: 'focusType', condition: FocusType): Promise<AccessibilityElement>;
findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback<AccessibilityElement>): void
@@ -136,7 +121,6 @@ declare interface AccessibilityElement {
* Find elements that match the condition.
* @param type The type of query condition is focus direction.
* @param condition Indicates the direction of search focus to query.
* @throws { BusinessError } 401 - Input parameter error.
*/
findElement(type: 'focusDirection', condition: FocusDirection): Promise<AccessibilityElement>;
findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback<AccessibilityElement>): void
@@ -228,9 +212,6 @@ type ElementAttributeValues = {
* Indicates whether the element is enable or not.
*/
'isEnable': boolean;
/**
* Indicates whether the element is hint state or not.
*/
'isHint': boolean;
/**
* Indicates whether the element is focused or not.
@@ -60,7 +60,7 @@ struct NAccessibilityConfigData {
OHOS::AccessibilityConfig::CaptionProperty captionProperty_ {};
OHOS::AccessibilityConfig::CONFIG_ID id_ = OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ID_MAX;
bool boolConfig_ = false;
OHOS::Accessibility::RetError ret_ = OHOS::Accessibility::RET_ERR_FAILED;
bool ret_ = false;
};
class NAccessibilityConfigClass {
@@ -35,8 +35,6 @@ napi_value NAccessibilityConfig::EnableAbility(napi_env env, napi_callback_info
NAccessibilityConfigData* callbackInfo = new(std::nothrow) NAccessibilityConfigData();
if (!callbackInfo) {
HILOG_ERROR("callbackInfo is nullptr");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
@@ -44,52 +42,23 @@ napi_value NAccessibilityConfig::EnableAbility(napi_env env, napi_callback_info
napi_value parameters[ARGS_SIZE_THREE] = {0};
napi_get_cb_info(env, info, &argc, parameters, nullptr, nullptr);
OHOS::Accessibility::RetError errCode = OHOS::Accessibility::RET_OK;
if (argc < ARGS_SIZE_THREE - 1) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
// parse name
std::string ability = "";
ParseString(env, ability, parameters[PARAM0]);
HILOG_INFO("ability = %{private}s", ability.c_str());
callbackInfo->abilityName_ = ability;
if (errCode == OHOS::Accessibility::RET_OK) {
// parse name
std::string ability = "";
if (ParseString(env, ability, parameters[PARAM0])) {
HILOG_INFO("ability = %{private}s", ability.c_str());
callbackInfo->abilityName_ = ability;
} else {
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
// parse capability
if (!ConvertJSToCapabilities(env, parameters[PARAM1], callbackInfo->capabilities_)) {
HILOG_ERROR("convert capabilities failed");
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
if (errCode == OHOS::Accessibility::RET_ERR_INVALID_PARAM) {
delete callbackInfo;
callbackInfo = nullptr;
napi_value err = CreateBusinessError(env, errCode);
HILOG_ERROR("invalid param");
napi_throw(env, err);
return nullptr;
}
// parse capability
ConvertJSToCapabilities(env, parameters[PARAM1], callbackInfo->capabilities_);
// parse function if it needs
napi_value promise = nullptr;
if (argc > ARGS_SIZE_THREE - 1) {
napi_valuetype valueType = napi_null;
napi_typeof(env, parameters[PARAM2], &valueType);
if (valueType == napi_function) {
napi_create_reference(env, parameters[PARAM2], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
if (argc >= ARGS_SIZE_THREE) {
napi_create_reference(env, parameters[PARAM2], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
napi_value resource = nullptr;
napi_create_string_utf8(env, "EnableAbility", NAPI_AUTO_LENGTH, &resource);
@@ -113,8 +82,6 @@ napi_value NAccessibilityConfig::DisableAbility(napi_env env, napi_callback_info
NAccessibilityConfigData* callbackInfo = new(std::nothrow) NAccessibilityConfigData();
if (!callbackInfo) {
HILOG_ERROR("callbackInfo is nullptr");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
@@ -122,46 +89,20 @@ napi_value NAccessibilityConfig::DisableAbility(napi_env env, napi_callback_info
napi_value parameters[ARGS_SIZE_TWO] = {0};
napi_get_cb_info(env, info, &argc, parameters, nullptr, nullptr);
OHOS::Accessibility::RetError errCode = OHOS::Accessibility::RET_OK;
if (argc < ARGS_SIZE_TWO - 1) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
if (errCode == OHOS::Accessibility::RET_OK) {
// parse name
std::string ability = "";
if (ParseString(env, ability, parameters[PARAM0])) {
HILOG_INFO("ability = %{private}s", ability.c_str());
callbackInfo->abilityName_ = ability;
} else {
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
if (errCode == OHOS::Accessibility::RET_ERR_INVALID_PARAM) {
delete callbackInfo;
callbackInfo = nullptr;
napi_value err = CreateBusinessError(env, errCode);
HILOG_ERROR("invalid param");
napi_throw(env, err);
return nullptr;
}
// parse name
std::string ability = "";
ParseString(env, ability, parameters[PARAM0]);
HILOG_INFO("ability = %{private}s", ability.c_str());
callbackInfo->abilityName_ = ability;
// parse function if it needs
napi_value promise = nullptr;
if (argc > ARGS_SIZE_TWO - 1) {
napi_valuetype valueType = napi_null;
napi_typeof(env, parameters[PARAM1], &valueType);
if (valueType == napi_function) {
napi_create_reference(env, parameters[PARAM1], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
if (argc >= ARGS_SIZE_TWO) {
napi_create_reference(env, parameters[PARAM1], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
napi_value resource = nullptr;
napi_create_string_utf8(env, "DisableAbility", NAPI_AUTO_LENGTH, &resource);
@@ -184,40 +125,16 @@ napi_value NAccessibilityConfig::SubscribeState(napi_env env, napi_callback_info
HILOG_INFO();
size_t argc = ARGS_SIZE_TWO;
napi_value args[ARGS_SIZE_TWO] = {0};
napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
OHOS::Accessibility::RetError errCode = OHOS::Accessibility::RET_OK;
if (argc < ARGS_SIZE_TWO) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
if (status != napi_ok) {
HILOG_ERROR("Failed to get callback info");
return nullptr;
}
if (errCode == OHOS::Accessibility::RET_OK) {
std::string observerType = "";
if (!ParseString(env, observerType, args[PARAM0])) {
HILOG_ERROR("observer type parse failed");
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
} else {
if (std::strcmp(observerType.c_str(), "enabledAccessibilityExtensionListChange") != 0) {
HILOG_ERROR("args[PARAM0] is wrong[%{public}s", observerType.c_str());
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
}
if (errCode == OHOS::Accessibility::RET_OK) {
napi_valuetype valueType = napi_null;
napi_typeof(env, args[PARAM1], &valueType);
if (valueType != napi_function) {
HILOG_ERROR("args[PARAM1] format is wrong");
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
if (errCode == OHOS::Accessibility::RET_ERR_INVALID_PARAM) {
napi_value err = CreateBusinessError(env, errCode);
HILOG_ERROR("invalid param");
napi_throw(env, err);
std::string observerType = "";
ParseString(env, observerType, args[PARAM0]);
if (std::strcmp(observerType.c_str(), "enableAbilityListsStateChanged")) {
HILOG_ERROR("args[PARAM0] is wrong[%{public}s]", observerType.c_str());
return nullptr;
}
@@ -234,42 +151,21 @@ napi_value NAccessibilityConfig::UnsubscribeState(napi_env env, napi_callback_in
HILOG_INFO();
size_t argc = ARGS_SIZE_TWO;
napi_value args[ARGS_SIZE_TWO] = {0};
napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
OHOS::Accessibility::RetError errCode = OHOS::Accessibility::RET_OK;
if (argc < ARGS_SIZE_TWO - 1) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
if (errCode == OHOS::Accessibility::RET_OK) {
std::string observerType = "";
if (!ParseString(env, observerType, args[PARAM0])) {
HILOG_ERROR("observer type parse failed");
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
} else {
if (std::strcmp(observerType.c_str(), "enabledAccessibilityExtensionListChange") != 0) {
HILOG_ERROR("args[PARAM0] is wrong[%{public}s", observerType.c_str());
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
}
if (errCode == OHOS::Accessibility::RET_ERR_INVALID_PARAM) {
napi_value err = CreateBusinessError(env, errCode);
HILOG_ERROR("invalid param");
napi_throw(env, err);
napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
if (status != napi_ok) {
HILOG_ERROR("Failed to get callback info");
return nullptr;
}
if (argc > ARGS_SIZE_TWO - 1) {
napi_valuetype valueType = napi_null;
napi_typeof(env, args[PARAM1], &valueType);
if (valueType == napi_function) {
enableAbilityListsObservers_->UnsubscribeObserver(args[PARAM1]);
} else {
enableAbilityListsObservers_->UnsubscribeObservers();
}
std::string observerType = "";
ParseString(env, observerType, args[PARAM0]);
if (std::strcmp(observerType.c_str(), "enableAbilityListsStateChanged")) {
HILOG_ERROR("args[PARAM0] is wrong[%{public}s]", observerType.c_str());
return nullptr;
}
if (argc >= ARGS_SIZE_TWO) {
enableAbilityListsObservers_->UnsubscribeObserver(args[PARAM1]);
} else {
enableAbilityListsObservers_->UnsubscribeObservers();
}
@@ -284,22 +180,29 @@ void NAccessibilityConfig::AsyncWorkComplete(napi_env env, napi_status status, v
HILOG_ERROR("callbackInfo is nullptr");
return;
}
napi_value result[ARGS_SIZE_ONE] = {0};
napi_value result[ARGS_SIZE_TWO] = {0};
napi_value callback = 0;
napi_value returnVal = 0;
napi_value undefined = 0;
napi_value ret = 0;
napi_get_undefined(env, &undefined);
result[PARAM0] = CreateBusinessError(env, callbackInfo->ret_);
napi_get_undefined(env, &ret);
if (callbackInfo->callback_) {
if (callbackInfo->ret_) {
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
} else {
result[PARAM0] = GetErrorValue(env, CODE_FAILED);
}
result[PARAM1] = ret;
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_call_function(env, undefined, callback, ARGS_SIZE_ONE, result, &returnVal);
napi_value returnVal;
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
napi_delete_reference(env, callbackInfo->callback_);
HILOG_DEBUG("complete function callback mode");
} else {
if (callbackInfo->ret_ == OHOS::Accessibility::RET_OK) {
if (callbackInfo->ret_) {
napi_resolve_deferred(env, callbackInfo->deferred_, undefined);
} else {
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM0]);
napi_reject_deferred(env, callbackInfo->deferred_, undefined);
}
HILOG_DEBUG("complete function promise mode");
}
@@ -316,55 +219,59 @@ void NAccessibilityConfig::SetConfigExecute(napi_env env, void* data)
HILOG_ERROR("callbackInfo is nullptr");
return;
}
if (!callbackInfo->ret_) {
HILOG_ERROR("check param error");
return;
}
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
switch (callbackInfo->id_) {
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRAST_TEXT:
callbackInfo->ret_ = instance.SetHighContrastTextState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.SetHighContrastTextState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
callbackInfo->ret_ = instance.SetInvertColorState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.SetInvertColorState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ANIMATION_OFF:
callbackInfo->ret_ = instance.SetAnimationOffState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.SetAnimationOffState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SCREEN_MAGNIFICATION:
callbackInfo->ret_ = instance.SetScreenMagnificationState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.SetScreenMagnificationState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_MONO:
callbackInfo->ret_ = instance.SetAudioMonoState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.SetAudioMonoState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_KEY:
callbackInfo->ret_ = instance.SetMouseKeyState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.SetMouseKeyState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY:
callbackInfo->ret_ = instance.SetShortKeyState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.SetShortKeyState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STATE:
callbackInfo->ret_ = instance.SetCaptionsState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.SetCaptionsState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CONTENT_TIMEOUT:
callbackInfo->ret_ = instance.SetContentTimeout(callbackInfo->uint32Config_);
callbackInfo->ret_ = RET_OK == instance.SetContentTimeout(callbackInfo->uint32Config_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_AUTOCLICK:
callbackInfo->ret_ = instance.SetMouseAutoClick(callbackInfo->int32Config_);
callbackInfo->ret_ = RET_OK == instance.SetMouseAutoClick(callbackInfo->int32Config_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_BALANCE:
callbackInfo->ret_ = instance.SetAudioBalance(callbackInfo->floatConfig_);
callbackInfo->ret_ = RET_OK == instance.SetAudioBalance(callbackInfo->floatConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_BRIGHTNESS_DISCOUNT:
callbackInfo->ret_ = instance.SetBrightnessDiscount(callbackInfo->floatConfig_);
callbackInfo->ret_ = RET_OK == instance.SetBrightnessDiscount(callbackInfo->floatConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_DALTONIZATION_COLOR_FILTER:
{
auto filter = ConvertStringToDaltonizationTypes(callbackInfo->stringConfig_);
callbackInfo->ret_ = instance.SetDaltonizationColorFilter(filter);
callbackInfo->ret_ = RET_OK == instance.SetDaltonizationColorFilter(filter);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY_TARGET:
callbackInfo->ret_ = instance.SetShortkeyTarget(callbackInfo->stringConfig_);
callbackInfo->ret_ = RET_OK == instance.SetShortkeyTarget(callbackInfo->stringConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STYLE:
callbackInfo->ret_ = instance.SetCaptionsProperty(callbackInfo->captionProperty_);
callbackInfo->ret_ = RET_OK == instance.SetCaptionsProperty(callbackInfo->captionProperty_);
break;
default:
break;
@@ -379,8 +286,11 @@ void NAccessibilityConfig::GetConfigComplete(napi_env env, napi_status status, v
HILOG_ERROR("callbackInfo is nullptr");
return;
}
HILOG_INFO("callbackInfo->id_ = %{public}d", callbackInfo->id_);
napi_value result[ARGS_SIZE_TWO] = {0};
napi_value callback = 0;
napi_value undefined = 0;
napi_get_undefined(env, &undefined);
HILOG_INFO("callbackInfo->id_ = %{public}d", callbackInfo->id_);
switch (callbackInfo->id_) {
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRAST_TEXT:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
@@ -411,22 +321,22 @@ void NAccessibilityConfig::GetConfigComplete(napi_env env, napi_status status, v
default:
break;
}
napi_value returnVal = 0;
napi_value callback = 0;
napi_value undefined = 0;
napi_get_undefined(env, &undefined);
result[PARAM0] = CreateBusinessError(env, callbackInfo->ret_);
if (callbackInfo->callback_) {
if (callbackInfo->ret_) {
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
} else {
result[PARAM0] = GetErrorValue(env, CODE_FAILED);
}
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_value returnVal;
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
napi_delete_reference(env, callbackInfo->callback_);
HILOG_DEBUG("complete function callback mode");
} else {
if (callbackInfo->ret_ == OHOS::Accessibility::RET_OK) {
if (callbackInfo->ret_) {
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
} else {
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM0]);
napi_reject_deferred(env, callbackInfo->deferred_, undefined);
}
}
napi_delete_async_work(env, callbackInfo->work_);
@@ -445,57 +355,57 @@ void NAccessibilityConfig::GetConfigExecute(napi_env env, void* data)
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
switch (callbackInfo->id_) {
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRAST_TEXT:
callbackInfo->ret_ = instance.GetHighContrastTextState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.GetHighContrastTextState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
callbackInfo->ret_ = instance.GetInvertColorState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.GetInvertColorState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ANIMATION_OFF:
callbackInfo->ret_ = instance.GetAnimationOffState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.GetAnimationOffState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SCREEN_MAGNIFICATION:
callbackInfo->ret_ = instance.GetScreenMagnificationState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.GetScreenMagnificationState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_MONO:
callbackInfo->ret_ = instance.GetAudioMonoState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.GetAudioMonoState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_KEY:
callbackInfo->ret_ = instance.GetMouseKeyState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.GetMouseKeyState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY:
callbackInfo->ret_ = instance.GetShortKeyState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.GetShortKeyState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STATE:
callbackInfo->ret_ = instance.GetCaptionsState(callbackInfo->boolConfig_);
callbackInfo->ret_ = RET_OK == instance.GetCaptionsState(callbackInfo->boolConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CONTENT_TIMEOUT:
{
uint32_t timeout = 0;
callbackInfo->ret_ = instance.GetContentTimeout(timeout);
callbackInfo->ret_ = RET_OK == instance.GetContentTimeout(timeout);
callbackInfo->int32Config_ = static_cast<int32_t>(timeout);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_AUTOCLICK:
callbackInfo->ret_ = instance.GetMouseAutoClick(callbackInfo->int32Config_);
callbackInfo->ret_ = RET_OK == instance.GetMouseAutoClick(callbackInfo->int32Config_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_BALANCE:
callbackInfo->ret_ = instance.GetAudioBalance(callbackInfo->floatConfig_);
callbackInfo->ret_ = RET_OK == instance.GetAudioBalance(callbackInfo->floatConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_BRIGHTNESS_DISCOUNT:
callbackInfo->ret_ = instance.GetBrightnessDiscount(callbackInfo->floatConfig_);
callbackInfo->ret_ = RET_OK == instance.GetBrightnessDiscount(callbackInfo->floatConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_DALTONIZATION_COLOR_FILTER:
{
OHOS::AccessibilityConfig::DALTONIZATION_TYPE type;
callbackInfo->ret_ = instance.GetDaltonizationColorFilter(type);
callbackInfo->ret_ = RET_OK == instance.GetDaltonizationColorFilter(type);
callbackInfo->stringConfig_ = ConvertDaltonizationTypeToString(type);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY_TARGET:
callbackInfo->ret_ = instance.GetShortkeyTarget(callbackInfo->stringConfig_);
callbackInfo->ret_ = RET_OK == instance.GetShortkeyTarget(callbackInfo->stringConfig_);
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STYLE:
callbackInfo->ret_ = instance.GetCaptionsProperty(callbackInfo->captionProperty_);
callbackInfo->ret_ = RET_OK == instance.GetCaptionsProperty(callbackInfo->captionProperty_);
break;
default:
break;
@@ -511,113 +421,76 @@ napi_value NAccessibilityConfig::SetConfig(napi_env env, napi_callback_info info
napi_get_cb_info(env, info, &argc, parameters, &jsthis, nullptr);
NAccessibilityConfigClass* obj;
napi_status status = napi_unwrap(env, jsthis, reinterpret_cast<void**>(&obj));
if (status != napi_ok) {
HILOG_ERROR("Failed to get unwrap obj");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_FAILED);
napi_throw(env, err);
return nullptr;
}
NAPI_CALL(env, napi_unwrap(env, jsthis, reinterpret_cast<void**>(&obj)));
if (!obj) {
HILOG_ERROR("obj is nullptr");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
HILOG_INFO("ConfigID = %{public}d", obj->GetConfigId());
NAccessibilityConfigData* callbackInfo = new(std::nothrow) NAccessibilityConfigData();
if (!callbackInfo) {
HILOG_ERROR("callbackInfo is nullptr");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
OHOS::Accessibility::RetError errCode = OHOS::Accessibility::RET_OK;
if (argc < ARGS_SIZE_TWO - 1) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
bool ret = false;
if (errCode == OHOS::Accessibility::RET_OK) {
switch (obj->GetConfigId()) {
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRAST_TEXT:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ANIMATION_OFF:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SCREEN_MAGNIFICATION:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_MONO:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_KEY:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STATE:
{
bool state = false;
ret = ParseBool(env, state, parameters[PARAM0]);
callbackInfo->boolConfig_ = state;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CONTENT_TIMEOUT:
{
int32_t timeout = 0;
ret = ParseInt32(env, timeout, parameters[PARAM0]);
callbackInfo->uint32Config_ = static_cast<uint32_t>(timeout);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_AUTOCLICK:
{
int32_t time = 0;
ret = ParseInt32(env, time, parameters[PARAM0]);
callbackInfo->int32Config_ = time;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_BALANCE:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_BRIGHTNESS_DISCOUNT:
{
double doubleTemp = 0;
ret = ParseDouble(env, doubleTemp, parameters[PARAM0]);
callbackInfo->floatConfig_ = static_cast<float>(doubleTemp);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_DALTONIZATION_COLOR_FILTER:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY_TARGET:
{
std::string target = "";
ret = ParseString(env, target, parameters[PARAM0]) && target.length() > 0;
callbackInfo->stringConfig_ = target;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STYLE:
ret = ConvertObjToCaptionProperty(env, parameters[PARAM0], &callbackInfo->captionProperty_);
break;
default:
break;
}
if (!ret) {
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
if (errCode == OHOS::Accessibility::RET_ERR_INVALID_PARAM) {
delete callbackInfo;
callbackInfo = nullptr;
delete obj;
obj = nullptr;
napi_value err = CreateBusinessError(env, errCode);
HILOG_ERROR("invalid param");
napi_throw(env, err);
return nullptr;
switch (obj->GetConfigId()) {
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_HIGH_CONTRAST_TEXT:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_INVERT_COLOR:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_ANIMATION_OFF:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SCREEN_MAGNIFICATION:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_MONO:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_KEY:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STATE:
{
bool state = false;
callbackInfo->ret_ = ParseBool(env, state, parameters[PARAM0]);
callbackInfo->boolConfig_ = state;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CONTENT_TIMEOUT:
{
int32_t timeout = 0;
callbackInfo->ret_ = ParseInt32(env, timeout, parameters[PARAM0]);
callbackInfo->uint32Config_ = static_cast<uint32_t>(timeout);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_MOUSE_AUTOCLICK:
{
int32_t time = 0;
callbackInfo->ret_ = ParseInt32(env, time, parameters[PARAM0]);
callbackInfo->int32Config_ = time;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_AUDIO_BALANCE:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_BRIGHTNESS_DISCOUNT:
{
double doubleTemp = 0;
callbackInfo->ret_ = ParseDouble(env, doubleTemp, parameters[PARAM0]);
callbackInfo->floatConfig_ = static_cast<float>(doubleTemp);
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_DALTONIZATION_COLOR_FILTER:
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_SHORT_KEY_TARGET:
{
std::string target = "";
callbackInfo->ret_ = ParseString(env, target, parameters[PARAM0]) && target.length() > 0;
callbackInfo->stringConfig_ = target;
}
break;
case OHOS::AccessibilityConfig::CONFIG_ID::CONFIG_CAPTION_STYLE:
callbackInfo->ret_ = ConvertObjToCaptionProperty(env, parameters[PARAM0], &callbackInfo->captionProperty_);
break;
default:
break;
}
callbackInfo->id_ = obj->GetConfigId();
// parse function if it needs
napi_value promise = nullptr;
if (argc >= ARGS_SIZE_TWO) {
napi_valuetype valueType = napi_null;
napi_typeof(env, parameters[PARAM1], &valueType);
if (valueType == napi_function) {
napi_create_reference(env, parameters[PARAM1], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
napi_create_reference(env, parameters[PARAM1], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
@@ -645,17 +518,9 @@ napi_value NAccessibilityConfig::GetConfig(napi_env env, napi_callback_info info
napi_get_cb_info(env, info, &argc, parameters, &jsthis, nullptr);
NAccessibilityConfigClass* obj;
napi_status status = napi_unwrap(env, jsthis, reinterpret_cast<void**>(&obj));
if (status != napi_ok) {
HILOG_ERROR("Failed to get unwrap obj");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_FAILED);
napi_throw(env, err);
return nullptr;
}
NAPI_CALL(env, napi_unwrap(env, jsthis, reinterpret_cast<void**>(&obj)));
if (!obj) {
HILOG_ERROR("obj is nullptr");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
HILOG_INFO("ConfigID = %{public}d", obj->GetConfigId());
@@ -663,8 +528,6 @@ napi_value NAccessibilityConfig::GetConfig(napi_env env, napi_callback_info info
NAccessibilityConfigData* callbackInfo = new(std::nothrow) NAccessibilityConfigData();
if (!callbackInfo) {
HILOG_ERROR("callbackInfo is nullptr");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
callbackInfo->id_ = obj->GetConfigId();
@@ -672,14 +535,8 @@ napi_value NAccessibilityConfig::GetConfig(napi_env env, napi_callback_info info
// parse function if it needs
napi_value promise = nullptr;
if (argc >= ARGS_SIZE_ONE) {
napi_valuetype valueType = napi_null;
napi_typeof(env, parameters[PARAM0], &valueType);
if (valueType == napi_function) {
napi_create_reference(env, parameters[PARAM0], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
napi_create_reference(env, parameters[PARAM0], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
@@ -705,41 +562,9 @@ napi_value NAccessibilityConfig::SubscribeConfigObserver(napi_env env, napi_call
napi_value jsthis;
napi_get_cb_info(env, info, &argc, parameters, &jsthis, nullptr);
NAccessibilityConfigClass* obj;
napi_status status = napi_unwrap(env, jsthis, reinterpret_cast<void**>(&obj));
if (status != napi_ok) {
HILOG_ERROR("Failed to get unwrap obj");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_FAILED);
napi_throw(env, err);
return nullptr;
}
NAPI_CALL(env, napi_unwrap(env, jsthis, reinterpret_cast<void**>(&obj)));
if (!obj) {
HILOG_ERROR("obj is nullptr");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
OHOS::Accessibility::RetError errCode = OHOS::Accessibility::RET_OK;
if (argc < ARGS_SIZE_ONE) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
if (errCode == OHOS::Accessibility::RET_OK) {
napi_valuetype valueType = napi_null;
napi_typeof(env, parameters[PARAM0], &valueType);
if (valueType != napi_function) {
HILOG_ERROR("parameters[PARAM1] format is wrong");
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
if (errCode == OHOS::Accessibility::RET_ERR_INVALID_PARAM) {
delete obj;
obj = nullptr;
napi_value err = CreateBusinessError(env, errCode);
HILOG_ERROR("invalid param");
napi_throw(env, err);
return nullptr;
}
@@ -760,27 +585,13 @@ napi_value NAccessibilityConfig::UnSubscribeConfigObserver(napi_env env, napi_ca
napi_value parameters[ARGS_SIZE_ONE] = {0};
napi_get_cb_info(env, info, &argc, parameters, &jsthis, nullptr);
NAccessibilityConfigClass* obj;
napi_status status = napi_unwrap(env, jsthis, reinterpret_cast<void**>(&obj));
if (status != napi_ok) {
HILOG_ERROR("Failed to get unwrap obj");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_FAILED);
napi_throw(env, err);
return nullptr;
}
NAPI_CALL(env, napi_unwrap(env, jsthis, reinterpret_cast<void**>(&obj)));
if (!obj) {
HILOG_ERROR("obj is nullptr");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
if (argc >= ARGS_SIZE_ONE) {
napi_valuetype valueType = napi_null;
napi_typeof(env, parameters[PARAM0], &valueType);
if (valueType == napi_function) {
configObservers_->UnsubscribeObserver(obj->GetConfigId(), parameters[PARAM0]);
} else {
configObservers_->UnsubscribeObservers(obj->GetConfigId());
}
configObservers_->UnsubscribeObserver(obj->GetConfigId(), parameters[PARAM0]);
} else {
configObservers_->UnsubscribeObservers(obj->GetConfigId());
}
@@ -35,73 +35,73 @@ public:
* @brief Obtains elementInfo of focus.
* @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
* @param elementInfo The accessibilityElementInfo of focus.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
RetError GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo);
bool GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo);
/**
* @brief Obtains elementInfo of focus.
* @param sourceInfo
* @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
* @param elementInfo The accessibilityElementInfo of focus.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
RetError GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType,
bool GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType,
AccessibilityElementInfo &elementInfo);
/**
* @brief Sends simulate gestures to the screen.
* @param gesturePath The gesture which need to send.
* @return Return RET_OK if the gesture sends successfully, otherwise refer to the RetError for the failure.
* @return Return true if the gesture sends successfully, else return false.
*/
RetError InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath);
bool InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath);
/**
* @brief Sends simulate gestures to the screen.
* @param gesturePaths The gesture which need to send.
* @return Return RET_OK if the gesture sends successfully, otherwise refer to the RetError for the failure.
* @return Return true if the gesture sends successfully, else return false.
*/
RetError InjectGesture(const std::vector<std::shared_ptr<AccessibilityGestureInjectPath>> &gesturePaths);
bool InjectGesture(const std::vector<std::shared_ptr<AccessibilityGestureInjectPath>> &gesturePaths);
/**
* @brief Obtains elementInfo of the accessible root node.
* @param elementInfo The elementInfo of the accessible root node.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
RetError GetRoot(AccessibilityElementInfo &elementInfo);
bool GetRoot(AccessibilityElementInfo &elementInfo);
/**
* @brief Obtains elementInfo of the accessible root node.
* @param windowInfo The source window info to get root.
* @param elementInfo The elementInfo of the accessible root node.
* @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains elementInfo successfully, else return false.
*/
RetError GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
bool GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
AccessibilityElementInfo &elementInfo);
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows);
bool GetWindows(std::vector<AccessibilityWindowInfo> &windows);
/**
* @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
* @param displayId the id of display
* @param windows The information of windows.
* @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if obtains windowInfo successfully, else return false.
*/
RetError GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows);
bool GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows);
/**
* @brief Gets the next focused node in the specified direction of the currently focused node.
* @param elementInfo
* @param direction Indicates the direction to obtain the next focused node. Refer to FocusMoveDirection
* @param nextElementInfo The info of next element.
* @return Return RET_OK if gets next elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets next elementInfo successfully, else return false.
*/
RetError GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction,
bool GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction,
AccessibilityElementInfo &nextElementInfo);
/**
@@ -109,9 +109,9 @@ public:
* @param index
* @param parent
* @param child The element info of child
* @return Return RET_OK if gets child elementInfo successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets child elementInfo successfully, else return false.
*/
RetError GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
bool GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
AccessibilityElementInfo &child);
/**
@@ -119,18 +119,18 @@ public:
* @param elementInfo
* @param text specified content
* @param elementInfos
* @return Return RET_OK if gets elementInfos successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets elementInfos successfully, else return false.
*/
RetError GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
bool GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
std::vector<AccessibilityElementInfo> &elementInfos);
/**
* @brief Get Parent node information
* @param child
* @param parent
* @return Return RET_OK if gets info successfully, otherwise refer to the RetError for the failure.
* @return Return true if gets info successfully, else return false.
*/
RetError GetParentElementInfo(const AccessibilityElementInfo &child, AccessibilityElementInfo &parent);
bool GetParentElementInfo(const AccessibilityElementInfo &child, AccessibilityElementInfo &parent);
/**
* @brief Executes a specified action.
@@ -150,17 +150,17 @@ public:
* {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
* action: ACCESSIBILITY_ACTION_SET_TEXT,
* actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
* @return Return RET_OK if performs action succeed, otherwise refer to the RetError for the failure.
* @return true Perform action succeed, otherwise is not.
*/
RetError ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
bool ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
const std::map<std::string, std::string> &actionArguments);
/**
* @brief Set target bundle names.
* @param targetBundleNames The target bundle name
* @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure.
* @return Return true if sets target bundle names successfully, else return false.
*/
RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames);
bool SetTargetBundleName(const std::vector<std::string> &targetBundleNames);
};
} // namespace Accessibility
} // namespace OHOS
@@ -16,7 +16,6 @@
#ifndef NAPI_ACCESSIBILITY_ELEMENT_H
#define NAPI_ACCESSIBILITY_ELEMENT_H
#include "napi_accessibility_def.h"
#include "accessibility_event_info.h"
#include "accessibility_window_info.h"
#include "napi/native_api.h"
@@ -56,7 +55,7 @@ struct NAccessibilityElementData {
std::string attribute_ = "";
std::string actionName_ = "";
std::string condition_ = "";
OHOS::Accessibility::RetError ret_ = OHOS::Accessibility::RetError::RET_ERR_FAILED;
bool ret_ = false;
};
class NAccessibilityElement {
@@ -21,161 +21,159 @@ using namespace std;
namespace OHOS {
namespace Accessibility {
RetError AccessibilityExtensionContext::GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo)
bool AccessibilityExtensionContext::GetFocus(const int32_t focusType, AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetFocus(focusType, elementInfo);
}
RetError AccessibilityExtensionContext::GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo,
bool AccessibilityExtensionContext::GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo,
const int32_t focusType, AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetFocusByElementInfo(sourceInfo, focusType, elementInfo);
}
RetError AccessibilityExtensionContext::InjectGesture(
const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
bool AccessibilityExtensionContext::InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->InjectGesture(gesturePath);
}
RetError AccessibilityExtensionContext::InjectGesture(
bool AccessibilityExtensionContext::InjectGesture(
const std::vector<std::shared_ptr<AccessibilityGestureInjectPath>> &gesturePaths)
{
HILOG_DEBUG("This method is temporarily not implemented!");
return RET_ERR_NOT_SUPPORT;
return false;
}
RetError AccessibilityExtensionContext::GetRoot(AccessibilityElementInfo &elementInfo)
bool AccessibilityExtensionContext::GetRoot(AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetRoot(elementInfo);
}
RetError AccessibilityExtensionContext::GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
bool AccessibilityExtensionContext::GetRootByWindow(const AccessibilityWindowInfo &windowInfo,
AccessibilityElementInfo &elementInfo)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetRootByWindow(windowInfo, elementInfo);
}
RetError AccessibilityExtensionContext::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
bool AccessibilityExtensionContext::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetWindows(windows);
}
RetError AccessibilityExtensionContext::GetWindows(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows)
bool AccessibilityExtensionContext::GetWindows(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetWindows(displayId, windows);
}
RetError AccessibilityExtensionContext::GetNext(const AccessibilityElementInfo &elementInfo,
bool AccessibilityExtensionContext::GetNext(const AccessibilityElementInfo &elementInfo,
const FocusMoveDirection direction, AccessibilityElementInfo &nextElementInfo)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetNext(elementInfo, direction, nextElementInfo);
}
RetError AccessibilityExtensionContext::GetChildElementInfo(const int32_t index,
const AccessibilityElementInfo &parent, AccessibilityElementInfo &child)
bool AccessibilityExtensionContext::GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent,
AccessibilityElementInfo &child)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetChildElementInfo(index, parent, child);
}
RetError AccessibilityExtensionContext::GetByContent(const AccessibilityElementInfo &elementInfo,
const std::string &text, std::vector<AccessibilityElementInfo> &elementInfos)
bool AccessibilityExtensionContext::GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text,
std::vector<AccessibilityElementInfo> &elementInfos)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetByContent(elementInfo, text, elementInfos);
}
RetError AccessibilityExtensionContext::GetParentElementInfo(const AccessibilityElementInfo &child,
bool AccessibilityExtensionContext::GetParentElementInfo(const AccessibilityElementInfo &child,
AccessibilityElementInfo &parent)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->GetParentElementInfo(child, parent);
}
RetError AccessibilityExtensionContext::ExecuteAction(const AccessibilityElementInfo &elementInfo,
const ActionType action, const std::map<std::string, std::string> &actionArguments)
bool AccessibilityExtensionContext::ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action,
const std::map<std::string, std::string> &actionArguments)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->ExecuteAction(elementInfo, action, actionArguments);
}
RetError AccessibilityExtensionContext::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
bool AccessibilityExtensionContext::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (!aaClient) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return aaClient->SetTargetBundleName(targetBundleNames);
}
@@ -186,17 +186,16 @@ napi_value NAccessibilityElement::AttributeNames(napi_env env, napi_callback_inf
callbackInfo->env_ = env;
napi_value promise = nullptr;
if (argc > ARGS_SIZE_ONE - 1) {
napi_valuetype valueType = napi_null;
napi_typeof(env, argv, &valueType);
if (valueType == napi_function) {
napi_create_reference(env, argv, 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
} else {
if (argc == ARGS_SIZE_ZERO) {
HILOG_DEBUG("promise mode");
napi_create_promise(env, &callbackInfo->deferred_, &promise);
} else if (argc == ARGS_SIZE_ONE) {
HILOG_DEBUG("callback mode");
napi_create_reference(env, argv, 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
HILOG_ERROR("The size of args is err[%{public}zu]", argc);
return ErrorOperation(callbackInfo);
}
AccessibilityElement* accessibilityElement = nullptr;
@@ -242,7 +241,7 @@ void NAccessibilityElement::AttributeNamesComplete(napi_env env, napi_status sta
if (callbackInfo->callback_) {
// Callback mode
result[PARAM0] = CreateBusinessError(env, OHOS::Accessibility::RetError::RET_OK);
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_value returnVal;
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
@@ -262,77 +261,44 @@ napi_value NAccessibilityElement::AttributeValue(napi_env env, napi_callback_inf
napi_value argv[ARGS_SIZE_TWO] = {0};
napi_value thisVar = nullptr;
void* data = nullptr;
napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
if (status != napi_ok) {
HILOG_ERROR("Failed to get cb info");
napi_value err = CreateBusinessError(env, RetError::RET_ERR_FAILED);
napi_throw(env, err);
return nullptr;
}
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
HILOG_DEBUG("argc = %{public}d", (int)argc);
// Unwrap AccessibilityElement
AccessibilityElement* accessibilityElement = nullptr;
status = napi_unwrap(env, thisVar, (void**)&accessibilityElement);
if (!accessibilityElement || status != napi_ok) {
HILOG_ERROR("accessibilityElement is null or status[%{public}d] is wrong", status);
napi_value err = CreateBusinessError(env, RetError::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
NAccessibilityElementData *callbackInfo = new(std::nothrow) NAccessibilityElementData();
if (!callbackInfo) {
HILOG_ERROR("Failed to create callbackInfo.");
napi_value err = CreateBusinessError(env, RetError::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
callbackInfo->env_ = env;
callbackInfo->accessibilityElement_ = *accessibilityElement;
NAccessibilityErrorCode errCode = NAccessibilityErrorCode::ACCESSIBILITY_OK;
if (argc < ARGS_SIZE_TWO - 1) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM;
}
if (errCode == NAccessibilityErrorCode::ACCESSIBILITY_OK) {
// Parse attribute name
std::string attribute = "";
if (ParseString(env, attribute, argv[PARAM0])) {
HILOG_INFO("attribute = %{public}s", attribute.c_str());
callbackInfo->attribute_ = attribute;
} else {
errCode = NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM;
}
}
if (errCode == NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM) {
delete callbackInfo;
callbackInfo = nullptr;
delete accessibilityElement;
accessibilityElement = nullptr;
napi_value err = CreateBusinessError(env, RetError::RET_ERR_INVALID_PARAM);
HILOG_ERROR("invalid param");
napi_throw(env, err);
return nullptr;
}
napi_value promise = nullptr;
if (argc > ARGS_SIZE_TWO - 1) {
napi_valuetype valueType = napi_null;
napi_typeof(env, argv[PARAM1], &valueType);
if (valueType == napi_function) {
napi_create_reference(env, argv[PARAM1], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
} else {
if (argc == ARGS_SIZE_ONE) {
// Promise mode
napi_create_promise(env, &callbackInfo->deferred_, &promise);
} else if (argc == ARGS_SIZE_TWO) {
// Callback mode
napi_create_reference(env, argv[PARAM1], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
HILOG_ERROR("The size of args is err[%{public}zu]", argc);
return ErrorOperation(callbackInfo);
}
// Parse attribute name
std::string attribute = "";
ParseString(env, attribute, argv[PARAM0]);
HILOG_INFO("attribute = %{public}s", attribute.c_str());
callbackInfo->attribute_ = attribute;
// Unwrap AccessibilityElement
AccessibilityElement* accessibilityElement = nullptr;
napi_status status = napi_unwrap(env, thisVar, (void**)&accessibilityElement);
if (!accessibilityElement || status != napi_ok) {
HILOG_ERROR("accessibilityElement is null or status[%{public}d] is wrong", status);
return ErrorOperation(callbackInfo);
}
callbackInfo->accessibilityElement_ = *accessibilityElement;
napi_value resource = nullptr;
napi_create_string_utf8(env, "AttributeValue", NAPI_AUTO_LENGTH, &resource);
napi_create_async_work(env, nullptr, resource, NAccessibilityElement::AttributeValueExecute,
@@ -371,7 +337,7 @@ void NAccessibilityElement::AttributeValueExecute(napi_env env, void* data)
HILOG_ERROR("windowInfo is nullptr");
}
} else {
callbackInfo->ret_ = RET_OK;
callbackInfo->ret_ = true;
}
HILOG_INFO("attribute[%{public}s], result[%{public}d]", callbackInfo->attribute_.c_str(), callbackInfo->ret_);
}
@@ -391,7 +357,7 @@ void NAccessibilityElement::AttributeValueComplete(napi_env env, napi_status sta
if (elementIter == elementInfoCompleteMap.end()) {
HILOG_ERROR("There is no the attribute[%{public}s] in element info", callbackInfo->attribute_.c_str());
napi_get_undefined(callbackInfo->env_, &result[PARAM1]);
callbackInfo->ret_ = RET_ERR_PROPERTY_NOT_EXIST;
callbackInfo->ret_ = false;
} else {
(*elementIter->second)(callbackInfo, result[PARAM1]);
}
@@ -401,25 +367,25 @@ void NAccessibilityElement::AttributeValueComplete(napi_env env, napi_status sta
if (windowIter == windowInfoCompleteMap.end()) {
HILOG_ERROR("There is no the attribute[%{public}s]", callbackInfo->attribute_.c_str());
napi_get_undefined(callbackInfo->env_, &result[PARAM1]);
callbackInfo->ret_ = RET_ERR_PROPERTY_NOT_EXIST;
callbackInfo->ret_ = false;
} else {
(*windowIter->second)(callbackInfo, result[PARAM1]);
}
}
HILOG_DEBUG("result is %{public}d", callbackInfo->ret_);
result[PARAM0] = CreateBusinessError(env, callbackInfo->ret_);
if (callbackInfo->callback_) {
result[PARAM0] = callbackInfo->ret_ ? GetErrorValue(env, CODE_SUCCESS) : GetErrorValue(env, CODE_FAILED);
napi_value callback, returnVal, undefined;
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_get_undefined(env, &undefined);
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
napi_delete_reference(env, callbackInfo->callback_);
} else {
if (callbackInfo->ret_ == RET_OK) {
if (callbackInfo->ret_) {
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
} else {
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM0]);
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM1]);
}
}
napi_delete_async_work(env, callbackInfo->work_);
@@ -436,7 +402,7 @@ bool NAccessibilityElement::CheckElementInfoParameter(NAccessibilityElementData
if (!callbackInfo->accessibilityElement_.elementInfo_) {
HILOG_ERROR("element info is nullptr");
napi_get_undefined(callbackInfo->env_, &value);
callbackInfo->ret_ = RET_ERR_FAILED;
callbackInfo->ret_ = false;
return false;
}
return true;
@@ -760,10 +726,10 @@ void NAccessibilityElement::GetElementInfoTextMoveUnit(NAccessibilityElementData
callbackInfo->accessibilityElement_.elementInfo_->GetTextMovementStep());
HILOG_DEBUG("ConvertTextMoveUnitToString: [%{public}s]", textMoveUnit.c_str());
if (textMoveUnit == "") {
callbackInfo->ret_ = RET_ERR_FAILED;
callbackInfo->ret_ = false;
napi_get_undefined(callbackInfo->env_, &value);
} else {
callbackInfo->ret_ = RET_OK;
callbackInfo->ret_ = true;
NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_string_utf8(callbackInfo->env_,
textMoveUnit.c_str(), NAPI_AUTO_LENGTH, &value));
}
@@ -774,7 +740,7 @@ void NAccessibilityElement::GetElementInfoParent(NAccessibilityElementData *call
if (!CheckElementInfoParameter(callbackInfo, value)) {
return;
}
if (callbackInfo->ret_ == RET_OK) {
if (callbackInfo->ret_) {
napi_value constructor = nullptr;
NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_get_reference_value(callbackInfo->env_,
NAccessibilityElement::consRef_, &constructor));
@@ -792,7 +758,7 @@ void NAccessibilityElement::GetElementInfoChildren(NAccessibilityElementData *ca
if (!CheckElementInfoParameter(callbackInfo, value)) {
return;
}
if (callbackInfo->ret_ == RET_OK) {
if (callbackInfo->ret_) {
NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_array(callbackInfo->env_, &value));
ConvertElementInfosToJS(callbackInfo->env_, value, callbackInfo->nodeInfos_);
} else {
@@ -810,10 +776,10 @@ void NAccessibilityElement::GetElementInfoTriggerAction(NAccessibilityElementDat
callbackInfo->accessibilityElement_.elementInfo_->GetTriggerAction());
HILOG_DEBUG("GetElementInfoTriggerAction: [%{public}s]", triggerAction.c_str());
if (triggerAction == "") {
callbackInfo->ret_ = RET_ERR_FAILED;
callbackInfo->ret_ = false;
napi_get_undefined(callbackInfo->env_, &value);
} else {
callbackInfo->ret_ = RET_OK;
callbackInfo->ret_ = true;
NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_string_utf8(callbackInfo->env_,
triggerAction.c_str(), NAPI_AUTO_LENGTH, &value));
}
@@ -875,7 +841,7 @@ bool NAccessibilityElement::CheckWindowInfoParameter(NAccessibilityElementData *
if (!callbackInfo->accessibilityElement_.windowInfo_) {
HILOG_ERROR("window info is nullptr");
napi_get_undefined(callbackInfo->env_, &value);
callbackInfo->ret_ = RET_ERR_FAILED;
callbackInfo->ret_ = false;
return false;
}
return true;
@@ -918,10 +884,10 @@ void NAccessibilityElement::GetWindowInfoType(NAccessibilityElementData *callbac
callbackInfo->accessibilityElement_.windowInfo_->GetAccessibilityWindowType());
HILOG_DEBUG("GetWindowInfoType: [%{public}s]", accessibilityWindowType.c_str());
if (accessibilityWindowType == "") {
callbackInfo->ret_ = RET_ERR_FAILED;
callbackInfo->ret_ = false;
napi_get_undefined(callbackInfo->env_, &value);
} else {
callbackInfo->ret_ = RET_OK;
callbackInfo->ret_ = true;
NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_create_string_utf8(callbackInfo->env_,
accessibilityWindowType.c_str(), NAPI_AUTO_LENGTH, &value));
}
@@ -932,7 +898,7 @@ void NAccessibilityElement::GetWindowInfoRootElement(NAccessibilityElementData *
if (!CheckWindowInfoParameter(callbackInfo, value)) {
return;
}
if (callbackInfo->ret_ == RET_OK) {
if (callbackInfo->ret_) {
napi_value constructor = nullptr;
NAPI_CALL_RETURN_VOID(callbackInfo->env_, napi_get_reference_value(callbackInfo->env_,
NAccessibilityElement::consRef_, &constructor));
@@ -981,17 +947,16 @@ napi_value NAccessibilityElement::ActionNames(napi_env env, napi_callback_info i
callbackInfo->env_ = env;
napi_value promise = nullptr;
if (argc > ARGS_SIZE_ONE - 1) {
napi_valuetype valueType = napi_null;
napi_typeof(env, argv, &valueType);
if (valueType == napi_function) {
napi_create_reference(env, argv, 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
} else {
if (argc == ARGS_SIZE_ZERO) {
HILOG_DEBUG("promise mode");
napi_create_promise(env, &callbackInfo->deferred_, &promise);
} else if (argc == ARGS_SIZE_ONE) {
HILOG_DEBUG("callback mode");
napi_create_reference(env, argv, 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
HILOG_ERROR("The size of args is err[%{public}zu]", argc);
return ErrorOperation(callbackInfo);
}
AccessibilityElement* accessibilityElement = nullptr;
@@ -1045,13 +1010,13 @@ void NAccessibilityElement::ActionNamesComplete(napi_env env, napi_status status
ConvertStringVecToJS(env, result[PARAM1], actionNames);
} else {
HILOG_ERROR("no elementInfo_");
callbackInfo->ret_ = RET_ERR_FAILED;
napi_get_undefined(env, &result[PARAM1]);
}
result[PARAM0] = CreateBusinessError(env, callbackInfo->ret_);
if (callbackInfo->callback_) {
// Callback mode
result[PARAM0] = callbackInfo->accessibilityElement_.elementInfo_ ?
GetErrorValue(env, CODE_SUCCESS) : GetErrorValue(env, CODE_FAILED);
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_value returnVal;
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
@@ -1061,7 +1026,7 @@ void NAccessibilityElement::ActionNamesComplete(napi_env env, napi_status status
if (callbackInfo->accessibilityElement_.elementInfo_) {
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
} else {
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM0]);
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM1]);
}
}
napi_delete_async_work(env, callbackInfo->work_);
@@ -1075,101 +1040,67 @@ napi_value NAccessibilityElement::PerformAction(napi_env env, napi_callback_info
napi_value argv[ARGS_SIZE_THREE] = {0};
napi_value thisVar;
void* data = nullptr;
napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
if (status != napi_ok) {
HILOG_ERROR("Failed to get cb info");
napi_value err = CreateBusinessError(env, RetError::RET_ERR_FAILED);
napi_throw(env, err);
return nullptr;
}
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
HILOG_DEBUG("argc = %{public}zu", argc);
// Unwrap AccessibilityElement
AccessibilityElement* accessibilityElement = nullptr;
status = napi_unwrap(env, thisVar, (void**)&accessibilityElement);
if (!accessibilityElement || status != napi_ok) {
HILOG_ERROR("accessibilityElement is null or status[%{public}d] is wrong", status);
napi_value err = CreateBusinessError(env, RetError::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
if (!(accessibilityElement->isElementInfo_ && accessibilityElement->elementInfo_)) {
HILOG_ERROR("accessibilityElement is wrong. isElementInfo_[%{public}d]", accessibilityElement->isElementInfo_);
napi_value err = CreateBusinessError(env, RetError::RET_ERR_FAILED);
napi_throw(env, err);
return nullptr;
}
NAccessibilityElementData *callbackInfo = new(std::nothrow) NAccessibilityElementData();
if (!callbackInfo) {
HILOG_ERROR("Failed to create callbackInfo.");
napi_value err = CreateBusinessError(env, RetError::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
callbackInfo->env_ = env;
NAccessibilityErrorCode errCode = NAccessibilityErrorCode::ACCESSIBILITY_OK;
if (argc < ARGS_SIZE_ONE) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM;
}
std::string actionName;
if (errCode == NAccessibilityErrorCode::ACCESSIBILITY_OK) {
if (!ParseString(env, actionName, argv[PARAM0])) {
HILOG_ERROR("parse action name failed");
errCode = NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM;
}
}
if (errCode == NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM) {
delete callbackInfo;
callbackInfo = nullptr;
delete accessibilityElement;
accessibilityElement = nullptr;
napi_value err = CreateBusinessError(env, RetError::RET_ERR_INVALID_PARAM);
HILOG_ERROR("invalid param");
napi_throw(env, err);
return nullptr;
}
napi_value promise = nullptr;
std::map<std::string, std::string> actionArguments {};
if (argc == ARGS_SIZE_THREE) {
napi_valuetype secondParamType = napi_null;
napi_typeof(env, argv[PARAM1], &secondParamType);
napi_valuetype thirdParamType = napi_null;
napi_typeof(env, argv[PARAM2], &thirdParamType);
if (secondParamType == napi_undefined && thirdParamType == napi_function) {
ConvertActionArgsJSToNAPI(env, argv[PARAM1], actionArguments,
ConvertStringToAccessibleOperationType(actionName));
napi_create_reference(env, argv[PARAM2], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
HILOG_INFO("argc is three, use promise");
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
if (argc == ARGS_SIZE_ONE) {
// Promise mode
napi_create_promise(env, &callbackInfo->deferred_, &promise);
ParseString(env, actionName, argv[PARAM0]);
} else if (argc == ARGS_SIZE_TWO) {
napi_valuetype valueType = napi_null;
napi_typeof(env, argv[PARAM1], &valueType);
if (valueType == napi_function) {
ParseString(env, actionName, argv[PARAM0]);
napi_valuetype valuetype;
napi_status status = napi_typeof(env, argv[PARAM1], &valuetype);
if (status != napi_ok) {
HILOG_ERROR("napi_typeof error and status is %{public}d", status);
return ErrorOperation(callbackInfo);
}
if (valuetype == napi_function) {
// Callback mode
napi_create_reference(env, argv[PARAM1], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
if (valueType == napi_undefined) {
ConvertActionArgsJSToNAPI(env, argv[PARAM1], actionArguments,
ConvertStringToAccessibleOperationType(actionName));
}
HILOG_INFO("argc is two, use promise");
// Promise mode
napi_create_promise(env, &callbackInfo->deferred_, &promise);
HILOG_INFO("actionName = %{public}s", actionName.c_str());
ConvertActionArgsJSToNAPI(env, argv[PARAM1], actionArguments,
ConvertStringToAccessibleOperationType(actionName));
}
} else if (argc == ARGS_SIZE_THREE) {
// Callback mode
ParseString(env, actionName, argv[PARAM0]);
HILOG_INFO("actionName = %{public}s", actionName.c_str());
ConvertActionArgsJSToNAPI(env, argv[PARAM1], actionArguments,
ConvertStringToAccessibleOperationType(actionName));
napi_create_reference(env, argv[PARAM2], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
HILOG_INFO("argc is others, use promise");
napi_create_promise(env, &callbackInfo->deferred_, &promise);
HILOG_ERROR("The size of args is err[%{public}zu]", argc);
return ErrorOperation(callbackInfo);
}
HILOG_INFO("actionName = %{public}s", actionName.c_str());
// Unwrap AccessibilityElement
AccessibilityElement* accessibilityElement = nullptr;
napi_status status = napi_unwrap(env, thisVar, (void**)&accessibilityElement);
if (!accessibilityElement || status != napi_ok) {
HILOG_ERROR("accessibilityElement is null or status[%{public}d] is wrong", status);
return ErrorOperation(callbackInfo);
}
if (!(accessibilityElement->isElementInfo_ && accessibilityElement->elementInfo_)) {
HILOG_ERROR("accessibilityElement is wrong. isElementInfo_[%{public}d]", accessibilityElement->isElementInfo_);
return ErrorOperation(callbackInfo);
}
callbackInfo->accessibilityElement_ = *accessibilityElement;
callbackInfo->actionName_ = actionName;
callbackInfo->actionArguments_ = actionArguments;
@@ -1192,11 +1123,6 @@ void NAccessibilityElement::PerformActionExecute(napi_env env, void* data)
}
ActionType action = ConvertStringToAccessibleOperationType(callbackInfo->actionName_);
if (action == ActionType::ACCESSIBILITY_ACTION_INVALID) {
HILOG_ERROR("The action is not supported");
callbackInfo->ret_ = OHOS::Accessibility::RetError::RET_ERR_ACTION_NOT_SUPPORT;
return;
}
callbackInfo->ret_ = AccessibleAbilityClient::GetInstance()->ExecuteAction(
*callbackInfo->accessibilityElement_.elementInfo_, action, callbackInfo->actionArguments_);
HILOG_DEBUG("callbackInfo->ret_[%{public}d]", callbackInfo->ret_);
@@ -1214,21 +1140,17 @@ void NAccessibilityElement::PerformActionComplete(napi_env env, napi_status stat
napi_value callback = 0;
napi_value undefined = 0;
napi_get_undefined(env, &undefined);
napi_get_undefined(env, &result[PARAM1]);
result[PARAM0] = CreateBusinessError(env, callbackInfo->ret_);
napi_get_boolean(callbackInfo->env_, callbackInfo->ret_, &result[PARAM1]);
if (callbackInfo->callback_) {
// Callback mode
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_value returnVal;
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
napi_delete_reference(env, callbackInfo->callback_);
} else {
// Promise mode
if (callbackInfo->ret_ == RET_OK) {
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
} else {
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM0]);
}
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
}
napi_delete_async_work(env, callbackInfo->work_);
@@ -1242,98 +1164,52 @@ napi_value NAccessibilityElement::FindElement(napi_env env, napi_callback_info i
napi_value argv[ARGS_SIZE_THREE] = {0};
napi_value thisVar;
void* data = nullptr;
napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
if (status != napi_ok) {
HILOG_ERROR("Failed to get cb info");
napi_value err = CreateBusinessError(env, RetError::RET_ERR_FAILED);
napi_throw(env, err);
return nullptr;
}
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
HILOG_DEBUG("argc = %{public}d", (int)argc);
// Unwrap AccessibilityElement
AccessibilityElement* accessibilityElement = nullptr;
status = napi_unwrap(env, thisVar, (void**)&accessibilityElement);
if (!accessibilityElement || status != napi_ok) {
HILOG_ERROR("accessibilityElement is null or status[%{public}d] is wrong", status);
napi_value err = CreateBusinessError(env, RetError::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
if (!accessibilityElement->isElementInfo_) {
HILOG_ERROR("Type of AccessibilityElement is not right");
napi_value err = CreateBusinessError(env, RetError::RET_ERR_FAILED);
napi_throw(env, err);
return nullptr;
}
NAccessibilityElementData *callbackInfo = new(std::nothrow) NAccessibilityElementData();
if (!callbackInfo) {
HILOG_ERROR("Failed to create callbackInfo.");
napi_value err = CreateBusinessError(env, RetError::RET_ERR_NULLPTR);
napi_throw(env, err);
return nullptr;
}
callbackInfo->env_ = env;
NAccessibilityErrorCode errCode = NAccessibilityErrorCode::ACCESSIBILITY_OK;
if (argc < ARGS_SIZE_THREE - 1) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM;
}
if (errCode == NAccessibilityErrorCode::ACCESSIBILITY_OK) {
// Parse conditionType name
std::string conditionType = "";
if (ParseString(env, conditionType, argv[PARAM0])) {
HILOG_INFO("conditionType = %{public}s", conditionType.c_str());
if (std::strcmp(conditionType.c_str(), "content") != 0 &&
std::strcmp(conditionType.c_str(), "focusType") != 0 &&
std::strcmp(conditionType.c_str(), "focusDirection") != 0) {
HILOG_ERROR("argv[PARAM0] is wrong[%{public}s", conditionType.c_str());
errCode = NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM;
} else {
callbackInfo->conditionId_ = ConvertStringToCondition(conditionType);
}
} else {
errCode = NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM;
}
// Parse queryData name
std::string queryData = "";
if (ParseString(env, queryData, argv[PARAM1])) {
HILOG_INFO("queryData = %{public}s", queryData.c_str());
callbackInfo->condition_ = queryData;
} else {
errCode = NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM;
}
}
if (errCode == NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM) {
delete callbackInfo;
callbackInfo = nullptr;
delete accessibilityElement;
accessibilityElement = nullptr;
napi_value err = CreateBusinessError(env, RetError::RET_ERR_INVALID_PARAM);
HILOG_ERROR("invalid param");
napi_throw(env, err);
return nullptr;
}
napi_value promise = nullptr;
if (argc > ARGS_SIZE_THREE - 1) {
napi_valuetype valueType = napi_null;
napi_typeof(env, argv[PARAM2], &valueType);
if (valueType == napi_function) {
napi_create_reference(env, argv[PARAM2], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
} else {
if (argc == ARGS_SIZE_TWO) {
// Promise mode
napi_create_promise(env, &callbackInfo->deferred_, &promise);
} else if (argc == ARGS_SIZE_THREE) {
// Callback mode
napi_create_reference(env, argv[PARAM2], 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
HILOG_ERROR("The size of args is err[%{public}zu]", argc);
return ErrorOperation(callbackInfo);
}
// Parse conditionType name
std::string conditionType = "";
ParseString(env, conditionType, argv[PARAM0]);
HILOG_INFO("conditionType = %{public}s", conditionType.c_str());
callbackInfo->conditionId_ = ConvertStringToCondition(conditionType);
// Parse queryData name
std::string queryData = "";
ParseString(env, queryData, argv[PARAM1]);
HILOG_INFO("queryData = %{public}s", queryData.c_str());
callbackInfo->condition_ = queryData;
// Unwrap AccessibilityElement
AccessibilityElement* accessibilityElement = nullptr;
napi_status status = napi_unwrap(env, thisVar, (void**)&accessibilityElement);
if (!accessibilityElement || status != napi_ok) {
HILOG_ERROR("accessibilityElement is null or status[%{public}d] is wrong", status);
return ErrorOperation(callbackInfo);
}
if (!accessibilityElement->isElementInfo_) {
HILOG_ERROR("Type of AccessibilityElement is not right");
return ErrorOperation(callbackInfo);
}
callbackInfo->accessibilityElement_ = *accessibilityElement;
napi_value resource = nullptr;
@@ -1355,7 +1231,7 @@ void NAccessibilityElement::FindElementExecute(napi_env env, void* data)
switch (callbackInfo->conditionId_) {
case FindElementCondition::FIND_ELEMENT_CONDITION_INVALID:
HILOG_ERROR("condition id is invalid");
callbackInfo->ret_ = RET_ERR_INVALID_PARAM;
callbackInfo->ret_ = false;
return;
case FindElementCondition::FIND_ELEMENT_CONDITION_CONTENT:
callbackInfo->ret_ = AccessibleAbilityClient::GetInstance()->GetByContent(
@@ -1367,8 +1243,7 @@ void NAccessibilityElement::FindElementExecute(napi_env env, void* data)
int32_t focusType = ConvertStringToFocusType(callbackInfo->condition_);
HILOG_INFO("focusType is %{public}d", focusType);
callbackInfo->ret_ = AccessibleAbilityClient::GetInstance()->GetFocusByElementInfo(
*(callbackInfo->accessibilityElement_.elementInfo_),
focusType, callbackInfo->nodeInfo_);
*(callbackInfo->accessibilityElement_.elementInfo_), focusType, callbackInfo->nodeInfo_);
}
break;
case FindElementCondition::FIND_ELEMENT_CONDITION_FOCUS_DIRECTION:
@@ -1376,8 +1251,7 @@ void NAccessibilityElement::FindElementExecute(napi_env env, void* data)
FocusMoveDirection direction = ConvertStringToDirection(callbackInfo->condition_);
HILOG_INFO("direction is %{public}d", direction);
callbackInfo->ret_ = AccessibleAbilityClient::GetInstance()->GetNext(
*(callbackInfo->accessibilityElement_.elementInfo_), direction,
callbackInfo->nodeInfo_);
*(callbackInfo->accessibilityElement_.elementInfo_), direction, callbackInfo->nodeInfo_);
}
break;
default:
@@ -1396,9 +1270,9 @@ void NAccessibilityElement::FindElementComplete(napi_env env, napi_status status
napi_value result[ARGS_SIZE_TWO] = {0};
GetElement(callbackInfo, result[PARAM1]);
result[PARAM0] = CreateBusinessError(env, callbackInfo->ret_);
if (callbackInfo->callback_) {
HILOG_DEBUG("callback mode. result is %{public}d", callbackInfo->ret_);
result[PARAM0] = callbackInfo->ret_ ? GetErrorValue(env, CODE_SUCCESS) : GetErrorValue(env, CODE_FAILED);
napi_value callback = 0;
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_value returnVal;
@@ -1408,10 +1282,10 @@ void NAccessibilityElement::FindElementComplete(napi_env env, napi_status status
napi_delete_reference(env, callbackInfo->callback_);
} else {
HILOG_DEBUG("promise mode. result is %{public}d", callbackInfo->ret_);
if (callbackInfo->ret_ == RET_OK) {
if (callbackInfo->ret_) {
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
} else {
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM0]);
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM1]);
}
}
napi_delete_async_work(env, callbackInfo->work_);
@@ -1423,7 +1297,7 @@ void NAccessibilityElement::GetElement(NAccessibilityElementData *callbackInfo,
{
HILOG_INFO("condition id[%{public}d]", callbackInfo->conditionId_);
napi_env env = callbackInfo->env_;
if (callbackInfo->ret_ != RET_OK) {
if (!callbackInfo->ret_) {
HILOG_ERROR("GetElementInfo failed!");
napi_get_undefined(env, &value);
return;
@@ -1432,7 +1306,7 @@ void NAccessibilityElement::GetElement(NAccessibilityElementData *callbackInfo,
switch (callbackInfo->conditionId_) {
case FindElementCondition::FIND_ELEMENT_CONDITION_INVALID:
HILOG_ERROR("condition id is invalid");
callbackInfo->ret_ = RET_ERR_INVALID_PARAM;
callbackInfo->ret_ = false;
return;
case FindElementCondition::FIND_ELEMENT_CONDITION_CONTENT:
napi_create_array(env, &value);
@@ -1491,9 +1365,9 @@ napi_value NAccessibilityElement::ErrorOperation(NAccessibilityElementData *call
napi_value callback = 0;
napi_value undefined = 0;
napi_get_undefined(env, &undefined);
result[PARAM0] = CreateBusinessError(env, callbackInfo->ret_);
if (callbackInfo->callback_) {
// Callback mode
result[PARAM0] = GetErrorValue(env, CODE_FAILED);
result[PARAM1] = undefined;
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_value returnVal;
@@ -1501,7 +1375,7 @@ napi_value NAccessibilityElement::ErrorOperation(NAccessibilityElementData *call
napi_delete_reference(env, callbackInfo->callback_);
} else {
// Promise mode
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM0]);
napi_reject_deferred(env, callbackInfo->deferred_, undefined);
}
napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo;
@@ -219,12 +219,12 @@ std::shared_ptr<AccessibilityElement> NAccessibilityExtension::GetElement(const
std::shared_ptr<AccessibilityElement> element = nullptr;
if (componentId > 0) {
std::shared_ptr<AccessibilityElementInfo> elementInfo = std::make_shared<AccessibilityElementInfo>();
if (aaClient->GetSource(eventInfo, *elementInfo) == RET_OK) {
if (aaClient->GetSource(eventInfo, *elementInfo)) {
element = std::make_shared<AccessibilityElement>(elementInfo);
}
} else if (windowId > 0) {
std::shared_ptr<AccessibilityWindowInfo> windowInfo = std::make_shared<AccessibilityWindowInfo>();
if (aaClient->GetWindow(windowId, *windowInfo) == RET_OK) {
if (aaClient->GetWindow(windowId, *windowInfo)) {
element = std::make_shared<AccessibilityElement>(windowInfo);
}
} else {
@@ -29,6 +29,10 @@ using namespace OHOS::AccessibilityNapi;
namespace OHOS {
namespace Accessibility {
namespace {
constexpr int32_t CONTEXT_ERROR = 1;
constexpr int32_t PARAMETER_ERROR = 2;
constexpr int32_t RESULT_ERROR = 3;
static void ConvertAccessibilityWindowInfoToJS(
napi_env env, napi_value result, const AccessibilityWindowInfo& accessibilityWindowInfo)
{
@@ -142,20 +146,16 @@ private:
auto context = weak.lock();
if (!context) {
HILOG_ERROR("context is released");
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY),
ERROR_MESSAGE_SYSTEM_ABNORMALITY));
task.Reject(engine, CreateJsError(engine, CONTEXT_ERROR, "Context is released"));
return;
}
RetError ret = context->SetTargetBundleName(targetBundleNames);
if (ret == RET_OK) {
bool ret = context->SetTargetBundleName(targetBundleNames);
if (ret) {
task.Resolve(engine, engine.CreateUndefined());
} else {
HILOG_ERROR("set target bundle name failed. ret: %{public}d.", ret);
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY),
ERROR_MESSAGE_SYSTEM_ABNORMALITY));
task.Reject(engine, CreateJsError(engine, RESULT_ERROR, "set target bundle name failed."));
}
};
@@ -207,15 +207,13 @@ private:
auto context = weak.lock();
if (!context) {
HILOG_ERROR("context is released");
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY),
ERROR_MESSAGE_SYSTEM_ABNORMALITY));
task.Reject(engine, CreateJsError(engine, CONTEXT_ERROR, "Context is released"));
return;
}
OHOS::Accessibility::AccessibilityElementInfo elementInfo;
RetError ret = context->GetFocus(focus, elementInfo);
if (ret == RET_OK) {
bool ret = context->GetFocus(focus, elementInfo);
if (ret) {
napi_value constructor = nullptr;
napi_get_reference_value(reinterpret_cast<napi_env>(&engine), NAccessibilityElement::consRef_,
&constructor);
@@ -227,9 +225,7 @@ private:
task.Resolve(engine, nativeElementInfo);
} else {
HILOG_ERROR("Get focus elementInfo failed. ret: %{public}d", ret);
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.at(ret).errCode),
ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.at(ret).message));
task.Reject(engine, CreateJsError(engine, RESULT_ERROR, "Get focus elementInfo failed."));
}
};
@@ -281,15 +277,13 @@ private:
auto context = weak.lock();
if (!context) {
HILOG_ERROR("context is released");
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY),
ERROR_MESSAGE_SYSTEM_ABNORMALITY));
task.Reject(engine, CreateJsError(engine, CONTEXT_ERROR, "Context is released"));
return;
}
HILOG_DEBUG("isActiveWindow[%{public}d] windowId[%{public}d]", isActiveWindow, windowId);
OHOS::Accessibility::AccessibilityElementInfo elementInfo;
RetError ret = RET_OK;
bool ret = false;
if (isActiveWindow) {
ret = context->GetRoot(elementInfo);
} else {
@@ -297,7 +291,7 @@ private:
windowInfo.SetWindowId(windowId);
ret = context->GetRootByWindow(windowInfo, elementInfo);
}
if (ret == RET_OK) {
if (ret) {
napi_value constructor = nullptr;
napi_get_reference_value(reinterpret_cast<napi_env>(&engine), NAccessibilityElement::consRef_,
&constructor);
@@ -311,9 +305,7 @@ private:
task.Resolve(engine, nativeElementInfo);
} else {
HILOG_ERROR("Get root elementInfo failed. ret : %{public}d", ret);
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.at(ret).errCode),
ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.at(ret).message));
task.Reject(engine, CreateJsError(engine, RESULT_ERROR, "Get root elementInfo failed."));
}
};
@@ -373,15 +365,13 @@ private:
auto context = weak.lock();
if (!context) {
HILOG_ERROR("context is released");
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY),
ERROR_MESSAGE_SYSTEM_ABNORMALITY));
task.Reject(engine, CreateJsError(engine, CONTEXT_ERROR, "Context is released"));
return;
}
std::vector<OHOS::Accessibility::AccessibilityWindowInfo> accessibilityWindows;
RetError ret = context->GetWindows(accessibilityWindows);
if (ret == RET_OK) {
bool ret = context->GetWindows(accessibilityWindows);
if (ret) {
napi_value napiWindowInfos = nullptr;
napi_create_array(reinterpret_cast<napi_env>(&engine), &napiWindowInfos);
ConvertAccessibilityWindowInfosToJS(
@@ -390,9 +380,7 @@ private:
task.Resolve(engine, nativeWindowInfos);
} else {
HILOG_ERROR("Get windowInfos failed.");
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.at(ret).errCode),
ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.at(ret).message));
task.Reject(engine, CreateJsError(engine, RESULT_ERROR, "Get windowInfos failed."));
}
};
@@ -411,23 +399,19 @@ private:
auto context = weak.lock();
if (!context) {
HILOG_ERROR("context is released");
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY),
ERROR_MESSAGE_SYSTEM_ABNORMALITY));
task.Reject(engine, CreateJsError(engine, CONTEXT_ERROR, "Context is released"));
return;
}
if (displayId < 0) {
HILOG_ERROR("displayId is error: %{public}" PRId64 "", displayId);
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM),
ERROR_MESSAGE_PARAMETER_ERROR));
task.Reject(engine, CreateJsError(engine, PARAMETER_ERROR, "displayId is error"));
return;
}
std::vector<OHOS::Accessibility::AccessibilityWindowInfo> accessibilityWindows;
RetError ret = context->GetWindows(static_cast<uint64_t>(displayId), accessibilityWindows);
if (ret == RET_OK) {
bool ret = context->GetWindows(static_cast<uint64_t>(displayId), accessibilityWindows);
if (ret) {
napi_value napiWindowInfos = nullptr;
napi_create_array(reinterpret_cast<napi_env>(&engine), &napiWindowInfos);
ConvertAccessibilityWindowInfosToJS(
@@ -436,9 +420,7 @@ private:
task.Resolve(engine, nativeWindowInfos);
} else {
HILOG_ERROR("Get windowInfos failed.");
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.at(ret).errCode),
ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.at(ret).message));
task.Reject(engine, CreateJsError(engine, RESULT_ERROR, "Get windowInfos failed."));
}
};
@@ -472,24 +454,20 @@ private:
auto context = weak.lock();
if (!context) {
HILOG_ERROR("context is released");
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY),
ERROR_MESSAGE_SYSTEM_ABNORMALITY));
task.Reject(engine, CreateJsError(engine, CONTEXT_ERROR, "Context is released"));
return;
}
RetError ret = RET_OK;
bool ret = false;
if (isParameterArray) {
ret = context->InjectGesture(gesturePathArray);
} else {
ret = context->InjectGesture(gesturePath);
}
if (ret == RET_OK) {
if (ret) {
task.Resolve(engine, engine.CreateUndefined());
} else {
HILOG_ERROR("Gesture inject failed. ret: %{public}d.", ret);
task.Reject(engine, CreateJsError(engine,
static_cast<int32_t>(ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.at(ret).errCode),
ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.at(ret).message));
task.Reject(engine, CreateJsError(engine, RESULT_ERROR, "Gesture inject failed."));
}
};
@@ -18,9 +18,6 @@
#include <cstdint>
#include <string>
#include <vector>
#include <map>
#include "accessibility_def.h"
constexpr size_t CALLBACK_SIZE = 1;
constexpr size_t ARGS_SIZE_ZERO = 0;
@@ -35,79 +32,5 @@ constexpr int32_t PARAM2 = 2;
constexpr int32_t CODE_SUCCESS = 0;
constexpr int32_t CODE_FAILED = -1;
constexpr int32_t CHAE_BUFFER_MAX = 1024;
const std::string ERROR_MESSAGE_PARAMETER_ERROR = "Input parameter error";
const std::string ERROR_MESSAGE_NO_PERMISSION = "Permission denied";
const std::string ERROR_MESSAGE_NO_RIGHT = "Do not have accessibility right for this operation";
const std::string ERROR_MESSAGE_SYSTEM_ABNORMALITY = "System abnormality";
const std::string ERROR_MESSAGE_PROPERTY_NOT_EXIST = "This property does not exist";
const std::string ERROR_MESSAGE_ACTION_NOT_SUPPORT = "This action is not supported";
const std::string ERROR_MESSAGE_INVALID_BUNDLE_NAME_OR_ABILITY_NAME = "Invalid bundle name or ability name";
const std::string ERROR_MESSAGE_TARGET_ABILITY_ALREADY_ENABLED = "Target ability already enabled";
enum class NAccessibilityErrorCode : int32_t {
ACCESSIBILITY_OK = 0,
ACCESSIBILITY_ERROR_NO_PERMISSION = 201,
ACCESSIBILITY_ERROR_INVALID_PARAM = 401,
ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY = 9300000,
ACCESSIBILITY_ERROR_ERROR_EXTENSION_NAME = 9300001,
ACCESSIBILITY_ERROR_TARGET_ABILITY_ALREADY_ENABLED = 9300002,
ACCESSIBILITY_ERROR_NO_RIGHT = 9300003,
ACCESSIBILITY_ERROR_PROPERTY_NOT_EXIST = 9300004,
ACCESSIBILITY_ERROR_ACTION_NOT_SUPPORT = 9300005,
};
struct NAccessibilityErrMsg {
NAccessibilityErrorCode errCode;
std::string message;
};
const std::map<OHOS::Accessibility::RetError, NAccessibilityErrMsg> ACCESSIBILITY_JS_TO_ERROR_CODE_MAP {
{OHOS::Accessibility::RetError::RET_OK,
{NAccessibilityErrorCode::ACCESSIBILITY_OK, ""}},
{OHOS::Accessibility::RetError::RET_ERR_FAILED,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_INVALID_PARAM,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM, ERROR_MESSAGE_PARAMETER_ERROR}},
{OHOS::Accessibility::RetError::RET_ERR_NULLPTR,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_IPC_FAILED,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_SAMGR,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_NO_PERMISSION,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_NO_PERMISSION, ERROR_MESSAGE_NO_PERMISSION}},
{OHOS::Accessibility::RetError::RET_ERR_TIME_OUT,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_NOT_SUPPORT,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_REGISTER_EXIST,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_NO_REGISTER,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_CONNECTION_EXIST,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_TARGET_ABILITY_ALREADY_ENABLED,
ERROR_MESSAGE_TARGET_ABILITY_ALREADY_ENABLED}},
{OHOS::Accessibility::RetError::RET_ERR_NO_CONNECTION,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_NO_WINDOW_CONNECTION,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_NO_CAPABILITY,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_NO_RIGHT, ERROR_MESSAGE_NO_RIGHT}},
{OHOS::Accessibility::RetError::RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_PERFORM_ACTION_FAILED_BY_ACE,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_NO_INJECTOR,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_SYSTEM_ABNORMALITY, ERROR_MESSAGE_SYSTEM_ABNORMALITY}},
{OHOS::Accessibility::RetError::RET_ERR_NOT_INSTALLED,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_ERROR_EXTENSION_NAME,
ERROR_MESSAGE_INVALID_BUNDLE_NAME_OR_ABILITY_NAME}},
{OHOS::Accessibility::RetError::RET_ERR_NOT_ENABLED,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_ERROR_EXTENSION_NAME,
ERROR_MESSAGE_INVALID_BUNDLE_NAME_OR_ABILITY_NAME}},
{OHOS::Accessibility::RetError::RET_ERR_PROPERTY_NOT_EXIST,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_PROPERTY_NOT_EXIST, ERROR_MESSAGE_PROPERTY_NOT_EXIST}},
{OHOS::Accessibility::RetError::RET_ERR_ACTION_NOT_SUPPORT,
{NAccessibilityErrorCode::ACCESSIBILITY_ERROR_ACTION_NOT_SUPPORT, ERROR_MESSAGE_ACTION_NOT_SUPPORT}},
};
#endif // NAPI_ACCESSIBILITY_DEF_H
@@ -78,7 +78,6 @@ struct NAccessibilitySystemAbilityClient {
bool setKeyEvenReturn_ = false;
OHOS::Accessibility::AccessibilityEventInfo eventInfo_ {};
bool result_ = false;
OHOS::Accessibility::RetError ret_ = OHOS::Accessibility::RET_ERR_FAILED;
std::string eventType_ = "";
std::map<std::string, std::vector<std::shared_ptr<StateListener>>> stateListeners_;
@@ -45,8 +45,7 @@ bool ParseString(napi_env env, std::string& param, napi_value args);
bool ParseNumber(napi_env env, napi_value args);
bool ParseInt32(napi_env env, int32_t& param, napi_value args);
bool ParseDouble(napi_env env, double& param, napi_value args);
NAccessibilityErrMsg QueryRetMsg(OHOS::Accessibility::RetError errorCode);
napi_value CreateBusinessError(napi_env env, OHOS::Accessibility::RetError errCode);
napi_value GetErrorValue(napi_env env, int errCode);
std::string ConvertWindowTypeToString(OHOS::Accessibility::AccessibilityWindowType type);
std::string ConvertDaltonizationTypeToString(OHOS::AccessibilityConfig::DALTONIZATION_TYPE type);
@@ -67,10 +66,10 @@ void ConvertCaptionPropertyToJS(napi_env env, napi_value& result,
OHOS::AccessibilityConfig::CaptionProperty captionProperty);
bool ConvertObjToCaptionProperty(
napi_env env, napi_value object, OHOS::AccessibilityConfig::CaptionProperty* ptrCaptionProperty);
bool ConvertJSToStringVec(napi_env env, napi_value arrayValue, std::vector<std::string> &values);
void ConvertJSToStringVec(napi_env env, napi_value arrayValue, std::vector<std::string> &values);
void ConvertStringVecToJS(napi_env env, napi_value &result, std::vector<std::string> values);
void ConvertJSToEventTypes(napi_env env, napi_value arrayValue, uint32_t &eventTypes);
bool ConvertJSToCapabilities(napi_env env, napi_value arrayValue, uint32_t &capabilities);
void ConvertJSToCapabilities(napi_env env, napi_value arrayValue, uint32_t &capabilities);
uint32_t GetColorValue(napi_env env, napi_value object, napi_value propertyNameValue);
uint32_t GetColorValue(napi_env env, napi_value value);
uint32_t ConvertColorStringToNumer(std::string colorStr);
@@ -88,7 +87,7 @@ const std::string ConvertWindowUpdateTypeToString(OHOS::Accessibility::WindowUpd
const std::string ConvertAccessibilityEventTypeToString(OHOS::Accessibility::EventType type);
void ConvertEventTypeToString(const OHOS::Accessibility::AccessibilityEventInfo &eventInfo,
std::string &eventTypeString);
bool ConvertGesturePathsJSToNAPI(napi_env env, napi_value object,
void ConvertGesturePathsJSToNAPI(napi_env env, napi_value object,
std::shared_ptr<OHOS::Accessibility::AccessibilityGestureInjectPath>& gesturePath,
std::vector<std::shared_ptr<OHOS::Accessibility::AccessibilityGestureInjectPath>>& gesturePathArray,
bool &isParameterArray);
@@ -48,15 +48,9 @@ napi_value NAccessibilityClient::IsOpenAccessibility(napi_env env, napi_callback
napi_value promise = nullptr;
if (argc > 0) {
napi_valuetype valueType = napi_null;
napi_typeof(env, argv, &valueType);
if (valueType == napi_function) {
HILOG_DEBUG("IsOpenAccessibility callback mode");
napi_create_reference(env, argv, 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
HILOG_DEBUG("IsOpenAccessibility callback mode");
napi_create_reference(env, argv, 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
HILOG_DEBUG("IsOpenAccessibility promise mode");
napi_create_promise(env, &callbackInfo->deferred_, &promise);
@@ -70,7 +64,7 @@ napi_value NAccessibilityClient::IsOpenAccessibility(napi_env env, napi_callback
NAccessibilitySystemAbilityClient* callbackInfo = static_cast<NAccessibilitySystemAbilityClient*>(data);
auto asaClient = AccessibilitySystemAbilityClient::GetInstance();
if (asaClient) {
callbackInfo->ret_ = asaClient->IsEnabled(callbackInfo->enabled_);
callbackInfo->enabled_ = asaClient->IsEnabled();
HILOG_INFO("IsOpenAccessibility Executing enabled[%{public}d]", callbackInfo->enabled_);
}
},
@@ -84,18 +78,15 @@ napi_value NAccessibilityClient::IsOpenAccessibility(napi_env env, napi_callback
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, callbackInfo->enabled_, &result[PARAM1]));
HILOG_INFO("IsOpenAccessibility completed enabled[%{public}d]", callbackInfo->enabled_);
result[PARAM0] = CreateBusinessError(env, callbackInfo->ret_);
if (callbackInfo->callback_) {
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_value returnVal;
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
napi_delete_reference(env, callbackInfo->callback_);
} else {
if (callbackInfo->ret_ == OHOS::Accessibility::RET_OK) {
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
} else {
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM0]);
}
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
}
napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo;
@@ -120,15 +111,9 @@ napi_value NAccessibilityClient::IsOpenTouchExploration(napi_env env, napi_callb
napi_value promise = nullptr;
if (argc > 0) {
napi_valuetype valueType = napi_null;
napi_typeof(env, argv, &valueType);
if (valueType == napi_function) {
HILOG_DEBUG("IsOpenTouchExploration callback mode");
napi_create_reference(env, argv, 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
napi_create_promise(env, &callbackInfo->deferred_, &promise);
}
HILOG_DEBUG("IsOpenTouchExploration callback mode");
napi_create_reference(env, argv, 1, &callbackInfo->callback_);
napi_get_undefined(env, &promise);
} else {
HILOG_DEBUG("IsOpenTouchExploration promise mode");
napi_create_promise(env, &callbackInfo->deferred_, &promise);
@@ -142,7 +127,7 @@ napi_value NAccessibilityClient::IsOpenTouchExploration(napi_env env, napi_callb
NAccessibilitySystemAbilityClient* callbackInfo = static_cast<NAccessibilitySystemAbilityClient*>(data);
auto asaClient = AccessibilitySystemAbilityClient::GetInstance();
if (asaClient) {
callbackInfo->ret_ = asaClient->IsTouchExplorationEnabled(callbackInfo->touchEnabled_);
callbackInfo->touchEnabled_ = asaClient->IsTouchExplorationEnabled();
HILOG_INFO("IsOpenTouchExploration Executing touchEnabled[%{public}d]", callbackInfo->touchEnabled_);
}
},
@@ -156,18 +141,15 @@ napi_value NAccessibilityClient::IsOpenTouchExploration(napi_env env, napi_callb
NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, callbackInfo->touchEnabled_, &result[PARAM1]));
HILOG_INFO("IsOpenTouchExploration completed touchEnabled_[%{public}d]", callbackInfo->touchEnabled_);
result[PARAM0] = CreateBusinessError(env, callbackInfo->ret_);
if (callbackInfo->callback_) {
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_value returnVal;
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
napi_delete_reference(env, callbackInfo->callback_);
} else {
if (callbackInfo->ret_ == OHOS::Accessibility::RET_OK) {
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
} else {
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM0]);
}
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
}
napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo;
@@ -214,7 +196,7 @@ napi_value NAccessibilityClient::GetAbilityList(napi_env env, napi_callback_info
NAccessibilitySystemAbilityClient* callbackInfo = static_cast<NAccessibilitySystemAbilityClient*>(data);
auto asaClient = AccessibilitySystemAbilityClient::GetInstance();
if (asaClient) {
callbackInfo->ret_ = asaClient->GetAbilityList(callbackInfo->abilityTypes_,
callbackInfo->result_ = asaClient->GetAbilityList(callbackInfo->abilityTypes_,
callbackInfo->stateTypes_, callbackInfo->abilityList_);
}
},
@@ -227,18 +209,18 @@ napi_value NAccessibilityClient::GetAbilityList(napi_env env, napi_callback_info
napi_get_undefined(env, &undefined);
napi_create_array(env, &result[PARAM1]);
ConvertAccessibleAbilityInfosToJS(env, result[PARAM1], callbackInfo->abilityList_);
result[PARAM0] = CreateBusinessError(env, callbackInfo->ret_);
if (callbackInfo->callback_) {
if (callbackInfo->result_) {
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
} else {
result[PARAM0] = GetErrorValue(env, CODE_FAILED);
}
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_value returnVal;
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
napi_delete_reference(env, callbackInfo->callback_);
} else {
if (callbackInfo->ret_ == OHOS::Accessibility::RET_OK) {
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
} else {
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM0]);
}
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
}
napi_delete_async_work(env, callbackInfo->work_);
delete callbackInfo;
@@ -281,9 +263,9 @@ napi_value NAccessibilityClient::SendEvent(napi_env env, napi_callback_info info
NAccessibilitySystemAbilityClient* callbackInfo = static_cast<NAccessibilitySystemAbilityClient*>(data);
auto asaClient = AccessibilitySystemAbilityClient::GetInstance();
if (callbackInfo->result_ && asaClient) {
callbackInfo->ret_ = asaClient->SendEvent(callbackInfo->eventInfo_);
callbackInfo->result_ = asaClient->SendEvent(callbackInfo->eventInfo_);
}
HILOG_INFO("SendEvent result[%{public}d]", callbackInfo->ret_);
HILOG_INFO("SendEvent result[%{public}d]", callbackInfo->result_);
},
[](napi_env env, napi_status status, void* data) {
NAccessibilitySystemAbilityClient* callbackInfo = static_cast<NAccessibilitySystemAbilityClient*>(data);
@@ -293,18 +275,22 @@ napi_value NAccessibilityClient::SendEvent(napi_env env, napi_callback_info info
napi_value ret = 0;
napi_get_undefined(env, &undefined);
napi_get_undefined(env, &ret);
result[PARAM0] = CreateBusinessError(env, callbackInfo->ret_);
result[PARAM1] = ret;
if (callbackInfo->callback_) {
if (callbackInfo->result_) {
result[PARAM0] = GetErrorValue(env, CODE_SUCCESS);
} else {
result[PARAM0] = GetErrorValue(env, CODE_FAILED);
}
result[PARAM1] = ret;
napi_get_reference_value(env, callbackInfo->callback_, &callback);
napi_value returnVal;
napi_call_function(env, undefined, callback, ARGS_SIZE_TWO, result, &returnVal);
napi_delete_reference(env, callbackInfo->callback_);
} else {
if (callbackInfo->ret_ == OHOS::Accessibility::RET_OK) {
napi_resolve_deferred(env, callbackInfo->deferred_, result[PARAM1]);
if (callbackInfo->result_) {
napi_resolve_deferred(env, callbackInfo->deferred_, undefined);
} else {
napi_reject_deferred(env, callbackInfo->deferred_, result[PARAM0]);
napi_reject_deferred(env, callbackInfo->deferred_, undefined);
}
}
napi_delete_async_work(env, callbackInfo->work_);
@@ -326,48 +312,17 @@ napi_value NAccessibilityClient::SubscribeState(napi_env env, napi_callback_info
napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
if (status != napi_ok) {
HILOG_ERROR("Failed to get event type");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_FAILED);
napi_throw(env, err);
return nullptr;
}
OHOS::Accessibility::RetError errCode = OHOS::Accessibility::RET_OK;
if (argc < ARGS_SIZE_TWO) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
std::string eventType = GetStringFromNAPI(env, args[0]);
uint32_t type = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED;
if (errCode == OHOS::Accessibility::RET_OK) {
std::string eventType = "";
if (!ParseString(env, eventType, args[PARAM0])) {
HILOG_ERROR("eventType type parse failed");
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
} else {
if (std::strcmp(eventType.c_str(), "accessibilityStateChange") == 0) {
type = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED;
} else if (std::strcmp(eventType.c_str(), "touchGuideStateChange") == 0) {
type = AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED;
} else {
HILOG_ERROR("SubscribeState eventType[%{public}s] is error", eventType.c_str());
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
}
if (errCode == OHOS::Accessibility::RET_OK) {
napi_valuetype valueType = napi_null;
napi_typeof(env, args[PARAM1], &valueType);
if (valueType != napi_function) {
HILOG_ERROR("args[PARAM1] format is wrong");
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
if (errCode == OHOS::Accessibility::RET_ERR_INVALID_PARAM) {
napi_value err = CreateBusinessError(env, errCode);
HILOG_ERROR("invalid param");
napi_throw(env, err);
if (!std::strcmp(eventType.c_str(), "accessibilityStateChange")) {
type = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED;
} else if (!std::strcmp(eventType.c_str(), "touchGuideStateChange")) {
type = AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED;
} else {
HILOG_ERROR("SubscribeState eventType[%{public}s] is error", eventType.c_str());
return nullptr;
}
@@ -394,60 +349,27 @@ napi_value NAccessibilityClient::UnsubscribeState(napi_env env, napi_callback_in
size_t argc = ARGS_SIZE_TWO;
napi_value args[ARGS_SIZE_TWO] = {0};
napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
OHOS::Accessibility::RetError errCode = OHOS::Accessibility::RET_OK;
if (argc < ARGS_SIZE_TWO - 1) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
std::string eventType = GetStringFromNAPI(env, args[PARAM0]);
uint32_t type = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED;
if (errCode == OHOS::Accessibility::RET_OK) {
std::string eventType = "";
if (!ParseString(env, eventType, args[PARAM0])) {
HILOG_ERROR("eventType type parse failed");
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
} else {
if (std::strcmp(eventType.c_str(), "accessibilityStateChange") == 0) {
type = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED;
} else if (std::strcmp(eventType.c_str(), "touchGuideStateChange") == 0) {
type = AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED;
} else {
HILOG_ERROR("SubscribeState eventType[%{public}s] is error", eventType.c_str());
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
}
if (errCode == OHOS::Accessibility::RET_ERR_INVALID_PARAM) {
napi_value err = CreateBusinessError(env, errCode);
HILOG_ERROR("invalid param");
napi_throw(env, err);
if (!std::strcmp(eventType.c_str(), "accessibilityStateChange")) {
type = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED;
} else if (!std::strcmp(eventType.c_str(), "touchGuideStateChange")) {
type = AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED;
} else {
HILOG_ERROR("UnsubscribeState eventType[%{public}s] is error", eventType.c_str());
return nullptr;
}
switch (type) {
case AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED:
if (argc >= ARGS_SIZE_TWO) {
napi_valuetype valueType = napi_null;
napi_typeof(env, args[PARAM1], &valueType);
if (valueType == napi_function) {
accessibilityStateListeners_->UnsubscribeObserver(args[PARAM1]);
} else {
accessibilityStateListeners_->UnsubscribeObservers();
}
accessibilityStateListeners_->UnsubscribeObserver(args[PARAM1]);
} else {
accessibilityStateListeners_->UnsubscribeObservers();
}
break;
case AccessibilityStateEventType::EVENT_TOUCH_GUIDE_STATE_CHANGED:
if (argc >= ARGS_SIZE_TWO) {
napi_valuetype valueType = napi_null;
napi_typeof(env, args[PARAM1], &valueType);
if (valueType == napi_function) {
touchGuideStateListeners_->UnsubscribeObserver(args[PARAM1]);
} else {
touchGuideStateListeners_->UnsubscribeObservers();
}
touchGuideStateListeners_->UnsubscribeObserver(args[PARAM1]);
} else {
touchGuideStateListeners_->UnsubscribeObservers();
}
@@ -563,32 +485,22 @@ napi_value NAccessibilityClient::SetCaptionStateEnabled(napi_env env, napi_callb
{
HILOG_INFO();
size_t argc = ARGS_SIZE_ONE;
bool captionState = false;
napi_value parameters[ARGS_SIZE_ONE] = {0};
napi_get_cb_info(env, info, &argc, parameters, nullptr, nullptr);
if (argc >= ARGS_SIZE_ONE) {
bool captionState = false;
OHOS::Accessibility::RetError ret = OHOS::Accessibility::RET_OK;
if (!ParseBool(env, captionState, parameters[PARAM0])) {
ret = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
} else {
HILOG_INFO("captionState = %{public}s", captionState ? "True" : "False");
napi_get_value_bool(env, parameters[PARAM0], &captionState);
HILOG_INFO("captionState = %{public}s", captionState ? "True" : "False");
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
ret = instance.SetCaptionsState(captionState);
}
if (ret != OHOS::Accessibility::RET_OK) {
napi_value err = CreateBusinessError(env, ret);
napi_throw(env, err);
}
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
instance.SetCaptionsState(captionState);
} else {
HILOG_ERROR("argc size Error");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_INVALID_PARAM);
napi_throw(env, err);
}
napi_value undefined = nullptr;
napi_get_undefined(env, &undefined);
return undefined;
napi_value ret = nullptr;
napi_get_undefined(env, &ret);
return ret;
}
napi_value NAccessibilityClient::GetCaptionStateEnabled(napi_env env, napi_callback_info info)
@@ -611,29 +523,19 @@ napi_value NAccessibilityClient::SetCaptionStyle(napi_env env, napi_callback_inf
HILOG_INFO();
size_t argc = ARGS_SIZE_ONE;
napi_value parameters[ARGS_SIZE_ONE] = {0};
OHOS::AccessibilityConfig::CaptionProperty captionProperty = {};
napi_get_cb_info(env, info, &argc, parameters, nullptr, nullptr);
if (argc >= ARGS_SIZE_ONE) {
OHOS::AccessibilityConfig::CaptionProperty captionProperty = {};
OHOS::Accessibility::RetError ret = OHOS::Accessibility::RET_OK;
if (!ConvertObjToCaptionProperty(env, parameters[PARAM0], &captionProperty)) {
ret = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
} else {
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
ret = instance.SetCaptionsProperty(captionProperty);
}
if (ret != OHOS::Accessibility::RET_OK) {
napi_value err = CreateBusinessError(env, ret);
napi_throw(env, err);
}
ConvertObjToCaptionProperty(env, parameters[PARAM0], &captionProperty);
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
instance.SetCaptionsProperty(captionProperty);
} else {
HILOG_ERROR("argc size Error");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_INVALID_PARAM);
napi_throw(env, err);
}
napi_value undefined = nullptr;
napi_get_undefined(env, &undefined);
return undefined;
napi_value ret = nullptr;
napi_get_undefined(env, &ret);
return ret;
}
napi_value NAccessibilityClient::GetCaptionStyle(napi_env env, napi_callback_info info)
@@ -654,48 +556,18 @@ napi_value NAccessibilityClient::RegisterCaptionStateCallback(napi_env env, napi
napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
if (status != napi_ok) {
HILOG_ERROR("Failed to get event type");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_FAILED);
napi_throw(env, err);
return nullptr;
}
OHOS::Accessibility::RetError errCode = OHOS::Accessibility::RET_OK;
if (argc < ARGS_SIZE_TWO) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
OHOS::AccessibilityConfig::CONFIG_ID type = OHOS::AccessibilityConfig::CONFIG_ID_MAX;
if (errCode == OHOS::Accessibility::RET_OK) {
std::string eventType = "";
if (!ParseString(env, eventType, args[PARAM0])) {
HILOG_ERROR("eventType type parse failed");
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
} else {
if (std::strcmp(eventType.c_str(), "enableChange") == 0) {
type = OHOS::AccessibilityConfig::CONFIG_CAPTION_STATE;
} else if (std::strcmp(eventType.c_str(), "styleChange") == 0) {
type = OHOS::AccessibilityConfig::CONFIG_CAPTION_STYLE;
} else {
HILOG_ERROR("SubscribeState eventType[%{public}s] is error", eventType.c_str());
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
}
if (errCode == OHOS::Accessibility::RET_OK) {
napi_valuetype valueType = napi_null;
napi_typeof(env, args[PARAM1], &valueType);
if (valueType != napi_function) {
HILOG_ERROR("args[PARAM1] format is wrong");
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
if (errCode == OHOS::Accessibility::RET_ERR_INVALID_PARAM) {
napi_value err = CreateBusinessError(env, errCode);
HILOG_ERROR("invalid param");
napi_throw(env, err);
std::string eventType = GetStringFromNAPI(env, args[0]);
OHOS::AccessibilityConfig::CONFIG_ID type =
OHOS::AccessibilityConfig::CONFIG_ID_MAX;
if (!std::strcmp(eventType.c_str(), "enableChange")) {
type = OHOS::AccessibilityConfig::CONFIG_CAPTION_STATE;
} else if (!std::strcmp(eventType.c_str(), "styleChange")) {
type = OHOS::AccessibilityConfig::CONFIG_CAPTION_STYLE;
} else {
HILOG_ERROR("SubscribeState eventType[%{public}s] is error", eventType.c_str());
return nullptr;
}
@@ -714,46 +586,21 @@ napi_value NAccessibilityClient::DeregisterCaptionStateCallback(napi_env env, na
size_t argc = ARGS_SIZE_TWO;
napi_value args[ARGS_SIZE_TWO] = {0};
napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
std::string eventType = GetStringFromNAPI(env, args[0]);
OHOS::Accessibility::RetError errCode = OHOS::Accessibility::RET_OK;
if (argc < ARGS_SIZE_TWO - 1) {
HILOG_ERROR("argc is invalid: %{public}zu", argc);
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
OHOS::AccessibilityConfig::CONFIG_ID type = OHOS::AccessibilityConfig::CONFIG_ID_MAX;
if (errCode == OHOS::Accessibility::RET_OK) {
std::string eventType = "";
if (!ParseString(env, eventType, args[PARAM0])) {
HILOG_ERROR("eventType type parse failed");
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
} else {
if (std::strcmp(eventType.c_str(), "enableChange") == 0) {
type = OHOS::AccessibilityConfig::CONFIG_CAPTION_STATE;
} else if (std::strcmp(eventType.c_str(), "styleChange") == 0) {
type = OHOS::AccessibilityConfig::CONFIG_CAPTION_STYLE;
} else {
HILOG_ERROR("SubscribeState eventType[%{public}s] is error", eventType.c_str());
errCode = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
}
}
if (errCode == OHOS::Accessibility::RET_ERR_INVALID_PARAM) {
napi_value err = CreateBusinessError(env, errCode);
HILOG_ERROR("invalid param");
napi_throw(env, err);
OHOS::AccessibilityConfig::CONFIG_ID type =
OHOS::AccessibilityConfig::CONFIG_ID_MAX;
if (!std::strcmp(eventType.c_str(), "enableChange")) {
type = OHOS::AccessibilityConfig::CONFIG_CAPTION_STATE;
} else if (!std::strcmp(eventType.c_str(), "styleChange")) {
type = OHOS::AccessibilityConfig::CONFIG_CAPTION_STYLE;
} else {
HILOG_ERROR("DeregisterCaptionStateCallback eventType[%{public}s] is error", eventType.c_str());
return nullptr;
}
if (argc >= ARGS_SIZE_TWO) {
napi_valuetype valueType = napi_null;
napi_typeof(env, args[PARAM1], &valueType);
if (valueType == napi_function) {
captionListeners_->UnsubscribeObserver(type, args[PARAM1]);
} else {
captionListeners_->UnsubscribeObservers(type);
}
captionListeners_->UnsubscribeObserver(type, args[PARAM1]);
} else {
captionListeners_->UnsubscribeObservers(type);
}
@@ -822,31 +669,23 @@ napi_value NAccessibilityClient::SetCaptionsFontFamily(napi_env env, napi_callba
napi_get_cb_info(env, info, &argc, parameters, nullptr, nullptr);
if (argc >= ARGS_SIZE_ONE) {
// Get input FontFamily
std::string fontFamily = "";
OHOS::Accessibility::RetError ret = OHOS::Accessibility::RET_OK;
if (ParseString(env, fontFamily, parameters[PARAM0]) && fontFamily.length() > 0) {
HILOG_INFO("FontFamily = %{public}s", fontFamily.c_str());
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
OHOS::AccessibilityConfig::CaptionProperty captionProperty {};
instance.GetCaptionsProperty(captionProperty);
// Change the input info and then set the CaptionProperty
captionProperty.SetFontFamily(std::string(fontFamily));
ret = instance.SetCaptionsProperty(captionProperty);
} else {
ret = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
if (ret != OHOS::Accessibility::RET_OK) {
napi_value err = CreateBusinessError(env, ret);
napi_throw(env, err);
}
char outBuffer[CHAE_BUFFER_MAX + 1] = {0};
size_t outSize = 0;
napi_get_value_string_utf8(env, parameters[PARAM0], outBuffer, CHAE_BUFFER_MAX, &outSize);
HILOG_INFO("FontFamily = %{public}s", outBuffer);
// Get CaptionProperty
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
OHOS::AccessibilityConfig::CaptionProperty captionProperty {};
instance.GetCaptionsProperty(captionProperty);
// Change the input info and then set the CaptionProperty
captionProperty.SetFontFamily(std::string(outBuffer));
instance.SetCaptionsProperty(captionProperty);
} else {
HILOG_ERROR("argc size Error");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_INVALID_PARAM);
napi_throw(env, err);
}
napi_value undefined = nullptr;
napi_get_undefined(env, &undefined);
return undefined;
napi_value ret = nullptr;
napi_get_undefined(env, &ret);
return ret;
}
napi_value NAccessibilityClient::GetCaptionsFontScale(napi_env env, napi_callback_info info)
@@ -869,30 +708,21 @@ napi_value NAccessibilityClient::SetCaptionsFontScale(napi_env env, napi_callbac
if (argc >= ARGS_SIZE_ONE) {
// Get input FontScale
int32_t num = 0;
OHOS::Accessibility::RetError ret = OHOS::Accessibility::RET_OK;
if (ParseInt32(env, num, parameters[PARAM0])) {
HILOG_INFO("FontScale = %{public}d", num);
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
OHOS::AccessibilityConfig::CaptionProperty captionProperty {};
instance.GetCaptionsProperty(captionProperty);
// Change the input info and then set the CaptionProperty
captionProperty.SetFontScale(num);
ret = instance.SetCaptionsProperty(captionProperty);
} else {
ret = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
if (ret != OHOS::Accessibility::RET_OK) {
napi_value err = CreateBusinessError(env, ret);
napi_throw(env, err);
}
napi_get_value_int32(env, parameters[PARAM0], &num);
HILOG_INFO("FontScale = %{public}d", num);
// Get CaptionProperty
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
OHOS::AccessibilityConfig::CaptionProperty captionProperty = {};
instance.GetCaptionsProperty(captionProperty);
// Change the input info and then set the CaptionProperty
captionProperty.SetFontScale(num);
instance.SetCaptionsProperty(captionProperty);
} else {
HILOG_ERROR("argc size Error");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_INVALID_PARAM);
napi_throw(env, err);
}
napi_value undefined = nullptr;
napi_get_undefined(env, &undefined);
return undefined;
napi_value ret = nullptr;
napi_get_undefined(env, &ret);
return ret;
}
napi_value NAccessibilityClient::GetCaptionFrontColor(napi_env env, napi_callback_info info)
@@ -916,25 +746,19 @@ napi_value NAccessibilityClient::SetCaptionFrontColor(napi_env env, napi_callbac
napi_get_cb_info(env, info, &argc, parameters, nullptr, nullptr);
if (argc >= ARGS_SIZE_ONE) {
uint32_t color = GetColorValue(env, parameters[PARAM0]);
OHOS::Accessibility::RetError ret = OHOS::Accessibility::RET_OK;
// Get CaptionProperty
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
OHOS::AccessibilityConfig::CaptionProperty captionProperty {};
OHOS::AccessibilityConfig::CaptionProperty captionProperty = {};
instance.GetCaptionsProperty(captionProperty);
// Change the input info and then set the CaptionProperty
captionProperty.SetFontColor(color);
ret = instance.SetCaptionsProperty(captionProperty);
if (ret != OHOS::Accessibility::RET_OK) {
napi_value err = CreateBusinessError(env, ret);
napi_throw(env, err);
}
(void)instance.SetCaptionsProperty(captionProperty);
} else {
HILOG_ERROR("argc size Error");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_INVALID_PARAM);
napi_throw(env, err);
}
napi_value undefined = nullptr;
napi_get_undefined(env, &undefined);
return undefined;
napi_value ret = nullptr;
napi_get_undefined(env, &ret);
return ret;
}
napi_value NAccessibilityClient::GetCaptionFontEdgeType(napi_env env, napi_callback_info info)
@@ -957,31 +781,23 @@ napi_value NAccessibilityClient::SetCaptionFontEdgeType(napi_env env, napi_callb
napi_get_cb_info(env, info, &argc, parameters, nullptr, nullptr);
if (argc >= ARGS_SIZE_ONE) {
// Get input FontEdgeType
std::string fontEdgeType = "";
OHOS::Accessibility::RetError ret = OHOS::Accessibility::RET_OK;
if (ParseString(env, fontEdgeType, parameters[PARAM0]) && fontEdgeType.length() > 0) {
HILOG_INFO("fontEdgeType = %{public}s", fontEdgeType.c_str());
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
OHOS::AccessibilityConfig::CaptionProperty captionProperty {};
instance.GetCaptionsProperty(captionProperty);
// Change the input info and then set the CaptionProperty
captionProperty.SetFontEdgeType(std::string(fontEdgeType));
ret = instance.SetCaptionsProperty(captionProperty);
} else {
ret = OHOS::Accessibility::RET_ERR_INVALID_PARAM;
}
if (ret != OHOS::Accessibility::RET_OK) {
napi_value err = CreateBusinessError(env, ret);
napi_throw(env, err);
}
char outBuffer[CHAE_BUFFER_MAX + 1] = {0};
size_t outSize = 0;
napi_get_value_string_utf8(env, parameters[PARAM0], outBuffer, CHAE_BUFFER_MAX, &outSize);
HILOG_INFO("FontEdgeType = %{public}s", outBuffer);
// Get CaptionProperty
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
OHOS::AccessibilityConfig::CaptionProperty captionProperty = {};
instance.GetCaptionsProperty(captionProperty);
// Change the input info and then set the CaptionProperty
captionProperty.SetFontEdgeType(std::string(outBuffer));
instance.SetCaptionsProperty(captionProperty);
} else {
HILOG_ERROR("argc size Error");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_INVALID_PARAM);
napi_throw(env, err);
}
napi_value undefined = nullptr;
napi_get_undefined(env, &undefined);
return undefined;
napi_value ret = nullptr;
napi_get_undefined(env, &ret);
return ret;
}
napi_value NAccessibilityClient::GetCaptionBackgroundColor(napi_env env, napi_callback_info info)
@@ -1005,25 +821,19 @@ napi_value NAccessibilityClient::SetCaptionBackgroundColor(napi_env env, napi_ca
napi_get_cb_info(env, info, &argc, parameters, nullptr, nullptr);
if (argc >= ARGS_SIZE_ONE) {
uint32_t color = GetColorValue(env, parameters[PARAM0]);
OHOS::Accessibility::RetError ret = OHOS::Accessibility::RET_OK;
// Get CaptionProperty
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
OHOS::AccessibilityConfig::CaptionProperty captionProperty {};
OHOS::AccessibilityConfig::CaptionProperty captionProperty = {};
instance.GetCaptionsProperty(captionProperty);
// Change the input info and then set the CaptionProperty
captionProperty.SetBackgroundColor(color);
ret = instance.SetCaptionsProperty(captionProperty);
if (ret != OHOS::Accessibility::RET_OK) {
napi_value err = CreateBusinessError(env, ret);
napi_throw(env, err);
}
(void)instance.SetCaptionsProperty(captionProperty);
} else {
HILOG_ERROR("argc size Error");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_INVALID_PARAM);
napi_throw(env, err);
}
napi_value undefined = nullptr;
napi_get_undefined(env, &undefined);
return undefined;
napi_value ret = nullptr;
napi_get_undefined(env, &ret);
return ret;
}
napi_value NAccessibilityClient::GetCaptionWindowColor(napi_env env, napi_callback_info info)
@@ -1047,25 +857,19 @@ napi_value NAccessibilityClient::SetCaptionWindowColor(napi_env env, napi_callba
napi_get_cb_info(env, info, &argc, parameters, nullptr, nullptr);
if (argc >= ARGS_SIZE_ONE) {
uint32_t color = GetColorValue(env, parameters[PARAM0]);
OHOS::Accessibility::RetError ret = OHOS::Accessibility::RET_OK;
// Get CaptionProperty
auto &instance = OHOS::AccessibilityConfig::AccessibilityConfig::GetInstance();
OHOS::AccessibilityConfig::CaptionProperty captionProperty {};
OHOS::AccessibilityConfig::CaptionProperty captionProperty = {};
instance.GetCaptionsProperty(captionProperty);
// Change the input info and then set the CaptionProperty
captionProperty.SetWindowColor(color);
ret = instance.SetCaptionsProperty(captionProperty);
if (ret != OHOS::Accessibility::RET_OK) {
napi_value err = CreateBusinessError(env, ret);
napi_throw(env, err);
}
(void)instance.SetCaptionsProperty(captionProperty);
} else {
HILOG_ERROR("argc size Error");
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_INVALID_PARAM);
napi_throw(env, err);
}
napi_value undefined = nullptr;
napi_get_undefined(env, &undefined);
return undefined;
napi_value ret = nullptr;
napi_get_undefined(env, &ret);
return ret;
}
void StateListenerImpl::SubscribeToFramework()
@@ -148,32 +148,13 @@ bool ParseDouble(napi_env env, double& param, napi_value args)
return true;
}
NAccessibilityErrMsg QueryRetMsg(OHOS::Accessibility::RetError errorCode)
{
auto iter = ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.find(errorCode);
if (iter != ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.end()) {
return iter->second;
} else {
return ACCESSIBILITY_JS_TO_ERROR_CODE_MAP.at(OHOS::Accessibility::RetError::RET_ERR_FAILED);
}
}
napi_value CreateBusinessError(napi_env env, OHOS::Accessibility::RetError errCode)
napi_value GetErrorValue(napi_env env, int errCode)
{
napi_value result = nullptr;
if (errCode == OHOS::Accessibility::RetError::RET_OK) {
napi_get_undefined(env, &result);
} else {
napi_value eCode = nullptr;
NAccessibilityErrMsg errMsg = QueryRetMsg(errCode);
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(errMsg.errCode), &eCode));
NAPI_CALL(env, napi_create_object(env, &result));
NAPI_CALL(env, napi_set_named_property(env, result, "code", eCode));
napi_value eMsg = nullptr;
NAPI_CALL(env, napi_create_string_utf8(env, errMsg.message.c_str(), NAPI_AUTO_LENGTH, &eMsg));
NAPI_CALL(env, napi_set_named_property(env, result, "message", eMsg));
}
napi_value eCode = nullptr;
NAPI_CALL(env, napi_create_int32(env, errCode, &eCode));
NAPI_CALL(env, napi_create_object(env, &result));
NAPI_CALL(env, napi_set_named_property(env, result, "code", eCode));
return result;
}
@@ -983,7 +964,7 @@ static void ConvertGesturePathJSToNAPI(napi_env env, napi_value object,
}
}
bool ConvertGesturePathsJSToNAPI(napi_env env, napi_value object,
void ConvertGesturePathsJSToNAPI(napi_env env, napi_value object,
std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath,
std::vector<std::shared_ptr<AccessibilityGestureInjectPath>>& gesturePathArray,
bool &isParameterArray)
@@ -991,21 +972,21 @@ bool ConvertGesturePathsJSToNAPI(napi_env env, napi_value object,
HILOG_DEBUG();
if (napi_is_array(env, object, &isParameterArray) != napi_ok) {
HILOG_ERROR("judge array error.");
return false;
return;
}
if (isParameterArray) {
uint32_t dataLen = 0;
if (napi_get_array_length(env, object, &dataLen) != napi_ok) {
HILOG_ERROR("get array length failed.");
return false;
return;
}
napi_value gesturePathJs = nullptr;
for (uint32_t i = 0; i < dataLen; i++) {
gesturePathJs = nullptr;
if (napi_get_element(env, object, i, &gesturePathJs) != napi_ok) {
HILOG_ERROR("get element of paths failed and i = %{public}d", i);
return false;
return;
}
std::shared_ptr<AccessibilityGestureInjectPath> path = std::make_shared<AccessibilityGestureInjectPath>();
ConvertGesturePathJSToNAPI(env, gesturePathJs, path);
@@ -1014,7 +995,6 @@ bool ConvertGesturePathsJSToNAPI(napi_env env, napi_value object,
} else {
ConvertGesturePathJSToNAPI(env, object, gesturePath);
}
return true;
}
KeyAction TransformKeyActionValue(int32_t keyAction)
@@ -1432,7 +1412,7 @@ bool ConvertObjToCaptionProperty(
return true;
}
bool ConvertJSToStringVec(napi_env env, napi_value arrayValue, std::vector<std::string>& values)
void ConvertJSToStringVec(napi_env env, napi_value arrayValue, std::vector<std::string>& values)
{
HILOG_DEBUG();
values.clear();
@@ -1442,22 +1422,15 @@ bool ConvertJSToStringVec(napi_env env, napi_value arrayValue, std::vector<std::
napi_has_element(env, arrayValue, i, &hasElement);
if (hasElement) {
napi_value value = nullptr;
napi_status status = napi_get_element(env, arrayValue, i, &value);
if (status != napi_ok) {
return false;
}
napi_get_element(env, arrayValue, i, &value);
char outBuffer[CHAE_BUFFER_MAX + 1] = {0};
size_t outSize = 0;
status = napi_get_value_string_utf8(env, value, outBuffer, CHAE_BUFFER_MAX, &outSize);
if (status != napi_ok) {
return false;
}
napi_get_value_string_utf8(env, value, outBuffer, CHAE_BUFFER_MAX, &outSize);
values.push_back(std::string(outBuffer));
}
}
return true;
}
void ConvertJSToEventTypes(napi_env env, napi_value arrayValue, uint32_t &eventTypes)
@@ -1478,7 +1451,7 @@ void ConvertJSToEventTypes(napi_env env, napi_value arrayValue, uint32_t &eventT
}
}
bool ConvertJSToCapabilities(napi_env env, napi_value arrayValue, uint32_t &capabilities)
void ConvertJSToCapabilities(napi_env env, napi_value arrayValue, uint32_t &capabilities)
{
HILOG_DEBUG();
capabilities = 0;
@@ -1490,11 +1463,10 @@ bool ConvertJSToCapabilities(napi_env env, napi_value arrayValue, uint32_t &capa
if (capability == 0) {
HILOG_ERROR("the capability is invalid");
capabilities = 0;
return false;
return;
}
capabilities |= capability;
}
return true;
}
void ConvertStringVecToJS(napi_env env, napi_value &result, std::vector<std::string> values)
@@ -34,11 +34,9 @@ static napi_value Init(napi_env env, napi_value exports)
DECLARE_NAPI_FUNCTION("isOpenAccessibility", NAccessibilityClient::IsOpenAccessibility),
DECLARE_NAPI_FUNCTION("isOpenTouchGuide", NAccessibilityClient::IsOpenTouchExploration),
DECLARE_NAPI_FUNCTION("getAbilityLists", NAccessibilityClient::GetAbilityList),
DECLARE_NAPI_FUNCTION("getAccessibilityExtensionList", NAccessibilityClient::GetAbilityList),
DECLARE_NAPI_FUNCTION("on", NAccessibilityClient::SubscribeState),
DECLARE_NAPI_FUNCTION("off", NAccessibilityClient::UnsubscribeState),
DECLARE_NAPI_FUNCTION("sendEvent", NAccessibilityClient::SendEvent),
DECLARE_NAPI_FUNCTION("sendAccessibilityEvent", NAccessibilityClient::SendEvent),
DECLARE_NAPI_FUNCTION("getCaptionsManager", NAccessibilityClient::GetCaptionsManager),
};
@@ -122,9 +122,9 @@ public:
/**
* @brief Remove accessibility that have been opened.
* @param name bundle name + / + ability name.
* @return return true if removes enabled ability successfully, otherwise refer to the RetError for the failure.
* @return return true if removes enabled ability successfully, else return false.
*/
RetError RemoveEnabledAbility(const std::string &name);
bool RemoveEnabledAbility(const std::string &name);
void AddInstalledAbility(AccessibilityAbilityInfo& abilityInfo); // For UT
@@ -248,7 +248,7 @@ public:
std::shared_ptr<AccessibilitySettingsConfig> GetConfig();
RetError EnableAbility(const std::string &name, const uint32_t capabilities);
bool EnableAbility(const std::string &name, const uint32_t capabilities);
void Init();
@@ -300,6 +300,9 @@ private:
void UpdateEnableAbilityListsState();
bool SetAbilityCapabilities(const std::string &name, const uint32_t capabilities);
uint32_t GetAbilityStaticCapabilities(const std::string &name) const;
int32_t id_;
bool isEventTouchGuideState_ = false;
bool isScreenMagnification_ = false;
@@ -28,42 +28,42 @@ class AccessibleAbilityChannel : public AccessibleAbilityChannelStub {
public:
AccessibleAbilityChannel(const int32_t accountId, const std::string &clientName);
~AccessibleAbilityChannel() = default;
RetError SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId, const int32_t elementId,
bool SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback,
const int32_t mode) override;
RetError SearchElementInfosByText(const int32_t accessibilityWindowId, const int32_t elementId,
bool SearchElementInfosByText(const int32_t accessibilityWindowId, const int32_t elementId,
const std::string &text, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback) override;
RetError FindFocusedElementInfo(const int32_t accessibilityWindowId, const int32_t elementId,
bool FindFocusedElementInfo(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t focusType, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback) override;
RetError FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t direction,
bool FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t direction,
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) override;
RetError ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t action,
bool ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t action,
const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback) override;
RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
bool GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
bool GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
RetError GetWindowsByDisplayId(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) override;
bool GetWindowsByDisplayId(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) override;
void SetOnKeyPressEventResult(const bool handled, const int32_t sequence) override;
RetError SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
bool SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
bool SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
private:
static sptr<AccessibleAbilityConnection> GetConnection(int32_t accountId, const std::string &clientName);
static RetError GetElementOperator(int32_t accountId, int32_t windowId, int32_t focusType,
const std::string &clientName, sptr<IAccessibilityElementOperator> &elementOperator);
RetError GetWindows(uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) const;
static sptr<IAccessibilityElementOperator> GetElementOperator(
int32_t accountId, int32_t windowId, int32_t focusType, const std::string &clientName);
bool GetWindows(uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) const;
std::string clientName_ = "";
int32_t accountId_ = -1;
@@ -63,7 +63,7 @@ public:
public:
/* For AccessibleAbilityManagerServiceStub */
RetError SendEvent(const AccessibilityEventInfo &uiEvent) override;
void SendEvent(const AccessibilityEventInfo &uiEvent) override;
uint32_t RegisterStateObserver(const sptr<IAccessibleAbilityManagerStateObserver> &callback) override;
@@ -72,13 +72,13 @@ public:
void RegisterEnableAbilityListsObserver(
const sptr<IAccessibilityEnableAbilityListsObserver> &observer) override;
RetError GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
bool GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
std::vector<AccessibilityAbilityInfo> &infos) override;
RetError RegisterElementOperator(const int32_t windowId,
void RegisterElementOperator(const int32_t windowId,
const sptr<IAccessibilityElementOperator> &operation) override;
RetError DeregisterElementOperator(const int32_t windowId) override;
void DeregisterElementOperator(const int32_t windowId) override;
RetError GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption) override;
RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption) override;
@@ -90,11 +90,11 @@ public:
bool GetGestureState() override;
bool GetKeyEventObserverState() override;
RetError EnableAbility(const std::string &name, const uint32_t capabilities) override;
RetError GetEnabledAbilities(std::vector<std::string> &enabledAbilities) override;
RetError DisableAbility(const std::string &name) override;
bool EnableAbility(const std::string &name, const uint32_t capabilities) override;
bool GetEnabledAbilities(std::vector<std::string> &enabledAbilities) override;
bool DisableAbility(const std::string &name) override;
RetError EnableUITestAbility(const sptr<IRemoteObject>& obj) override;
RetError DisableUITestAbility() override;
bool DisableUITestAbility() override;
int32_t GetActiveWindow() override;
public:
@@ -249,8 +249,8 @@ private:
void OnRemoteDied(const wptr<IRemoteObject> &remote) final;
};
RetError InnerEnableAbility(const std::string &name, const uint32_t capabilities);
RetError InnerDisableAbility(const std::string &name);
bool InnerEnableAbility(const std::string &name, const uint32_t capabilities);
bool InnerDisableAbility(const std::string &name);
sptr<AccessibilityWindowConnection> GetAccessibilityWindowConnection(int32_t windowId);
void ClearFocus(int32_t windowId);
@@ -244,7 +244,7 @@ void AccessibilityAccountData::AddEnabledAbility(const std::string &name)
HILOG_DEBUG("Add EnabledAbility: %{public}zu", enabledAbilities_.size());
}
RetError AccessibilityAccountData::RemoveEnabledAbility(const std::string &name)
bool AccessibilityAccountData::RemoveEnabledAbility(const std::string &name)
{
HILOG_DEBUG("start");
for (auto it = enabledAbilities_.begin(); it != enabledAbilities_.end(); it++) {
@@ -253,11 +253,11 @@ RetError AccessibilityAccountData::RemoveEnabledAbility(const std::string &name)
enabledAbilities_.erase(it);
UpdateEnableAbilityListsState();
HILOG_DEBUG("EnabledAbility size(%{public}zu)", enabledAbilities_.size());
return RET_OK;
return true;
}
}
HILOG_ERROR("The ability(%{public}s) is not enabled.", name.c_str());
return RET_ERR_NOT_ENABLED;
return false;
}
void AccessibilityAccountData::AddInstalledAbility(AccessibilityAbilityInfo& abilityInfo)
@@ -469,30 +469,25 @@ void AccessibilityAccountData::UpdateMagnificationCapability()
isScreenMagnification_ = false;
}
RetError AccessibilityAccountData::EnableAbility(const std::string &name, const uint32_t capabilities)
bool AccessibilityAccountData::EnableAbility(const std::string &name, const uint32_t capabilities)
{
HILOG_DEBUG("start and name[%{public}s] capabilities[%{public}d]", name.c_str(), capabilities);
bool isInstalled = false;
for (auto itr = installedAbilities_.begin(); itr != installedAbilities_.end(); itr++) {
if (itr->GetId() == name) {
isInstalled = true;
// Parse config from bms according to bundle name and ability name
uint32_t configCapabilities = GetAbilityStaticCapabilities(name);
// Judge capabilities
uint32_t resultCapabilities = itr->GetStaticCapabilityValues() & capabilities;
HILOG_DEBUG("resultCapabilities is [%{public}d]", resultCapabilities);
if (resultCapabilities == 0) {
HILOG_ERROR("the result of capabilities is wrong");
return RET_ERR_NO_CAPABILITY;
}
itr->SetCapabilityValues(capabilities);
break;
}
// Judge capabilities
uint32_t resultCapabilities = configCapabilities & capabilities;
HILOG_DEBUG("resultCapabilities is [%{public}d]", resultCapabilities);
if (resultCapabilities == 0) {
HILOG_ERROR("the result of capabilities is wrong");
return false;
}
if (!isInstalled) {
HILOG_ERROR("the ability[%{public}s] is not installed", name.c_str());
return RET_ERR_NOT_INSTALLED;
bool result = SetAbilityCapabilities(name, resultCapabilities);
if (!result) {
HILOG_ERROR("Reset capabilities failed");
return false;
}
// Add enabled ability
@@ -501,13 +496,13 @@ RetError AccessibilityAccountData::EnableAbility(const std::string &name, const
return abilityName == name;
})) {
HILOG_ERROR("The ability[%{public}s] is already enabled", name.c_str());
return RET_ERR_CONNECTION_EXIST;
return false;
}
enabledAbilities_.push_back(name);
UpdateEnableAbilityListsState();
UpdateAbilities();
Utils::RecordStartingA11yEvent(name);
return RET_OK;
return true;
}
bool AccessibilityAccountData::GetInstalledAbilitiesFromBMS()
@@ -547,6 +542,32 @@ void AccessibilityAccountData::Init()
}
}
bool AccessibilityAccountData::SetAbilityCapabilities(const std::string &name, const uint32_t capabilities)
{
HILOG_DEBUG("start. name[%{public}s] capabilities[%{public}d]", name.c_str(), capabilities);
for (auto &installedAbility : installedAbilities_) {
if (installedAbility.GetId() == name) {
HILOG_DEBUG("reset ability capabilities");
installedAbility.SetCapabilityValues(capabilities);
return true;
}
}
HILOG_ERROR("not found the ability %{public}s", name.c_str());
return false;
}
uint32_t AccessibilityAccountData::GetAbilityStaticCapabilities(const std::string &name) const
{
HILOG_DEBUG("start. name[%{public}s]", name.c_str());
for (auto &installedAbility : installedAbilities_) {
if (installedAbility.GetId() == name) {
return installedAbility.GetStaticCapabilityValues();
}
}
HILOG_ERROR("not found the ability %{public}s", name.c_str());
return 0;
}
void AccessibilityAccountData::AddConfigCallback(
const sptr<IAccessibleAbilityManagerConfigObserver>& callback)
{
@@ -149,7 +149,7 @@ int32_t AccessibilityWindowManager::ConvertToRealWindowId(int32_t windowId, int3
return activeWindowId_;
}
}
HILOG_DEBUG("After convert windowId[%{public}d] and activeId[%{public}d]", windowId, activeWindowId_);
HILOG_DEBUG("After convert windowId[%{public}d]", windowId);
return windowId;
}
+69 -102
View File
@@ -29,7 +29,7 @@ AccessibleAbilityChannel::AccessibleAbilityChannel(const int32_t accountId, cons
Singleton<AccessibleAbilityManagerService>::GetInstance().GetMainRunner());
}
RetError AccessibleAbilityChannel::SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannel::SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
const int32_t elementId, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback,
const int32_t mode)
{
@@ -37,29 +37,24 @@ RetError AccessibleAbilityChannel::SearchElementInfoByAccessibilityId(const int3
if (!eventHandler_) {
HILOG_ERROR("eventHandler_ is nullptr.");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
eventHandler_->PostTask(std::bind([&syncPromise, accessibilityWindowId, elementId, requestId, callback, mode](
int32_t accountId, const std::string &name) -> void {
eventHandler_->PostTask(std::bind([=](int32_t accountId, const std::string &name) -> void {
HILOG_DEBUG("accountId[%{public}d], name[%{public}s]", accountId, name.c_str());
sptr<IAccessibilityElementOperator> elementOperator = nullptr;
RetError ret = GetElementOperator(accountId, accessibilityWindowId, FOCUS_TYPE_INVALID, name, elementOperator);
if (ret != RET_OK) {
sptr<IAccessibilityElementOperator> elementOperator =
GetElementOperator(accountId, accessibilityWindowId, FOCUS_TYPE_INVALID, name);
if (!elementOperator) {
HILOG_ERROR("Get elementOperator failed! accessibilityWindowId[%{public}d]", accessibilityWindowId);
syncPromise.set_value(ret);
return;
}
elementOperator->SearchElementInfoByAccessibilityId(elementId, requestId, callback, mode);
HILOG_DEBUG("AccessibleAbilityChannel::SearchElementInfoByAccessibilityId successfully");
syncPromise.set_value(RET_OK);
}, accountId_, clientName_), "SearchElementInfoByAccessibilityId");
return syncFuture.get();
return true;
}
RetError AccessibleAbilityChannel::SearchElementInfosByText(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannel::SearchElementInfosByText(const int32_t accessibilityWindowId,
const int32_t elementId, const std::string &text, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback)
{
@@ -67,28 +62,23 @@ RetError AccessibleAbilityChannel::SearchElementInfosByText(const int32_t access
if (!eventHandler_) {
HILOG_ERROR("eventHandler_ is nullptr.");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
eventHandler_->PostTask(std::bind([&syncPromise, accessibilityWindowId, elementId, text, requestId, callback](
int32_t accountId, const std::string &name) -> void {
eventHandler_->PostTask(std::bind([=](int32_t accountId, const std::string &name) -> void {
HILOG_DEBUG("accountId[%{public}d], name[%{public}s]", accountId, name.c_str());
sptr<IAccessibilityElementOperator> elementOperator = nullptr;
RetError ret = GetElementOperator(accountId, accessibilityWindowId, FOCUS_TYPE_INVALID, name, elementOperator);
if (ret != RET_OK) {
sptr<IAccessibilityElementOperator> elementOperator =
GetElementOperator(accountId, accessibilityWindowId, FOCUS_TYPE_INVALID, name);
if (!elementOperator) {
HILOG_ERROR("Get elementOperator failed! accessibilityWindowId[%{public}d]", accessibilityWindowId);
syncPromise.set_value(ret);
return;
}
elementOperator->SearchElementInfosByText(elementId, text, requestId, callback);
syncPromise.set_value(RET_OK);
}, accountId_, clientName_), "SearchElementInfosByText");
return syncFuture.get();
return true;
}
RetError AccessibleAbilityChannel::FindFocusedElementInfo(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannel::FindFocusedElementInfo(const int32_t accessibilityWindowId,
const int32_t elementId, const int32_t focusType, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback)
{
@@ -96,56 +86,46 @@ RetError AccessibleAbilityChannel::FindFocusedElementInfo(const int32_t accessib
if (!eventHandler_) {
HILOG_ERROR("eventHandler_ is nullptr.");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
eventHandler_->PostTask(std::bind([&syncPromise, accessibilityWindowId, elementId,
focusType, requestId, callback](int32_t accountId, const std::string &name) -> void {
eventHandler_->PostTask(std::bind([=](int32_t accountId, const std::string &name) -> void {
HILOG_DEBUG("accountId[%{public}d], name[%{public}s]", accountId, name.c_str());
sptr<IAccessibilityElementOperator> elementOperator = nullptr;
RetError ret = GetElementOperator(accountId, accessibilityWindowId, focusType, name, elementOperator);
if (ret != RET_OK) {
sptr<IAccessibilityElementOperator> elementOperator =
GetElementOperator(accountId, accessibilityWindowId, focusType, name);
if (!elementOperator) {
HILOG_ERROR("Get elementOperator failed! accessibilityWindowId[%{public}d]", accessibilityWindowId);
syncPromise.set_value(ret);
return;
}
elementOperator->FindFocusedElementInfo(elementId, focusType, requestId, callback);
syncPromise.set_value(RET_OK);
}, accountId_, clientName_), "FindFocusedElementInfo");
return syncFuture.get();
return true;
}
RetError AccessibleAbilityChannel::FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
bool AccessibleAbilityChannel::FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t direction, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
{
HILOG_DEBUG();
if (!eventHandler_) {
HILOG_ERROR("eventHandler_ is nullptr.");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
eventHandler_->PostTask(std::bind([&syncPromise, accessibilityWindowId,
elementId, direction, requestId, callback](int32_t accountId, const std::string &name) -> void {
eventHandler_->PostTask(std::bind([=](int32_t accountId, const std::string &name) -> void {
HILOG_DEBUG("accountId[%{public}d], name[%{public}s]", accountId, name.c_str());
sptr<IAccessibilityElementOperator> elementOperator = nullptr;
RetError ret = GetElementOperator(accountId, accessibilityWindowId, FOCUS_TYPE_INVALID, name, elementOperator);
if (ret != RET_OK) {
sptr<IAccessibilityElementOperator> elementOperator =
GetElementOperator(accountId, accessibilityWindowId, FOCUS_TYPE_INVALID, name);
if (!elementOperator) {
HILOG_ERROR("Get elementOperator failed! accessibilityWindowId[%{public}d]", accessibilityWindowId);
syncPromise.set_value(ret);
return;
}
elementOperator->FocusMoveSearch(elementId, direction, requestId, callback);
syncPromise.set_value(RET_OK);
}, accountId_, clientName_), "FocusMoveSearch");
return syncFuture.get();
return true;
}
RetError AccessibleAbilityChannel::ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId,
bool AccessibleAbilityChannel::ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t action, const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback> &callback)
{
@@ -153,37 +133,32 @@ RetError AccessibleAbilityChannel::ExecuteAction(const int32_t accessibilityWind
if (!eventHandler_) {
HILOG_ERROR("eventHandler_ is nullptr.");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::future syncFuture = syncPromise.get_future();
eventHandler_->PostTask(std::bind([&syncPromise, accessibilityWindowId, elementId, action,
actionArguments, requestId, callback](int32_t accountId, const std::string &name) -> void {
eventHandler_->PostTask(std::bind([=](int32_t accountId, const std::string &name) -> void {
HILOG_DEBUG("accountId[%{public}d], name[%{public}s]", accountId, name.c_str());
sptr<IAccessibilityElementOperator> elementOperator = nullptr;
RetError ret = GetElementOperator(accountId, accessibilityWindowId, FOCUS_TYPE_INVALID, name, elementOperator);
if (ret != RET_OK) {
sptr<IAccessibilityElementOperator> elementOperator =
GetElementOperator(accountId, accessibilityWindowId, FOCUS_TYPE_INVALID, name);
if (!elementOperator) {
HILOG_ERROR("Get elementOperator failed! accessibilityWindowId[%{public}d]", accessibilityWindowId);
syncPromise.set_value(ret);
return;
}
elementOperator->ExecuteAction(elementId, action, actionArguments, requestId, callback);
syncPromise.set_value(RET_OK);
}, accountId_, clientName_), "ExecuteAction");
return syncFuture.get();
return true;
}
RetError AccessibleAbilityChannel::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
bool AccessibleAbilityChannel::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
{
HILOG_DEBUG("windowId:%{public}d", windowId);
if (!eventHandler_) {
HILOG_ERROR("eventHandler_ is nullptr.");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::promise<bool> syncPromise;
std::future syncFuture = syncPromise.get_future();
eventHandler_->PostTask(std::bind([windowId, &windowInfo, &syncPromise](
int32_t accountId, const std::string &name) -> void {
@@ -191,25 +166,25 @@ RetError AccessibleAbilityChannel::GetWindow(const int32_t windowId, Accessibili
sptr<AccessibleAbilityConnection> clientConnection = GetConnection(accountId, name);
if (!clientConnection) {
HILOG_ERROR("There is no client connection");
syncPromise.set_value(RET_ERR_NO_CONNECTION);
syncPromise.set_value(false);
return;
}
if (!(clientConnection->GetAbilityInfo().GetCapabilityValues() & Capability::CAPABILITY_RETRIEVE)) {
HILOG_ERROR("AccessibleAbilityChannel::GetWindow failed: no capability");
syncPromise.set_value(RET_ERR_NO_CAPABILITY);
syncPromise.set_value(false);
return;
}
if (Singleton<AccessibilityWindowManager>::GetInstance().GetAccessibilityWindow(windowId, windowInfo)) {
syncPromise.set_value(RET_OK);
syncPromise.set_value(true);
} else {
syncPromise.set_value(RET_ERR_NO_WINDOW_CONNECTION);
syncPromise.set_value(false);
}
}, accountId_, clientName_), "GetWindow");
return syncFuture.get();
}
RetError AccessibleAbilityChannel::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
bool AccessibleAbilityChannel::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_DEBUG();
uint64_t displayId = Singleton<AccessibilityDisplayManager>::GetInstance().GetDefaultDisplayId();
@@ -217,21 +192,21 @@ RetError AccessibleAbilityChannel::GetWindows(std::vector<AccessibilityWindowInf
return GetWindows(displayId, windows);
}
RetError AccessibleAbilityChannel::GetWindowsByDisplayId(const uint64_t displayId,
bool AccessibleAbilityChannel::GetWindowsByDisplayId(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows)
{
HILOG_DEBUG();
return GetWindows(displayId, windows);
}
RetError AccessibleAbilityChannel::GetWindows(uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) const
bool AccessibleAbilityChannel::GetWindows(uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) const
{
if (!eventHandler_) {
HILOG_ERROR("eventHandler_ is nullptr.");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::promise<bool> syncPromise;
std::future syncFuture = syncPromise.get_future();
eventHandler_->PostTask(std::bind([displayId, &windows, &syncPromise](
int32_t accountId, const std::string &name) -> void {
@@ -239,13 +214,13 @@ RetError AccessibleAbilityChannel::GetWindows(uint64_t displayId, std::vector<Ac
sptr<AccessibleAbilityConnection> clientConnection = GetConnection(accountId, name);
if (!clientConnection) {
HILOG_ERROR("There is no client connection");
syncPromise.set_value(RET_ERR_NO_CONNECTION);
syncPromise.set_value(false);
return;
}
if (!(clientConnection->GetAbilityInfo().GetCapabilityValues() & Capability::CAPABILITY_RETRIEVE)) {
HILOG_ERROR("GetWindows failed: no capability");
syncPromise.set_value(RET_ERR_NO_CAPABILITY);
syncPromise.set_value(false);
return;
}
@@ -256,7 +231,7 @@ RetError AccessibleAbilityChannel::GetWindows(uint64_t displayId, std::vector<Ac
windows.emplace_back(window);
}
}
syncPromise.set_value(RET_OK);
syncPromise.set_value(true);
}, accountId_, clientName_), "GetWindows");
return syncFuture.get();
}
@@ -286,15 +261,14 @@ void AccessibleAbilityChannel::SetOnKeyPressEventResult(const bool handled, cons
}, accountId_, clientName_), "SetOnKeyPressEventResult");
}
RetError AccessibleAbilityChannel::SendSimulateGesture(
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
bool AccessibleAbilityChannel::SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
{
HILOG_INFO();
if (!eventHandler_) {
HILOG_ERROR("eventHandler_ is nullptr");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::promise<bool> syncPromise;
std::future syncFuture = syncPromise.get_future();
eventHandler_->PostTask(std::bind([gesturePath, &syncPromise](int32_t accountId, const std::string &name) -> void {
@@ -302,13 +276,13 @@ RetError AccessibleAbilityChannel::SendSimulateGesture(
sptr<AccessibleAbilityConnection> clientConnection = GetConnection(accountId, name);
if (!clientConnection) {
HILOG_ERROR("There is no client connection");
syncPromise.set_value(RET_ERR_NO_CONNECTION);
syncPromise.set_value(false);
return;
}
if (!(clientConnection->GetAbilityInfo().GetCapabilityValues() & Capability::CAPABILITY_GESTURE)) {
HILOG_ERROR("AccessibleAbilityChannel::SendSimulateGesture failed: no capability");
syncPromise.set_value(RET_ERR_NO_CAPABILITY);
syncPromise.set_value(false);
return;
}
@@ -316,23 +290,23 @@ RetError AccessibleAbilityChannel::SendSimulateGesture(
Singleton<AccessibleAbilityManagerService>::GetInstance().GetTouchEventInjector();
if (!touchEventInjector) {
HILOG_ERROR("touchEventInjector is null");
syncPromise.set_value(RET_ERR_NO_INJECTOR);
syncPromise.set_value(false);
return;
}
touchEventInjector->InjectEvents(gesturePath);
syncPromise.set_value(RET_OK);
syncPromise.set_value(true);
}, accountId_, clientName_), "SendSimulateGesture");
return syncFuture.get();
}
RetError AccessibleAbilityChannel::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
bool AccessibleAbilityChannel::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
{
HILOG_DEBUG();
if (!eventHandler_) {
HILOG_ERROR("eventHandler_ is nullptr");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::promise<bool> syncPromise;
std::future syncFuture = syncPromise.get_future();
eventHandler_->PostTask(std::bind([targetBundleNames, &syncPromise](
@@ -341,12 +315,12 @@ RetError AccessibleAbilityChannel::SetTargetBundleName(const std::vector<std::st
sptr<AccessibleAbilityConnection> clientConnection = GetConnection(accountId, name);
if (!clientConnection) {
HILOG_ERROR("There is no client connection");
syncPromise.set_value(RET_ERR_NO_CONNECTION);
syncPromise.set_value(false);
return;
}
clientConnection->SetAbilityInfoTargetBundleName(targetBundleNames);
syncPromise.set_value(RET_OK);
syncPromise.set_value(true);
}, accountId_, clientName_), "SetTargetBundleName");
return syncFuture.get();
}
@@ -366,40 +340,33 @@ sptr<AccessibleAbilityConnection> AccessibleAbilityChannel::GetConnection(
return accountData->GetAccessibleAbilityConnection(clientName);
}
RetError AccessibleAbilityChannel::GetElementOperator(
int32_t accountId, int32_t windowId, int32_t focusType, const std::string &clientName,
sptr<IAccessibilityElementOperator> &elementOperator)
sptr<IAccessibilityElementOperator> AccessibleAbilityChannel::GetElementOperator(
int32_t accountId, int32_t windowId, int32_t focusType, const std::string &clientName)
{
HILOG_DEBUG();
elementOperator = nullptr;
sptr<AccessibleAbilityConnection> clientConnection = GetConnection(accountId, clientName);
if (!clientConnection) {
HILOG_ERROR("There is no client connection");
return RET_ERR_NO_CONNECTION;
return nullptr;
}
if (!(clientConnection->GetAbilityInfo().GetCapabilityValues() & Capability::CAPABILITY_RETRIEVE)) {
HILOG_ERROR("the client has no retieve capability");
return RET_ERR_NO_CAPABILITY;
return nullptr;
}
sptr<AccessibilityAccountData> accountData =
Singleton<AccessibleAbilityManagerService>::GetInstance().GetAccountData(accountId);
if (!accountData) {
HILOG_ERROR("accountData is nullptr");
return RET_ERR_NULLPTR;
return nullptr;
}
int32_t realId = Singleton<AccessibilityWindowManager>::GetInstance().ConvertToRealWindowId(windowId, focusType);
sptr<AccessibilityWindowConnection> connection = accountData->GetAccessibilityWindowConnection(realId);
if (!connection) {
HILOG_ERROR("windowId[%{public}d] has no connection", realId);
return RET_ERR_NO_WINDOW_CONNECTION;
return nullptr;
}
elementOperator = connection->GetProxy();
if (!elementOperator) {
HILOG_ERROR("The proxy of window connection is nullptr");
return RET_ERR_NULLPTR;
}
return RET_OK;
return connection->GetProxy();
}
} // namespace Accessibility
} // namespace OHOS
@@ -210,12 +210,12 @@ int AccessibleAbilityManagerService::Dump(int fd, const std::vector<std::u16stri
return accessibilityDumper_->Dump(fd, args);
}
RetError AccessibleAbilityManagerService::SendEvent(const AccessibilityEventInfo &uiEvent)
void AccessibleAbilityManagerService::SendEvent(const AccessibilityEventInfo &uiEvent)
{
HILOG_DEBUG("eventType[%{public}d] gestureId[%{public}d]", uiEvent.GetEventType(), uiEvent.GetGestureType());
if (!handler_) {
HILOG_ERROR("Parameters check failed!");
return RET_ERR_NULLPTR;
return;
}
UpdateAccessibilityWindowStateByEvent(uiEvent);
@@ -235,7 +235,6 @@ RetError AccessibleAbilityManagerService::SendEvent(const AccessibilityEventInfo
}
}
}, uiEvent), "TASK_SEND_EVENT");
return RET_OK;
}
uint32_t AccessibleAbilityManagerService::RegisterStateObserver(
@@ -365,22 +364,22 @@ void AccessibleAbilityManagerService::RegisterEnableAbilityListsObserver(
return syncFuture.get();
}
RetError AccessibleAbilityManagerService::GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
bool AccessibleAbilityManagerService::GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
std::vector<AccessibilityAbilityInfo> &infos)
{
HILOG_DEBUG("abilityTypes(%{public}d) stateType(%{public}d)", abilityTypes, stateType);
if (!handler_ || (stateType > ABILITY_STATE_INSTALLED) || (stateType < ABILITY_STATE_ENABLE)) {
HILOG_ERROR("Parameters check failed! stateType:%{public}d, handler:%{public}p", stateType, handler_.get());
return RET_ERR_INVALID_PARAM;
return false;
}
std::promise<RetError> syncPromise;
std::promise<void> syncPromise;
std::future syncFuture = syncPromise.get_future();
handler_->PostTask(std::bind([this, &syncPromise, &infos, abilityTypes, stateType]() -> void {
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (!accountData) {
HILOG_ERROR("Get current account data failed!!");
syncPromise.set_value(RET_ERR_FAILED);
syncPromise.set_value();
return;
}
@@ -394,19 +393,21 @@ RetError AccessibleAbilityManagerService::GetAbilityList(const uint32_t abilityT
}
}
HILOG_DEBUG("infos count is %{public}zu", infos.size());
syncPromise.set_value(RET_OK);
syncPromise.set_value();
}), "TASK_GET_ABILITY_LIST");
return syncFuture.get();
syncFuture.get();
return true;
}
RetError AccessibleAbilityManagerService::RegisterElementOperator(
void AccessibleAbilityManagerService::RegisterElementOperator(
const int32_t windowId, const sptr<IAccessibilityElementOperator> &operation)
{
if (!handler_) {
Utils::RecordUnavailableEvent(A11yUnavailableEvent::CONNECT_EVENT,
A11yError::ERROR_CONNECT_TARGET_APPLICATION_FAILED);
HILOG_ERROR("handler_ is nullptr.");
return RET_ERR_NULLPTR;
return;
}
handler_->PostTask(std::bind([=]() -> void {
@@ -451,14 +452,13 @@ RetError AccessibleAbilityManagerService::RegisterElementOperator(
HILOG_DEBUG("The result of adding operation's death recipient is %{public}d", result);
}
}), "TASK_REGISTER_ELEMENT_OPERATOR");
return RET_OK;
}
RetError AccessibleAbilityManagerService::DeregisterElementOperator(int32_t windowId)
void AccessibleAbilityManagerService::DeregisterElementOperator(int32_t windowId)
{
if (!handler_) {
HILOG_ERROR("handler_ is nullptr.");
return RET_ERR_NULLPTR;
return;
}
handler_->PostTask(std::bind([=]() -> void {
@@ -491,7 +491,6 @@ RetError AccessibleAbilityManagerService::DeregisterElementOperator(int32_t wind
}
}
}), "TASK_DEREGISTER_ELEMENT_OPERATOR");
return RET_OK;
}
RetError AccessibleAbilityManagerService::GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption)
@@ -687,92 +686,94 @@ bool AccessibleAbilityManagerService::GetKeyEventObserverState()
return syncFuture.get();
}
RetError AccessibleAbilityManagerService::EnableAbility(const std::string &name, const uint32_t capabilities)
bool AccessibleAbilityManagerService::EnableAbility(const std::string &name, const uint32_t capabilities)
{
HILOG_DEBUG();
if (!handler_) {
HILOG_ERROR("handler_ is nullptr.");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::promise<bool> syncPromise;
std::future syncFuture = syncPromise.get_future();
handler_->PostTask(std::bind([this, &syncPromise, &name, &capabilities]() -> void {
HILOG_DEBUG();
RetError result = InnerEnableAbility(name, capabilities);
bool result = InnerEnableAbility(name, capabilities);
syncPromise.set_value(result);
}), "TASK_ENABLE_ABILITIES");
return syncFuture.get();
}
RetError AccessibleAbilityManagerService::InnerEnableAbility(const std::string &name, const uint32_t capabilities)
bool AccessibleAbilityManagerService::InnerEnableAbility(const std::string &name, const uint32_t capabilities)
{
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (!accountData) {
HILOG_ERROR("accountData is nullptr");
return RET_ERR_NULLPTR;
return false;
}
return accountData->EnableAbility(name, capabilities);
bool result = accountData->EnableAbility(name, capabilities);
return result;
}
RetError AccessibleAbilityManagerService::GetEnabledAbilities(std::vector<std::string> &enabledAbilities)
bool AccessibleAbilityManagerService::GetEnabledAbilities(std::vector<std::string> &enabledAbilities)
{
HILOG_DEBUG();
if (!handler_) {
HILOG_ERROR("handler_ is nullptr.");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::promise<void> syncPromise;
std::future syncFuture = syncPromise.get_future();
handler_->PostTask(std::bind([this, &syncPromise, &enabledAbilities]() -> void {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (!accountData) {
HILOG_ERROR("accountData is nullptr");
syncPromise.set_value(RET_ERR_NULLPTR);
syncPromise.set_value();
return;
}
enabledAbilities = accountData->GetEnabledAbilities();
syncPromise.set_value(RET_OK);
syncPromise.set_value();
}), "TASK_GET_ENABLE_ABILITIES");
return syncFuture.get();
syncFuture.get();
return true;
}
RetError AccessibleAbilityManagerService::DisableAbility(const std::string &name)
bool AccessibleAbilityManagerService::DisableAbility(const std::string &name)
{
HILOG_DEBUG();
if (!handler_) {
HILOG_ERROR("handler_ is nullptr.");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::promise<bool> syncPromise;
std::future syncFuture = syncPromise.get_future();
handler_->PostTask(std::bind([this, &syncPromise, &name]() -> void {
HILOG_DEBUG();
RetError result = InnerDisableAbility(name);
bool result = InnerDisableAbility(name);
syncPromise.set_value(result);
}), "TASK_DISABLE_ABILITIES");
return syncFuture.get();
}
RetError AccessibleAbilityManagerService::InnerDisableAbility(const std::string &name)
bool AccessibleAbilityManagerService::InnerDisableAbility(const std::string &name)
{
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (!accountData) {
HILOG_ERROR("accountData is nullptr");
return RET_ERR_NULLPTR;
return false;
}
RetError ret = accountData->RemoveEnabledAbility(name);
if (ret != RET_OK) {
if (!accountData->RemoveEnabledAbility(name)) {
HILOG_ERROR("RemoveEnabledAbility failed");
return ret;
return false;
}
accountData->UpdateAbilities();
return RET_OK;
return true;
}
RetError AccessibleAbilityManagerService::EnableUITestAbility(const sptr<IRemoteObject> &obj)
@@ -809,35 +810,35 @@ RetError AccessibleAbilityManagerService::EnableUITestAbility(const sptr<IRemote
return syncFuture.get();
}
RetError AccessibleAbilityManagerService::DisableUITestAbility()
bool AccessibleAbilityManagerService::DisableUITestAbility()
{
HILOG_DEBUG();
if (!handler_) {
HILOG_ERROR("handler_ is nullptr.");
return RET_ERR_NULLPTR;
return false;
}
std::promise<RetError> syncPromise;
std::promise<bool> syncPromise;
std::future syncFuture = syncPromise.get_future();
handler_->PostTask(std::bind([this, &syncPromise]() -> void {
HILOG_DEBUG();
sptr<AccessibilityAccountData> accountData = GetCurrentAccountData();
if (!accountData) {
HILOG_ERROR("accountData is nullptr");
syncPromise.set_value(RET_ERR_NULLPTR);
syncPromise.set_value(false);
return;
}
std::string uiTestUri = Utils::GetUri(UI_TEST_BUNDLE_NAME, UI_TEST_ABILITY_NAME);
sptr<AccessibleAbilityConnection> connection = accountData->GetAccessibleAbilityConnection(uiTestUri);
if (!connection) {
HILOG_ERROR("connection is not existed!!");
syncPromise.set_value(RET_ERR_NO_CONNECTION);
syncPromise.set_value(false);
return;
}
std::function<void()> removeUITestClientFunc =
std::bind(&AccessibilityAccountData::RemoveUITestClient, accountData, connection, UI_TEST_BUNDLE_NAME);
handler_->PostTask(removeUITestClientFunc, "RemoveUITestClient");
syncPromise.set_value(RET_OK);
syncPromise.set_value(true);
}), "TASK_DISABLE_UI_TEST_ABILITIES");
return syncFuture.get();
}
@@ -1887,7 +1888,9 @@ bool AccessibleAbilityManagerService::EnableShortKeyTargetAbility()
}
uint32_t capabilities = CAPABILITY_GESTURE | CAPABILITY_KEY_EVENT_OBSERVER | CAPABILITY_RETRIEVE |
CAPABILITY_TOUCH_GUIDE | CAPABILITY_ZOOM;
return InnerEnableAbility(targetAbility, capabilities) == RET_OK;
bool result = InnerEnableAbility(targetAbility, capabilities);
HILOG_DEBUG("result is %{public}d", result);
return result;
}
bool AccessibleAbilityManagerService::DisableShortKeyTargetAbility()
@@ -1905,7 +1908,9 @@ bool AccessibleAbilityManagerService::DisableShortKeyTargetAbility()
HILOG_ERROR("target ability is null");
return false;
}
return InnerDisableAbility(targetAbility) == RET_OK;
bool result = InnerDisableAbility(targetAbility);
HILOG_DEBUG("result is %{public}d", result);
return result;
}
uint32_t AccessibleAbilityManagerService::RegisterConfigObserver(
+1 -3
View File
@@ -290,6 +290,7 @@ ohos_unittest("accessibility_input_interceptor_test") {
"../src/accessibility_mouse_autoclick.cpp",
"../src/accessibility_mouse_key.cpp",
"../src/accessibility_short_key.cpp",
"../src/accessible_ability_manager_service.cpp",
"../src/accessible_ability_manager_service_event_handler.cpp",
"../src/utils.cpp",
"//foundation/barrierfree/accessibility/common/interface/src/accessible_ability_channel_proxy.cpp",
@@ -306,7 +307,6 @@ ohos_unittest("accessibility_input_interceptor_test") {
"mock/src/mock_accessibility_touchEvent_injector.cpp",
"mock/src/mock_accessibility_touch_guider.cpp",
"mock/src/mock_accessibility_window_manager.cpp",
"mock/src/mock_accessible_ability_manager_service.cpp",
"mock/src/mock_accessible_ability_manager_service_stub.cpp",
"mock/src/mock_os_account_manager.cpp",
"mock/src/mock_system_ability.cpp",
@@ -600,7 +600,6 @@ ohos_unittest("accessibility_touchevent_injector_test") {
"mock/src/mock_accessibility_common_event.cpp",
"mock/src/mock_accessibility_event_transmission.cpp",
"mock/src/mock_accessible_ability_client_stub_impl.cpp",
"mock/src/mock_accessible_ability_manager_service.cpp",
"mock/src/mock_common_event_data.cpp",
"mock/src/mock_common_event_manager.cpp",
"mock/src/mock_common_event_subscribe_info.cpp",
@@ -628,7 +627,6 @@ ohos_unittest("accessibility_touchevent_injector_test") {
external_deps = [
"ability_base:want",
"c_utils:utils",
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"input:libmmi-client",
"ipc:ipc_core",
@@ -40,7 +40,7 @@ public:
MOCK_METHOD1(RemoveAccessibilityWindowConnection, void(const int32_t windowId));
MOCK_METHOD1(AddConnectingA11yAbility, void(const AppExecFwk::ElementName& elementName));
MOCK_METHOD1(AddEnabledAbility, void(const AppExecFwk::ElementName& elementName));
MOCK_METHOD1(RemoveEnabledAbility, RetError(const std::string& bundleName));
MOCK_METHOD1(RemoveEnabledAbility, bool(const std::string& bundleName));
MOCK_METHOD1(AddInstalledAbility, void(AccessibilityAbilityInfo& abilityInfo));
MOCK_METHOD1(RemoveInstalledAbility, void(const std::string &bundleName));
MOCK_METHOD0(ClearInstalledAbility, void());
@@ -27,27 +27,26 @@ public:
~MockAccessibleAbilityChannel();
MOCK_METHOD5(SearchElementInfoByAccessibilityId,
RetError(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t requestId,
bool(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback, const int32_t mode));
MOCK_METHOD5(SearchElementInfosByText,
RetError(const int32_t accessibilityWindowId, const int32_t elementId, const std::string& text,
bool(const int32_t accessibilityWindowId, const int32_t elementId, const std::string& text,
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD5(FindFocusedElementInfo,
RetError(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t focusType,
bool(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t focusType,
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD5(
FocusMoveSearch, RetError(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t direction,
FocusMoveSearch, bool(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t direction,
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD6(ExecuteAction, RetError(const int32_t accessibilityWindowId, const int32_t elementId,
MOCK_METHOD6(ExecuteAction, bool(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t action, const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback));
MOCK_METHOD1(GetWindows, RetError(std::vector<AccessibilityWindowInfo> &windows));
MOCK_METHOD2(GetWindowsByDisplayId, RetError(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows));
MOCK_METHOD1(GetWindows, bool(std::vector<AccessibilityWindowInfo> &windows));
MOCK_METHOD2(GetWindowsByDisplayId, bool(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows));
MOCK_METHOD2(SetOnKeyPressEventResult, void(const bool handled, const int32_t sequence));
MOCK_METHOD1(SendSimulateGesture, RetError(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
MOCK_METHOD1(SendSimulateGesture, bool(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
};
class MockAccessibleAbilityConnection : public AccessibleAbilityConnection {
@@ -27,16 +27,16 @@ class MockAccessibleAbilityManagerService : public AccessibleAbilityManagerServi
public:
MOCK_METHOD0(OnStart, void());
MOCK_METHOD0(OnStop, void());
MOCK_METHOD1(SendEvent, RetError(const AccessibilityEventInfo& uiEvent));
MOCK_METHOD1(SendEvent, void(const AccessibilityEventInfo& uiEvent));
MOCK_METHOD2(RegisterStateCallback,
uint32_t(const sptr<AccessibleAbilityManagerServiceStub>& callback, const int32_t accountId));
MOCK_METHOD2(RegisterCaptionPropertyCallback,
uint32_t(const sptr<IAccessibleAbilityManagerCaptionObserver>& callback, const int32_t accountId));
MOCK_METHOD3(GetAbilityList, RetError(const uint32_t abilityTypes, const int32_t stateType,
MOCK_METHOD3(GetAbilityList, bool(const uint32_t abilityTypes, const int32_t stateType,
std::vector<AccessibilityAbilityInfo> &infos));
MOCK_METHOD2(RegisterElementOperator,
RetError(const int32_t windowId, const sptr<IAccessibilityElementOperator>& operation));
MOCK_METHOD1(DeregisterElementOperator, RetError(const int32_t windowId));
void(const int32_t windowId, const sptr<IAccessibilityElementOperator>& operation));
MOCK_METHOD1(DeregisterElementOperator, void(const int32_t windowId));
MOCK_METHOD1(GetCaptionProperty, RetError(AccessibilityConfig::CaptionProperty& caption));
MOCK_METHOD1(SetCaptionProperty, RetError(const AccessibilityConfig::CaptionProperty& caption));
MOCK_METHOD1(SetCaptionState, RetError(const bool state));
@@ -92,7 +92,9 @@ public:
MOCK_METHOD1(SetGestureState, bool(const bool state));
MOCK_METHOD1(SetKeyEventObserverState, bool(const bool state));
MOCK_METHOD1(SetEnabledObj, bool(std::map<std::string, AppExecFwk::ElementName> it));
MOCK_METHOD1(GetEnabledAbilities, RetError(std::vector<std::string> &enabledAbilities));
MOCK_METHOD1(GetEnabledAbilities, bool(std::vector<std::string> &enabledAbilities));
MOCK_METHOD1(RegisterUITestAbilityConnectionClient, bool(const sptr<IRemoteObject>& obj));
MOCK_METHOD0(DeregisterUITestAbilityConnectionClient, bool());
MOCK_METHOD0(GetActiveWindow, int32_t());
};
} // namespace Accessibility
@@ -167,7 +167,7 @@ void AccessibilityAccountData::AddEnabledAbility(const std::string& bundleName)
HILOG_DEBUG("Add EnabledAbility: %{public}zu", enabledAbilities_.size());
}
RetError AccessibilityAccountData::RemoveEnabledAbility(const std::string &name)
bool AccessibilityAccountData::RemoveEnabledAbility(const std::string &name)
{
HILOG_DEBUG("start");
for (auto it = enabledAbilities_.begin(); it != enabledAbilities_.end(); it++) {
@@ -175,11 +175,11 @@ RetError AccessibilityAccountData::RemoveEnabledAbility(const std::string &name)
HILOG_DEBUG("Removed %{public}s from EnabledAbility: ", name.c_str());
enabledAbilities_.erase(it);
HILOG_DEBUG("EnabledAbility size(%{public}zu)", enabledAbilities_.size());
return RET_OK;
return true;
}
}
HILOG_ERROR("The ability(%{public}s) is not enabled.", name.c_str());
return RET_ERR_NOT_ENABLED;
return false;
}
// For UT
@@ -286,17 +286,17 @@ void AccessibilityAccountData::UpdateMagnificationCapability()
isScreenMagnification_ = false;
}
RetError AccessibilityAccountData::EnableAbility(const std::string &name, const uint32_t capabilities)
bool AccessibilityAccountData::EnableAbility(const std::string &name, const uint32_t capabilities)
{
HILOG_DEBUG("start.");
for (const auto &enabledAbility : enabledAbilities_) {
if (enabledAbility == name) {
HILOG_ERROR("The ability[%{public}s] is already enabled", name.c_str());
return RET_ERR_CONNECTION_EXIST;
return false;
}
}
enabledAbilities_.push_back(name);
return RET_OK;
return true;
}
bool AccessibilityAccountData::GetInstalledAbilitiesFromBMS()
@@ -39,7 +39,7 @@ bool AccessibleAbilityChannelProxy::SendTransactCmd(
return true;
}
RetError AccessibleAbilityChannelProxy::SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannelProxy::SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
const int32_t elementId, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback,
const int32_t mode)
{
@@ -48,10 +48,10 @@ RetError AccessibleAbilityChannelProxy::SearchElementInfoByAccessibilityId(const
(void)requestId;
(void)callback;
(void)mode;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::SearchElementInfosByText(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannelProxy::SearchElementInfosByText(const int32_t accessibilityWindowId,
const int32_t elementId, const std::string& text, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback)
{
@@ -60,22 +60,21 @@ RetError AccessibleAbilityChannelProxy::SearchElementInfosByText(const int32_t a
(void)requestId;
(void)callback;
(void)text;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::FindFocusedElementInfo(const int32_t accessibilityWindowId,
const int32_t elementId, const int32_t focusType, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback)
bool AccessibleAbilityChannelProxy::FindFocusedElementInfo(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t focusType, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback)
{
(void)accessibilityWindowId;
(void)elementId;
(void)requestId;
(void)callback;
(void)focusType;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
bool AccessibleAbilityChannelProxy::FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t direction, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback)
{
(void)accessibilityWindowId;
@@ -83,10 +82,10 @@ RetError AccessibleAbilityChannelProxy::FocusMoveSearch(const int32_t accessibil
(void)requestId;
(void)callback;
(void)direction;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId,
bool AccessibleAbilityChannelProxy::ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t action, const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback)
{
@@ -95,28 +94,28 @@ RetError AccessibleAbilityChannelProxy::ExecuteAction(const int32_t accessibilit
(void)requestId;
(void)callback;
(void)actionArguments;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
bool AccessibleAbilityChannelProxy::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
{
(void)windowId;
(void)windowInfo;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
bool AccessibleAbilityChannelProxy::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
{
(void)windows;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::GetWindowsByDisplayId(const uint64_t displayId,
bool AccessibleAbilityChannelProxy::GetWindowsByDisplayId(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows)
{
(void)displayId;
(void)windows;
return RET_OK;
return true;
}
void AccessibleAbilityChannelProxy::SetOnKeyPressEventResult(const bool handled, const int32_t sequence)
@@ -125,17 +124,17 @@ void AccessibleAbilityChannelProxy::SetOnKeyPressEventResult(const bool handled,
(void)sequence;
}
RetError AccessibleAbilityChannelProxy::SendSimulateGesture(
bool AccessibleAbilityChannelProxy::SendSimulateGesture(
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
{
(void)gesturePath;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannelProxy::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
bool AccessibleAbilityChannelProxy::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
{
(void)targetBundleNames;
return RET_OK;
return true;
}
} // namespace Accessibility
} // namespace OHOS
@@ -40,7 +40,7 @@ AccessibleAbilityChannel::AccessibleAbilityChannel(const int32_t accountId, cons
{
}
RetError AccessibleAbilityChannel::SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannel::SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
const int32_t elementId, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback,
const int32_t mode)
{
@@ -49,10 +49,10 @@ RetError AccessibleAbilityChannel::SearchElementInfoByAccessibilityId(const int3
(void)requestId;
(void)callback;
(void)mode;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannel::SearchElementInfosByText(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannel::SearchElementInfosByText(const int32_t accessibilityWindowId,
const int32_t elementId, const std::string& text, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback)
{
@@ -61,10 +61,10 @@ RetError AccessibleAbilityChannel::SearchElementInfosByText(const int32_t access
(void)text;
(void)requestId;
(void)callback;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannel::FindFocusedElementInfo(const int32_t accessibilityWindowId,
bool AccessibleAbilityChannel::FindFocusedElementInfo(const int32_t accessibilityWindowId,
const int32_t elementId, const int32_t focusType, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback)
{
@@ -73,10 +73,10 @@ RetError AccessibleAbilityChannel::FindFocusedElementInfo(const int32_t accessib
(void)focusType;
(void)requestId;
(void)callback;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannel::FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
bool AccessibleAbilityChannel::FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t direction, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback)
{
(void)accessibilityWindowId;
@@ -84,10 +84,10 @@ RetError AccessibleAbilityChannel::FocusMoveSearch(const int32_t accessibilityWi
(void)direction;
(void)requestId;
(void)callback;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannel::ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId,
bool AccessibleAbilityChannel::ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId,
const int32_t action, const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
const sptr<IAccessibilityElementOperatorCallback>& callback)
{
@@ -97,46 +97,46 @@ RetError AccessibleAbilityChannel::ExecuteAction(const int32_t accessibilityWind
(void)actionArguments;
(void)requestId;
(void)callback;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannel::GetWindows(uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) const
bool AccessibleAbilityChannel::GetWindows(uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) const
{
(void)displayId;
(void)windows;
sptr<AccessibleAbilityConnection> clientConnection = GetConnection(accountId_, clientName_);
if (!clientConnection) {
HILOG_ERROR("There is no client connection");
return RET_ERR_NO_CONNECTION;
return false;
}
if (!(clientConnection->GetAbilityInfo().GetCapabilityValues() & Capability::CAPABILITY_RETRIEVE)) {
HILOG_ERROR("AccessibleAbilityChannel::GetWindows failed: no capability");
return RET_ERR_NO_CAPABILITY;
return false;
}
return RET_OK;
return true;
}
RetError AccessibleAbilityChannel::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
bool AccessibleAbilityChannel::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
{
uint64_t displayId = 0;
return GetWindows(displayId, windows);
}
RetError AccessibleAbilityChannel::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
bool AccessibleAbilityChannel::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
{
(void)windowId;
(void)windowInfo;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannel::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
bool AccessibleAbilityChannel::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
{
(void)targetBundleNames;
return RET_OK;
return true;
}
RetError AccessibleAbilityChannel::GetWindowsByDisplayId(const uint64_t displayId,
bool AccessibleAbilityChannel::GetWindowsByDisplayId(const uint64_t displayId,
std::vector<AccessibilityWindowInfo> &windows)
{
return GetWindows(displayId, windows);
@@ -148,11 +148,10 @@ void AccessibleAbilityChannel::SetOnKeyPressEventResult(const bool handled, cons
(void)sequence;
}
RetError AccessibleAbilityChannel::SendSimulateGesture(
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
bool AccessibleAbilityChannel::SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
{
(void)gesturePath;
return RET_OK;
return true;
}
sptr<AccessibleAbilityConnection> AccessibleAbilityChannel::GetConnection(int32_t accountId,
@@ -79,7 +79,7 @@ int AccessibleAbilityManagerService::Dump(int fd, const std::vector<std::u16stri
return 0;
}
RetError AccessibleAbilityManagerService::SendEvent(const AccessibilityEventInfo& uiEvent)
void AccessibleAbilityManagerService::SendEvent(const AccessibilityEventInfo& uiEvent)
{
HILOG_INFO("AccessibleAbilityManagerService::SendEvent successfully");
EventType uTeventType = uiEvent.GetEventType();
@@ -96,7 +96,6 @@ RetError AccessibleAbilityManagerService::SendEvent(const AccessibilityEventInfo
HILOG_DEBUG("start");
AccessibilityAbilityHelper::GetInstance().AddSendEventTimes();
}), "TASK_SEND_EVENT");
return RET_OK;
}
uint32_t AccessibleAbilityManagerService::RegisterStateObserver(
@@ -106,27 +105,25 @@ uint32_t AccessibleAbilityManagerService::RegisterStateObserver(
return 0;
}
RetError AccessibleAbilityManagerService::GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
bool AccessibleAbilityManagerService::GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
std::vector<AccessibilityAbilityInfo> &infos)
{
(void)abilityTypes;
(void)stateType;
(void)infos;
return RET_OK;
return true;
}
RetError AccessibleAbilityManagerService::RegisterElementOperator(
void AccessibleAbilityManagerService::RegisterElementOperator(
const int32_t windowId, const sptr<IAccessibilityElementOperator>& operation)
{
(void)windowId;
(void)operation;
return RET_OK;
}
RetError AccessibleAbilityManagerService::DeregisterElementOperator(int32_t windowId)
void AccessibleAbilityManagerService::DeregisterElementOperator(int32_t windowId)
{
(void)windowId;
return RET_OK;
}
sptr<AccessibilityAccountData> AccessibleAbilityManagerService::GetCurrentAccountData()
@@ -198,17 +195,17 @@ bool AccessibleAbilityManagerService::GetKeyEventObserverState()
return true;
}
RetError AccessibleAbilityManagerService::EnableAbility(const std::string &name, const uint32_t capabilities)
bool AccessibleAbilityManagerService::EnableAbility(const std::string &name, const uint32_t capabilities)
{
(void)name;
(void)capabilities;
return RET_OK;
return true;
}
RetError AccessibleAbilityManagerService::GetEnabledAbilities(std::vector<std::string> &enabledAbilities)
bool AccessibleAbilityManagerService::GetEnabledAbilities(std::vector<std::string> &enabledAbilities)
{
(void)enabledAbilities;
return RET_OK;
return true;
}
uint32_t AccessibleAbilityManagerService::RegisterCaptionObserver(
@@ -218,10 +215,10 @@ uint32_t AccessibleAbilityManagerService::RegisterCaptionObserver(
return NO_ERROR;
}
RetError AccessibleAbilityManagerService::DisableAbility(const std::string &name)
bool AccessibleAbilityManagerService::DisableAbility(const std::string &name)
{
(void)name;
return RET_OK;
return true;
}
RetError AccessibleAbilityManagerService::EnableUITestAbility(const sptr<IRemoteObject>& obj)
@@ -230,9 +227,9 @@ RetError AccessibleAbilityManagerService::EnableUITestAbility(const sptr<IRemote
return RET_OK;
}
RetError AccessibleAbilityManagerService::DisableUITestAbility()
bool AccessibleAbilityManagerService::DisableUITestAbility()
{
return RET_OK;
return true;
}
int32_t AccessibleAbilityManagerService::GetActiveWindow()
@@ -921,17 +921,10 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_EnableA
const int32_t accountId = 1;
sptr<AccessibilityAccountData> accountData = new AccessibilityAccountData(accountId);
accountData->Init();
AccessibilityAbilityInitParams initParams;
initParams.bundleName = "bundle";
initParams.name = "ability";
std::shared_ptr<AccessibilityAbilityInfo> abilityInfo = std::make_shared<AccessibilityAbilityInfo>(initParams);
accountData->AddInstalledAbility(*abilityInfo);
const std::string name = "bundle/ability";
uint32_t capabilities = 0;
RetError test = accountData->EnableAbility(name, capabilities);
EXPECT_EQ(test, RET_ERR_NO_CAPABILITY);
bool test = accountData->EnableAbility(name, capabilities);
EXPECT_FALSE(test);
ASSERT_EQ(0, (int)accountData->GetConfig()->GetEnabledAbilityInfos().size());
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_EnableAbility_001 end";
@@ -956,7 +949,7 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_EnableA
accountData->AddInstalledAbility(*abilityInfo);
std::string name = "bundle/ability";
accountData->AddEnabledAbility(name);
EXPECT_EQ(RET_ERR_CONNECTION_EXIST, accountData->EnableAbility(name, CAPABILITY_RETRIEVE));
EXPECT_FALSE(accountData->EnableAbility(name, CAPABILITY_RETRIEVE));
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_EnableAbility_002 end";
}
@@ -979,24 +972,11 @@ HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_EnableA
std::shared_ptr<AccessibilityAbilityInfo> abilityInfo = std::make_shared<AccessibilityAbilityInfo>(initParams);
accountData->AddInstalledAbility(*abilityInfo);
const std::string name = "bundle/ability";
EXPECT_EQ(RET_OK, accountData->EnableAbility(name, CAPABILITY_RETRIEVE));
EXPECT_TRUE(accountData->EnableAbility(name, CAPABILITY_RETRIEVE));
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_EnableAbility_003 end";
}
/**
* @tc.number: AccessibilityAccountData_Unittest_EnableAbility_004
* @tc.name: EnableAbility
* @tc.desc: Enable specified ability which is not installed.
*/
HWTEST_F(AccessibilityAccountDataTest, AccessibilityAccountData_Unittest_EnableAbility_004, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_EnableAbility_004 start";
sptr<AccessibilityAccountData> accountData = new AccessibilityAccountData(0);
EXPECT_EQ(RET_ERR_NOT_INSTALLED, accountData->EnableAbility("bundle/ability", 0));
GTEST_LOG_(INFO) << "AccessibilityAccountData_Unittest_EnableAbility_004 end";
}
/**
* @tc.number: AccessibilityAccountData_Unittest_GetImportantEnabledAbilities_001
* @tc.name: GetImportantEnabledAbilities
@@ -51,6 +51,8 @@ void AccessibilityInputInterceptorTest::SetUpTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityInputInterceptorTest SetUpTestCase";
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
AccessibilityCommonHelper::GetInstance().WaitForServicePublish();
Singleton<AccessibleAbilityManagerService>::GetInstance().SwitchedUser(AccessibilityAbilityHelper::accountId_);
}
void AccessibilityInputInterceptorTest::TearDownTestCase()
@@ -55,6 +55,8 @@ void TouchEventInjectorTest::SetUpTestCase()
{
GTEST_LOG_(INFO) << "TouchEventInjectorTest SetUpTestCase";
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
AccessibilityCommonHelper::GetInstance().WaitForServicePublish();
Singleton<AccessibleAbilityManagerService>::GetInstance().SwitchedUser(AccessibilityAbilityHelper::accountId_);
}
void TouchEventInjectorTest::TearDownTestCase()
@@ -210,7 +210,7 @@ HWTEST_F(AccessibleAbilityChannelUnitTest,
{
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_GetWindow_001 start";
AccessibilityWindowInfo windowInfo;
EXPECT_EQ(channel_->GetWindow(WINDOW_ID, windowInfo), RET_ERR_NO_WINDOW_CONNECTION);
EXPECT_FALSE(channel_->GetWindow(WINDOW_ID, windowInfo));
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_GetWindow_001 end";
}
@@ -231,7 +231,7 @@ HWTEST_F(AccessibleAbilityChannelUnitTest,
sptr<AccessibleAbilityChannel> channel = new AccessibleAbilityChannel(accountData->GetAccountId(), ability);
AccessibilityWindowInfo windowInfo;
EXPECT_EQ(channel->GetWindow(WINDOW_ID, windowInfo), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(channel->GetWindow(WINDOW_ID, windowInfo));
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_GetWindow_002 end";
}
@@ -259,7 +259,7 @@ HWTEST_F(AccessibleAbilityChannelUnitTest,
EXPECT_TRUE(accountData->GetAccessibleAbilityConnection(ability));
AccessibilityWindowInfo windowInfo;
EXPECT_EQ(channel->GetWindow(WINDOW_ID, windowInfo), RET_ERR_NO_CAPABILITY);
EXPECT_FALSE(channel->GetWindow(WINDOW_ID, windowInfo));
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_GetWindow_003 end";
}
@@ -273,7 +273,7 @@ HWTEST_F(AccessibleAbilityChannelUnitTest,
{
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_GetWindows_001 start";
std::vector<AccessibilityWindowInfo> windows;
EXPECT_EQ(channel_->GetWindows(windows), RET_OK);
EXPECT_TRUE(channel_->GetWindows(windows));
EXPECT_EQ(static_cast<int>(windows.size()), 0);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_GetWindows_001 end";
}
@@ -295,7 +295,7 @@ HWTEST_F(AccessibleAbilityChannelUnitTest,
sptr<AccessibleAbilityChannel> channel = new AccessibleAbilityChannel(accountData->GetAccountId(), abilityName);
std::vector<AccessibilityWindowInfo> windows;
EXPECT_EQ(channel->GetWindows(windows), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(channel->GetWindows(windows));
EXPECT_EQ(static_cast<int>(windows.size()), 0);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_GetWindows_002 end";
}
@@ -327,7 +327,7 @@ HWTEST_F(AccessibleAbilityChannelUnitTest,
EXPECT_TRUE(accountData->GetAccessibleAbilityConnection(abilityInfo->GetId()));
std::vector<AccessibilityWindowInfo> windows;
EXPECT_EQ(channel->GetWindows(windows), RET_ERR_NO_CAPABILITY);
EXPECT_FALSE(channel->GetWindows(windows));
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_GetWindows_003 end";
}
@@ -341,7 +341,7 @@ HWTEST_F(AccessibleAbilityChannelUnitTest,
{
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_GetWindowsByDisplayId_001 start";
std::vector<AccessibilityWindowInfo> windows;
EXPECT_EQ(channel_->GetWindowsByDisplayId(DISPLAY_ID, windows), RET_OK);
EXPECT_TRUE(channel_->GetWindowsByDisplayId(DISPLAY_ID, windows));
EXPECT_EQ(static_cast<int>(windows.size()), 0);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_GetWindowsByDisplayId_001 end";
}
@@ -391,7 +391,7 @@ HWTEST_F(AccessibleAbilityChannelUnitTest,
AccessibleAbilityChannel_Unittest_SendSimulateGesture_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_SendSimulateGesture_001 start";
EXPECT_EQ(channel_->SendSimulateGesture(nullptr), RET_ERR_NO_INJECTOR);
EXPECT_FALSE(channel_->SendSimulateGesture(nullptr));
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_SendSimulateGesture_001 end";
}
@@ -410,7 +410,7 @@ HWTEST_F(AccessibleAbilityChannelUnitTest,
ASSERT_TRUE(accountData);
EXPECT_FALSE(accountData->GetAccessibleAbilityConnection(abilityName));
sptr<AccessibleAbilityChannel> channel = new AccessibleAbilityChannel(accountData->GetAccountId(), abilityName);
EXPECT_EQ(channel->SendSimulateGesture(nullptr), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(channel->SendSimulateGesture(nullptr));
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_SendSimulateGesture_002 end";
}
@@ -424,7 +424,7 @@ HWTEST_F(AccessibleAbilityChannelUnitTest,
{
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_SetTargetBundleName_001 start";
std::vector<std::string> targetBundleNames;
EXPECT_EQ(channel_->SetTargetBundleName(targetBundleNames), RET_OK);
EXPECT_TRUE(channel_->SetTargetBundleName(targetBundleNames));
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_SetTargetBundleName_001 end";
}
@@ -444,7 +444,7 @@ HWTEST_F(AccessibleAbilityChannelUnitTest,
EXPECT_FALSE(accountData->GetAccessibleAbilityConnection(abilityName));
sptr<AccessibleAbilityChannel> channel = new AccessibleAbilityChannel(accountData->GetAccountId(), abilityName);
std::vector<std::string> targetBundleNames;
EXPECT_EQ(channel->SetTargetBundleName(targetBundleNames), RET_ERR_NO_CONNECTION);
EXPECT_FALSE(channel->SetTargetBundleName(targetBundleNames));
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_Unittest_SetTargetBundleName_002 end";
}
} // namespace Accessibility
@@ -161,12 +161,11 @@ HWTEST_F(AccessibleAbilityManagerServiceUnitTest, GetAbilityList_001, TestSize.L
HWTEST_F(AccessibleAbilityManagerServiceUnitTest, RegisterElementOperator_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibleAbilityManagerServiceUnitTest_Unittest_RegisterElementOperator_001 start";
auto &aams = Singleton<AccessibleAbilityManagerService>::GetInstance();
auto accountData = aams.GetCurrentAccountData();
auto accountData = Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
ASSERT_TRUE(accountData);
auto map = accountData->GetAsacConnections();
EXPECT_EQ(int(map.size()), 0);
EXPECT_EQ(RET_OK, aams.RegisterElementOperator(0, nullptr));
Singleton<AccessibleAbilityManagerService>::GetInstance().RegisterElementOperator(0, nullptr);
sleep(SLEEP_TIME_1);
GTEST_LOG_(INFO) << "RegisterElementOperator OK";
map = accountData->GetAsacConnections();
@@ -183,10 +182,9 @@ HWTEST_F(AccessibleAbilityManagerServiceUnitTest, RegisterElementOperator_001, T
HWTEST_F(AccessibleAbilityManagerServiceUnitTest, DeregisterElementOperator_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_DeregisterElementOperator_001 start";
auto &aams = Singleton<AccessibleAbilityManagerService>::GetInstance();
auto accountData = aams.GetCurrentAccountData();
auto accountData = Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
ASSERT_TRUE(accountData);
EXPECT_EQ(RET_OK, aams.DeregisterElementOperator(0));
Singleton<AccessibleAbilityManagerService>::GetInstance().DeregisterElementOperator(0);
sleep(SLEEP_TIME_1);
auto map = accountData->GetAsacConnections();
EXPECT_EQ(int(map.size()), 0);
@@ -530,18 +528,6 @@ HWTEST_F(AccessibleAbilityManagerServiceUnitTest, SetCaptionState_001, TestSize.
GTEST_LOG_(INFO) << "AccessibleAbilityManagerServiceUnitTest_SetCaptionState_001 end";
}
/**
* @tc.number: AccessibleAbilityManagerServiceUnitTest_GetEnabledState_001
* @tc.name: GetEnabledState
* @tc.desc: Test function GetEnabledState
*/
HWTEST_F(AccessibleAbilityManagerServiceUnitTest, GetEnabledState_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibleAbilityManagerServiceUnitTest_GetEnabledState_001 start";
EXPECT_TRUE(Singleton<AccessibleAbilityManagerService>::GetInstance().GetEnabledState());
GTEST_LOG_(INFO) << "AccessibleAbilityManagerServiceUnitTest_GetEnabledState_001 end";
}
/**
* @tc.number: AccessibleAbilityManagerServiceUnitTest_GetTouchGuideState_001
* @tc.name: GetTouchGuideState
@@ -684,8 +670,7 @@ HWTEST_F(AccessibleAbilityManagerServiceUnitTest, EnableAbility_001, TestSize.Le
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_EnableAbility_001 start";
std::string name = "test";
uint32_t capabilities = 1;
EXPECT_EQ(RET_ERR_NOT_INSTALLED,
Singleton<AccessibleAbilityManagerService>::GetInstance().EnableAbility(name, capabilities));
EXPECT_FALSE(Singleton<AccessibleAbilityManagerService>::GetInstance().EnableAbility(name, capabilities));
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_EnableAbility_001 end";
}
@@ -698,7 +683,7 @@ HWTEST_F(AccessibleAbilityManagerServiceUnitTest, DisableAbility_001, TestSize.L
{
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_DisableAbility_001 start";
std::string name = "test";
EXPECT_EQ(RET_ERR_NOT_ENABLED, Singleton<AccessibleAbilityManagerService>::GetInstance().DisableAbility(name));
EXPECT_FALSE(Singleton<AccessibleAbilityManagerService>::GetInstance().DisableAbility(name));
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_DisableAbility_001 end";
}
@@ -711,8 +696,7 @@ HWTEST_F(AccessibleAbilityManagerServiceUnitTest, GetEnabledAbilities_001, TestS
{
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_GetEnabledAbilities_001 start";
std::vector<std::string> enabledAbilities;
EXPECT_EQ(RET_OK,
Singleton<AccessibleAbilityManagerService>::GetInstance().GetEnabledAbilities(enabledAbilities));
EXPECT_TRUE(Singleton<AccessibleAbilityManagerService>::GetInstance().GetEnabledAbilities(enabledAbilities));
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_GetEnabledAbilities_001 end";
}
@@ -737,7 +721,7 @@ HWTEST_F(AccessibleAbilityManagerServiceUnitTest, EnableUITestAbility_001, TestS
HWTEST_F(AccessibleAbilityManagerServiceUnitTest, DisableUITestAbility_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_DisableUITestAbility_001 start";
EXPECT_EQ(RET_ERR_NO_CONNECTION, Singleton<AccessibleAbilityManagerService>::GetInstance().DisableUITestAbility());
EXPECT_FALSE(Singleton<AccessibleAbilityManagerService>::GetInstance().DisableUITestAbility());
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_DisableUITestAbility_001 end";
}
@@ -984,8 +968,7 @@ HWTEST_F(AccessibleAbilityManagerServiceUnitTest, EnableAbility_002, TestSize.Le
Singleton<AccessibleAbilityManagerService>::GetInstance().SwitchedUser(-1);
std::string name = "test";
uint32_t capabilities = 1;
EXPECT_EQ(RET_ERR_NULLPTR,
Singleton<AccessibleAbilityManagerService>::GetInstance().EnableAbility(name, capabilities));
EXPECT_FALSE(Singleton<AccessibleAbilityManagerService>::GetInstance().EnableAbility(name, capabilities));
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_EnableAbility_002 end";
}
@@ -999,8 +982,7 @@ HWTEST_F(AccessibleAbilityManagerServiceUnitTest, GetEnabledAbilities_002, TestS
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_GetEnabledAbilities_002 start";
Singleton<AccessibleAbilityManagerService>::GetInstance().SwitchedUser(-1);
std::vector<std::string> enabledAbilities;
EXPECT_EQ(RET_ERR_NULLPTR,
Singleton<AccessibleAbilityManagerService>::GetInstance().GetEnabledAbilities(enabledAbilities));
EXPECT_TRUE(Singleton<AccessibleAbilityManagerService>::GetInstance().GetEnabledAbilities(enabledAbilities));
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_GetEnabledAbilities_002 end";
}
@@ -1014,7 +996,7 @@ HWTEST_F(AccessibleAbilityManagerServiceUnitTest, DisableAbility_002, TestSize.L
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_DisableAbility_002 start";
Singleton<AccessibleAbilityManagerService>::GetInstance().SwitchedUser(-1);
std::string name = "test";
EXPECT_EQ(RET_ERR_NULLPTR, Singleton<AccessibleAbilityManagerService>::GetInstance().DisableAbility(name));
EXPECT_FALSE(Singleton<AccessibleAbilityManagerService>::GetInstance().DisableAbility(name));
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_DisableAbility_002 end";
}
@@ -1041,7 +1023,7 @@ HWTEST_F(AccessibleAbilityManagerServiceUnitTest, DisableUITestAbility_002, Test
{
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_DisableUITestAbility_002 start";
Singleton<AccessibleAbilityManagerService>::GetInstance().SwitchedUser(-1);
EXPECT_EQ(Singleton<AccessibleAbilityManagerService>::GetInstance().DisableUITestAbility(), RET_ERR_NULLPTR);
EXPECT_FALSE(Singleton<AccessibleAbilityManagerService>::GetInstance().DisableUITestAbility());
GTEST_LOG_(INFO) << "Accessible_Ability_Manager_ServiceUnittest_DisableUITestAbility_002 end";
}
@@ -54,10 +54,9 @@ int MockAccessibleAbilityManagerServiceStub::OnRemoteRequest(
return 0;
}
RetError MockAccessibleAbilityManagerServiceStub::SendEvent(const AccessibilityEventInfo &uiEvent)
void MockAccessibleAbilityManagerServiceStub::SendEvent(const AccessibilityEventInfo &uiEvent)
{
(void)uiEvent;
return RET_OK;
}
RetError MockAccessibleAbilityManagerServiceStub::SetCaptionProperty(
@@ -80,27 +79,25 @@ uint32_t MockAccessibleAbilityManagerServiceStub::RegisterStateObserver(
return 0;
}
RetError MockAccessibleAbilityManagerServiceStub::GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
bool MockAccessibleAbilityManagerServiceStub::GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
std::vector<AccessibilityAbilityInfo> &infos)
{
(void)abilityTypes;
(void)stateType;
(void)infos;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityManagerServiceStub::RegisterElementOperator(
void MockAccessibleAbilityManagerServiceStub::RegisterElementOperator(
int32_t windowId, const sptr<IAccessibilityElementOperator> &operation)
{
(void)windowId;
(void)operation;
return RET_OK;
}
RetError MockAccessibleAbilityManagerServiceStub::DeregisterElementOperator(const int32_t windowId)
void MockAccessibleAbilityManagerServiceStub::DeregisterElementOperator(const int32_t windowId)
{
(void)windowId;
return RET_OK;
}
RetError MockAccessibleAbilityManagerServiceStub::GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption)
@@ -142,7 +139,7 @@ bool MockAccessibleAbilityManagerServiceStub::GetKeyEventObserverState()
return true;
}
RetError MockAccessibleAbilityManagerServiceStub::EnableAbility(const std::string &name, const uint32_t capabilities)
bool MockAccessibleAbilityManagerServiceStub::EnableAbility(const std::string &name, const uint32_t capabilities)
{
(void)name;
(void)capabilities;
@@ -151,19 +148,19 @@ RetError MockAccessibleAbilityManagerServiceStub::EnableAbility(const std::strin
abilityObserver_->OnAccessibilityEnableAbilityListsChanged();
}), "NotifyEnableAbility");
}
return RET_OK;
return true;
}
RetError MockAccessibleAbilityManagerServiceStub::GetEnabledAbilities(std::vector<std::string> &enabledAbilities)
bool MockAccessibleAbilityManagerServiceStub::GetEnabledAbilities(std::vector<std::string> &enabledAbilities)
{
(void)enabledAbilities;
return RET_OK;
return true;
}
RetError MockAccessibleAbilityManagerServiceStub::DisableAbility(const std::string &name)
bool MockAccessibleAbilityManagerServiceStub::DisableAbility(const std::string &name)
{
(void)name;
return RET_OK;
return true;
}
int32_t MockAccessibleAbilityManagerServiceStub::GetActiveWindow()
@@ -177,9 +174,9 @@ RetError MockAccessibleAbilityManagerServiceStub::EnableUITestAbility(const sptr
return RET_ERR_IPC_FAILED;
}
RetError MockAccessibleAbilityManagerServiceStub::DisableUITestAbility()
bool MockAccessibleAbilityManagerServiceStub::DisableUITestAbility()
{
return RET_OK;
return true;
}
RetError MockAccessibleAbilityManagerServiceStub::SetScreenMagnificationState(const bool state)
@@ -34,7 +34,7 @@ public:
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
RetError SendEvent(const AccessibilityEventInfo &uiEvent) override;
void SendEvent(const AccessibilityEventInfo &uiEvent) override;
uint32_t RegisterStateObserver(const sptr<IAccessibleAbilityManagerStateObserver> &callback) override;
@@ -43,13 +43,13 @@ public:
void RegisterEnableAbilityListsObserver(
const sptr<IAccessibilityEnableAbilityListsObserver> &observer) override;
RetError GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
bool GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
std::vector<AccessibilityAbilityInfo> &infos) override;
RetError RegisterElementOperator(const int32_t windowId,
void RegisterElementOperator(const int32_t windowId,
const sptr<IAccessibilityElementOperator> &operation) override;
RetError DeregisterElementOperator(const int32_t windowId) override;
void DeregisterElementOperator(const int32_t windowId) override;
RetError GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption) override;
RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption) override;
@@ -61,14 +61,14 @@ public:
bool GetGestureState() override;
bool GetKeyEventObserverState() override;
RetError EnableAbility(const std::string &name, const uint32_t capabilities) override;
RetError GetEnabledAbilities(std::vector<std::string> &enabledAbilities) override;
bool EnableAbility(const std::string &name, const uint32_t capabilities) override;
bool GetEnabledAbilities(std::vector<std::string> &enabledAbilities) override;
RetError DisableAbility(const std::string &name) override;
bool DisableAbility(const std::string &name) override;
int32_t GetActiveWindow() override;
RetError EnableUITestAbility(const sptr<IRemoteObject> &obj) override;
RetError DisableUITestAbility() override;
bool DisableUITestAbility() override;
RetError SetScreenMagnificationState(const bool state) override;
RetError SetShortKeyState(const bool state) override;
@@ -15,7 +15,6 @@
#include <mutex>
#include "mock_input_manager.h"
#include "hilog_wrapper.h"
namespace OHOS {
namespace MMI {
@@ -54,39 +53,33 @@ int32_t MockInputManager::GetTouchActionOfTargetIndex(int32_t index)
void MockInputManager::ClearInputEventConsumer()
{
HILOG_DEBUG();
mockInputEventConsumer = nullptr;
}
std::shared_ptr<IInputEventConsumer> MockInputManager::GetInputEventConsumer()
{
HILOG_DEBUG();
return mockInputEventConsumer;
}
InputManager *InputManager::instance_ = new(std::nothrow) InputManager();
InputManager *InputManager::GetInstance()
{
HILOG_DEBUG();
return instance_;
}
void InputManager::MoveMouse(int32_t offsetX, int32_t offsetY)
{
HILOG_DEBUG();
(void)offsetX;
(void)offsetY;
}
void InputManager::SimulateInputEvent(std::shared_ptr<KeyEvent> keyEvent)
{
HILOG_DEBUG();
mockKeyCode = keyEvent->GetKeyCode();
}
void InputManager::SimulateInputEvent(std::shared_ptr<PointerEvent> pointerEvent)
{
HILOG_DEBUG();
std::lock_guard<std::mutex> lock(g_mtx);
int32_t touchAction = pointerEvent->GetPointerAction();
mockTouchActions.push_back(touchAction);
@@ -94,27 +87,22 @@ void InputManager::SimulateInputEvent(std::shared_ptr<PointerEvent> pointerEvent
int32_t InputManager::AddInterceptor(std::shared_ptr<IInputEventConsumer> interceptorId)
{
HILOG_DEBUG();
mockInputEventConsumer = interceptorId;
return 0;
}
int32_t InputManager::AddInterceptor(std::function<void(std::shared_ptr<KeyEvent>)> interceptor)
{
HILOG_DEBUG();
mockKeyEventCallback = interceptor;
return 0;
}
std::function<void(std::shared_ptr<KeyEvent>)> MockInputManager::GetKeyEventInterceptor()
{
HILOG_DEBUG();
return mockKeyEventCallback;
}
void InputManager::RemoveInterceptor(int32_t interceptorId)
{
HILOG_DEBUG();
}
{}
} // namespace MMI
} // namespace OHOS
@@ -79,21 +79,17 @@ public:
};
void AamsKeyEventFilterTest::SetUpTestCase(void)
{}
void AamsKeyEventFilterTest::TearDownTestCase(void)
{}
void AamsKeyEventFilterTest::SetUp()
{
GTEST_LOG_(INFO) << "AamsKeyEventFilterTest ModuleTest SetUp";
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
AccessibilityCommonHelper::GetInstance().WaitForServicePublish();
Singleton<AccessibleAbilityManagerService>::GetInstance().SwitchedUser(AccessibilityHelper::accountId_);
GTEST_LOG_(INFO) << "AccessibleAbilityManagerService is published";
}
void AamsKeyEventFilterTest::TearDownTestCase(void)
{
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStop();
}
void AamsKeyEventFilterTest::SetUp()
{
GTEST_LOG_(INFO) << "AamsKeyEventFilterTest ModuleTest SetUp";
// Add an ability connection client
AccessibilityAbilityInitParams initParams;
@@ -53,30 +53,32 @@ public:
void SetUp() override;
void TearDown() override;
sptr<AccessibilityInputInterceptor> inputInterceptor_ = nullptr;
sptr<AccessibleAbilityChannel> aacs_ = nullptr;
sptr<AccessibleAbilityChannel> aastub_ = nullptr;
void WritefileAll(const char* fname, const char* data);
void AddAccessibilityWindowConnection();
};
void AamsInjectorTest::SetUpTestCase()
{
GTEST_LOG_(INFO) << "AamsInjectorTest SetUpTestCase";
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
AccessibilityCommonHelper::GetInstance().WaitForServicePublish();
Singleton<AccessibleAbilityManagerService>::GetInstance().SwitchedUser(AccessibilityHelper::accountId_);
GTEST_LOG_(INFO) << "AccessibleAbilityManagerService is published";
}
void AamsInjectorTest::TearDownTestCase()
{
GTEST_LOG_(INFO) << "AamsInjectorTest TearDownTestCase";
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStop();
}
void AamsInjectorTest::SetUp()
{
GTEST_LOG_(INFO) << "AamsInjectorTest SetUp";
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
AccessibilityCommonHelper::GetInstance().WaitForServicePublish();
Singleton<AccessibleAbilityManagerService>::GetInstance().SwitchedUser(AccessibilityHelper::accountId_);
GTEST_LOG_(INFO) << "AccessibleAbilityManagerService is published";
// add an ability connection client
AccessibilityAbilityInitParams initParams;
std::shared_ptr<AccessibilityAbilityInfo> abilityInfo = std::make_shared<AccessibilityAbilityInfo>(initParams);
@@ -106,24 +108,27 @@ void AamsInjectorTest::SetUp()
void AamsInjectorTest::TearDown()
{
GTEST_LOG_(INFO) << "TouchEventInjectorTest TearDown";
inputInterceptor_ = nullptr;
aacs_ = nullptr;
aastub_ = nullptr;
Singleton<AccessibleAbilityManagerService>::GetInstance().DeregisterElementOperator(0);
bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
auto &aams = Singleton<AccessibleAbilityManagerService>::GetInstance();
if (aams.GetMainRunner()->GetEventQueue()->IsIdle()) {
return true;
} else {
return false;
}
}), 1);
if (!ret) {
GTEST_LOG_(INFO) << "AamsAccessibleAbilityChannelTest TearDown EventQueue is not empty";
}
sleep(SLEEP_TIME_2);
MMI::MockInputManager::ClearTouchActions();
AccessibilityHelper::GetInstance().GetEventType().clear();
}
void AamsInjectorTest::WritefileAll(const char* fname, const char* data)
{
FILE* fp;
if (!(fp = fopen(fname, "w"))) {
printf("open file %s fail \n", fname);
return;
}
(void)fprintf(fp, "%s", data);
(void)fclose(fp);
}
void AamsInjectorTest::AddAccessibilityWindowConnection()
{
GTEST_LOG_(INFO) << "AamsInjectorTest AddAccessibilityWindowConnection";
@@ -146,48 +151,38 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_001,
{
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_001 start";
AccessibilityHelper::GetInstance().GetEventType().clear();
AccessibilityHelper::GetInstance().GetEventType() = {};
MMI::MockInputManager::ClearTouchActions();
AccessibilityGesturePosition point {500.0f, 500.0f};
std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
gesturePath->AddPosition(point);
gesturePath->SetDurationTime(100);
aacs_->SendSimulateGesture(gesturePath);
bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) {
return true;
} else {
return false;
}
}), SLEEP_TIME_2);
EXPECT_TRUE(ret);
EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0));
sleep(3);
ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
if (EventType::TYPE_TOUCH_END == AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3)) {
return true;
} else {
return false;
}
}), SLEEP_TIME_2);
EXPECT_TRUE(ret);
EXPECT_EQ(EventType::TYPE_TOUCH_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0));
EXPECT_EQ(EventType::TYPE_TOUCH_GUIDE_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1));
EXPECT_EQ(EventType::TYPE_TOUCH_GUIDE_END, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2));
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE;
auto mtTouchAction = MMI::MockInputManager::GetTouchActions();
EXPECT_EQ(mtTouchAction[0], expectValue);
EXPECT_EQ(mtTouchAction[1], expectValue);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[0], EventType::TYPE_TOUCH_BEGIN);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[1], EventType::TYPE_TOUCH_GUIDE_BEGIN);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[2], EventType::TYPE_TOUCH_GUIDE_END);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[3], EventType::TYPE_TOUCH_END);
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_001 end";
}
/**
* @tc.number: TouchEventInjector002
* @tc.number: TouchEventInjector004
* @tc.name:TouchEventInjector
* @tc.desc: Check that the injected LEFT gesture can be recognized in touchGuide.
*/
HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_002, TestSize.Level1)
HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_004, TestSize.Level1)
{
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_002 start";
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_004 start";
AccessibilityHelper::GetInstance().GetEventType().clear();
AccessibilityHelper::GetInstance().GetEventType() = {};
MMI::MockInputManager::ClearTouchActions();
AccessibilityGesturePosition point1 {2500.0f, 2500.0f};
AccessibilityGesturePosition point2 {1000.0f, 2500.0f};
@@ -199,38 +194,33 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_002,
gesturePath->SetDurationTime(200);
aacs_->SendSimulateGesture(gesturePath);
bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) {
return true;
} else {
return false;
}
}), SLEEP_TIME_2);
EXPECT_TRUE(ret);
EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0));
sleep(3);
ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
if (static_cast<int32_t>(GestureType::GESTURE_SWIPE_LEFT) ==
AccessibilityHelper::GetInstance().GetGestureId()) {
return true;
} else {
return false;
}
}), SLEEP_TIME_2);
EXPECT_TRUE(ret);
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_002 end";
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE;
auto mtTouchAction = MMI::MockInputManager::GetTouchActions();
EXPECT_EQ(mtTouchAction[0], expectValue);
EXPECT_EQ(mtTouchAction[1], expectValue);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[0], EventType::TYPE_TOUCH_BEGIN);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[1], EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[2], EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[3], EventType::TYPE_TOUCH_END);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast<int32_t>(GestureType::GESTURE_SWIPE_LEFT));
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_004 end";
}
/**
* @tc.number: TouchEventInjector003
* @tc.number: TouchEventInjector005
* @tc.name:TouchEventInjector
* @tc.desc: Check that the injected RIGHT_THEN_DOWN gesture can be recognized in touchGuide.
*/
HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_003, TestSize.Level1)
HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_005, TestSize.Level1)
{
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_003 start";
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_005 start";
AccessibilityHelper::GetInstance().GetEventType().clear();
AccessibilityHelper::GetInstance().GetEventType() = {};
MMI::MockInputManager::ClearTouchActions();
AccessibilityGesturePosition point1 {2500.0f, 2500.0f};
AccessibilityGesturePosition point2 {3500.0f, 2500.0f};
@@ -244,40 +234,34 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_003,
gesturePath->SetDurationTime(300);
aacs_->SendSimulateGesture(gesturePath);
bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) {
return true;
} else {
return false;
}
}), SLEEP_TIME_2);
EXPECT_TRUE(ret);
EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0));
EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1));
sleep(3);
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE;
auto mtTouchAction = MMI::MockInputManager::GetTouchActions();
EXPECT_EQ(mtTouchAction[0], expectValue);
EXPECT_EQ(mtTouchAction[1], expectValue);
EXPECT_EQ(mtTouchAction[2], expectValue);
ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
if (static_cast<int32_t>(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP) ==
AccessibilityHelper::GetInstance().GetGestureId()) {
return true;
} else {
return false;
}
}), SLEEP_TIME_2);
EXPECT_TRUE(ret);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[0], EventType::TYPE_TOUCH_BEGIN);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[1], EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[2], EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[3], EventType::TYPE_TOUCH_END);
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_003 end";
EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
static_cast<int32_t>(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP));
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_005 end";
}
/**
* @tc.number: TouchEventInjector004
* @tc.number: TouchEventInjector006
* @tc.name:TouchEventInjector
* @tc.desc: Check that the injected LEFT_THEN_DOWN gesture can be recognized in touchGuide.
*/
HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_004, TestSize.Level1)
HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_006, TestSize.Level1)
{
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_004 start";
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_006 start";
AccessibilityHelper::GetInstance().GetEventType().clear();
AccessibilityHelper::GetInstance().GetEventType() = {};
MMI::MockInputManager::ClearTouchActions();
AccessibilityGesturePosition point1 {2500.0f, 2500.0f};
AccessibilityGesturePosition point2 {1500.0f, 2500.0f};
@@ -291,40 +275,35 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_004,
gesturePath->SetDurationTime(300);
aacs_->SendSimulateGesture(gesturePath);
bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) {
return true;
} else {
return false;
}
}), SLEEP_TIME_2);
EXPECT_TRUE(ret);
EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0));
EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1));
sleep(3);
ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
if (static_cast<int32_t>(GestureType::GESTURE_SWIPE_LEFT_THEN_UP) ==
AccessibilityHelper::GetInstance().GetGestureId()) {
return true;
} else {
return false;
}
}), SLEEP_TIME_2);
EXPECT_TRUE(ret);
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE;
auto mtTouchAction = MMI::MockInputManager::GetTouchActions();
EXPECT_EQ(mtTouchAction[0], expectValue);
EXPECT_EQ(mtTouchAction[1], expectValue);
EXPECT_EQ(mtTouchAction[2], expectValue);
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_004 end";
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[0], EventType::TYPE_TOUCH_BEGIN);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[1], EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[2], EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[3], EventType::TYPE_TOUCH_END);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
static_cast<int32_t>(GestureType::GESTURE_SWIPE_LEFT_THEN_UP));
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_006 end";
}
/**
* @tc.number: TouchEventInjector005
* @tc.number: TouchEventInjector007
* @tc.name:TouchEventInjector
* @tc.desc: Check that the injected UP_THEN_LEFT gesture can be recognized in touchGuide.
*/
HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_005, TestSize.Level1)
HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_007, TestSize.Level1)
{
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_005 start";
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_007 start";
AccessibilityHelper::GetInstance().GetEventType().clear();
AccessibilityHelper::GetInstance().GetEventType() = {};
MMI::MockInputManager::ClearTouchActions();
AccessibilityGesturePosition point1 {2500.0f, 2500.0f};
AccessibilityGesturePosition point2 {2500.0f, 3500.0f};
@@ -338,40 +317,35 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_005,
gesturePath->SetDurationTime(300);
aacs_->SendSimulateGesture(gesturePath);
bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) {
return true;
} else {
return false;
}
}), SLEEP_TIME_2);
EXPECT_TRUE(ret);
EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0));
EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1));
sleep(3);
ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
if (static_cast<int32_t>(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT) ==
AccessibilityHelper::GetInstance().GetGestureId()) {
return true;
} else {
return false;
}
}), SLEEP_TIME_2);
EXPECT_TRUE(ret);
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE;
auto mtTouchAction = MMI::MockInputManager::GetTouchActions();
EXPECT_EQ(mtTouchAction[0], expectValue);
EXPECT_EQ(mtTouchAction[1], expectValue);
EXPECT_EQ(mtTouchAction[2], expectValue);
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_005 end";
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[0], EventType::TYPE_TOUCH_BEGIN);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[1], EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[2], EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[3], EventType::TYPE_TOUCH_END);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
static_cast<int32_t>(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT));
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_007 end";
}
/**
* @tc.number: TouchEventInjector006
* @tc.number: TouchEventInjector008
* @tc.name:TouchEventInjector
* @tc.desc: Check that the injected UP_THEN_RIGHT gesture can be recognized in touchGuide.
*/
HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_006, TestSize.Level1)
HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_008, TestSize.Level1)
{
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_006 start";
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_008 start";
AccessibilityHelper::GetInstance().GetEventType().clear();
AccessibilityHelper::GetInstance().GetEventType() = {};
MMI::MockInputManager::ClearTouchActions();
AccessibilityGesturePosition point1 {2500.0f, 2500.0f};
AccessibilityGesturePosition point2 {2500.0f, 3500.0f};
@@ -385,28 +359,23 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_TouchEventInjector_006,
gesturePath->SetDurationTime(300);
aacs_->SendSimulateGesture(gesturePath);
bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) {
return true;
} else {
return false;
}
}), SLEEP_TIME_2);
EXPECT_TRUE(ret);
EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0));
EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1));
sleep(3);
ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
if (static_cast<int32_t>(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT) ==
AccessibilityHelper::GetInstance().GetGestureId()) {
return true;
} else {
return false;
}
}), SLEEP_TIME_2);
EXPECT_TRUE(ret);
int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE;
auto mtTouchAction = MMI::MockInputManager::GetTouchActions();
EXPECT_EQ(mtTouchAction[0], expectValue);
EXPECT_EQ(mtTouchAction[1], expectValue);
EXPECT_EQ(mtTouchAction[2], expectValue);
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_006 end";
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[0], EventType::TYPE_TOUCH_BEGIN);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[1], EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[2], EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventType()[3], EventType::TYPE_TOUCH_END);
EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
static_cast<int32_t>(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT));
GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_TouchEventInjector_008 end";
}
} // namespace Accessibility
} // namespace OHOS
@@ -79,22 +79,22 @@ void AamsTouchGuideTest::WritefileAll(const char* fname, const char* data)
void AamsTouchGuideTest::SetUpTestCase()
{
GTEST_LOG_(INFO) << "AamsTouchGuideTest SetUpTestCase";
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
AccessibilityCommonHelper::GetInstance().WaitForServicePublish();
Singleton<AccessibleAbilityManagerService>::GetInstance().SwitchedUser(AccessibilityHelper::accountId_);
GTEST_LOG_(INFO) << "AccessibleAbilityManagerService is published";
}
void AamsTouchGuideTest::TearDownTestCase()
{
GTEST_LOG_(INFO) << "AamsTouchGuideTest TearDownTestCase";
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStop();
}
void AamsTouchGuideTest::SetUp()
{
GTEST_LOG_(INFO) << "AamsTouchGuideTest SetUp";
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
AccessibilityCommonHelper::GetInstance().WaitForServicePublish();
Singleton<AccessibleAbilityManagerService>::GetInstance().SwitchedUser(AccessibilityHelper::accountId_);
GTEST_LOG_(INFO) << "AccessibleAbilityManagerService is published";
interceptorId_ = std::make_shared<AccessibilityInputEventConsumer>();
MMI::InputManager::GetInstance()->AddInterceptor(interceptorId_);
@@ -56,6 +56,17 @@ public:
void AamsAccessibleAbilityChannelTest::SetUpTestCase()
{
GTEST_LOG_(INFO) << "AamsAccessibleAbilityChannelTest SetUpTestCase";
}
void AamsAccessibleAbilityChannelTest::TearDownTestCase()
{
GTEST_LOG_(INFO) << "AamsAccessibleAbilityChannelTest TearDownTestCase";
}
void AamsAccessibleAbilityChannelTest::SetUp()
{
GTEST_LOG_(INFO) << "AamsAccessibleAbilityChannelTest SetUp";
// Start AAMS
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
AccessibilityCommonHelper::GetInstance().WaitForServicePublish();
@@ -63,23 +74,10 @@ void AamsAccessibleAbilityChannelTest::SetUpTestCase()
GTEST_LOG_(INFO) << "AccessibleAbilityManagerService is published";
}
void AamsAccessibleAbilityChannelTest::TearDownTestCase()
{
GTEST_LOG_(INFO) << "AamsAccessibleAbilityChannelTest TearDownTestCase";
// Stop AAMS
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStop();
}
void AamsAccessibleAbilityChannelTest::SetUp()
{
GTEST_LOG_(INFO) << "AamsAccessibleAbilityChannelTest SetUp";
}
void AamsAccessibleAbilityChannelTest::TearDown()
{
GTEST_LOG_(INFO) << "AamsAccessibleAbilityChannelTest TearDown";
Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData()->OnAccountSwitched();
// Deregister ElementOperator
Singleton<AccessibleAbilityManagerService>::GetInstance().DeregisterElementOperator(0);
bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool {
@@ -93,6 +91,8 @@ void AamsAccessibleAbilityChannelTest::TearDown()
if (!ret) {
GTEST_LOG_(INFO) << "AamsAccessibleAbilityChannelTest TearDown EventQueue is not empty";
}
// Stop AAMS
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStop();
accountData_ = nullptr;
aastub_ = nullptr;
elementName_ = nullptr;
@@ -125,12 +125,10 @@ void AamsAccessibleAbilityChannelTest::AddAccessibleAbilityConnection(bool isNoC
AccessibilityAbilityInitParams initParams;
std::shared_ptr<AccessibilityAbilityInfo> abilityInfo = std::make_shared<AccessibilityAbilityInfo>(initParams);
abilityInfo->SetAccessibilityAbilityType(AccessibilityAbilityTypes::ACCESSIBILITY_ABILITY_TYPE_ALL);
uint32_t capabilities = 0;
if (!isNoCapability) {
capabilities = Capability::CAPABILITY_RETRIEVE | Capability::CAPABILITY_TOUCH_GUIDE |
Capability::CAPABILITY_GESTURE | Capability::CAPABILITY_KEY_EVENT_OBSERVER;
abilityInfo->SetCapabilityValues(Capability::CAPABILITY_RETRIEVE | Capability::CAPABILITY_TOUCH_GUIDE |
Capability::CAPABILITY_GESTURE | Capability::CAPABILITY_KEY_EVENT_OBSERVER);
}
abilityInfo->SetCapabilityValues(capabilities);
accountData_ = Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
accountData_->Init();
AAConnection_ = new AccessibleAbilityConnection(accountData_->GetAccountId(), 0, *abilityInfo);
@@ -180,14 +178,16 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_S
AddAccessibilityWindowConnection();
AddAccessibleAbilityConnection();
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
RetError result =
bool result =
AccessibilityHelper::GetInstance().GetTestStub()->SearchElementInfoByAccessibilityId(0, 0, 0, nullptr, 0);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(0, proxy_->testChannelElementId_);
EXPECT_EQ(0, proxy_->testChannelRequestId_);
EXPECT_EQ(0, proxy_->testChannelMode_);
EXPECT_EQ(result, RET_OK);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_SearchElementInfoByAccessibilityId_001 end";
}
@@ -206,14 +206,16 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_S
AddAccessibilityWindowConnection();
AddAccessibleAbilityConnection();
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
RetError result = AccessibilityHelper::GetInstance().GetTestStub()->SearchElementInfoByAccessibilityId(
bool result = AccessibilityHelper::GetInstance().GetTestStub()->SearchElementInfoByAccessibilityId(
ACTIVE_WINDOW_ID, 0, 0, nullptr, 0);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(-1, proxy_->testChannelElementId_);
EXPECT_EQ(-1, proxy_->testChannelRequestId_);
EXPECT_EQ(-1, proxy_->testChannelMode_);
EXPECT_EQ(result, RET_ERR_NO_WINDOW_CONNECTION);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_SearchElementInfoByAccessibilityId_002 end";
}
@@ -232,14 +234,15 @@ HWTEST_F(
AddAccessibleAbilityConnection();
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
string text = "text";
RetError result =
AccessibilityHelper::GetInstance().GetTestStub()->SearchElementInfosByText(0, 0, text, 0, nullptr);
bool result = AccessibilityHelper::GetInstance().GetTestStub()->SearchElementInfosByText(0, 0, text, 0, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(0, proxy_->testChannelElementId_);
EXPECT_EQ(0, proxy_->testChannelRequestId_);
EXPECT_EQ(text, proxy_->testText_);
EXPECT_EQ(result, RET_OK);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_SearchElementInfosByText_001 end";
}
@@ -258,14 +261,16 @@ HWTEST_F(
AddAccessibleAbilityConnection();
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
string text = "text";
RetError result = AccessibilityHelper::GetInstance().GetTestStub()->SearchElementInfosByText(
bool result = AccessibilityHelper::GetInstance().GetTestStub()->SearchElementInfosByText(
ACTIVE_WINDOW_ID, 0, text, 0, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(-1, proxy_->testChannelElementId_);
EXPECT_EQ(-1, proxy_->testChannelRequestId_);
EXPECT_NE(text, proxy_->testText_);
EXPECT_EQ(result, RET_ERR_NO_WINDOW_CONNECTION);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_SearchElementInfosByText_002 end";
}
@@ -284,14 +289,15 @@ HWTEST_F(
AddAccessibleAbilityConnection();
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
int32_t focusType = OHOS::Accessibility::FOCUS_TYPE_INPUT;
RetError result =
AccessibilityHelper::GetInstance().GetTestStub()->FindFocusedElementInfo(0, 0, focusType, 0, nullptr);
bool result = AccessibilityHelper::GetInstance().GetTestStub()->FindFocusedElementInfo(0, 0, focusType, 0, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(0, proxy_->testChannelElementId_);
EXPECT_EQ(0, proxy_->testChannelRequestId_);
EXPECT_EQ(focusType, proxy_->testFocusType_);
EXPECT_EQ(result, RET_OK);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_FindFocusedElementInfo_001 end";
}
@@ -310,14 +316,16 @@ HWTEST_F(
AddAccessibleAbilityConnection();
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
int32_t focusType = OHOS::Accessibility::FOCUS_TYPE_INPUT;
RetError result = AccessibilityHelper::GetInstance().GetTestStub()->FindFocusedElementInfo(
bool result = AccessibilityHelper::GetInstance().GetTestStub()->FindFocusedElementInfo(
ACTIVE_WINDOW_ID, 0, focusType, 0, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(-1, proxy_->testChannelElementId_);
EXPECT_EQ(-1, proxy_->testChannelRequestId_);
EXPECT_NE(focusType, proxy_->testFocusType_);
EXPECT_EQ(result, RET_ERR_NO_WINDOW_CONNECTION);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_FindFocusedElementInfo_002 end";
}
@@ -336,14 +344,15 @@ HWTEST_F(
AddAccessibleAbilityConnection();
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
int32_t focusType = OHOS::Accessibility::FOCUS_TYPE_ACCESSIBILITY;
RetError result =
AccessibilityHelper::GetInstance().GetTestStub()->FindFocusedElementInfo(0, 0, focusType, 1, nullptr);
bool result = AccessibilityHelper::GetInstance().GetTestStub()->FindFocusedElementInfo(0, 0, focusType, 1, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(0, proxy_->testChannelElementId_);
EXPECT_EQ(1, proxy_->testChannelRequestId_);
EXPECT_EQ(focusType, proxy_->testFocusType_);
EXPECT_EQ(result, RET_OK);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_FindFocusedElementInfo_003 end";
}
@@ -361,13 +370,15 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_F
AddAccessibleAbilityConnection();
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
int32_t direction = FocusMoveDirection::UP;
RetError result = AccessibilityHelper::GetInstance().GetTestStub()->FocusMoveSearch(0, 0, direction, 0, nullptr);
bool result = AccessibilityHelper::GetInstance().GetTestStub()->FocusMoveSearch(0, 0, direction, 0, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(0, proxy_->testChannelElementId_);
EXPECT_EQ(0, proxy_->testChannelRequestId_);
EXPECT_EQ(direction, proxy_->testDirection_);
EXPECT_EQ(result, RET_OK);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_FocusMoveSearch_001 end";
}
@@ -385,14 +396,16 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_F
AddAccessibleAbilityConnection();
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
int32_t direction = FocusMoveDirection::UP;
RetError result =
bool result =
AccessibilityHelper::GetInstance().GetTestStub()->FocusMoveSearch(ACTIVE_WINDOW_ID, 0, direction, 0, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(-1, proxy_->testChannelElementId_);
EXPECT_EQ(-1, proxy_->testChannelRequestId_);
EXPECT_NE(direction, proxy_->testDirection_);
EXPECT_EQ(result, RET_ERR_NO_WINDOW_CONNECTION);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_FocusMoveSearch_002 end";
}
@@ -412,15 +425,16 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_E
actionArguments.insert(std::make_pair("invalid", "invalid"));
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
RetError result =
AccessibilityHelper::GetInstance().GetTestStub()->ExecuteAction(0, 4, 3, actionArguments, 0, nullptr);
bool result = AccessibilityHelper::GetInstance().GetTestStub()->ExecuteAction(0, 4, 3, actionArguments, 0, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(4, proxy_->testChannelElementId_);
EXPECT_EQ(0, proxy_->testChannelRequestId_);
EXPECT_EQ(3, proxy_->testAction_);
EXPECT_EQ(actionArguments, proxy_->testActionArguments_);
EXPECT_EQ(result, RET_OK);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_ExecuteAction_001 end";
}
@@ -440,14 +454,16 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_E
actionArguments.insert(std::make_pair("invalid", "invalid"));
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
RetError result = AccessibilityHelper::GetInstance().GetTestStub()->ExecuteAction(
bool result = AccessibilityHelper::GetInstance().GetTestStub()->ExecuteAction(
ACTIVE_WINDOW_ID, 4, 3, actionArguments, 0, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(-1, proxy_->testChannelElementId_);
EXPECT_EQ(-1, proxy_->testChannelRequestId_);
EXPECT_EQ(0, proxy_->testAction_);
EXPECT_EQ(result, RET_ERR_NO_WINDOW_CONNECTION);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_ExecuteAction_002 end";
}
@@ -469,6 +485,8 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_G
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(0, windows.size());
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_GetWindows_002 end";
}
@@ -491,8 +509,10 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_S
gesturePath->SetDurationTime(100);
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
RetError result = AccessibilityHelper::GetInstance().GetTestStub()->SendSimulateGesture(gesturePath);
EXPECT_EQ(result, RET_OK);
AccessibilityHelper::GetInstance().GetTestStub()->SendSimulateGesture(gesturePath);
sleep(2);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_SendSimulateGesture_001 end";
}
@@ -512,14 +532,16 @@ HWTEST_F(AamsAccessibleAbilityChannelTest,
AddAccessibilityWindowConnection();
AddAccessibleAbilityConnection(true);
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
RetError result =
bool result =
AccessibilityHelper::GetInstance().GetTestStub()->SearchElementInfoByAccessibilityId(0, 0, 0, nullptr, 0);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(-1, proxy_->testChannelElementId_);
EXPECT_EQ(-1, proxy_->testChannelRequestId_);
EXPECT_EQ(-1, proxy_->testChannelMode_);
EXPECT_EQ(result, RET_ERR_NO_CAPABILITY);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_SearchElementInfoByAccessibilityId_NoCapability_001 end";
}
@@ -538,14 +560,15 @@ HWTEST_F(AamsAccessibleAbilityChannelTest,
AddAccessibleAbilityConnection(true);
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
string text = "text";
RetError result =
AccessibilityHelper::GetInstance().GetTestStub()->SearchElementInfosByText(0, 0, text, 0, nullptr);
bool result = AccessibilityHelper::GetInstance().GetTestStub()->SearchElementInfosByText(0, 0, text, 0, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(-1, proxy_->testChannelElementId_);
EXPECT_EQ(-1, proxy_->testChannelRequestId_);
EXPECT_NE(text, proxy_->testText_);
EXPECT_EQ(result, RET_ERR_NO_CAPABILITY);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_SearchElementInfosByText_NoCapability_001 end";
}
@@ -564,14 +587,15 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_F
AddAccessibleAbilityConnection(true);
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
int32_t focusType = OHOS::Accessibility::FOCUS_TYPE_INPUT;
RetError result =
AccessibilityHelper::GetInstance().GetTestStub()->FindFocusedElementInfo(0, 0, focusType, 0, nullptr);
bool result = AccessibilityHelper::GetInstance().GetTestStub()->FindFocusedElementInfo(0, 0, focusType, 0, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(-1, proxy_->testChannelElementId_);
EXPECT_EQ(-1, proxy_->testChannelRequestId_);
EXPECT_NE(focusType, proxy_->testFocusType_);
EXPECT_EQ(result, RET_ERR_NO_CAPABILITY);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_FindFocusedElementInfo_NoCapability_001 end";
}
@@ -590,13 +614,15 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_F
AddAccessibleAbilityConnection(true);
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
int32_t direction = FocusMoveDirection::UP;
RetError result = AccessibilityHelper::GetInstance().GetTestStub()->FocusMoveSearch(0, 0, direction, 0, nullptr);
bool result = AccessibilityHelper::GetInstance().GetTestStub()->FocusMoveSearch(0, 0, direction, 0, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(-1, proxy_->testChannelElementId_);
EXPECT_EQ(-1, proxy_->testChannelRequestId_);
EXPECT_NE(direction, proxy_->testDirection_);
EXPECT_EQ(result, RET_ERR_NO_CAPABILITY);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_FocusMoveSearch_NoCapability_001 end";
}
@@ -617,15 +643,16 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_E
actionArguments.insert(std::make_pair("invalid", "invalid"));
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
RetError result =
AccessibilityHelper::GetInstance().GetTestStub()->ExecuteAction(0, 4, 3, actionArguments, 0, nullptr);
bool result = AccessibilityHelper::GetInstance().GetTestStub()->ExecuteAction(0, 4, 3, actionArguments, 0, nullptr);
sleep(2);
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(-1, proxy_->testChannelElementId_);
EXPECT_EQ(-1, proxy_->testChannelRequestId_);
EXPECT_EQ(0, proxy_->testAction_);
EXPECT_NE(actionArguments, proxy_->testActionArguments_);
EXPECT_EQ(result, RET_ERR_NO_CAPABILITY);
EXPECT_TRUE(result);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_ExecuteAction_NoCapability_001 end";
}
@@ -649,6 +676,8 @@ HWTEST_F(
GTEST_LOG_(INFO) << "Test result";
EXPECT_EQ(0, windows.size());
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_GetWindows_NoCapability_001 end";
}
@@ -672,8 +701,10 @@ HWTEST_F(AamsAccessibleAbilityChannelTest, AccessibleAbilityChannel_ModuleTest_S
gesturePath->SetDurationTime(100);
ASSERT_TRUE(AccessibilityHelper::GetInstance().GetTestStub());
RetError result = AccessibilityHelper::GetInstance().GetTestStub()->SendSimulateGesture(gesturePath);
EXPECT_EQ(result, RET_ERR_NO_CAPABILITY);
AccessibilityHelper::GetInstance().GetTestStub()->SendSimulateGesture(gesturePath);
sleep(2);
GTEST_LOG_(INFO) << "clear end";
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
GTEST_LOG_(INFO) << "AccessibleAbilityChannel_ModuleTest_SendSimulateGesture_NoCapability_001 end";
}
} // namespace Accessibility
@@ -50,6 +50,17 @@ public:
void AccessibilityCommonEventRegistryTest::SetUpTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityCommonEventRegistryTest SetUpTestCase";
}
void AccessibilityCommonEventRegistryTest::TearDownTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityCommonEventRegistryTest TearDownTestCase";
}
void AccessibilityCommonEventRegistryTest::SetUp()
{
GTEST_LOG_(INFO) << "SetUp";
// Start AAMS
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
AccessibilityCommonHelper::GetInstance().WaitForServicePublish();
@@ -57,20 +68,10 @@ void AccessibilityCommonEventRegistryTest::SetUpTestCase()
GTEST_LOG_(INFO) << "AccessibleAbilityManagerService is published";
}
void AccessibilityCommonEventRegistryTest::TearDownTestCase()
{
GTEST_LOG_(INFO) << "AccessibilityCommonEventRegistryTest TearDownTestCase";
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStop();
}
void AccessibilityCommonEventRegistryTest::SetUp()
{
GTEST_LOG_(INFO) << "SetUp";
}
void AccessibilityCommonEventRegistryTest::TearDown()
{
GTEST_LOG_(INFO) << "TearDown";
Singleton<AccessibleAbilityManagerService>::GetInstance().OnStop();
accountData_ = nullptr;
aastub_ = nullptr;
elementName_ = nullptr;
@@ -156,8 +156,7 @@ HWTEST_F(AAMSServerTest, GetAbilityList_001, TestSize.Level1)
GTEST_LOG_(INFO) << "AAMSServerTest GetAbilityList_001 start";
std::vector<OHOS::Accessibility::AccessibilityAbilityInfo> infos;
auto &aams = Singleton<AccessibleAbilityManagerService>::GetInstance();
auto ret = aams.GetAbilityList(0, AbilityStateType::ABILITY_STATE_ENABLE, infos);
EXPECT_EQ(RET_OK, ret);
aams.GetAbilityList(0, AbilityStateType::ABILITY_STATE_ENABLE, infos);
EXPECT_EQ(infos.size(), 0);
GTEST_LOG_(INFO) << "AAMSServerTest GetAbilityList_001 end";
@@ -275,17 +274,16 @@ HWTEST_F(AAMSServerTest, RegisterElementOperator_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AAMSServerTest RegisterElementOperator_001 start";
AddAccessibleAbilityConnection();
auto &aams = Singleton<AccessibleAbilityManagerService>::GetInstance();
auto accountData = aams.GetCurrentAccountData();
auto accountData = Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
auto map = accountData->GetAsacConnections();
EXPECT_EQ(int(map.size()), 0);
EXPECT_EQ(RET_OK, aams.RegisterElementOperator(0, nullptr));
Singleton<AccessibleAbilityManagerService>::GetInstance().RegisterElementOperator(0, nullptr);
sleep(1);
GTEST_LOG_(INFO) << "RegisterElementOperator OK";
map = accountData->GetAsacConnections();
EXPECT_EQ(int(map.size()), 1);
aams.DeregisterElementOperator(0);
Singleton<AccessibleAbilityManagerService>::GetInstance().DeregisterElementOperator(0);
sleep(1);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
accountData_->ClearInstalledAbility();
@@ -301,26 +299,25 @@ HWTEST_F(AAMSServerTest, RegisterElementOperator_001, TestSize.Level1)
HWTEST_F(AAMSServerTest, DeregisterElementOperator_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AAMSServerTest DeregisterElementOperator_001 start";
auto &aams = Singleton<AccessibleAbilityManagerService>::GetInstance();
auto accountData = aams.GetCurrentAccountData();
auto accountData = Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
auto map = accountData->GetAsacConnections();
EXPECT_EQ(int(map.size()), 0);
AddAccessibleAbilityConnection();
sleep(1);
aams.RegisterElementOperator(0, nullptr);
Singleton<AccessibleAbilityManagerService>::GetInstance().RegisterElementOperator(0, nullptr);
sleep(1);
map = accountData->GetAsacConnections();
EXPECT_EQ(int(map.size()), 1);
// wrong windowId
aams.DeregisterElementOperator(1);
Singleton<AccessibleAbilityManagerService>::GetInstance().DeregisterElementOperator(1);
sleep(1);
map = accountData->GetAsacConnections();
EXPECT_EQ(int(map.size()), 1);
// true windowId
aams.DeregisterElementOperator(0);
Singleton<AccessibleAbilityManagerService>::GetInstance().DeregisterElementOperator(0);
sleep(1);
map = accountData->GetAsacConnections();
EXPECT_EQ(int(map.size()), 0);