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