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