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
26namespace OHOS {
27namespace Rosen {
28class DisplayPowerController : public RefBase {
29using DisplayStateChangeListener = std::function<void(DisplayId, sptr<DisplayInfo>,
30    const std::map<DisplayId, sptr<DisplayInfo>>&, DisplayStateChangeType)>;
31public:
32    DisplayPowerController(std::recursive_mutex& mutex, DisplayStateChangeListener listener)
33        : mutex_(mutex), displayStateChangeListener_(listener)
34    {
35    }
36    virtual ~DisplayPowerController() = default;
37
38    bool SuspendBegin(PowerStateChangeReason reason);
39    bool SetDisplayState(DisplayState state);
40    DisplayState GetDisplayState(DisplayId displayId);
41    void NotifyDisplayEvent(DisplayEvent event);
42
43private:
44    DisplayState displayState_ { DisplayState::UNKNOWN };
45    bool isKeyguardDrawn_ { false };
46    std::recursive_mutex& mutex_;
47    DisplayStateChangeListener displayStateChangeListener_;
48};
49}
50}
51#endif // OHOS_ROSEN_DISPLAY_POWER_CONTROLLER_H