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, 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 SetLightBrightnessThreshold(std::vector<int32_t> threshold, sptr<IDisplayBrightnessCallback> callback); 55 uint32_t GetCurrentDisplayId(uint32_t defaultId) const; 56 void SetDisplayId(uint32_t id = 0); 57 bool SetMaxBrightness(double value); 58 bool SetMaxBrightnessNit(uint32_t nit); 59 int NotifyScreenPowerStatus(uint32_t displayId, uint32_t status); 60 61 private: 62 BrightnessManager() = default; 63 virtual ~BrightnessManager() = default; 64 65 private: 66 BrightnessManagerExt mBrightnessManagerExt; 67 }; 68 } // namespace DisplayPowerMgr 69 } // namespace OHOS 70 #endif // BRIGHTNESS_MANAGER_H