1 /* 2 * Copyright (c) 2022 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 POWERMGR_POWER_MANAGER_SETTING_HELPER_H 17 #define POWERMGR_POWER_MANAGER_SETTING_HELPER_H 18 19 #include <cstdint> 20 #include <string> 21 22 #include "setting_provider.h" 23 24 namespace OHOS { 25 namespace PowerMgr { 26 class SettingHelper { 27 public: 28 enum class SwitchStatus : int32_t { 29 INVALID = -1, 30 DISABLE = 0, 31 ENABLE = 1, 32 }; 33 static bool IsDisplayOffTimeSettingValid(); 34 static int64_t GetSettingDisplayOffTime(int64_t defaultVal); 35 static void SetSettingDisplayOffTime(int64_t time); 36 static sptr<SettingObserver> RegisterSettingDisplayOffTimeObserver(SettingObserver::UpdateFunc& func); 37 static void UnregisterSettingDisplayOffTimeObserver(sptr<SettingObserver>& observer); 38 static bool IsAutoAdjustBrightnessSettingValid(); 39 static void SetSettingAutoAdjustBrightness(SwitchStatus status); 40 static bool IsBrightnessSettingValid(); 41 static void SetSettingBrightness(int32_t brightness); 42 static bool IsVibrationSettingValid(); 43 static void SetSettingVibration(SwitchStatus status); 44 static bool IsWindowRotationSettingValid(); 45 static void SetSettingWindowRotation(SwitchStatus status); 46 static sptr<SettingObserver> RegisterSettingSuspendSourcesObserver(SettingObserver::UpdateFunc& func); 47 static void UnregisterSettingSuspendSourcesObserver(sptr<SettingObserver>& observer); 48 static bool IsSuspendSourcesSettingValid(); 49 static const std::string GetSettingSuspendSources(); 50 static void SetSettingSuspendSources(const std::string& jsonConfig); 51 static sptr<SettingObserver> RegisterSettingWakeupSourcesObserver(SettingObserver::UpdateFunc& func); 52 static void UnregisterSettingWakeupSourcesObserver(sptr<SettingObserver>& observer); 53 static bool IsWakeupSourcesSettingValid(); 54 static const std::string GetSettingWakeupSources(); 55 static void SetSettingWakeupSources(const std::string& jsonConfig); 56 57 private: 58 static constexpr const char* SETTING_DISPLAY_OFF_TIME_KEY {"settings.display.screen_off_timeout"}; 59 static constexpr const char* SETTING_AUTO_ADJUST_BRIGHTNESS_KEY {"settings.display.auto_screen_brightness"}; 60 static constexpr const char* SETTING_BRIGHTNESS_KEY {"settings.display.screen_brightness_status"}; 61 static constexpr const char* SETTING_VIBRATION_KEY {"settings.sound.vibrate_status"}; 62 static constexpr const char* SETTING_WINDOW_ROTATION_KEY {"settings.display.default_screen_rotation"}; 63 static constexpr const char* SETTING_POWER_SUSPEND_SOURCES_KEY {"settings.power.suspend_sources"}; 64 static constexpr const char* SETTING_POWER_WAKEUP_SOURCES_KEY {"settings.power.wakeup_sources"}; 65 }; 66 } // namespace PowerMgr 67 } // namespace OHOS 68 69 #endif // POWERMGR_POWER_MANAGER_SETTING_HELPER_H 70