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 "input_windows_manager_mock.h" 17 18 namespace OHOS { 19 namespace MMI { 20 21 std::shared_ptr<IInputWindowsManager> IInputWindowsManager::instance_; 22 std::mutex IInputWindowsManager::mutex_; 23 GetInstance()24std::shared_ptr<IInputWindowsManager> IInputWindowsManager::GetInstance() 25 { 26 return InputWindowsManagerMock::GetInstance(); 27 } 28 29 std::shared_ptr<InputWindowsManagerMock> InputWindowsManagerMock::instance_; 30 std::mutex InputWindowsManagerMock::mutex_; 31 GetInstance()32std::shared_ptr<InputWindowsManagerMock> InputWindowsManagerMock::GetInstance() 33 { 34 std::lock_guard<std::mutex> lock(mutex_); 35 if (instance_ == nullptr) { 36 instance_ = std::make_shared<InputWindowsManagerMock>(); 37 } 38 return instance_; 39 } 40 ReleaseInstance()41void InputWindowsManagerMock::ReleaseInstance() 42 { 43 std::lock_guard<std::mutex> lock(mutex_); 44 instance_.reset(); 45 } 46 } // namespace MMI 47 } // namespace OHOS 48