• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 OHOS_ROSEN_DISPLAY_POWER_CONTROLLER_H
17 #define OHOS_ROSEN_DISPLAY_POWER_CONTROLLER_H
18 
19 #include <map>
20 #include <mutex>
21 #include <refbase.h>
22 #include "display.h"
23 #include "display_change_listener.h"
24 #include "dm_common.h"
25 
26 namespace OHOS {
27 namespace Rosen {
28 class DisplayPowerController : public RefBase {
29 using DisplayStateChangeListener = std::function<void(DisplayId, DisplayStateChangeType)>;
30 public:
DisplayPowerController(std::recursive_mutex & mutex,DisplayStateChangeListener listener)31     DisplayPowerController(std::recursive_mutex& mutex, DisplayStateChangeListener listener)
32         : mutex_(mutex), displayStateChangeListener_(listener)
33     {
34     }
35     virtual ~DisplayPowerController() = default;
36 
37     bool SuspendBegin(PowerStateChangeReason reason);
38     bool SetDisplayState(DisplayState state);
39     DisplayState GetDisplayState(DisplayId displayId);
40     void NotifyDisplayEvent(DisplayEvent event);
41 
42 private:
43     DisplayState displayState_ { DisplayState::UNKNOWN };
44     bool isKeyguardDrawn_ { false };
45     std::recursive_mutex& mutex_;
46     DisplayStateChangeListener displayStateChangeListener_;
47 };
48 }
49 }
50 #endif // OHOS_ROSEN_DISPLAY_POWER_CONTROLLER_H