• 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 <cstdint>
20 #include <list>
21 #include <string>
22 
23 #include "accessibility_element_operator_callback_interface.h"
24 #include "iremote_proxy.h"
25 
26 namespace OHOS {
27 namespace Accessibility {
28 /*
29 * The class supply the callback to feedback the result from UI to AA.
30 */
31 class AccessibilityElementOperatorCallbackProxy : public IRemoteProxy<IAccessibilityElementOperatorCallback> {
32 public:
33     /**
34      * @brief construct function
35      * @param object The object of IPC
36      * @return
37      */
38     explicit AccessibilityElementOperatorCallbackProxy(const sptr<IRemoteObject> &object);
39 
40     /**
41      * @brief destruct function
42      * @param
43      * @return
44      */
45     virtual ~AccessibilityElementOperatorCallbackProxy() override;
46 
47     /**
48      * @brief Set the element information by accessibility id to AA.
49      * @param infos The element info searched by accessibility id.
50      * @param requestId The request id from AA, it is used to match with request and response.
51      * @return
52      */
53     void SetSearchElementInfoByAccessibilityIdResult(const std::vector<AccessibilityElementInfo> &infos,
54         const int 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      * @return
61      */
62     void SetSearchElementInfoByTextResult(const std::vector<AccessibilityElementInfo> &infos,
63         const int requestId) override;
64 
65     /**
66      * @brief Set the element information matched with focus type to AA.
67      * @param info The element information searched matched with focus type.
68      * @param requestId The request id from AA, it is used to match with request and response.
69      * @return
70      */
71     void SetFindFocusedElementInfoResult(const AccessibilityElementInfo &info, const int requestId) override;
72 
73     /**
74      * @brief Set the element information by focus direction to AA.
75      * @param info The element information searched by focus direction.
76      * @param requestId The request id from AA, it is used to match with request and response.
77      * @return
78      */
79     void SetFocusMoveSearchResult(const AccessibilityElementInfo &info, const int requestId) override;
80 
81     /**
82      * @brief Set the result of action executed to AA.
83      * @param succeeded True: The action is executed successfully; otherwise is false.
84      * @param requestId The request id from AA, it is used to match with request and response.
85      * @return
86      */
87     void SetExecuteActionResult(const bool succeeded, const int requestId) override;
88 
89 private:
90     /**
91      * @brief Write the descriptor of IPC.
92      * @param data It is include the descriptor of IPC.
93      * @return true: Write the descriptor successfully; otherwise is not.
94      */
95     bool WriteInterfaceToken(MessageParcel &data);
96 
97     /**
98      * @brief Write the serializable data
99      * @param parcelableVector The communication data of IPC
100      * @param reply Serializable data
101      * @return true: Write the serializable data successfully; otherwise is not.
102      */
103     template<typename T>
104     bool WriteParcelableVector(const std::vector<T> &parcelableVector, Parcel &reply);
105     static inline BrokerDelegator<AccessibilityElementOperatorCallbackProxy> delegator;
106 };
107 } // namespace Accessibility
108 } // namespace OHOS
109 #endif