1/*
2 * Copyright (c) 2023-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 BRIGHTNESS_ACTION_H
17#define BRIGHTNESS_ACTION_H
18
19#include <cstdint>
20#include <functional>
21#include <memory>
22#include <mutex>
23#include <vector>
24
25#include "brightness_base.h"
26#include "display_power_info.h"
27
28namespace OHOS {
29namespace DisplayPowerMgr {
30class BrightnessAction {
31public:
32    explicit BrightnessAction(uint32_t displayId);
33    ~BrightnessAction() = default;
34    BrightnessAction(const BrightnessAction&) = delete;
35    BrightnessAction& operator=(const BrightnessAction&) = delete;
36    BrightnessAction(BrightnessAction&&) = delete;
37    BrightnessAction& operator=(BrightnessAction&&) = delete;
38
39    static uint32_t GetDefaultDisplayId();
40    static std::vector<uint32_t> GetAllDisplayId();
41
42    uint32_t GetDisplayId();
43    void SetDisplayId(uint32_t displayId);
44    DisplayState GetDisplayState();
45    bool SetDisplayState(DisplayState state, const std::function<void(DisplayState)>& callback);
46    bool SetDisplayPower(DisplayState state, uint32_t reason);
47    uint32_t GetBrightness();
48    bool SetBrightness(uint32_t value);
49    bool SetBrightness(uint32_t displayId, uint32_t value);
50
51private:
52    std::mutex mMutexBrightness;
53    uint32_t mBrightness {102};
54    uint32_t mDisplayId {DEFAULT_DISPLAY_ID};
55};
56} // namespace DisplayPowerMgr
57} // namespace OHOS
58#endif // BRIGHTNESS_ACTION_H
59