• 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 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 "iaccessibility_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, bool systemApi = 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, bool systemApi = false) = 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, bool systemApi = false) = 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, bool systemApi = false) = 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 Hold running lock to prevent screen turning off automatically.
148      * @param null.
149      * @return Return RET_OK if hold running lock successfully, otherwise refer to the RetError for the failure.
150      */
151     virtual RetError HoldRunningLock() = 0;
152 
153     /**
154      * @brief Unhold running lock to prevent screen turning off automatically
155      * @param null.
156      * @return Return RET_OK if Unhold running lock successfully, otherwise refer to the RetError for the failure.
157      */
158     virtual RetError UnholdRunningLock() = 0;
159 
160     /**
161      * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
162      * @param windows The information of windows.
163      * @param systemApi Whether the API is called by the system.
164      * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
165      */
166     virtual RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows, bool systemApi = false) = 0;
167 
168     /**
169      * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
170      * @param displayId the id of display
171      * @param windows The information of windows.
172      * @param systemApi Whether the API is called by the system.
173      * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
174      */
175     virtual RetError GetWindowsByDisplayId(const uint64_t displayId,
176         std::vector<AccessibilityWindowInfo> &windows, bool systemApi = false) = 0;
177 
178     /**
179      * @brief Set the result of key press event.
180      * @param handled The result of key press event, true if the event has been consumed, otherwise false.
181      * @param sequence The sequence of key press event result.
182      */
183     virtual void SetOnKeyPressEventResult(const bool handled, const int32_t sequence) = 0;
184 
185     /**
186      * @brief Send simulation gesture.
187      * @param gesturePath The gesture path to send.
188      * @return Return RET_OK if gesture injection is successfully, otherwise refer to the RetError for the failure.
189      */
190     virtual RetError SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) = 0;
191 
192     /**
193      * @brief Set target bundle names.
194      * @param targetBundleNames The target bundle name
195      * @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure.
196      */
197     virtual RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) = 0;
198 
199     /**
200      * @brief Set is register disconnectCallback.
201      * @param isRegister The isRegister state
202      * @return Return RET_OK if sets isRegister callback successfully, otherwise refer to the RetError for the failure.
203      */
204     virtual RetError SetIsRegisterDisconnectCallback(bool isRegister) = 0;
205 
206     /**
207      * @brief Notify disconnect.
208      * @return Return RET_OK if notifyDisconnect successfully, otherwise refer to the RetError for the failure.
209      */
210     virtual RetError NotifyDisconnect() = 0;
211 
212     /**
213      * @brief Configure events.
214      * @return Return RET_OK if configureEvents successfully, otherwise refer to the RetError for the failure.
215      */
216     virtual RetError ConfigureEvents(const std::vector<uint32_t> needEvents) = 0;
217 
218     /**
219      * @brief Search element infos by specific property.
220      * @param elementBasicInfo The basic info of the element.
221      * @param param The specific property parameters.
222      * @param requestId The request id from AA, it is used to match with request and response.
223      * @param callback The callback to return the result.
224      */
225     virtual void SearchElementInfoBySpecificProperty(const ElementBasicInfo elementBasicInfo,
226         const SpecificPropertyParam& param, const int32_t requestId,
227         const sptr<IAccessibilityElementOperatorCallback> &callback) = 0;
228 };
229 } // namespace Accessibility
230 } // namespace OHOS
231 #endif // INTERFACE_ACCESSIBLE_ABILITY_CHANNEL_H