• 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 ACCESSIBLE_ABILITY_CHANNEL_INTERFACE_H
17 #define ACCESSIBLE_ABILITY_CHANNEL_INTERFACE_H
18 
19 #include <string>
20 #include <vector>
21 #include <map>
22 
23 #include "accessibility_element_operator_callback_interface.h"
24 #include "accessibility_element_info.h"
25 #include "accessibility_window_info.h"
26 #include "gesture_simulation.h"
27 #include "iremote_broker.h"
28 #include "refbase.h"
29 
30 namespace OHOS {
31 namespace Accessibility {
32 class IAccessibleAbilityChannel : public IRemoteBroker {
33 public:
34     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accessibility.IAccessibleAbilityChannel");
35 
36     /**
37      * @brief Searches elementInfo by accessibility id and set the result by callback.
38      * @param accessibilityWindowId The id of accessibility window.
39      * @param elementId The unique id of the component ID.
40      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
41      * @param callback To transfer the element info to ASAC.
42      * @param mode PREFETCH_PREDECESSORS: Need to make the parent element info also.
43      *             PREFETCH_SIBLINGS: Need to make the sister/brothers element info also.
44      *             PREFETCH_CHILDREN: Need to make the child element info also.
45      *             otherwise: Make the element information by elementId only.
46      * @return Return true if search elementInfo successfully, else return false.
47      */
48     virtual bool SearchElementInfoByAccessibilityId(const int accessibilityWindowId,
49         const long elementId, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback,
50         const int mode) = 0;
51 
52     /**
53      * @brief Make the child element information by accessibility ID and filtered by text and
54      *        set the result by callback.
55      * @param accessibilityWindowId The id of accessibility window.
56      * @param elementId: The unique id of the component ID.
57      * @param text  Filter for the child components to matched with the text
58      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
59      * @param callback  To transfer the element info to ASAC and it defined by ASAC.
60      * @return Return true if search elementInfo successfully, else return false.
61      */
62     virtual bool SearchElementInfosByText(const int accessibilityWindowId, const long elementId,
63         const std::string &text, const int requestId,
64         const sptr<IAccessibilityElementOperatorCallback> &callback) = 0;
65 
66     /**
67      * @brief Make the element information of the component focused by the focus type specified.
68      * @param accessibilityWindowId The id of accessibility window.
69      * @param elementId: The unique id of the component ID.
70      * @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus
71      *                  FOCUS_TYPE_INPUT: text input focus
72      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
73      * @param callback  To transfer the element info to ASAC and it defined by ASAC.
74      * @return Return true if find elementInfo successfully, else return false.
75      */
76     virtual bool FindFocusedElementInfo(const int accessibilityWindowId, const long elementId,
77         const int focusType, const int requestId,
78         const sptr<IAccessibilityElementOperatorCallback> &callback) = 0;
79 
80     /**
81      * @brief Make the element info by current focus move direction.
82      * @param accessibilityWindowId The id of accessibility window.
83      * @param elementId: The unique id of the component ID.
84      * @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
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 true if search elementInfo successfully, else return false.
88      */
89     virtual bool FocusMoveSearch(const int accessibilityWindowId, const long elementId,
90         const int direction, const int requestId,
91         const sptr<IAccessibilityElementOperatorCallback> &callback) = 0;
92 
93     /**
94      * @brief To perform action.
95      * @param accessibilityWindowId The id of accessibility window.
96      * @param elementId: The unique id of the component ID.
97      * @param action Refer to [AccessibilityElementInfo.ActionType]
98      * @param actionArguments The parameter for action type.
99      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
100      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
101      * @return Return true if perform action successfully, else return false.
102      */
103     virtual bool ExecuteAction(const int accessibilityWindowId, const long elementId, const int action,
104         std::map<std::string, std::string> &actionArguments, const int requestId,
105         const sptr<IAccessibilityElementOperatorCallback> &callback) = 0;
106 
107     /**
108      * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
109      * @param
110      * @return The information of windows.
111      */
112     virtual std::vector<AccessibilityWindowInfo> GetWindows() = 0;
113 
114     /**
115      * @brief Executes a specified action.
116      * @param action The action of OHOS::Accessibility::GlobalAction.
117      * @return Return true if performs action successfully, else return false.
118      */
119     virtual bool ExecuteCommonAction(const int action) = 0;
120 
121     /**
122      * @brief Set the result of key press event.
123      * @param handled The result of key press event, true if the event has been consumed, otherwise false.
124      * @param sequence The sequence of key press event result.
125      * @return
126      */
127     virtual void SetOnKeyPressEventResult(const bool handled, const int sequence) = 0;
128 
129     /**
130      * @brief Obtains the resizing scale of this display resizing rectangle.
131      * @param displayId The id of display.
132      * @return Returns the resizing scale.
133      */
134     virtual float GetDisplayResizeScale(const int displayId) = 0;
135 
136     /**
137      * @brief Obtains the X coordinate of the center in this display resizing rectangle.
138      * @param displayId The id of display.
139      * @return Returns the X coordinate of the center.
140      */
141     virtual float GetDisplayResizeCenterX(const int displayId) = 0;
142 
143     /**
144      * @brief Obtains the Y coordinate of the center in this display resizing rectangle.
145      * @param displayId The id of display.
146      * @return Returns the Y coordinate of the center.
147      */
148     virtual float GetDisplayResizeCenterY(const int displayId) = 0;
149 
150     /**
151      * @brief Obtains the display resizing rectangle.
152      * @param displayId The id of display.
153      * @return Returns the display resizing rectangle.
154      */
155     virtual Rect GetDisplayResizeRect(const int displayId) = 0;
156 
157     /**
158      * @brief Resets the display to its initial size.
159      * @param displayId The id of display.
160      * @param animate Specifies whether animation is required.
161      * @return Returns true if the display is successfully reset; returns false otherwise.
162      */
163     virtual bool ResetDisplayResize(const int displayId, const bool animate) = 0;
164 
165     /**
166      * @brief Sets the center coordinates and scale for the display resizing rectangle.
167      * @param displayId The id of display.
168      * @param scale Indicates the scale for resizing the display
169      * @param centerX Indicates the X coordinate of the center for resizing the display.
170      * @param centerY Indicates the Y coordinate of the center for resizing the display.
171      * @param animate Specifies whether animation is required.
172      * @return Returns true if the center coordinates and scale are successfully set; returns false otherwise.
173      */
174     virtual bool SetDisplayResizeScaleAndCenter(const int displayId, const float scale, const float centerX,
175         const float centerY, const bool animate) = 0;
176 
177     /**
178      * @brief Send simulation gesture.
179      * @param requestId The sequence of simulation gesture.
180      * @param gestureSteps The gesture to send.
181      * @return
182      */
183     virtual void SendSimulateGesture(const int requestId, const std::vector<GesturePathDefine> &gestureSteps) = 0;
184 
185     enum class Message {
186         SEARCH_ELEMENTINFO_BY_ACCESSIBILITYID = 0,
187         SEARCH_ELEMENTINFOS_BY_TEXT,
188         FIND_FOCUSED_ELEMENTINFO,
189         FOCUS_MOVE_SEARCH,
190         PERFORM_ACTION,
191         GET_WINDOWS,
192         EXECUTE_COMMON_ACTION,
193         DISABLE_ABILITY,
194         SET_ON_KEY_PRESS_EVENT_RESULT,
195         GET_DISPALYRESIZE_SCALE,
196         GET_DISPALYRESIZE_CETER_X,
197         GET_DISPLAYRESIZE_CETER_Y,
198         GET_DISPLAYRESIZE_RECT,
199         RESET_DISPALYRESIZE,
200         SET_DISPLAYRESIZE_SCALE_AND_CENTER,
201         SEND_SIMULATE_GESTURE,
202     };
203 };
204 } // namespace Accessibility
205 } // namespace OHOS
206 #endif // ACCESSIBLE_ABILITY_CHANNEL_INTERFACE_H