• 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 <cstdint>
20 #include <string>
21 #include <vector>
22 #include "accessible_ability_channel_interface.h"
23 #include "hilog_wrapper.h"
24 #include "iremote_proxy.h"
25 #include "message_parcel.h"
26 
27 namespace OHOS {
28 namespace Accessibility {
29 class AccessibleAbilityChannelProxy : public IRemoteProxy<IAccessibleAbilityChannel> {
30 public:
31     /**
32      * @brief construct function
33      * @param object The object of IPC
34      * @return
35      */
36     explicit AccessibleAbilityChannelProxy(const sptr<IRemoteObject> &object);
37 
38     /**
39      * @brief destruct function
40      * @param
41      * @return
42      */
43     virtual ~AccessibleAbilityChannelProxy() = default;
44 
45     /**
46      * @brief Searches elementInfo by accessibility id and set the result by callback through the proxy object.
47      * @param accessibilityWindowId The id of accessibility window.
48      * @param elementId The unique id of the component ID.
49      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
50      * @param callback To transfer the element info to ASAC.
51      * @param mode PREFETCH_PREDECESSORS: Need to make the parent element info also.
52      *             PREFETCH_SIBLINGS: Need to make the sister/brothers element info also.
53      *             PREFETCH_CHILDREN: Need to make the child element info also.
54      *             otherwise: Make the element information by elementId only.
55      * @return Return true if search elementInfo successfully, else return false.
56      */
57     virtual bool SearchElementInfoByAccessibilityId(const int accessibilityWindowId,
58         const long elementId, const int requestId, const sptr<IAccessibilityElementOperatorCallback> &callback,
59         const int mode) override;
60 
61     /**
62      * @brief Make the child element information by accessibility ID and filtered by text and
63      *        set the result by callback through the proxy object.
64      * @param accessibilityWindowId The id of accessibility window.
65      * @param elementId: The unique id of the component ID.
66      * @param text  Filter for the child components to matched with the text
67      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
68      * @param callback  To transfer the element info to ASAC and it defined by ASAC.
69      * @return Return true if search elementInfo successfully, else return false.
70      */
71     virtual bool SearchElementInfosByText(const int accessibilityWindowId, const long elementId,
72         const std::string &text, const int requestId,
73         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
74 
75     /**
76      * @brief Make the element information of the component focused
77      *        by the focus type specified through the proxy object.
78      * @param accessibilityWindowId The id of accessibility window.
79      * @param elementId: The unique id of the component ID.
80      * @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus
81      *                  FOCUS_TYPE_INPUT: text input focus
82      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
83      * @param callback  To transfer the element info to ASAC and it defined by ASAC.
84      * @return Return true if find elementInfo successfully, else return false.
85      */
86     virtual bool FindFocusedElementInfo(const int accessibilityWindowId, const long elementId,
87         const int focusType, const int requestId,
88         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
89 
90     /**
91      * @brief Make the element info by current focus move direction through the proxy object.
92      * @param accessibilityWindowId The id of accessibility window.
93      * @param elementId: The unique id of the component ID.
94      * @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD)
95      * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only.
96      * @param callback  To transfer the element info to ASAC and it defined by ASAC.
97      * @return Return true if search elementInfo successfully, else return false.
98      */
99     virtual bool FocusMoveSearch(const int accessibilityWindowId, const long elementId,
100         const int direction, const int requestId,
101         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
102 
103     /**
104      * @brief To perform action through the proxy object.
105      * @param accessibilityWindowId The id of accessibility window.
106      * @param elementId: The unique id of the component ID.
107      * @param action Refer to [AccessibilityElementInfo.ActionType]
108      * @param actionArguments The parameter for action type.
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 true if perform action successfully, else return false.
112      */
113     virtual bool ExecuteAction(const int accessibilityWindowId, const long elementId, const int action,
114         std::map<std::string, std::string> &actionArguments, const int requestId,
115         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
116 
117     /**
118      * @brief Obtains the list of interactive windows on the device,
119      *        in the layers they are visible to users through the proxy object.
120      * @param
121      * @return The information of windows.
122      */
123     virtual std::vector<AccessibilityWindowInfo> GetWindows() override;
124 
125     /**
126      * @brief Executes a specified action through the proxy object.
127      * @param action The action of OHOS::Accessibility::GlobalAction.
128      * @return Return true if performs action successfully, else return false.
129      */
130     virtual bool ExecuteCommonAction(const int action) override;
131 
132     /**
133      * @brief Set the result of key press event through the proxy object.
134      * @param handled The result of key press event, true if the event has been consumed, otherwise false.
135      * @param sequence The sequence of key press event result.
136      * @return
137      */
138     virtual void SetOnKeyPressEventResult(const bool handled, const int sequence) override;
139 
140     /**
141      * @brief Obtains the resizing scale of this display resizing rectangle through the proxy object.
142      * @param displayId The id of display.
143      * @return Returns the resizing scale.
144      */
145     virtual float GetDisplayResizeScale(const int displayId) override;
146 
147     /**
148      * @brief Obtains the X coordinate of the center in this display resizing rectangle through the proxy object.
149      * @param displayId The id of display.
150      * @return Returns the X coordinate of the center.
151      */
152     virtual float GetDisplayResizeCenterX(const int displayId) override;
153 
154     /**
155      * @brief Obtains the Y coordinate of the center in this display resizing rectangle through the proxy object.
156      * @param displayId The id of display.
157      * @return Returns the Y coordinate of the center.
158      */
159     virtual float GetDisplayResizeCenterY(const int displayId) override;
160 
161     /**
162      * @brief Obtains the display resizing rectangle through the proxy object.
163      * @param displayId The id of display.
164      * @return Returns the display resizing rectangle.
165      */
166     virtual Rect GetDisplayResizeRect(const int displayId) override;
167 
168     /**
169      * @brief Resets the display to its initial size through the proxy object.
170      * @param displayId The id of display.
171      * @param animate Specifies whether animation is required.
172      * @return Returns true if the display is successfully reset; returns false otherwise.
173      */
174     virtual bool ResetDisplayResize(const int displayId, const bool animate) override;
175 
176     /**
177      * @brief Sets the center coordinates and scale for the display resizing rectangle through the proxy object.
178      * @param displayId The id of display.
179      * @param scale Indicates the scale for resizing the display
180      * @param centerX Indicates the X coordinate of the center for resizing the display.
181      * @param centerY Indicates the Y coordinate of the center for resizing the display.
182      * @param animate Specifies whether animation is required.
183      * @return Returns true if the center coordinates and scale are successfully set; returns false otherwise.
184      */
185     virtual bool SetDisplayResizeScaleAndCenter(const int displayId, const float scale, const float centerX,
186         const float centerY, const bool animate) override;
187 
188     /**
189      * @brief Send simulation gesture through the proxy object.
190      * @param requestId The sequence of simulation gesture.
191      * @param gestureSteps The gesture to send.
192      * @return
193      */
194     virtual void SendSimulateGesture(const int requestId, const std::vector<GesturePathDefine> &gestureSteps) override;
195 
196 private:
197     /**
198      * @brief Write the descriptor of IPC.
199      * @param data It is include the descriptor of IPC.
200      * @return true: Write the descriptor successfully; otherwise is not.
201      */
202     bool WriteInterfaceToken(MessageParcel &data);
203     /**
204      * @brief Send the command data from proxy to stub in IPC mechanism.
205      * @param code The code matched the function called.
206      * @param data Serializable data
207      * @param reply The response of IPC
208      * @param option The option parameter of IPC,such as: async,sync
209      * @return true: Write the descriptor successfully; otherwise is not.
210      */
211     bool SendTransactCmd(IAccessibleAbilityChannel::Message code, MessageParcel &data,
212         MessageParcel &reply,  MessageOption &option);
213     static inline BrokerDelegator<AccessibleAbilityChannelProxy> delegator;
214 };
215 } // namespace Accessibility
216 } // namespace OHOS
217 #endif // ACCESSIBLE_ABILITY_CHANNEL_PROXY_H