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 #ifndef DISTRIBUTEDDATAMGR_FRAMEWORK_SCREEN_LOCK_H 16 #define DISTRIBUTEDDATAMGR_FRAMEWORK_SCREEN_LOCK_H 17 18 #include <memory> 19 #include <mutex> 20 21 #include "executor_pool.h" 22 #include "visibility.h" 23 24 namespace OHOS { 25 namespace DistributedData { 26 class ScreenManager { 27 public: 28 class Observer { 29 public: 30 virtual ~Observer() = default; 31 virtual void OnScreenUnlocked(int32_t user) = 0; 32 virtual std::string GetName() = 0; 33 }; 34 API_EXPORT static std::shared_ptr<ScreenManager> GetInstance(); 35 API_EXPORT static bool RegisterInstance(std::shared_ptr<ScreenManager> instance); 36 ScreenManager() = default; 37 virtual ~ScreenManager() = default; 38 virtual bool IsLocked(); 39 virtual void Subscribe(std::shared_ptr<Observer> observer); 40 virtual void Unsubscribe(std::shared_ptr<Observer> observer); 41 virtual void BindExecutor(std::shared_ptr<ExecutorPool> executors); 42 virtual void SubscribeScreenEvent(); 43 virtual void UnsubscribeScreenEvent(); 44 45 private: 46 static std::mutex mutex_; 47 static std::shared_ptr<ScreenManager> instance_; 48 }; 49 } // namespace DistributedData 50 } // namespace OHOS 51 #endif //DISTRIBUTEDDATAMGR_FRAMEWORK_SCREEN_LOCK_H