• 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_PROXY_H
17 #define ACCESSIBLE_ABILITY_CHANNEL_PROXY_H
18 
19 #include "accessibility_ipc_interface_code.h"
20 #include "i_accessible_ability_channel.h"
21 #include "iremote_proxy.h"
22 
23 namespace OHOS {
24 namespace Accessibility {
25 class AccessibleAbilityChannelProxy : public IRemoteProxy<IAccessibleAbilityChannel> {
26 public:
27     /**
28      * @brief construct function
29      * @param object The object of IPC
30      */
31     explicit AccessibleAbilityChannelProxy(const sptr<IRemoteObject> &object);
32 
33     /**
34      * @brief destruct function
35      */
36     virtual ~AccessibleAbilityChannelProxy() = default;
37 
38     /**
39      * @brief Searches elementInfo by accessibility id and set the result by callback through the proxy object.
40      * @param accessibilityWindowId The id of accessibility window.
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 element info to ASAC.
44      * @param mode PREFETCH_PREDECESSORS: Need to make the parent element info also.
45      *             PREFETCH_SIBLINGS: Need to make the sister/brothers element info also.
46      *             PREFETCH_CHILDREN: Need to make the child element info also.
47      *             otherwise: Make the element information by elementId only.
48      * @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure.
49      */
50     virtual RetError SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId,
51         const int64_t elementId, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback,
52         const int32_t mode) override;
53 
54     /**
55      * @brief Make the child element information by accessibility ID and filtered by text and
56      *        set the result by callback through the proxy object.
57      * @param accessibilityWindowId The id of accessibility window.
58      * @param elementId: The unique id of the component ID.
59      * @param text  Filter for the child components to matched with the text
60      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
61      * @param callback  To transfer the element info to ASAC and it defined by ASAC.
62      * @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure.
63      */
64     virtual RetError SearchElementInfosByText(const int32_t accessibilityWindowId, const int64_t elementId,
65         const std::string &text, const int32_t requestId,
66         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
67 
68     /**
69      * @brief Make the element information of the component focused
70      *        by the focus type specified through the proxy object.
71      * @param accessibilityWindowId The id of accessibility window.
72      * @param elementId: The unique id of the component ID.
73      * @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus
74      *                  FOCUS_TYPE_INPUT: text input focus
75      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
76      * @param callback  To transfer the element info to ASAC and it defined by ASAC.
77      * @return Return RET_OK if find elementInfo successfully, otherwise refer to the RetError for the failure.
78      */
79     virtual RetError FindFocusedElementInfo(const int32_t accessibilityWindowId, const int64_t elementId,
80         const int32_t focusType, const int32_t requestId,
81         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
82 
83     /**
84      * @brief Make the element info by current focus move direction through the proxy object.
85      * @param accessibilityWindowId The id of accessibility window.
86      * @param elementId: The unique id of the component ID.
87      * @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
88      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
89      * @param callback  To transfer the element info to ASAC and it defined by ASAC.
90      * @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure.
91      */
92     virtual RetError FocusMoveSearch(const int32_t accessibilityWindowId, const int64_t elementId,
93         const int32_t direction, const int32_t requestId,
94         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
95 
96     /**
97      * @brief To perform action through the proxy object.
98      * @param accessibilityWindowId The id of accessibility window.
99      * @param elementId: The unique id of the component ID.
100      * @param action Refer to [AccessibilityElementInfo.ActionType]
101      * @param actionArguments The parameter for action type.
102      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
103      * @param callback  To transfer the node info to ASAC and it defined by ASAC.
104      * @return Return RET_OK if perform action successfully, otherwise refer to the RetError for the failure.
105      */
106     virtual RetError ExecuteAction(const int32_t accessibilityWindowId, const int64_t elementId, const int32_t action,
107         const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
108         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
109 
110     /**
111      * @brief Get the window information related with the event
112      * @param windowId The window id.
113      * @param windowInfo The window information.
114      * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
115      */
116     virtual RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
117 
118     /**
119      * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
120      * @param windows The information of windows.
121      * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
122      */
123     virtual RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
124 
125     /**
126      * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
127      * @param displayId the id of display
128      * @param windows The information of windows.
129      * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
130      */
131     virtual RetError GetWindowsByDisplayId(const uint64_t displayId,
132         std::vector<AccessibilityWindowInfo> &windows) override;
133 
134     /**
135      * @brief Set the result of key press event through the proxy object.
136      * @param handled The result of key press event, true if the event has been consumed, otherwise false.
137      * @param sequence The sequence of key press event result.
138      */
139     virtual void SetOnKeyPressEventResult(const bool handled, const int32_t sequence) override;
140 
141     /**
142      * @brief Send simulation gesture through the proxy object.
143      * @param gesturePath The gesture path to send.
144      * @return Return RET_OK if gesture injection is successfully, otherwise refer to the RetError for the failure.
145      */
146     virtual RetError SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
147 
148     /**
149      * @brief Set target bundle names.
150      * @param targetBundleNames The target bundle name
151      * @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure.
152      */
153     virtual RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
154 
155 private:
156     /**
157      * @brief Write the descriptor of IPC.
158      * @param data It is include the descriptor of IPC.
159      * @return true: Write the descriptor successfully; otherwise is not.
160      */
161     bool WriteInterfaceToken(MessageParcel &data);
162     /**
163      * @brief Send the command data from proxy to stub in IPC mechanism.
164      * @param code The code matched the function called.
165      * @param data Serializable data
166      * @param reply The response of IPC
167      * @param option The option parameter of IPC,such as: async,sync
168      * @return true: Write the descriptor successfully; otherwise is not.
169      */
170     bool SendTransactCmd(AccessibilityInterfaceCode code, MessageParcel &data,
171         MessageParcel &reply,  MessageOption &option);
172     static inline BrokerDelegator<AccessibleAbilityChannelProxy> delegator;
173 };
174 } // namespace Accessibility
175 } // namespace OHOS
176 #endif // ACCESSIBLE_ABILITY_CHANNEL_PROXY_H