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