1 /*
2  * Copyright (c) 2021-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 DISPLAYMGR_SCREEN_ACTION_H
17 #define DISPLAYMGR_SCREEN_ACTION_H
18 
19 #include <cstdint>
20 #include <functional>
21 #include <memory>
22 #include <mutex>
23 #include <vector>
24 
25 #include "dm_common.h"
26 #include "display_manager_lite.h"
27 #include "display_power_info.h"
28 
29 namespace OHOS {
30 namespace DisplayPowerMgr {
31 class ScreenAction {
32 public:
33     ScreenAction(uint32_t displayId);
34     ~ScreenAction() = default;
35 
36     static uint32_t GetDefaultDisplayId();
37     static std::vector<uint32_t> GetAllDisplayId();
38 
39     uint32_t GetDisplayId();
40     DisplayState GetDisplayState();
41     bool SetDisplayState(DisplayState state, const std::function<void(DisplayState)>& callback);
42     bool SetDisplayPower(DisplayState state, uint32_t reason);
43     uint32_t GetBrightness();
44     bool SetBrightness(uint32_t value);
45     void SetCoordinated(bool coordinated);
46     bool EnableSkipSetDisplayState(uint32_t reason);
47 
48 private:
49     static constexpr uint32_t DEFAULT_DISPLAY_ID = 0;
50     std::mutex mutexBrightness_;
51     uint32_t brightness_ {102};
52     uint32_t displayId_ {DEFAULT_DISPLAY_ID};
53     bool coordinated_ {false};
54     bool skipSetDisplayState_ {false};
55     Rosen::PowerStateChangeReason ParseSpecialReason(uint32_t reason);
56 };
57 } // namespace DisplayPowerMgr
58 } // namespace OHOS
59 #endif // DISPLAYMGR_SCREEN_ACTION_H
60