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 #include "ohos_adapter_helper.h" 17 18 #include "aafwk_app_mgr_client_adapter_impl.h" 19 #include "access_token_adapter_impl.h" 20 #include "audio_renderer_adapter_impl.h" 21 #include "audio_capturer_adapter_impl.h" 22 #include "audio_system_manager_adapter_impl.h" 23 #include "battery_mgr_client_adapter_impl.h" 24 #include "camera_manager_adapter_impl.h" 25 #include "cert_mgr_adapter_impl.h" 26 #include "datashare_adapter_impl.h" 27 #include "display_manager_adapter_impl.h" 28 #include "enterprise_device_management_adapter_impl.h" 29 #include "event_handler_adapter_impl.h" 30 #include "hisysevent_adapter_impl.h" 31 #include "hitrace_adapter_impl.h" 32 #include "imf_adapter_impl.h" 33 #include "keystore_adapter_impl.h" 34 #include "mmi_adapter_impl.h" 35 #include "net_connect_adapter_impl.h" 36 #include "net_proxy_adapter_impl.h" 37 #include "ohos_init_web_adapter_impl.h" 38 #include "ohos_resource_adapter_impl.h" 39 #include "ohos_web_data_base_adapter_impl.h" 40 #include "ohos_web_dns_data_base_adapter_impl.h" 41 #include "ohos_web_permission_data_base_adapter_impl.h" 42 #include "pasteboard_client_adapter_impl.h" 43 #include "player_framework_adapter_impl.h" 44 #include "power_mgr_client_adapter_impl.h" 45 #include "print_manager_adapter_impl.h" 46 #include "screen_capture_adapter_impl.h" 47 #include "soc_perf_client_adapter_impl.h" 48 #include "surface_adapter_impl.h" 49 #include "system_properties_adapter_impl.h" 50 #include "vsync_adapter_impl.h" 51 #include "window_adapter_impl.h" 52 53 namespace OHOS::NWeb { 54 // static GetInstance()55OhosAdapterHelper& OhosAdapterHelper::GetInstance() 56 { 57 static OhosAdapterHelper ohosAdapter; 58 return ohosAdapter; 59 } 60 CreateAafwkAdapter()61std::unique_ptr<AafwkAppMgrClientAdapter> OhosAdapterHelper::CreateAafwkAdapter() 62 { 63 return std::make_unique<AafwkAppMgrClientAdapterImpl>(); 64 } 65 CreatePowerMgrClientAdapter()66std::unique_ptr<PowerMgrClientAdapter> OhosAdapterHelper::CreatePowerMgrClientAdapter() 67 { 68 return std::make_unique<PowerMgrClientAdapterImpl>(); 69 } 70 CreateDisplayMgrAdapter()71std::unique_ptr<DisplayManagerAdapter> OhosAdapterHelper::CreateDisplayMgrAdapter() 72 { 73 return std::make_unique<DisplayManagerAdapterImpl>(); 74 } 75 CreateBatteryClientAdapter()76std::unique_ptr<BatteryMgrClientAdapter> OhosAdapterHelper::CreateBatteryClientAdapter() 77 { 78 return std::make_unique<BatteryMgrClientAdapterImpl>(); 79 } 80 GetOhosWebDataBaseAdapterInstance()81OhosWebDataBaseAdapter& OhosAdapterHelper::GetOhosWebDataBaseAdapterInstance() 82 { 83 return OhosWebDataBaseAdapterImpl::GetInstance(); 84 } 85 CreateNetConnectAdapter()86std::unique_ptr<NetConnectAdapter> OhosAdapterHelper::CreateNetConnectAdapter() 87 { 88 return std::make_unique<NetConnectAdapterImpl>(); 89 } 90 GetPasteBoard() const91PasteBoardClientAdapter& OhosAdapterHelper::GetPasteBoard() const 92 { 93 return PasteBoardClientAdapterImpl::GetInstance(); 94 } 95 CreateAudioRendererAdapter()96std::unique_ptr<AudioRendererAdapter> OhosAdapterHelper::CreateAudioRendererAdapter() 97 { 98 return std::make_unique<AudioRendererAdapterImpl>(); 99 } 100 CreateAudioCapturerAdapter()101std::unique_ptr<AudioCapturerAdapter> OhosAdapterHelper::CreateAudioCapturerAdapter() 102 { 103 return std::make_unique<AudioCapturerAdapterImpl>(); 104 } 105 GetAudioSystemManager() const106AudioSystemManagerAdapter& OhosAdapterHelper::GetAudioSystemManager() const 107 { 108 return AudioSystemManagerAdapterImpl::GetInstance(); 109 } 110 GetWebPermissionDataBaseInstance()111OhosWebPermissionDataBaseAdapter& OhosAdapterHelper::GetWebPermissionDataBaseInstance() 112 { 113 return OhosWebPermissionDataBaseAdapterImpl::GetInstance(); 114 } 115 CreateMMIAdapter()116std::unique_ptr<MMIAdapter> OhosAdapterHelper::CreateMMIAdapter() 117 { 118 return std::make_unique<MMIAdapterImpl>(); 119 } 120 CreateSocPerfClientAdapter()121std::unique_ptr<SocPerfClientAdapter> OhosAdapterHelper::CreateSocPerfClientAdapter() 122 { 123 return std::make_unique<SocPerfClientAdapterImpl>(); 124 } 125 GetWebDnsDataBaseInstance()126OhosWebDnsDataBaseAdapter& OhosAdapterHelper::GetWebDnsDataBaseInstance() 127 { 128 return OhosWebDnsDataBaseAdapterImpl::GetInstance(); 129 } 130 GetResourceAdapter(const std::string & hapPath) const131std::unique_ptr<OhosResourceAdapter> OhosAdapterHelper::GetResourceAdapter(const std::string& hapPath) const 132 { 133 return std::make_unique<OhosResourceAdapterImpl>(hapPath); 134 } 135 GetSystemPropertiesInstance() const136SystemPropertiesAdapter& OhosAdapterHelper::GetSystemPropertiesInstance() const 137 { 138 return SystemPropertiesAdapterImpl::GetInstance(); 139 } 140 GetVSyncAdapter() const141std::unique_ptr<VSyncAdapter> OhosAdapterHelper::GetVSyncAdapter() const 142 { 143 return std::make_unique<VSyncAdapterImpl>(); 144 } 145 GetInitWebAdapter() const146std::unique_ptr<OhosInitWebAdapter> OhosAdapterHelper::GetInitWebAdapter() const 147 { 148 return std::make_unique<OhosInitWebAdapterImpl>(); 149 } 150 GetKeystoreAdapterInstance() const151KeystoreAdapter& OhosAdapterHelper::GetKeystoreAdapterInstance() const 152 { 153 return KeystoreAdapterImpl::GetInstance(); 154 } 155 GetEnterpriseDeviceManagementInstance() const156EnterpriseDeviceManagementAdapter& OhosAdapterHelper::GetEnterpriseDeviceManagementInstance() const 157 { 158 return EnterpriseDeviceManagementAdapterImpl::GetInstance(); 159 } 160 GetDatashareInstance() const161DatashareAdapter& OhosAdapterHelper::GetDatashareInstance() const 162 { 163 return DatashareAdapterImpl::GetInstance(); 164 } 165 CreateIMFAdapter() const166std::unique_ptr<IMFAdapter> OhosAdapterHelper::CreateIMFAdapter() const 167 { 168 return std::make_unique<IMFAdapterImpl>(); 169 } 170 GetRootCertDataAdapter() const171std::unique_ptr<CertManagerAdapter> OhosAdapterHelper::GetRootCertDataAdapter() const 172 { 173 return std::make_unique<CertManagerAdapterImpl>(); 174 } 175 GetAccessTokenAdapterInstance() const176AccessTokenAdapter& OhosAdapterHelper::GetAccessTokenAdapterInstance() const 177 { 178 return AccessTokenAdapterImpl::GetInstance(); 179 } 180 GetEventHandlerAdapter() const181std::unique_ptr<EventHandlerAdapter> OhosAdapterHelper::GetEventHandlerAdapter() const 182 { 183 return std::make_unique<EventHandlerAdapterImpl>(); 184 } 185 GetPrintManagerInstance() const186PrintManagerAdapter& OhosAdapterHelper::GetPrintManagerInstance() const 187 { 188 return PrintManagerAdapterImpl::GetInstance(); 189 } 190 CreateConsumerSurfaceAdapter() const191std::unique_ptr<IConsumerSurfaceAdapter> OhosAdapterHelper::CreateConsumerSurfaceAdapter() const 192 { 193 return std::make_unique<ConsumerSurfaceAdapterImpl>(); 194 } 195 CreatePlayerAdapter() const196std::unique_ptr<PlayerAdapter> OhosAdapterHelper::CreatePlayerAdapter() const 197 { 198 return std::make_unique<PlayerAdapterImpl>(); 199 } 200 GetWindowAdapterInstance() const201WindowAdapter& OhosAdapterHelper::GetWindowAdapterInstance() const 202 { 203 return WindowAdapterImpl::GetInstance(); 204 } 205 GetHiSysEventAdapterInstance() const206HiSysEventAdapter& OhosAdapterHelper::GetHiSysEventAdapterInstance() const 207 { 208 return HiSysEventAdapterImpl::GetInstance(); 209 } 210 GetHiTraceAdapterInstance() const211HiTraceAdapter& OhosAdapterHelper::GetHiTraceAdapterInstance() const 212 { 213 return HiTraceAdapterImpl::GetInstance(); 214 } 215 GetNetProxyInstance() const216NetProxyAdapter& OhosAdapterHelper::GetNetProxyInstance() const 217 { 218 return NetProxyAdapterImpl::GetInstance(); 219 } 220 GetCameraManagerAdapter() const221CameraManagerAdapter& OhosAdapterHelper::GetCameraManagerAdapter() const 222 { 223 return CameraManagerAdapterImpl::GetInstance(); 224 } 225 CreateScreenCaptureAdapter() const226std::unique_ptr<ScreenCaptureAdapter> OhosAdapterHelper::CreateScreenCaptureAdapter() const 227 { 228 return std::make_unique<ScreenCaptureAdapterImpl>(); 229 } 230 } // namespace OHOS::NWeb 231