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