1 /*
2  * Copyright (c) 2020-2021 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 "lite_wms_client.h"
17 #include "gfx_utils/graphic_log.h"
18 #include "lite_wm_type.h"
19 #include "samgr_lite.h"
20 
21 namespace OHOS {
GetInstance()22 LiteWMSClient* LiteWMSClient::GetInstance()
23 {
24     static LiteWMSClient client;
25     return &client;
26 }
27 
~LiteWMSClient()28 LiteWMSClient::~LiteWMSClient()
29 {
30     if (proxy_ != nullptr) {
31         proxy_->Release(reinterpret_cast<IUnknown*>(proxy_));
32         proxy_ = nullptr;
33     }
34 }
35 
InitLiteWMSClient()36 bool LiteWMSClient::InitLiteWMSClient()
37 {
38     if (proxy_ == nullptr) {
39         IUnknown* iUnknown = SAMGR_GetInstance()->GetDefaultFeatureApi(SERVICE_NAME);
40         if (iUnknown == nullptr) {
41             GRAPHIC_LOGE("iUnknown is NULL");
42             return false;
43         }
44         (void)iUnknown->QueryInterface(iUnknown, CLIENT_PROXY_VER, (void**)&proxy_);
45         if (proxy_ == nullptr) {
46             GRAPHIC_LOGE("QueryInterface failed!");
47             return false;
48         }
49     }
50     return true;
51 }
52 } // namespace OHOS