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 #define LOG_TAG "ScreenManager"
17 #include "screen/screen_manager.h"
18 #include "log_print.h"
19 
20 namespace OHOS::DistributedData {
21 std::mutex ScreenManager::mutex_;
22 std::shared_ptr<ScreenManager> ScreenManager::instance_ = nullptr;
GetInstance()23 std::shared_ptr<ScreenManager> ScreenManager::GetInstance()
24 {
25     std::lock_guard<decltype(mutex_)> lock(mutex_);
26     if (instance_ != nullptr) {
27         return instance_;
28     }
29     instance_ = std::make_shared<ScreenManager>();
30     ZLOGW("no register, new instance!");
31     return instance_;
32 }
33 
RegisterInstance(std::shared_ptr<ScreenManager> instance)34 bool ScreenManager::RegisterInstance(std::shared_ptr<ScreenManager> instance)
35 {
36     std::lock_guard<decltype(mutex_)> lock(mutex_);
37     instance_ = std::move(instance);
38     return true;
39 }
40 
IsLocked()41 bool ScreenManager::IsLocked()
42 {
43     return false;
44 }
45 
46 } // namespace OHOS::DistributedData