• 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 ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_PROXY_H
17 #define ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_PROXY_H
18 
19 #include "accessibility_ipc_interface_code.h"
20 #include "i_accessibility_element_operator_callback.h"
21 #include "iremote_proxy.h"
22 namespace OHOS {
23 namespace Accessibility {
24 /*
25 * The class supply the callback to feedback the result from UI to AA.
26 */
27 class AccessibilityElementOperatorCallbackProxy : public IRemoteProxy<IAccessibilityElementOperatorCallback> {
28 public:
29     /**
30      * @brief construct function
31      * @param object The object of IPC
32      */
33     explicit AccessibilityElementOperatorCallbackProxy(const sptr<IRemoteObject> &object);
34 
35     /**
36      * @brief destruct function
37      */
38     virtual ~AccessibilityElementOperatorCallbackProxy() override;
39 
40     /**
41      * @brief Set the element information by accessibility id to AA.
42      * @param infos The element info searched by accessibility id.
43      * @param requestId The request id from AA, it is used to match with request and response.
44      */
45     void SetSearchElementInfoByAccessibilityIdResult(const std::vector<AccessibilityElementInfo> &infos,
46         const int32_t requestId) override;
47 
48     /**
49      * @brief Set the Default Focus by window id to AA.
50      * @param infos The element info searched by window id.
51      * @param requestId The request id from AA, it is used to match with request and response.
52      */
53     void SetSearchDefaultFocusByWindowIdResult(const std::vector<AccessibilityElementInfo> &infos,
54         const int32_t requestId) override;
55 
56     /**
57      * @brief Set the element information matched with text to AA.
58      * @param infos The element information searched matched with text.
59      * @param requestId The request id from AA, it is used to match with request and response.
60      */
61     void SetSearchElementInfoByTextResult(const std::vector<AccessibilityElementInfo> &infos,
62         const int32_t requestId) override;
63 
64     /**
65      * @brief Set the element information matched with focus type to AA.
66      * @param info The element information searched matched with focus type.
67      * @param requestId The request id from AA, it is used to match with request and response.
68      */
69     void SetFindFocusedElementInfoResult(const AccessibilityElementInfo &info, const int32_t requestId) override;
70 
71     /**
72      * @brief Set the element information by focus direction to AA.
73      * @param info The element information searched by focus direction.
74      * @param requestId The request id from AA, it is used to match with request and response.
75      */
76     void SetFocusMoveSearchResult(const AccessibilityElementInfo &info, const int32_t requestId) override;
77 
78     /**
79      * @brief Set the result of action executed to AA.
80      * @param succeeded True: The action is executed successfully; otherwise is false.
81      * @param requestId The request id from AA, it is used to match with request and response.
82      */
83     void SetExecuteActionResult(const bool succeeded, const int32_t requestId) override;
84 
85     /**
86      * @brief Set the result of cursor position to AA.
87      * @param cursorPosition The position of the cursor to return.
88      * @param requestId The request id from AA, it is used to match with request and response.
89      */
90     void SetCursorPositionResult(const int32_t cursorPosition, const int32_t requestId) override;
91 
92 private:
93     /**
94      * @brief Write the descriptor of IPC.
95      * @param data It is include the descriptor of IPC.
96      * @return true: Write the descriptor successfully; otherwise is not.
97      */
98     bool WriteInterfaceToken(MessageParcel &data);
99 
100     /**
101      * @brief Send the command data from proxy to stub in IPC mechanism.
102      * @param code The code matched the function called.
103      * @param data Serializable data
104      * @param reply The response of IPC
105      * @param option The option parameter of IPC,such as: async,sync
106      * @return true: Write the descriptor successfully; otherwise is not.
107      */
108     bool SendTransactCmd(AccessibilityInterfaceCode code, MessageParcel &data,
109         MessageParcel &reply,  MessageOption &option);
110 
111     static inline BrokerDelegator<AccessibilityElementOperatorCallbackProxy> delegator;
112 };
113 } // namespace Accessibility
114 } // namespace OHOS
115 #endif // ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_PROXY_H