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 #include "wms_connection_monitor_manager.h" 17 18 #include "global.h" 19 #ifdef SCENE_BOARD_ENABLE 20 #include "window_manager_lite.h" 21 #else 22 #include "window_manager.h" 23 #endif 24 #include "wms_connection_observer.h" 25 26 namespace OHOS { 27 namespace MiscServices { 28 using namespace Rosen; GetInstance()29WmsConnectionMonitorManager &WmsConnectionMonitorManager::GetInstance() 30 { 31 static WmsConnectionMonitorManager manager; 32 return manager; 33 } 34 RegisterWMSConnectionChangedListener(const ChangeHandler & handler)35void WmsConnectionMonitorManager::RegisterWMSConnectionChangedListener(const ChangeHandler &handler) 36 { 37 sptr<IWMSConnectionChangedListener> listener = new (std::nothrow) WmsConnectionObserver(handler); 38 if (listener == nullptr) { 39 IMSA_HILOGE("failed to create listener!"); 40 return; 41 } 42 #ifdef SCENE_BOARD_ENABLE 43 WMError ret = WindowManagerLite::GetInstance().RegisterWMSConnectionChangedListener(listener); 44 #else 45 WMError ret = WindowManager::GetInstance().RegisterWMSConnectionChangedListener(listener); 46 #endif 47 IMSA_HILOGI("register WMS connection listener ret: %{public}d.", ret); 48 } 49 } // namespace MiscServices 50 } // namespace OHOS