• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "accessibility_ipc_interface_code.h"
20 #include "i_accessibility_element_operator.h"
21 #include "iremote_proxy.h"
22 
23 namespace OHOS {
24 namespace Accessibility {
25 /*
26 * The class define the interface for UI to implement.
27 * It triggered by ABMS when AA to request the accessibility information.
28 */
29 class AccessibilityElementOperatorProxy : public IRemoteProxy<IAccessibilityElementOperator> {
30 public:
31     /**
32      * @brief construct function
33      * @param object The object of IPC
34      */
35     explicit AccessibilityElementOperatorProxy(const sptr<IRemoteObject> &object);
36 
37     /**
38      * @brief destruct function
39      */
40     virtual ~AccessibilityElementOperatorProxy() = default;
41 
42     /**
43      * @brief Make the node information by accessibility ID and set the result by callback.
44      * @param elementId: The unique id of the component ID.
45      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
46      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
47      * @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also.
48      *              PREFETCH_SIBLINGS: Need to make the sister/brothers node info also.
49      *              PREFETCH_CHILDREN: Need to make the child node info also.
50      *              otherwise: Make the node information by elementId only.
51      * @sysCap Accessibility
52      */
53     virtual void SearchElementInfoByAccessibilityId(const int64_t elementId, const int32_t requestId,
54         const sptr<IAccessibilityElementOperatorCallback> &callback, const int32_t mode,
55         bool isFilter = false) override;
56 
57     /**
58      * @brief Make the node information by window ID and set the result by callback.
59      * @param windowId: The window id.
60      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
61      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
62      * @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also.
63      *              PREFETCH_SIBLINGS: Need to make the sister/brothers node info also.
64      *              PREFETCH_CHILDREN: Need to make the child node info also.
65      *              otherwise: Make the node information by elementId only.
66      * @sysCap Accessibility
67      */
68     virtual void SearchDefaultFocusedByWindowId(const int32_t windowId, const int32_t requestId,
69         const sptr<IAccessibilityElementOperatorCallback> &callback, const int32_t mode,
70         bool isFilter = false) override;
71 
72     /**
73      * @brief Make the child node information by accessibility ID and filtered by text and set the result by callback.
74      * @param elementId: The unique id of the component ID.
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 node info to ASAC and it defined by ASAC.
77      * @param text  Filter for the child components to matched with the text
78      */
79     virtual void SearchElementInfosByText(const int64_t elementId, const std::string &text,
80         const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) override;
81 
82     /**
83      * @brief Make the node information of the component focused by the focus type specified.
84      * @param elementId: The unique id of the component ID.
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 node info to ASAC and it defined by ASAC.
87      * @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus
88      *                  FOCUS_TYPE_INPUT: text input focus
89      */
90     virtual void FindFocusedElementInfo(const int64_t elementId, const int32_t focusType, const int32_t requestId,
91         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
92 
93     /**
94      * @brief Make the node info by current focus move direction.
95      * @param elementId: The unique id of the component ID.
96      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
97      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
98      * @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
99      */
100     virtual void FocusMoveSearch(const int64_t elementId, const int32_t direction, const int32_t requestId,
101         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
102 
103     /**
104      * @brief To return the result of perform action.
105      * @param elementId: The unique id of the component ID.
106      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
107      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
108      * @param action Refer to [AccessibilityElementInfo.ActionType]
109      * @param actionArguments The parameter for action type. such as:
110      *      action: ACCESSIBILITY_ACTION_NEXT_HTML_ITEM,
111      *                  actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
112      *      action: ACCESSIBILITY_ACTION_PREVIOUS_HTML_ITEM,
113      *                  actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
114      *      action: ACCESSIBILITY_ACTION_NEXT_TEXT,
115      *                  actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
116      *      action: ACCESSIBILITY_ACTION_PREVIOUS_TEXT,
117      *                  actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
118      *      action: ACCESSIBILITY_ACTION_SET_SELECTION,
119      *                  actionArguments({ACTION_ARGU_SELECT_TEXT_START,"1"(start location)},
120      *                                  {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
121      *      action: ACCESSIBILITY_ACTION_SET_TEXT,
122      *                  actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
123      */
124     virtual void ExecuteAction(const int64_t elementId, const int32_t action,
125         const std::map<std::string, std::string> &actionArguments,
126         int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) override;
127 
128     /**
129      * @brief To return the result of cursor position.
130      * @param elementId: The unique id of the component ID.
131      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
132      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
133      */
134     virtual void GetCursorPosition(const int64_t elementId,
135         int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) override;
136 
137     /**
138      * @brief The function is called while accessibility System check the id of window is not equal
139      * to the id of active window when sendAccessibility.
140      */
141     virtual void ClearFocus() override;
142 
143     /**
144      * @brief the low layer is notified by the function called while accessibility system execute
145      * the function of executeAction from AS to check the all low windows cared the outside event.
146      * Example: PopupWindow receive the OUTSIDE_EVENT to close itself.
147      */
148     virtual void OutsideTouch() override;
149 
150     /**
151      * @brief Set isFilter.
152      * @param enableFilter True : Perform filtering ;otherwise is false.
153      */
154     void SetIsFilter(bool enableFilter);
155 
156     /**
157      * @brief Get isFilter.
158      */
159     bool GetFilter();
160 
161     /**
162     * @brief To return the result of elementId, treeId, childWindowId.
163     * @param elementId: The element Id.
164     * @param treeId: The tree Id.
165     * @param childWindowId The childwindow Id.
166     */
167     virtual void SetChildTreeIdAndWinId(const int64_t elementId, const int32_t treeId,
168         const int32_t childWindowId) override;
169 
170     /**
171     * @brief To return the result of treeId
172     * @param treeId: The tree Id.
173     */
174     virtual void SetBelongTreeId(const int32_t treeId) override;
175 
176     /**
177      * @brief Set the parent window Id to the element info.
178      * @param iParentWindowId The parent window Id
179      * @sysCap Accessibility
180     */
181     void SetParentWindowId(const int32_t iParentWindowId) override;
182 private:
183     bool isFilter = false;
184 
185     /**
186      * @brief Write the descriptor of IPC.
187      * @param data It is include the descriptor of IPC.
188      * @return true: Write the descriptor successfully; otherwise is not.
189      */
190     bool WriteInterfaceToken(MessageParcel &data);
191 
192     /**
193      * @brief Send the command data from proxy to stub in IPC mechanism.
194      * @param code The code matched the function called.
195      * @param data Serializable data
196      * @param reply The response of IPC
197      * @param option The option parameter of IPC,such as: async,sync
198      * @return true: Write the descriptor successfully; otherwise is not.
199      */
200     bool SendTransactCmd(AccessibilityInterfaceCode code, MessageParcel &data,
201         MessageParcel &reply,  MessageOption &option);
202     static inline BrokerDelegator<AccessibilityElementOperatorProxy> delegator;
203 };
204 } // namespace Accessibility
205 } // namespace OHOS
206 #endif // ACCESSIBILITY_ELEMENT_OPERATOR_PROXY_H