1 /* 2 * Copyright (c) 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 #ifndef POWERMGR_DISPLAY_MANAGER_DISPLAY_SETTING_HELPER_H 16 #define POWERMGR_DISPLAY_MANAGER_DISPLAY_SETTING_HELPER_H 17 18 #include <cstdint> 19 #include <string> 20 21 #include "setting_observer.h" 22 23 namespace OHOS { 24 namespace DisplayPowerMgr { 25 using namespace OHOS::PowerMgr; 26 class DisplaySettingHelper { 27 public: 28 static void RegisterSettingBrightnessObserver(SettingObserver::UpdateFunc func); 29 static void UnregisterSettingBrightnessObserver(); 30 static void SetSettingBrightness(uint32_t value); 31 static ErrCode GetSettingBrightness(uint32_t& brightness, const std::string& key = SETTING_BRIGHTNESS_KEY); 32 33 static void RegisterSettingAutoBrightnessObserver(SettingObserver::UpdateFunc func); 34 static void UnregisterSettingAutoBrightnessObserver(); 35 static void SetSettingAutoBrightness(bool enable); 36 static bool GetSettingAutoBrightness(const std::string& key = SETTING_AUTO_ADJUST_BRIGHTNESS_KEY); 37 private: 38 static const constexpr char* SETTING_BRIGHTNESS_KEY {"settings.display.screen_brightness_status"}; 39 static const constexpr char* SETTING_AUTO_ADJUST_BRIGHTNESS_KEY {"settings.display.auto_screen_brightness"}; 40 41 static sptr<SettingObserver> autoBrightnessObserver_; 42 static sptr<SettingObserver> brightnessObserver_; 43 }; 44 } // namespace PowerMgr 45 } // namespace OHOS 46 47 #endif // POWERMGR_DISPLAY_MANAGER_DISPLAY_SETTING_HELPER_H