/**
* Class to decide whether to turn on battery saver mode for specific service
*
* IMPORTANT: This class shares the power manager lock, which is very low in the lock hierarchy.
* Do not call out with the lock held, such as AccessibilityManager. (Settings provider is okay.)
*
* Test:
atest ${ANDROID_BUILD_TOP}/frameworks/base/services/tests/servicestests/src/com/android/server/power/BatterySaverPolicyTest.java
*/
public class BatterySaverPolicy extends ContentObserver {
private static final String TAG = "BatterySaverPolicy";
public static final boolean DEBUG = true; // DO NOT SUBMIT WITH TRUE.
// Secure setting for GPS behavior when battery saver mode is on.
public static final String SECURE_KEY_GPS_MODE = "batterySaverGpsMode";
private static final String KEY_GPS_MODE = "gps_mode"; // GPS 省电
private static final String KEY_VIBRATION_DISABLED = "vibration_disabled"; // 禁用触摸震动
private static final String KEY_ANIMATION_DISABLED = "animation_disabled"; // 禁用动画,但是这里可能会带来闪屏现象
private static final String KEY_SOUNDTRIGGER_DISABLED = "soundtrigger_disabled"; // 禁用触摸声音
private static final String KEY_FIREWALL_DISABLED = "firewall_disabled"; // 联网防火墙
private static final String KEY_ADJUST_BRIGHTNESS_DISABLED = "adjust_brightness_disabled";// 屏幕亮度省电
private static final String KEY_DATASAVER_DISABLED = "datasaver_disabled"; // 流量节省
private static final String KEY_LAUNCH_BOOST_DISABLED = "launch_boost_disabled"; // 启动加速
private static final String KEY_ADJUST_BRIGHTNESS_FACTOR = "adjust_brightness_factor"; // 屏幕亮度
private static final String KEY_FULLBACKUP_DEFERRED = "fullbackup_deferred"; // 新机制
private static final String KEY_KEYVALUE_DEFERRED = "keyvaluebackup_deferred";// 新机制
private static final String KEY_FORCE_ALL_APPS_STANDBY = "force_all_apps_standby";// 新机制
private static final String KEY_FORCE_BACKGROUND_CHECK = "force_background_check";// 新机制
private static final String KEY_OPTIONAL_SENSORS_DISABLED = "optional_sensors_disabled";// 新机制 传感器省电
private static final String KEY_AOD_DISABLED = "aod_disabled";
private static final String KEY_SEND_TRON_LOG = "send_tron_log";
private static final String KEY_CPU_FREQ_INTERACTIVE = "cpufreq-i"; // CPU模式切换
private static final String KEY_CPU_FREQ_NONINTERACTIVE = "cpufreq-n";
private final Object mLock;
private final Handler mHandler;