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_PROXY_H 17 #define ACCESSIBILITY_ELEMENT_OPERATOR_PROXY_H 18 19 #include <cstdint> 20 #include <list> 21 #include <string> 22 23 #include "accessibility_element_operator_callback_interface.h" 24 #include "accessibility_element_operator_interface.h" 25 26 #include "iremote_proxy.h" 27 28 namespace OHOS { 29 namespace Accessibility { 30 /* 31 * The class define the interface for UI to implement. 32 * It triggered by ABMS when AA to request the accessibility information. 33 */ 34 class AccessibilityElementOperatorProxy : public IRemoteProxy<IAccessibilityElementOperator> { 35 public: 36 /** 37 * @brief construct function 38 * @param object The object of IPC 39 * @return 40 */ 41 explicit AccessibilityElementOperatorProxy(const sptr<IRemoteObject> &object); 42 43 /** 44 * @brief destruct function 45 * @param 46 * @return 47 */ 48 virtual ~AccessibilityElementOperatorProxy() override; 49 50 /** 51 * @brief Make the node information by accessibility ID and set the result by callback. 52 * @param elementId: The unique id of the component ID. 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 node info to ASAC and it defined by ASAC. 55 * @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also. 56 * PREFETCH_SIBLINGS: Need to make the sister/brothers node info also. 57 * PREFETCH_CHILDREN: Need to make the child node info also. 58 * otherwise: Make the node information by elementId only. 59 * @return - 60 * @sysCap Accessibility 61 */ 62 virtual void SearchElementInfoByAccessibilityId(const long elementId, const int requestId, 63 const sptr<IAccessibilityElementOperatorCallback> &callback, const int mode) override; 64 65 /** 66 * @brief Make the child node information by accessibility ID and filtered by text and set the result by callback. 67 * @param elementId: The unique id of the component ID. 68 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 69 * @param callback To transfer the node info to ASAC and it defined by ASAC. 70 * @param text Filter for the child components to matched with the text 71 * @return 72 */ 73 virtual void SearchElementInfosByText(const long elementId, const std::string &text, 74 const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) override; 75 76 /** 77 * @brief Make the node information of the component focused by the focus type specified. 78 * @param elementId: The unique id of the component ID. 79 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 80 * @param callback To transfer the node info to ASAC and it defined by ASAC. 81 * @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus 82 * FOCUS_TYPE_INPUT: text input focus 83 * @return 84 */ 85 virtual void FindFocusedElementInfo(const long elementId, const int focusType, const int requestId, 86 const sptr<IAccessibilityElementOperatorCallback> &callback) override; 87 88 /** 89 * @brief Make the node info by current focus move direction. 90 * @param elementId: The unique id of the component ID. 91 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 92 * @param callback To transfer the node info to ASAC and it defined by ASAC. 93 * @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD) 94 * @return - 95 */ 96 virtual void FocusMoveSearch(const long elementId, const int direction, const int requestId, 97 const sptr<IAccessibilityElementOperatorCallback> &callback) override; 98 99 /** 100 * @brief To return the result of perform action. 101 * @param elementId: The unique id of the component ID. 102 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 103 * @param callback To transfer the node info to ASAC and it defined by ASAC. 104 * @param action Refer to [AccessibilityElementInfo.ActionType] 105 * @param actionArguments The parameter for action type. such as: 106 * action: ACCESSIBILITY_ACTION_NEXT_HTML_ITEM, 107 * actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType) 108 * action: ACCESSIBILITY_ACTION_PREVIOUS_HTML_ITEM, 109 * actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType) 110 * action: ACCESSIBILITY_ACTION_NEXT_TEXT, 111 * actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX) 112 * action: ACCESSIBILITY_ACTION_PREVIOUS_TEXT, 113 * actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX) 114 * action: ACCESSIBILITY_ACTION_SET_SELECTION, 115 * actionArguments({ACTION_ARGU_SELECT_TEXT_START,"1"(start location)}, 116 * {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)}) 117 * action: ACCESSIBILITY_ACTION_SET_TEXT, 118 * actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted") 119 * @return 120 */ 121 virtual void ExecuteAction(const long elementId, const int action, 122 const std::map<std::string, std::string> actionArguments, 123 int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) override; 124 125 /** 126 * @brief The function is called while accessibility System check the id of window is not equal 127 * to the id of active window when sendAccessibility. 128 * @param - 129 * @return 130 */ 131 virtual void ClearFocus() override; 132 133 /** 134 * @brief the low layser is notified by the function called while accessibility system execute 135 * the function of executeAction from AS to check the all low windows cared the outside event. 136 * Example: PopupWindow receive the OUTSIDE_EVENT to close itself. 137 * @param - 138 * @return 139 */ 140 virtual void OutsideTouch() override; 141 private: 142 /** 143 * @brief Write the descriptor of IPC. 144 * @param data It is include the descriptor of IPC. 145 * @return true: Write the descriptor successfully; otherwise is not. 146 */ 147 bool WriteInterfaceToken(MessageParcel &data); 148 static inline BrokerDelegator<AccessibilityElementOperatorProxy> delegator; 149 }; 150 } // namespace Accessibility 151 } // namespace OHOS 152 #endif