• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
21 namespace OHOS {
22 namespace DisplayPowerMgr {
23 class BrightnessManager {
24 public:
25     BrightnessManager(const BrightnessManager&) = delete;
26     BrightnessManager& operator=(const BrightnessManager&) = delete;
27     BrightnessManager(BrightnessManager&&) = delete;
28     BrightnessManager& operator=(BrightnessManager&&) = delete;
29 
30     static BrightnessManager& Get();
31 
32     void Init();
33     void DeInit();
34     void SetDisplayState(uint32_t id, DisplayState state);
35     DisplayState GetState();
36     bool AutoAdjustBrightness(bool enable);
37     bool SetBrightness(uint32_t value, uint32_t gradualDuration = 0, bool continuous = false);
38     bool DiscountBrightness(double discount);
39     double GetDiscount() const;
40     void SetScreenOnBrightness();
41     uint32_t GetScreenOnBrightness() const;
42     bool OverrideBrightness(uint32_t value, uint32_t gradualDuration = 0);
43     bool RestoreBrightness(uint32_t gradualDuration = 0);
44     bool BoostBrightness(uint32_t timeoutMs, uint32_t gradualDuration = 0);
45     bool CancelBoostBrightness(uint32_t gradualDuration = 0);
46     bool IsBrightnessOverridden() const;
47     bool IsBrightnessBoosted() const;
48     uint32_t GetBrightness();
49     uint32_t GetDeviceBrightness();
50     void ClearOffset();
51     uint32_t GetCurrentDisplayId() const;
52     void SetDisplayId(uint32_t id = 0);
53 
54 private:
55     BrightnessManager() = default;
56     virtual ~BrightnessManager() = default;
57 };
58 } // namespace DisplayPowerMgr
59 } // namespace OHOS
60 #endif // BRIGHTNESS_MANAGER_H