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