1 /* 2 * Copyright (c) 2023 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 #ifndef SCREEN_STATE_MONITOR 17 #define SCREEN_STATE_MONITOR 18 19 #include <memory> 20 #include <mutex> 21 22 #include "iam_common_defines.h" 23 24 #include "nocopyable.h" 25 26 namespace OHOS { 27 namespace UserIam { 28 namespace FingerprintAuth { 29 class ScreenStateMonitor : public NoCopyable { 30 public: 31 static ScreenStateMonitor &GetInstance(); 32 33 void Subscribe(); 34 void Unsubscribe(); 35 36 void SetScreenOn(bool isOn); 37 bool GetScreenOn(); 38 39 private: 40 ScreenStateMonitor() = default; 41 ~ScreenStateMonitor() = default; 42 43 bool isSubscribing_ = false; 44 bool isOn_ = false; 45 std::mutex mutex_; 46 }; 47 } // namespace FingerprintAuth 48 } // namespace UserIam 49 } // namespace OHOS 50 51 #endif // SCREEN_STATE_MONITOR