1 /* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ACCESSIBILITY_ELEMENT_OPERATOR_H 17 #define ACCESSIBILITY_ELEMENT_OPERATOR_H 18 19 #include <map> 20 #include "accessibility_element_operator_callback.h" 21 22 namespace OHOS { 23 namespace Accessibility { 24 /* 25 * The class define the interface for UI to implement. 26 * It triggered by AAMS when AA to request the accessibility information. 27 */ 28 class AccessibilityElementOperator { 29 public: 30 /** 31 * @brief Destruct 32 */ 33 virtual ~AccessibilityElementOperator() = default; 34 35 /** 36 * @brief Make the node information by accessibility ID and set the result by callback. 37 * @param elementId: The unique id of the component ID. 38 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 39 * @param callback To transfer the node info to ASAC and it defined by ASAC. 40 * @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also. 41 * PREFETCH_SIBLINGS: Need to make the sister/brothers node info also. 42 * PREFETCH_CHILDREN: Need to make the child node info also. 43 * otherwise: Make the node information by elementId only. 44 */ 45 virtual void SearchElementInfoByAccessibilityId(const int64_t elementId, 46 const int32_t requestId, AccessibilityElementOperatorCallback &callback, const int32_t mode) = 0; 47 48 /** 49 * @brief Make the child node information by accessibility ID and filtered by text and set the result by callback. 50 * @param elementId: The unique id of the component ID. 51 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 52 * @param callback To transfer the node info to ASAC and it defined by ASAC. 53 * @param text Filter for the child components to matched with the text 54 */ 55 virtual void SearchElementInfosByText(const int64_t elementId, const std::string &text, 56 const int32_t requestId, AccessibilityElementOperatorCallback &callback) = 0; 57 58 /** 59 * @brief Make the node information of the component focused by the focus type specified. 60 * @param elementId: The unique id of the component ID. 61 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 62 * @param callback To transfer the node info to ASAC and it defined by ASAC. 63 * @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus 64 * FOCUS_TYPE_INPUT: text input focus 65 */ 66 virtual void FindFocusedElementInfo(const int64_t elementId, const int32_t focusType, const int32_t requestId, 67 AccessibilityElementOperatorCallback &callback) = 0; 68 69 /** 70 * @brief Make the node info by current focus move direction. 71 * @param elementId: The unique id of the component ID. 72 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 73 * @param callback To transfer the node info to ASAC and it defined by ASAC. 74 * @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD) 75 */ 76 virtual void FocusMoveSearch(const int64_t elementId, const int32_t direction, const int32_t requestId, 77 AccessibilityElementOperatorCallback &callback) = 0; 78 79 /** 80 * @brief To return the result of execute action. 81 * @param elementId: The unique id of the component ID. 82 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 83 * @param callback To transfer the node info to ASAC and it defined by ASAC. 84 * @param action Refer to [AccessibilityElementInfo.ActionType] 85 * @param actionArguments The parameter for action type. such as: 86 * action: ACCESSIBILITY_ACTION_NEXT_HTML_ITEM, 87 * actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType) 88 * action: ACCESSIBILITY_ACTION_PREVIOUS_HTML_ITEM, 89 * actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType) 90 * action: ACCESSIBILITY_ACTION_NEXT_TEXT, 91 * actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX) 92 * action: ACCESSIBILITY_ACTION_PREVIOUS_TEXT, 93 * actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX) 94 * action: ACCESSIBILITY_ACTION_SET_SELECTION, 95 * actionArguments({ACTION_ARGU_SELECT_TEXT_START,"1"(start location)}, 96 * {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)}) 97 * action: ACCESSIBILITY_ACTION_SET_TEXT, 98 * actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted") 99 */ 100 virtual void ExecuteAction(const int64_t elementId, const int32_t action, 101 const std::map<std::string, std::string> &actionArguments, 102 const int32_t requestId, AccessibilityElementOperatorCallback &callback) = 0; 103 104 /** 105 * @brief To return the result of cursor position. 106 * @param elementId: The unique id of the component ID. 107 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 108 * @param callback To transfer the node info to ASAC and it defined by ASAC. 109 */ 110 virtual void GetCursorPosition(const int64_t elementId, 111 const int32_t requestId, AccessibilityElementOperatorCallback &callback) = 0; 112 113 /** 114 * @brief The function is called while accessibility System check the id of window is not equal 115 * to the id of active window when sendAccessibility. 116 */ 117 virtual void ClearFocus() = 0; 118 119 /** 120 * @brief The low layer is notified by the function called while accessibility system execute 121 * the function of executeAction from AS to check the all low windows cared the outside event. 122 * Example: PopupWindow receive the OUTSIDE_EVENT to close itself. 123 */ 124 virtual void OutsideTouch() = 0; 125 126 /** 127 * @brief To return the result of elementId, treeId, childWindowId. 128 * @param elementId: The element Id. 129 * @param treeId: The tree Id. 130 * @param childWindowId: The childwindow Id. 131 */ SetChildTreeIdAndWinId(const int64_t elementId,const int32_t treeId,const int32_t childWindowId)132 virtual void SetChildTreeIdAndWinId(const int64_t elementId, const int32_t treeId, const int32_t childWindowId) 133 { 134 (void)elementId; 135 (void)treeId; 136 (void)childWindowId; 137 } 138 139 /** 140 * @brief To return the result of treeId 141 * @param treeId: The tree Id. 142 */ SetBelongTreeId(const int32_t treeId)143 virtual void SetBelongTreeId(const int32_t treeId) 144 { 145 (void)treeId; 146 } 147 148 /** 149 * @brief To return the result of parentWindowId 150 * @param parentWindowId: The parentWindowId Id. 151 */ SetParentWindowId(const int32_t parentWindowId)152 virtual void SetParentWindowId(const int32_t parentWindowId) 153 { 154 (void)parentWindowId; 155 } 156 }; 157 } // namespace Accessibility 158 } // namespace OHOS 159 #endif // ACCESSIBILITY_ELEMENT_OPERATOR_H