• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2024 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_EXT_H
17 #define BRIGHTNESS_MANAGER_EXT_H
18 
19 #include "brightness_service.h"
20 
21 namespace OHOS {
22 namespace DisplayPowerMgr {
23 class BrightnessManagerExt {
24 public:
25     BrightnessManagerExt();
26     ~BrightnessManagerExt();
27 
28     BrightnessManagerExt(const BrightnessManagerExt&) = delete;
29     BrightnessManagerExt& operator=(const BrightnessManagerExt&) = delete;
30     BrightnessManagerExt(BrightnessManagerExt&&) = delete;
31     BrightnessManagerExt& operator=(BrightnessManagerExt&&) = delete;
32 
33     void Init(uint32_t defaultMax, uint32_t defaultMin);
34     void DeInit();
35     void SetDisplayState(uint32_t id, DisplayState state, uint32_t reason);
36     DisplayState GetState();
37     bool IsSupportLightSensor(void);
38     bool IsAutoAdjustBrightness(void);
39     bool AutoAdjustBrightness(bool enable);
40     bool SetBrightness(uint32_t value, uint32_t gradualDuration = 0, bool continuous = false);
41     bool DiscountBrightness(double discount);
42     double GetDiscount() const;
43     void SetScreenOnBrightness();
44     uint32_t GetScreenOnBrightness() const;
45     bool OverrideBrightness(uint32_t value, uint32_t gradualDuration = 0);
46     bool RestoreBrightness(uint32_t gradualDuration = 0);
47     bool BoostBrightness(uint32_t timeoutMs, uint32_t gradualDuration = 0);
48     bool CancelBoostBrightness(uint32_t gradualDuration = 0);
49     bool IsBrightnessOverridden() const;
50     bool IsBrightnessBoosted() const;
51     uint32_t GetBrightness();
52     uint32_t GetDeviceBrightness();
53     void ClearOffset();
54     uint32_t GetCurrentDisplayId(uint32_t defaultId) const;
55     void SetDisplayId(uint32_t id = 0);
56     uint32_t SetLightBrightnessThreshold(std::vector<int32_t> threshold, sptr<IDisplayBrightnessCallback> callback);
57     bool SetMaxBrightness(double value);
58     bool SetMaxBrightnessNit(uint32_t maxNit);
59     int NotifyScreenPowerStatus(uint32_t displayId, uint32_t status);
60 
61 private:
62     bool LoadBrightnessExtLibrary();
63     void CloseBrightnessExtLibrary();
64     bool LoadBrightnessOps();
65     bool LoadBrightnessOpsEx1();
66     bool LoadBrightnessControl();
67     bool LoadBrightnessStatus();
68 
69 #ifndef BRIGHTNESS_DT_ENABLE
70 private:
71 #else
72 public:
73 #endif
74     bool mBrightnessManagerExtEnable = false;
75     void* mBrightnessManagerExtHandle = nullptr;
76     void* mBrightnessManagerInitFunc = nullptr;
77     void* mBrightnessManagerDeInitFunc = nullptr;
78     void* mSetDisplayStateFunc = nullptr;
79     void* mGetDisplayStateFunc = nullptr;
80     void* mIsSupportLightSensorFunc = nullptr;
81     void* mIsAutoAdjustBrightnessFunc = nullptr;
82     void* mAutoAdjustBrightnessFunc = nullptr;
83     void* mSetBrightnessFunc = nullptr;
84     void* mDiscountBrightnessFunc = nullptr;
85     void* mGetDiscountFunc = nullptr;
86     void* mSetScreenOnBrightnessFunc = nullptr;
87     void* mGetScreenOnBrightnessFunc = nullptr;
88     void* mOverrideBrightnessFunc = nullptr;
89     void* mRestoreBrightnessFunc = nullptr;
90     void* mBoostBrightnessFunc = nullptr;
91     void* mCancelBoostBrightnessFunc = nullptr;
92     void* mIsBrightnessOverriddenFunc = nullptr;
93     void* mIsBrightnessBoostedFunc = nullptr;
94     void* mGetBrightnessFunc = nullptr;
95     void* mGetDeviceBrightnessFunc = nullptr;
96     void* mClearOffsetFunc = nullptr;
97     void* mGetCurrentDisplayIdFunc = nullptr;
98     void* mSetDisplayIdFunc = nullptr;
99     void* mSetLightBrightnessThresholdFunc = nullptr;
100     void* mSetMaxBrightnessFunc = nullptr;
101     void* mSetMaxBrightnessNitFunc = nullptr;
102     void* mNotifyScreenPowerStatusFunc = nullptr;
103 };
104 } // namespace DisplayPowerMgr
105 } // namespace OHOS
106 #endif // BRIGHTNESS_MANAGER_EXT_H