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_STUB_H 17 #define ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_STUB_H 18 19 #include <map> 20 #include "i_accessibility_element_operator_callback.h" 21 #include "iremote_stub.h" 22 #include "ffrt.h" 23 24 namespace OHOS { 25 namespace Accessibility { 26 27 class StoreElementData { 28 public: 29 StoreElementData() = default; 30 ~StoreElementData() = default; 31 void WriteData(std::vector<AccessibilityElementInfo> &infos); 32 std::vector<AccessibilityElementInfo> ReadData(); 33 size_t Size(); 34 void Clear(); 35 std::vector<AccessibilityElementInfo> storeData_ = {}; 36 ffrt::mutex mutex_; 37 }; 38 39 /* 40 * The class define the interface for UI to implement. 41 * It triggered by ABMS when AA to request the accessibility information. 42 */ 43 class AccessibilityElementOperatorCallbackStub : public IRemoteStub<IAccessibilityElementOperatorCallback> { 44 public: 45 /** 46 * @brief construct function 47 * @param object The object of IPC 48 */ 49 AccessibilityElementOperatorCallbackStub(); 50 51 /** 52 * @brief destruct function 53 */ 54 virtual ~AccessibilityElementOperatorCallbackStub(); 55 56 /** 57 * @brief Receive the event from proxy by IPC mechanism. 58 * @param code The code is matched with the process function. 59 * @param data The data of process communication 60 * @param reply The response of IPC request 61 * @param option The option parameter of IPC,such as: async,sync 62 */ 63 virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, 64 MessageOption &option) override; 65 66 static StoreElementData storeElementData; 67 private: 68 /** 69 * @brief Handle the IPC request for the function:SetSearchElementInfoByAccessibilityIdResult. 70 * @param data The data of process communication 71 * @param reply The response of IPC request 72 * @return NO_ERROR: successful; otherwise is failed. 73 */ 74 ErrCode HandleSetSearchElementInfoByAccessibilityIdResult(MessageParcel &data, MessageParcel &reply); 75 76 /** 77 * @brief Handle the IPC request for the function:SetSearchElementInfoByTextResult. 78 * @param data The data of process communication 79 * @param reply The response of IPC request 80 * @return NO_ERROR: successful; otherwise is failed. 81 */ 82 ErrCode HandleSetSearchElementInfoByTextResult(MessageParcel &data, MessageParcel &reply); 83 84 /** 85 * @brief Handle the IPC request for the function:SetFindFocusedElementInfoResult. 86 * @param data The data of process communication 87 * @param reply The response of IPC request 88 * @return NO_ERROR: successful; otherwise is failed. 89 */ 90 ErrCode HandleSetFindFocusedElementInfoResult(MessageParcel &data, MessageParcel &reply); 91 92 /** 93 * @brief Handle the IPC request for the function:SetFocusMoveSearchResult. 94 * @param data The data of process communication 95 * @param reply The response of IPC request 96 * @return NO_ERROR: successful; otherwise is failed. 97 */ 98 ErrCode HandleSetFocusMoveSearchResult(MessageParcel &data, MessageParcel &reply); 99 100 /** 101 * @brief Handle the IPC request for the function:SetExecuteActionResult. 102 * @param data The data of process communication 103 * @param reply The response of IPC request 104 * @return NO_ERROR: successful; otherwise is failed. 105 */ 106 ErrCode HandleSetExecuteActionResult(MessageParcel &data, MessageParcel &reply); 107 108 /** 109 * @brief Handle the IPC request for the function:SetCursorPositionResult. 110 * @param data The data of process communication 111 * @param reply The response of IPC request 112 * @return NO_ERROR: successful; otherwise is failed. 113 */ 114 ErrCode HandleSetCursorPositionResult(MessageParcel &data, MessageParcel &reply); 115 116 using AccessibilityElementOperatorCallbackFunc = 117 ErrCode (AccessibilityElementOperatorCallbackStub::*)(MessageParcel &data, MessageParcel &reply); 118 }; 119 } // namespace Accessibility 120 } // namespace OHOS 121 #endif // ACCESSIBILITY_ELEMENT_OPERATOR_CALLBACK_STUB_H