1885b47fbSopenharmony_ci/*
2885b47fbSopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd.
3885b47fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4885b47fbSopenharmony_ci * you may not use this file except in compliance with the License.
5885b47fbSopenharmony_ci * You may obtain a copy of the License at
6885b47fbSopenharmony_ci *
7885b47fbSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8885b47fbSopenharmony_ci *
9885b47fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10885b47fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11885b47fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12885b47fbSopenharmony_ci * See the License for the specific language governing permissions and
13885b47fbSopenharmony_ci * limitations under the License.
14885b47fbSopenharmony_ci */
15885b47fbSopenharmony_ci
16885b47fbSopenharmony_ci#ifndef ACCESSIBLE_ABILITY_CHANNEL_PROXY_H
17885b47fbSopenharmony_ci#define ACCESSIBLE_ABILITY_CHANNEL_PROXY_H
18885b47fbSopenharmony_ci
19885b47fbSopenharmony_ci#include "accessibility_ipc_interface_code.h"
20885b47fbSopenharmony_ci#include "i_accessible_ability_channel.h"
21885b47fbSopenharmony_ci#include "iremote_proxy.h"
22885b47fbSopenharmony_ci
23885b47fbSopenharmony_cinamespace OHOS {
24885b47fbSopenharmony_cinamespace Accessibility {
25885b47fbSopenharmony_ciclass AccessibleAbilityChannelProxy : public IRemoteProxy<IAccessibleAbilityChannel> {
26885b47fbSopenharmony_cipublic:
27885b47fbSopenharmony_ci    /**
28885b47fbSopenharmony_ci     * @brief construct function
29885b47fbSopenharmony_ci     * @param object The object of IPC
30885b47fbSopenharmony_ci     */
31885b47fbSopenharmony_ci    explicit AccessibleAbilityChannelProxy(const sptr<IRemoteObject> &object);
32885b47fbSopenharmony_ci
33885b47fbSopenharmony_ci    /**
34885b47fbSopenharmony_ci     * @brief destruct function
35885b47fbSopenharmony_ci     */
36885b47fbSopenharmony_ci    virtual ~AccessibleAbilityChannelProxy() = default;
37885b47fbSopenharmony_ci
38885b47fbSopenharmony_ci    /**
39885b47fbSopenharmony_ci     * @brief Searches elementInfo by accessibility id and set the result by callback through the proxy object.
40885b47fbSopenharmony_ci     * @param accessibilityWindowId The id of accessibility window.
41885b47fbSopenharmony_ci     * @param elementId The unique id of the component ID.
42885b47fbSopenharmony_ci     * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
43885b47fbSopenharmony_ci     * @param callback To transfer the element info to ASAC.
44885b47fbSopenharmony_ci     * @param mode PREFETCH_PREDECESSORS: Need to make the parent element info also.
45885b47fbSopenharmony_ci     *             PREFETCH_SIBLINGS: Need to make the sister/brothers element info also.
46885b47fbSopenharmony_ci     *             PREFETCH_CHILDREN: Need to make the child element info also.
47885b47fbSopenharmony_ci     *             otherwise: Make the element information by elementId only.
48885b47fbSopenharmony_ci     * @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure.
49885b47fbSopenharmony_ci     */
50885b47fbSopenharmony_ci    virtual RetError SearchElementInfoByAccessibilityId(const ElementBasicInfo elementBasicInfo,
51885b47fbSopenharmony_ci        const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback,
52885b47fbSopenharmony_ci        const int32_t mode, bool isFilter) override;
53885b47fbSopenharmony_ci
54885b47fbSopenharmony_ci    /**
55885b47fbSopenharmony_ci     * @brief Make the child element information by accessibility ID and filtered by text and
56885b47fbSopenharmony_ci     *        set the result by callback through the proxy object.
57885b47fbSopenharmony_ci     * @param accessibilityWindowId The id of accessibility window.
58885b47fbSopenharmony_ci     * @param elementId: The unique id of the component ID.
59885b47fbSopenharmony_ci     * @param text  Filter for the child components to matched with the text
60885b47fbSopenharmony_ci     * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
61885b47fbSopenharmony_ci     * @param callback  To transfer the element info to ASAC and it defined by ASAC.
62885b47fbSopenharmony_ci     * @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure.
63885b47fbSopenharmony_ci     */
64885b47fbSopenharmony_ci    virtual RetError SearchElementInfosByText(const int32_t accessibilityWindowId, const int64_t elementId,
65885b47fbSopenharmony_ci        const std::string &text, const int32_t requestId,
66885b47fbSopenharmony_ci        const sptr<IAccessibilityElementOperatorCallback> &callback) override;
67885b47fbSopenharmony_ci
68885b47fbSopenharmony_ci    /**
69885b47fbSopenharmony_ci     * @brief Make the element information of the component focused
70885b47fbSopenharmony_ci     *        by the focus type specified through the proxy object.
71885b47fbSopenharmony_ci     * @param accessibilityWindowId The id of accessibility window.
72885b47fbSopenharmony_ci     * @param elementId: The unique id of the component ID.
73885b47fbSopenharmony_ci     * @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus
74885b47fbSopenharmony_ci     *                  FOCUS_TYPE_INPUT: text input focus
75885b47fbSopenharmony_ci     * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
76885b47fbSopenharmony_ci     * @param callback  To transfer the element info to ASAC and it defined by ASAC.
77885b47fbSopenharmony_ci     * @return Return RET_OK if find elementInfo successfully, otherwise refer to the RetError for the failure.
78885b47fbSopenharmony_ci     */
79885b47fbSopenharmony_ci    virtual RetError FindFocusedElementInfo(const int32_t accessibilityWindowId, const int64_t elementId,
80885b47fbSopenharmony_ci        const int32_t focusType, const int32_t requestId,
81885b47fbSopenharmony_ci        const sptr<IAccessibilityElementOperatorCallback> &callback) override;
82885b47fbSopenharmony_ci
83885b47fbSopenharmony_ci    /**
84885b47fbSopenharmony_ci     * @brief Make the element info by current focus move direction through the proxy object.
85885b47fbSopenharmony_ci     * @param accessibilityWindowId The id of accessibility window.
86885b47fbSopenharmony_ci     * @param elementId: The unique id of the component ID.
87885b47fbSopenharmony_ci     * @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
88885b47fbSopenharmony_ci     * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
89885b47fbSopenharmony_ci     * @param callback  To transfer the element info to ASAC and it defined by ASAC.
90885b47fbSopenharmony_ci     * @return Return RET_OK if search elementInfo successfully, otherwise refer to the RetError for the failure.
91885b47fbSopenharmony_ci     */
92885b47fbSopenharmony_ci    virtual RetError FocusMoveSearch(const int32_t accessibilityWindowId, const int64_t elementId,
93885b47fbSopenharmony_ci        const int32_t direction, const int32_t requestId,
94885b47fbSopenharmony_ci        const sptr<IAccessibilityElementOperatorCallback> &callback) override;
95885b47fbSopenharmony_ci
96885b47fbSopenharmony_ci    /**
97885b47fbSopenharmony_ci     * @brief To perform action through the proxy object.
98885b47fbSopenharmony_ci     * @param accessibilityWindowId The id of accessibility window.
99885b47fbSopenharmony_ci     * @param elementId: The unique id of the component ID.
100885b47fbSopenharmony_ci     * @param action Refer to [AccessibilityElementInfo.ActionType]
101885b47fbSopenharmony_ci     * @param actionArguments The parameter for action type.
102885b47fbSopenharmony_ci     * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
103885b47fbSopenharmony_ci     * @param callback  To transfer the node info to ASAC and it defined by ASAC.
104885b47fbSopenharmony_ci     * @return Return RET_OK if perform action successfully, otherwise refer to the RetError for the failure.
105885b47fbSopenharmony_ci     */
106885b47fbSopenharmony_ci    virtual RetError ExecuteAction(const int32_t accessibilityWindowId, const int64_t elementId, const int32_t action,
107885b47fbSopenharmony_ci        const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
108885b47fbSopenharmony_ci        const sptr<IAccessibilityElementOperatorCallback> &callback) override;
109885b47fbSopenharmony_ci
110885b47fbSopenharmony_ci    /**
111885b47fbSopenharmony_ci     * @brief Get the result of Cursor Position through the proxy object.
112885b47fbSopenharmony_ci     * @param accessibilityWindowId The target winid.
113885b47fbSopenharmony_ci     * @param elementId The element Id.
114885b47fbSopenharmony_ci     * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
115885b47fbSopenharmony_ci     * @param callback  To transfer the node info to ASAC and it defined by ASAC.
116885b47fbSopenharmony_ci     * @return Return RET_OK if Cursor Position successfully, otherwise refer to the RetError for the failure.
117885b47fbSopenharmony_ci     */
118885b47fbSopenharmony_ci    virtual RetError GetCursorPosition(const int32_t accessibilityWindowId, const int64_t elementId,
119885b47fbSopenharmony_ci        const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) override;
120885b47fbSopenharmony_ci
121885b47fbSopenharmony_ci    /**
122885b47fbSopenharmony_ci     * @brief Get the window information related with the event
123885b47fbSopenharmony_ci     * @param windowId The window id.
124885b47fbSopenharmony_ci     * @param windowInfo The window information.
125885b47fbSopenharmony_ci     * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
126885b47fbSopenharmony_ci     */
127885b47fbSopenharmony_ci    virtual RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
128885b47fbSopenharmony_ci
129885b47fbSopenharmony_ci    /**
130885b47fbSopenharmony_ci     * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
131885b47fbSopenharmony_ci     * @param windows The information of windows.
132885b47fbSopenharmony_ci     * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
133885b47fbSopenharmony_ci     */
134885b47fbSopenharmony_ci    virtual RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
135885b47fbSopenharmony_ci
136885b47fbSopenharmony_ci    /**
137885b47fbSopenharmony_ci     * @brief Package and transfer isenable to the data table
138885b47fbSopenharmony_ci     * @param isEnable The information of status.
139885b47fbSopenharmony_ci     * @return Return RET_OK if obtains screen curtain status successfully.
140885b47fbSopenharmony_ci     */
141885b47fbSopenharmony_ci    virtual RetError EnableScreenCurtain(bool isEnable) override;
142885b47fbSopenharmony_ci
143885b47fbSopenharmony_ci    /**
144885b47fbSopenharmony_ci     * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
145885b47fbSopenharmony_ci     * @param displayId the id of display
146885b47fbSopenharmony_ci     * @param windows The information of windows.
147885b47fbSopenharmony_ci     * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure.
148885b47fbSopenharmony_ci     */
149885b47fbSopenharmony_ci    virtual RetError GetWindowsByDisplayId(const uint64_t displayId,
150885b47fbSopenharmony_ci        std::vector<AccessibilityWindowInfo> &windows) override;
151885b47fbSopenharmony_ci
152885b47fbSopenharmony_ci    /**
153885b47fbSopenharmony_ci     * @brief Set the result of key press event through the proxy object.
154885b47fbSopenharmony_ci     * @param handled The result of key press event, true if the event has been consumed, otherwise false.
155885b47fbSopenharmony_ci     * @param sequence The sequence of key press event result.
156885b47fbSopenharmony_ci     */
157885b47fbSopenharmony_ci    virtual void SetOnKeyPressEventResult(const bool handled, const int32_t sequence) override;
158885b47fbSopenharmony_ci
159885b47fbSopenharmony_ci    /**
160885b47fbSopenharmony_ci     * @brief Send simulation gesture through the proxy object.
161885b47fbSopenharmony_ci     * @param gesturePath The gesture path to send.
162885b47fbSopenharmony_ci     * @return Return RET_OK if gesture injection is successfully, otherwise refer to the RetError for the failure.
163885b47fbSopenharmony_ci     */
164885b47fbSopenharmony_ci    virtual RetError SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
165885b47fbSopenharmony_ci
166885b47fbSopenharmony_ci    /**
167885b47fbSopenharmony_ci     * @brief Set target bundle names.
168885b47fbSopenharmony_ci     * @param targetBundleNames The target bundle name
169885b47fbSopenharmony_ci     * @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure.
170885b47fbSopenharmony_ci     */
171885b47fbSopenharmony_ci    virtual RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
172885b47fbSopenharmony_ci
173885b47fbSopenharmony_ciprivate:
174885b47fbSopenharmony_ci    /**
175885b47fbSopenharmony_ci     * @brief Write the descriptor of IPC.
176885b47fbSopenharmony_ci     * @param data It is include the descriptor of IPC.
177885b47fbSopenharmony_ci     * @return true: Write the descriptor successfully; otherwise is not.
178885b47fbSopenharmony_ci     */
179885b47fbSopenharmony_ci    bool WriteInterfaceToken(MessageParcel &data);
180885b47fbSopenharmony_ci    /**
181885b47fbSopenharmony_ci     * @brief Send the command data from proxy to stub in IPC mechanism.
182885b47fbSopenharmony_ci     * @param code The code matched the function called.
183885b47fbSopenharmony_ci     * @param data Serializable data
184885b47fbSopenharmony_ci     * @param reply The response of IPC
185885b47fbSopenharmony_ci     * @param option The option parameter of IPC,such as: async,sync
186885b47fbSopenharmony_ci     * @return true: Write the descriptor successfully; otherwise is not.
187885b47fbSopenharmony_ci     */
188885b47fbSopenharmony_ci    bool SendTransactCmd(AccessibilityInterfaceCode code, MessageParcel &data,
189885b47fbSopenharmony_ci        MessageParcel &reply,  MessageOption &option);
190885b47fbSopenharmony_ci    static inline BrokerDelegator<AccessibleAbilityChannelProxy> delegator;
191885b47fbSopenharmony_ci};
192885b47fbSopenharmony_ci} // namespace Accessibility
193885b47fbSopenharmony_ci} // namespace OHOS
194885b47fbSopenharmony_ci#endif // ACCESSIBLE_ABILITY_CHANNEL_PROXY_H