• 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_H
17 #define ACCESSIBILITY_ELEMENT_OPERATOR_H
18 
19 #include <map>
20 #include "accessibility_element_operator_callback.h"
21 
22 namespace OHOS {
23 namespace Accessibility {
24 /*
25 * The class define the interface for UI to implement.
26 * It triggered by AAMS when AA to request the accessibility information.
27 */
28 class AccessibilityElementOperator {
29 public:
30     /**
31      * @brief Destruct
32      */
33     virtual ~AccessibilityElementOperator() = default;
34 
35     /**
36      * @brief Make the node information by accessibility ID and set the result by callback.
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 node info to ASAC and it defined by ASAC.
40      * @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also.
41      *             PREFETCH_SIBLINGS: Need to make the sister/brothers node info also.
42      *             PREFETCH_CHILDREN: Need to make the child node info also.
43      *             otherwise: Make the node information by elementId only.
44      */
45     virtual void SearchElementInfoByAccessibilityId(const int64_t elementId,
46         const int32_t requestId, AccessibilityElementOperatorCallback &callback, const int32_t mode) = 0;
47 
48     /**
49      * @brief Make the node information by window ID and set the result by callback.
50      * @param windowId: The window id.
51      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
52      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
53      * @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also.
54      *             PREFETCH_SIBLINGS: Need to make the sister/brothers node info also.
55      *             PREFETCH_CHILDREN: Need to make the child node info also.
56      *             otherwise: Make the node information by elementId only.
57      */
58     virtual void SearchDefaultFocusByWindowId(const int32_t windowId,
59         const int32_t requestId, AccessibilityElementOperatorCallback &callback, const int32_t pageId) = 0;
60 
61     /**
62      * @brief Make the child node information by accessibility ID and filtered by text and set the result by callback.
63      * @param elementId: The unique id of the component ID.
64      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
65      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
66      * @param text  Filter for the child components to matched with the text
67      */
68     virtual void SearchElementInfosByText(const int64_t elementId, const std::string &text,
69         const int32_t requestId, AccessibilityElementOperatorCallback &callback) = 0;
70 
71     /**
72      * @brief Make the node information of the component focused by the focus type specified.
73      * @param elementId: The unique id of the component ID.
74      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
75      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
76      * @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus
77      *                  FOCUS_TYPE_INPUT: text input focus
78      */
79     virtual void FindFocusedElementInfo(const int64_t elementId, const int32_t focusType, const int32_t requestId,
80         AccessibilityElementOperatorCallback &callback) = 0;
81 
82     /**
83      * @brief Make the node info by current focus move direction.
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 direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
88      */
89     virtual void FocusMoveSearch(const int64_t elementId, const int32_t direction, const int32_t requestId,
90         AccessibilityElementOperatorCallback &callback) = 0;
91 
92     /**
93      * @brief To return the result of execute action.
94      * @param elementId: The unique id of the component ID.
95      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
96      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
97      * @param action Refer to [AccessibilityElementInfo.ActionType]
98      * @param actionArguments The parameter for action type. such as:
99      *      action: ACCESSIBILITY_ACTION_NEXT_HTML_ITEM,
100      *                  actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
101      *      action: ACCESSIBILITY_ACTION_PREVIOUS_HTML_ITEM,
102      *                  actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
103      *      action: ACCESSIBILITY_ACTION_NEXT_TEXT,
104      *                  actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
105      *      action: ACCESSIBILITY_ACTION_PREVIOUS_TEXT,
106      *                  actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
107      *      action: ACCESSIBILITY_ACTION_SET_SELECTION,
108      *                  actionArguments({ACTION_ARGU_SELECT_TEXT_START,"1"(start location)},
109      *                                  {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
110      *      action: ACCESSIBILITY_ACTION_SET_TEXT,
111      *                  actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
112      */
113     virtual void ExecuteAction(const int64_t elementId, const int32_t action,
114         const std::map<std::string, std::string> &actionArguments,
115         const int32_t requestId, AccessibilityElementOperatorCallback &callback) = 0;
116 
117     /**
118      * @brief To return the result of cursor position.
119      * @param elementId: The unique id of the component ID.
120      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
121      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
122      */
123     virtual void GetCursorPosition(const int64_t elementId,
124         const int32_t requestId, AccessibilityElementOperatorCallback &callback) = 0;
125 
126     /**
127     * @brief The function is called while accessibility System check the id of window is not equal
128     *        to the id of active window when sendAccessibility.
129     */
130     virtual void ClearFocus() = 0;
131 
132     /**
133     * @brief The low layer is notified by the function called while accessibility system execute
134     *        the function of executeAction from AS to check the all low windows cared the outside event.
135     *        Example: PopupWindow receive the OUTSIDE_EVENT to close itself.
136     */
137     virtual void OutsideTouch() = 0;
138 
139     /**
140     * @brief To return the result of elementId, treeId, childWindowId.
141     * @param elementId: The element Id.
142     * @param treeId: The tree Id.
143     * @param childWindowId: The childwindow Id.
144     */
SetChildTreeIdAndWinId(const int64_t elementId,const int32_t treeId,const int32_t childWindowId)145     virtual void SetChildTreeIdAndWinId(const int64_t elementId, const int32_t treeId, const int32_t childWindowId)
146     {
147         (void)elementId;
148         (void)treeId;
149         (void)childWindowId;
150     }
151 
152     /**
153     * @brief To return the result of treeId
154     * @param treeId: The tree Id.
155     */
SetBelongTreeId(const int32_t treeId)156     virtual void SetBelongTreeId(const int32_t treeId)
157     {
158         (void)treeId;
159     }
160 
161     /**
162     * @brief To return the result of parentWindowId
163     * @param parentWindowId: The parentWindowId Id.
164     */
SetParentWindowId(const int32_t parentWindowId)165     virtual void SetParentWindowId(const int32_t parentWindowId)
166     {
167         (void)parentWindowId;
168     }
169 };
170 } // namespace Accessibility
171 } // namespace OHOS
172 #endif // ACCESSIBILITY_ELEMENT_OPERATOR_H