• 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_PROXY_H
17 #define ACCESSIBILITY_ELEMENT_OPERATOR_PROXY_H
18 
19 #include "i_accessibility_element_operator.h"
20 #include "iremote_proxy.h"
21 
22 namespace OHOS {
23 namespace Accessibility {
24 /*
25 * The class define the interface for UI to implement.
26 * It triggered by ABMS when AA to request the accessibility information.
27 */
28 class AccessibilityElementOperatorProxy : public IRemoteProxy<IAccessibilityElementOperator> {
29 public:
30     /**
31      * @brief construct function
32      * @param object The object of IPC
33      */
34     explicit AccessibilityElementOperatorProxy(const sptr<IRemoteObject> &object);
35 
36     /**
37      * @brief destruct function
38      */
39     virtual ~AccessibilityElementOperatorProxy() = default;
40 
41     /**
42      * @brief Make the node information by accessibility ID and set the result by callback.
43      * @param elementId: The unique id of the component ID.
44      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
45      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
46      * @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also.
47      *              PREFETCH_SIBLINGS: Need to make the sister/brothers node info also.
48      *              PREFETCH_CHILDREN: Need to make the child node info also.
49      *              otherwise: Make the node information by elementId only.
50      * @sysCap Accessibility
51      */
52     virtual void SearchElementInfoByAccessibilityId(const int32_t elementId, const int32_t requestId,
53         const sptr<IAccessibilityElementOperatorCallback> &callback, const int32_t mode) override;
54 
55     /**
56      * @brief Make the child node information by accessibility ID and filtered by text and set the result by callback.
57      * @param elementId: The unique id of the component ID.
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 node info to ASAC and it defined by ASAC.
60      * @param text  Filter for the child components to matched with the text
61      */
62     virtual void SearchElementInfosByText(const int32_t elementId, const std::string &text,
63         const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) override;
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      */
73     virtual void FindFocusedElementInfo(const int32_t elementId, const int32_t focusType, const int32_t requestId,
74         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
75 
76     /**
77      * @brief Make the node info by current focus move direction.
78      * @param elementId: The unique id of the component ID.
79      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
80      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
81      * @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
82      */
83     virtual void FocusMoveSearch(const int32_t elementId, const int32_t direction, const int32_t requestId,
84         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
85 
86     /**
87      * @brief To return the result of perform action.
88      * @param elementId: The unique id of the component ID.
89      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
90      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
91      * @param action Refer to [AccessibilityElementInfo.ActionType]
92      * @param actionArguments The parameter for action type. such as:
93      *      action: ACCESSIBILITY_ACTION_NEXT_HTML_ITEM,
94      *                  actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
95      *      action: ACCESSIBILITY_ACTION_PREVIOUS_HTML_ITEM,
96      *                  actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType)
97      *      action: ACCESSIBILITY_ACTION_NEXT_TEXT,
98      *                  actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
99      *      action: ACCESSIBILITY_ACTION_PREVIOUS_TEXT,
100      *                  actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX)
101      *      action: ACCESSIBILITY_ACTION_SET_SELECTION,
102      *                  actionArguments({ACTION_ARGU_SELECT_TEXT_START,"1"(start location)},
103      *                                  {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)})
104      *      action: ACCESSIBILITY_ACTION_SET_TEXT,
105      *                  actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted")
106      */
107     virtual void ExecuteAction(const int32_t elementId, const int32_t action,
108         const std::map<std::string, std::string> &actionArguments,
109         int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) override;
110 
111     /**
112      * @brief The function is called while accessibility System check the id of window is not equal
113      * to the id of active window when sendAccessibility.
114      */
115     virtual void ClearFocus() override;
116 
117     /**
118      * @brief the low layer is notified by the function called while accessibility system execute
119      * the function of executeAction from AS to check the all low windows cared the outside event.
120      * Example: PopupWindow receive the OUTSIDE_EVENT to close itself.
121      */
122     virtual void OutsideTouch() override;
123 private:
124     /**
125      * @brief Write the descriptor of IPC.
126      * @param data It is include the descriptor of IPC.
127      * @return true: Write the descriptor successfully; otherwise is not.
128      */
129     bool WriteInterfaceToken(MessageParcel &data);
130 
131     /**
132      * @brief Send the command data from proxy to stub in IPC mechanism.
133      * @param code The code matched the function called.
134      * @param data Serializable data
135      * @param reply The response of IPC
136      * @param option The option parameter of IPC,such as: async,sync
137      * @return true: Write the descriptor successfully; otherwise is not.
138      */
139     bool SendTransactCmd(IAccessibilityElementOperator::Message code, MessageParcel &data,
140         MessageParcel &reply,  MessageOption &option);
141     static inline BrokerDelegator<AccessibilityElementOperatorProxy> delegator;
142 };
143 } // namespace Accessibility
144 } // namespace OHOS
145 #endif // ACCESSIBILITY_ELEMENT_OPERATOR_PROXY_H