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