1 /* 2 * Copyright (c) 2024 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_CONTENT_SERVICE_INTERFACE_H 17 #define FOUNDATION_ACE_INTERFACE_UI_CONTENT_SERVICE_INTERFACE_H 18 #include <iremote_broker.h> 19 20 #include "base/utils/macros.h" 21 22 namespace OHOS::Ace { 23 class ACE_FORCE_EXPORT IUiContentService : public OHOS::IRemoteBroker { 24 public: 25 using EventCallback = std::function<void(std::string)>; 26 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.ace.UIContentService"); 27 IUiContentService() = default; 28 ~IUiContentService() override = default; 29 enum { 30 UI_CONTENT_SERVICE_GET_TREE, 31 UI_CONTENT_CONNECT, 32 REGISTER_CLICK_EVENT, 33 REGISTER_SEARCH_EVENT, 34 REGISTER_ROUTER_CHANGE_EVENT, 35 REGISTER_COMPONENT_EVENT, 36 REGISTER_WEB_UNFOCUS_EVENT, 37 UNREGISTER_CLICK_EVENT, 38 UNREGISTER_SEARCH_EVENT, 39 UNREGISTER_ROUTER_CHANGE_EVENT, 40 UNREGISTER_COMPONENT_EVENT, 41 UNREGISTER_WEB_UNFOCUS_EVENT, 42 }; 43 44 /** 45 * @description: define get the current page inspector tree info interface 46 * @return: result number 47 */ 48 virtual int32_t GetInspectorTree(const std::function<void(std::string, int32_t, bool)>& eventCallback) = 0; 49 50 /** 51 * @description: define SA process and current process connect interface 52 * @return: result number 53 */ 54 virtual int32_t Connect(const EventCallback& eventCallback) = 0; 55 56 /** 57 * @description: define register a callback on click event occur to execute interface 58 * @return: result number 59 */ 60 virtual int32_t RegisterClickEventCallback(const EventCallback& eventCallback) = 0; 61 62 /** 63 * @description: define register a callback on switch event occur to execute interface 64 * @return: result number 65 */ 66 virtual int32_t RegisterRouterChangeEventCallback(const EventCallback& eventCallback) = 0; 67 68 /** 69 * @description: define register a callback on search event occur to execute interface 70 * @return: result number 71 */ 72 virtual int32_t RegisterSearchEventCallback(const EventCallback& eventCallback) = 0; 73 74 /** 75 * @description: define register a callback on component event occur to execute interface 76 * @return: result number 77 */ 78 virtual int32_t RegisterComponentChangeEventCallback(const EventCallback& eventCallback) = 0; 79 80 /** 81 * @description: define register a callback on web unfocus event occur to execute interface 82 * @return: result number 83 */ 84 virtual int32_t RegisterWebUnfocusEventCallback( 85 const std::function<void(int64_t accessibilityId, const std::string& data)>& eventCallback) = 0; 86 87 /** 88 * @description: define unregister the click event occur callback last register interface 89 * @return: result number 90 */ 91 virtual int32_t UnregisterClickEventCallback() = 0; 92 93 /** 94 * @description: define unregister the search event occur callback last register interface 95 * @return: result number 96 */ 97 virtual int32_t UnregisterSearchEventCallback() = 0; 98 99 /** 100 * @description: define unregister the switch event occur callback last register interface 101 * @return: result number 102 */ 103 virtual int32_t UnregisterRouterChangeEventCallback() = 0; 104 105 /** 106 * @description: define unregister the component event occur callback last register interface 107 * @return: result number 108 */ 109 virtual int32_t UnregisterComponentChangeEventCallback() = 0; 110 111 /** 112 * @description: define unregister the web focus event occur callback last register interface 113 * @return: result number 114 */ 115 virtual int32_t UnregisterWebUnfocusEventCallback() = 0; 116 }; 117 class ACE_FORCE_EXPORT ReportService : public OHOS::IRemoteBroker { 118 public: 119 using EventCallback = std::function<void(std::string)>; 120 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.ace.ReportService"); 121 ReportService() = default; 122 ~ReportService() override = default; 123 enum { 124 REPORT_CLICK_EVENT, 125 REPORT_SWITCH_EVENT, 126 REPORT_COMPONENT_EVENT, 127 REPORT_SEARCH_EVENT, 128 REPORT_INSPECTOR_VALUE, 129 REPORT_WEB_UNFOCUS_EVENT, 130 SEND_BASE_INFO, 131 }; 132 133 /** 134 * @description: define reports the click event to the proxy interface 135 */ 136 virtual void ReportClickEvent(const std::string& data) = 0; 137 138 /** 139 * @description: define reports the switch event to the proxy interface 140 */ 141 virtual void ReportRouterChangeEvent(const std::string& data) = 0; 142 143 /** 144 * @description: define reports the component change event to the proxy interface 145 */ 146 virtual void ReportComponentChangeEvent(const std::string& data) = 0; 147 148 /** 149 * @description: define reports the search event to the proxy interface 150 */ 151 virtual void ReportSearchEvent(const std::string& data) = 0; 152 153 /** 154 * @description: define reports inspector value to the proxy interface 155 */ 156 virtual void ReportInspectorTreeValue(const std::string& data, int32_t partNum, bool isLastPart) = 0; 157 158 /** 159 * @description: define reports web unfocus value to the proxy interface 160 */ 161 virtual void ReportWebUnfocusEvent(int64_t accessibilityId, const std::string& data) = 0; 162 163 /** 164 * @description: define send base info value to the proxy interface 165 */ 166 virtual void SendBaseInfo(const std::string& data) = 0; 167 }; 168 } // namespace OHOS::Ace 169 #endif // FOUNDATION_ACE_INTERFACE_UI_CONTENT_SERVICE_INTERFACE_H 170