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_CALLBACK_PROXY_H 17 #define ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_PROXY_H 18 19 #include "accessibility_ipc_interface_code.h" 20 #include "iaccessibility_element_operator_callback.h" 21 #include "iremote_proxy.h" 22 namespace OHOS { 23 namespace Accessibility { 24 /* 25 * The class supply the callback to feedback the result from UI to AA. 26 */ 27 class AccessibilityElementOperatorCallbackProxy : public IRemoteProxy<IAccessibilityElementOperatorCallback> { 28 public: 29 /** 30 * @brief construct function 31 * @param object The object of IPC 32 */ 33 explicit AccessibilityElementOperatorCallbackProxy(const sptr<IRemoteObject> &object); 34 35 /** 36 * @brief destruct function 37 */ 38 virtual ~AccessibilityElementOperatorCallbackProxy() override; 39 40 /** 41 * @brief Set the element information by accessibility id to AA. 42 * @param infos The element info searched by accessibility id. 43 * @param requestId The request id from AA, it is used to match with request and response. 44 */ 45 void SetSearchElementInfoByAccessibilityIdResult(const std::vector<AccessibilityElementInfo> &infos, 46 const int32_t requestId) override; 47 48 /** 49 * @brief Set the Default Focus by window id to AA. 50 * @param infos The element info searched by window id. 51 * @param requestId The request id from AA, it is used to match with request and response. 52 */ 53 void SetSearchDefaultFocusByWindowIdResult(const std::vector<AccessibilityElementInfo> &infos, 54 const int32_t requestId) override; 55 56 /** 57 * @brief Set the element information matched with text to AA. 58 * @param infos The element information searched matched with text. 59 * @param requestId The request id from AA, it is used to match with request and response. 60 */ 61 void SetSearchElementInfoByTextResult(const std::vector<AccessibilityElementInfo> &infos, 62 const int32_t requestId) override; 63 64 /** 65 * @brief Set the element information matched with focus type to AA. 66 * @param info The element information searched matched with focus type. 67 * @param requestId The request id from AA, it is used to match with request and response. 68 */ 69 void SetFindFocusedElementInfoResult(const AccessibilityElementInfo &info, const int32_t requestId) override; 70 71 /** 72 * @brief Set the element information by focus direction to AA. 73 * @param info The element information searched by focus direction. 74 * @param requestId The request id from AA, it is used to match with request and response. 75 */ 76 void SetFocusMoveSearchResult(const AccessibilityElementInfo &info, const int32_t requestId) override; 77 78 /** 79 * @brief Set the result of action executed to AA. 80 * @param succeeded True: The action is executed successfully; otherwise is false. 81 * @param requestId The request id from AA, it is used to match with request and response. 82 */ 83 void SetExecuteActionResult(const bool succeeded, const int32_t requestId) override; 84 85 /** 86 * @brief Set the result of cursor position to AA. 87 * @param cursorPosition The position of the cursor to return. 88 * @param requestId The request id from AA, it is used to match with request and response. 89 */ 90 void SetCursorPositionResult(const int32_t cursorPosition, const int32_t requestId) override; 91 92 /** 93 * @brief Set the search element info by specific property result. 94 * @param infos The element infos searched by specific property. 95 * @param treeInfos The element infos searched by specific property. 96 * @param requestId The request id from AA, it is used to match with request and response. 97 */ 98 void SetSearchElementInfoBySpecificPropertyResult(const std::list<AccessibilityElementInfo> &infos, 99 const std::list<AccessibilityElementInfo> &treeInfos, const int32_t requestId) override; 100 101 private: 102 /** 103 * @brief Write the descriptor of IPC. 104 * @param data It is include the descriptor of IPC. 105 * @return true: Write the descriptor successfully; otherwise is not. 106 */ 107 bool WriteInterfaceToken(MessageParcel &data); 108 109 /** 110 * @brief Send the command data from proxy to stub in IPC mechanism. 111 * @param code The code matched the function called. 112 * @param data Serializable data 113 * @param reply The response of IPC 114 * @param option The option parameter of IPC,such as: async,sync 115 * @return true: Write the descriptor successfully; otherwise is not. 116 */ 117 bool SendTransactCmd(AccessibilityInterfaceCode code, MessageParcel &data, 118 MessageParcel &reply, MessageOption &option); 119 120 /** 121 * @brief Write accessibility element infos to MessageParcel as raw data for 122 * SetSearchElementInfoBySpecificPropertyResult. 123 * @param infos The accessibility element infos to write. 124 * @param data The MessageParcel to write raw data to. 125 * @return true: Write successfully; otherwise is false. 126 */ 127 bool WriteElementInfosToRawData(const std::list<AccessibilityElementInfo> &infos, MessageParcel &data); 128 129 static inline BrokerDelegator<AccessibilityElementOperatorCallbackProxy> delegator; 130 }; 131 } // namespace Accessibility 132 } // namespace OHOS 133 #endif // ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_PROXY_H