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_MANAGER_H
17 #define BRIGHTNESS_MANAGER_H
18 
19 #include "brightness_service.h"
20 #include "brightness_manager_ext.h"
21 
22 namespace OHOS {
23 namespace DisplayPowerMgr {
24 class BrightnessManager {
25 public:
26     BrightnessManager(const BrightnessManager&) = delete;
27     BrightnessManager& operator=(const BrightnessManager&) = delete;
28     BrightnessManager(BrightnessManager&&) = delete;
29     BrightnessManager& operator=(BrightnessManager&&) = delete;
30 
31     static BrightnessManager& Get();
32 
33     void Init(uint32_t defaultMax, uint32_t defaultMin);
34     void DeInit();
35     void SetDisplayState(uint32_t id, DisplayState state);
36     DisplayState GetState();
37     bool AutoAdjustBrightness(bool enable);
38     bool SetBrightness(uint32_t value, uint32_t gradualDuration = 0, bool continuous = false);
39     bool DiscountBrightness(double discount);
40     double GetDiscount() const;
41     void SetScreenOnBrightness();
42     uint32_t GetScreenOnBrightness() const;
43     bool OverrideBrightness(uint32_t value, uint32_t gradualDuration = 0);
44     bool RestoreBrightness(uint32_t gradualDuration = 0);
45     bool BoostBrightness(uint32_t timeoutMs, uint32_t gradualDuration = 0);
46     bool CancelBoostBrightness(uint32_t gradualDuration = 0);
47     bool IsBrightnessOverridden() const;
48     bool IsBrightnessBoosted() const;
49     uint32_t GetBrightness();
50     uint32_t GetDeviceBrightness();
51     void ClearOffset();
52     uint32_t SetLightBrightnessThreshold(std::vector<int32_t> threshold, sptr<IDisplayBrightnessCallback> callback);
53     uint32_t GetCurrentDisplayId(uint32_t defaultId) const;
54     void SetDisplayId(uint32_t id = 0);
55     bool SetMaxBrightness(double value);
56     bool SetMaxBrightnessNit(uint32_t nit);
57 
58 private:
59     BrightnessManager() = default;
60     virtual ~BrightnessManager() = default;
61 
62 private:
63     BrightnessManagerExt mBrightnessManagerExt;
64 };
65 } // namespace DisplayPowerMgr
66 } // namespace OHOS
67 #endif // BRIGHTNESS_MANAGER_H