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 FOUNDATION_ACE_INTERFACE_UI_REPORT_STUB_H 17 #define FOUNDATION_ACE_INTERFACE_UI_REPORT_STUB_H 18 19 #include <iremote_object.h> 20 #include <iremote_stub.h> 21 22 #include "ui_content_service_interface.h" 23 24 #include "base/utils/macros.h" 25 26 namespace OHOS::Ace { 27 class ACE_FORCE_EXPORT UiReportStub : public IRemoteStub<ReportService> { 28 public: 29 virtual int32_t OnRemoteRequest( 30 uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; 31 32 /** 33 * @description: receive proxy side communication to execute click callback 34 */ 35 void ReportClickEvent(const std::string& data) override; 36 37 /** 38 * @description: receive proxy side communication to execute switch callback 39 */ 40 void ReportRouterChangeEvent(const std::string& data) override; 41 42 /** 43 * @description: receive proxy side communication to execute component callback 44 */ 45 void ReportComponentChangeEvent(const std::string& data) override; 46 47 /** 48 * @description: receive proxy side communication to execute search callback 49 */ 50 void ReportSearchEvent(const std::string& data) override; 51 52 /** 53 * @description: register a callback when click event occurs execute 54 * @param eventCallback callback to be performed 55 */ 56 void RegisterClickEventCallback(const EventCallback& eventCallback); 57 58 /** 59 * @description: register a callback when page switch event occurs execute 60 * @param eventCallback callback to be performed 61 */ 62 void RegisterRouterChangeEventCallback(const EventCallback& eventCallback); 63 64 /** 65 * @description: register a callback when search component do search occurs execute 66 * @param eventCallback callback to be performed 67 */ 68 void RegisterSearchEventCallback(const EventCallback& eventCallback); 69 70 /** 71 * @description: register a callback when specified component change occurs execute 72 * @param eventCallback callback to be performed 73 */ 74 void RegisterComponentChangeEventCallback(const EventCallback& eventCallback); 75 76 /** 77 * @description: register a callback when get inspector tree 78 * @param eventCallback callback to be performed 79 */ 80 void RegisterGetInspectorTreeCallback(const std::function<void(std::string, int32_t, bool)>& eventCallback); 81 82 /** 83 * @description: register a callback when get inspector tree 84 * @param eventCallback callback to be performed 85 */ 86 void RegisterWebUnfocusEventCallback( 87 const std::function<void(int64_t accessibilityId, const std::string& data)>& eventCallback); 88 89 /** 90 * @description: register a callback when get base info 91 * @param eventCallback callback to be performed 92 */ 93 void RegisterGetBaseInfoCallback(const EventCallback& eventCallback); 94 95 /** 96 * @description: unregister the click callback last register 97 */ 98 void UnregisterClickEventCallback(); 99 100 /** 101 * @description: unregister the search callback last register 102 */ 103 void UnregisterSearchEventCallback(); 104 105 /** 106 * @description: unregister the switch callback last register 107 */ 108 void UnregisterRouterChangeEventCallback(); 109 110 /** 111 * @description: unregister the component callback last register 112 */ 113 void UnregisterComponentChangeEventCallback(); 114 115 /** 116 * @description: unregister the web unfocus event callback last register 117 */ 118 void UnregisterWebUnfocusEventCallback(); 119 120 /** 121 * @description: report whole inspectorTree for SA 122 */ 123 void ReportInspectorTreeValue(const std::string& data, int32_t partNum, bool isLastPart) override; 124 125 /** 126 * @description: report web unfocus value for SA 127 */ 128 void ReportWebUnfocusEvent(int64_t accessibilityId, const std::string& data) override; 129 130 /** 131 * @description: report whole inspectorTree for SA 132 */ 133 void SendBaseInfo(const std::string& data) override; 134 void RegisterGetShowingImageCallback( 135 const std::function<void(std::vector<std::pair<int32_t, std::shared_ptr<Media::PixelMap>>>)>& eventCallback); 136 void RegisterGetWebViewCurrentLanguage(const EventCallback& eventCallback); 137 void RegisterGetCurrentPageName(const EventCallback& eventCallback); 138 void RegisterGetTranslateTextCallback(const std::function<void(int32_t, std::string)>& eventCallback); 139 void SendCurrentLanguage(const std::string& data) override; 140 void SendCurrentPageName(const std::string& result) override; 141 void SendWebText(int32_t nodeId, std::string res) override; 142 void SendShowingImage(std::vector<std::pair<int32_t, std::shared_ptr<Media::PixelMap>>> maps) override; 143 void ClearAshmem(sptr<Ashmem>& optMem); 144 void RegisterExeAppAIFunction(const std::function<void(uint32_t)>& finishCallback); 145 void SendExeAppAIFunctionResult(uint32_t result) override; 146 147 private: 148 EventCallback clickEventCallback_; 149 EventCallback searchEventCallback_; 150 EventCallback RouterChangeEventCallback_; 151 EventCallback ComponentChangeEventCallback_; 152 EventCallback sendBaseInfoCallback_; 153 EventCallback getWebViewCurrentLanguageCallback_; 154 EventCallback getCurrentPageNameCallback_; 155 std::function<void(int32_t, std::string)> getTranslateTextCallback_; 156 std::function<void(std::string, int32_t, bool)> inspectorTreeCallback_; 157 std::function<void(int64_t accessibilityId, const std::string& data)> unfocusEvent_; 158 std::function<void(std::vector<std::pair<int32_t, std::shared_ptr<Media::PixelMap>>>)> getShowingImageCallback_; 159 std::function<void(uint32_t)> exeAppAIFunctionCallback_; 160 }; 161 } // namespace OHOS::Ace 162 #endif // FOUNDATION_ACE_INTERFACE_UI_REPORT_STUB_H 163