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