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 INTERFACE_ACCESSIBLE_ABILITY_CHANNEL_H 17 #define INTERFACE_ACCESSIBLE_ABILITY_CHANNEL_H 18 19 #include <string> 20 #include <vector> 21 #include <map> 22 23 #include "accessibility_gesture_inject_path.h" 24 #include "accessibility_window_info.h" 25 #include "i_accessibility_element_operator_callback.h" 26 #include "iremote_broker.h" 27 28 namespace OHOS { 29 namespace Accessibility { 30 class IAccessibleAbilityChannel : public IRemoteBroker { 31 public: 32 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibleAbilityChannel"); 33 34 /** 35 * @brief Searches elementInfo by accessibility id and set the result by callback. 36 * @param accessibilityWindowId The id of accessibility window. 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 element info to ASAC. 40 * @param mode PREFETCH_PREDECESSORS: Need to make the parent element info also. 41 * PREFETCH_SIBLINGS: Need to make the sister/brothers element info also. 42 * PREFETCH_CHILDREN: Need to make the child element info also. 43 * otherwise: Make the element information by elementId only. 44 * @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure. 45 */ 46 virtual RetError SearchElementInfoByAccessibilityId(const ElementBasicInfo elementBasicInfo, 47 const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback, 48 const int32_t mode, bool isFilter = false) = 0; 49 50 /** 51 * @brief Searches elementInfo by window id and set the result by callback. 52 * @param elementBasicInfo 53 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 54 * @param callback To transfer the element info to ASAC. 55 * @param mode PREFETCH_PREDECESSORS: Need to make the parent element info also. 56 * PREFETCH_SIBLINGS: Need to make the sister/brothers element info also. 57 * PREFETCH_CHILDREN: Need to make the child element info also. 58 * otherwise: Make the element information by elementId only. 59 * @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure. 60 */ 61 virtual RetError SearchDefaultFocusedByWindowId(const ElementBasicInfo elementBasicInfo, 62 const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback, 63 const int32_t mode, bool isFilter = false) = 0; 64 65 /** 66 * @brief Make the child element information by accessibility ID and filtered by text and 67 * set the result by callback. 68 * @param accessibilityWindowId The id of accessibility window. 69 * @param elementId: The unique id of the component ID. 70 * @param text Filter for the child components to matched with the text 71 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 72 * @param callback To transfer the element info to ASAC and it defined by ASAC. 73 * @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure. 74 */ 75 virtual RetError SearchElementInfosByText(const int32_t accessibilityWindowId, const int64_t elementId, 76 const std::string &text, const int32_t requestId, 77 const sptr<IAccessibilityElementOperatorCallback> &callback) = 0; 78 79 /** 80 * @brief Make the element information of the component focused by the focus type specified. 81 * @param accessibilityWindowId The id of accessibility window. 82 * @param elementId: The unique id of the component ID. 83 * @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus 84 * FOCUS_TYPE_INPUT: text input focus 85 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 86 * @param callback To transfer the element info to ASAC and it defined by ASAC. 87 * @return Return RET_OK if find elementInfo successfully, otherwise refer to the RetError for the failure. 88 */ 89 virtual RetError FindFocusedElementInfo(const int32_t accessibilityWindowId, const int64_t elementId, 90 const int32_t focusType, const int32_t requestId, 91 const sptr<IAccessibilityElementOperatorCallback> &callback) = 0; 92 93 /** 94 * @brief Make the element info by current focus move direction. 95 * @param accessibilityWindowId The id of accessibility window. 96 * @param elementId: The unique id of the component ID. 97 * @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD) 98 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 99 * @param callback To transfer the element info to ASAC and it defined by ASAC. 100 * @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure. 101 */ 102 virtual RetError FocusMoveSearch(const int32_t accessibilityWindowId, const int64_t elementId, 103 const int32_t direction, const int32_t requestId, 104 const sptr<IAccessibilityElementOperatorCallback> &callback) = 0; 105 106 /** 107 * @brief To perform action. 108 * @param accessibilityWindowId The id of accessibility window. 109 * @param elementId: The unique id of the component ID. 110 * @param action Refer to [AccessibilityElementInfo.ActionType] 111 * @param actionArguments The parameter for action type. 112 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 113 * @param callback To transfer the node info to ASAC and it defined by ASAC. 114 * @return Return RET_OK if perform action successfully, otherwise refer to the RetError for the failure. 115 */ 116 virtual RetError ExecuteAction(const int32_t accessibilityWindowId, const int64_t elementId, const int32_t action, 117 const std::map<std::string, std::string> &actionArguments, const int32_t requestId, 118 const sptr<IAccessibilityElementOperatorCallback> &callback) = 0; 119 120 /** 121 * @brief Get the result of Cursor Position through the proxy object. 122 * @param accessibilityWindowId The target winid. 123 * @param elementId The element Id. 124 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 125 * @param callback To transfer the node info to ASAC and it defined by ASAC. 126 * @return Return RET_OK if Cursor Position successfully, otherwise refer to the RetError for the failure. 127 */ 128 virtual RetError GetCursorPosition(const int32_t accessibilityWindowId, const int64_t elementId, 129 const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) = 0; 130 131 /** 132 * @brief Get the window information related with the event 133 * @param windowId The window id. 134 * @param windowInfo The window information. 135 * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure. 136 */ 137 virtual RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) = 0; 138 139 /** 140 * @brief Send switch information. 141 * @param isEnable The switch info. 142 * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure. 143 */ 144 virtual RetError EnableScreenCurtain(bool isEnable) = 0; 145 146 /** 147 * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users. 148 * @param windows The information of windows. 149 * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure. 150 */ 151 virtual RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows) = 0; 152 153 /** 154 * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users. 155 * @param displayId the id of display 156 * @param windows The information of windows. 157 * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure. 158 */ 159 virtual RetError GetWindowsByDisplayId(const uint64_t displayId, 160 std::vector<AccessibilityWindowInfo> &windows) = 0; 161 162 /** 163 * @brief Set the result of key press event. 164 * @param handled The result of key press event, true if the event has been consumed, otherwise false. 165 * @param sequence The sequence of key press event result. 166 */ 167 virtual void SetOnKeyPressEventResult(const bool handled, const int32_t sequence) = 0; 168 169 /** 170 * @brief Send simulation gesture. 171 * @param gesturePath The gesture path to send. 172 * @return Return RET_OK if gesture injection is successfully, otherwise refer to the RetError for the failure. 173 */ 174 virtual RetError SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) = 0; 175 176 /** 177 * @brief Set target bundle names. 178 * @param targetBundleNames The target bundle name 179 * @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure. 180 */ 181 virtual RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) = 0; 182 }; 183 } // namespace Accessibility 184 } // namespace OHOS 185 #endif // INTERFACE_ACCESSIBLE_ABILITY_CHANNEL_H