• 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 #include "brightness_manager.h"
17 
18 namespace OHOS {
19 namespace DisplayPowerMgr {
Get()20 BrightnessManager& BrightnessManager::Get()
21 {
22     static BrightnessManager brightnessManager;
23     return brightnessManager;
24 }
25 
Init()26 void BrightnessManager::Init()
27 {
28     BrightnessService::Get().Init();
29 }
30 
DeInit()31 void BrightnessManager::DeInit()
32 {
33     BrightnessService::Get().DeInit();
34 }
35 
SetDisplayState(uint32_t id,DisplayState state)36 void BrightnessManager::SetDisplayState(uint32_t id, DisplayState state)
37 {
38     BrightnessService::Get().SetDisplayState(id, state);
39 }
40 
GetState()41 DisplayState BrightnessManager::GetState()
42 {
43     return BrightnessService::Get().GetDisplayState();
44 }
45 
AutoAdjustBrightness(bool enable)46 bool BrightnessManager::AutoAdjustBrightness(bool enable)
47 {
48 #ifdef ENABLE_SENSOR_PART
49     return BrightnessService::Get().AutoAdjustBrightness(enable);
50 #else
51     return false;
52 #endif
53 }
54 
SetBrightness(uint32_t value,uint32_t gradualDuration,bool continuous)55 bool BrightnessManager::SetBrightness(uint32_t value, uint32_t gradualDuration, bool continuous)
56 {
57     return BrightnessService::Get().SetBrightness(value, gradualDuration, continuous);
58 }
59 
DiscountBrightness(double discount)60 bool BrightnessManager::DiscountBrightness(double discount)
61 {
62     return BrightnessService::Get().DiscountBrightness(discount);
63 }
64 
GetDiscount() const65 double BrightnessManager::GetDiscount() const
66 {
67     return BrightnessService::Get().GetDiscount();
68 }
69 
SetScreenOnBrightness()70 void BrightnessManager::SetScreenOnBrightness()
71 {
72     BrightnessService::Get().SetScreenOnBrightness();
73 }
74 
GetScreenOnBrightness() const75 uint32_t BrightnessManager::GetScreenOnBrightness() const
76 {
77     return BrightnessService::Get().GetScreenOnBrightness(false);
78 }
79 
ClearOffset()80 void BrightnessManager::ClearOffset()
81 {
82     BrightnessService::Get().ClearOffset();
83 }
84 
OverrideBrightness(uint32_t value,uint32_t gradualDuration)85 bool BrightnessManager::OverrideBrightness(uint32_t value, uint32_t gradualDuration)
86 {
87     return BrightnessService::Get().OverrideBrightness(value, gradualDuration);
88 }
89 
RestoreBrightness(uint32_t gradualDuration)90 bool BrightnessManager::RestoreBrightness(uint32_t gradualDuration)
91 {
92     return BrightnessService::Get().RestoreBrightness(gradualDuration);
93 }
94 
BoostBrightness(uint32_t timeoutMs,uint32_t gradualDuration)95 bool BrightnessManager::BoostBrightness(uint32_t timeoutMs, uint32_t gradualDuration)
96 {
97     return BrightnessService::Get().BoostBrightness(timeoutMs, gradualDuration);
98 }
99 
CancelBoostBrightness(uint32_t gradualDuration)100 bool BrightnessManager::CancelBoostBrightness(uint32_t gradualDuration)
101 {
102     return BrightnessService::Get().CancelBoostBrightness(gradualDuration);
103 }
104 
GetBrightness()105 uint32_t BrightnessManager::GetBrightness()
106 {
107     return BrightnessService::Get().GetBrightness();
108 }
109 
GetDeviceBrightness()110 uint32_t BrightnessManager::GetDeviceBrightness()
111 {
112     return BrightnessService::Get().GetDeviceBrightness();
113 }
114 
SetLightBrightnessThreshold(std::vector<int32_t> threshold,sptr<IDisplayBrightnessCallback> callback)115 uint32_t BrightnessManager::SetLightBrightnessThreshold(
116     std::vector<int32_t> threshold, sptr<IDisplayBrightnessCallback> callback)
117 {
118     return BrightnessService::Get().SetLightBrightnessThreshold(threshold, callback);
119 }
IsBrightnessOverridden() const120 bool BrightnessManager::IsBrightnessOverridden() const
121 {
122     return BrightnessService::Get().IsBrightnessOverridden();
123 }
124 
IsBrightnessBoosted() const125 bool BrightnessManager::IsBrightnessBoosted() const
126 {
127     return BrightnessService::Get().IsBrightnessBoosted();
128 }
129 
GetCurrentDisplayId(uint32_t defaultId) const130 uint32_t BrightnessManager::GetCurrentDisplayId(uint32_t defaultId) const
131 {
132     return BrightnessService::Get().GetCurrentDisplayId(defaultId);
133 }
134 
SetDisplayId(uint32_t id)135 void BrightnessManager::SetDisplayId(uint32_t id)
136 {
137     return BrightnessService::Get().SetDisplayId(id);
138 }
139 } // namespace DisplayPowerMgr
140 } // namespace OHOS
141