Loading core/java/android/provider/Settings.java +31 −1 Original line number Diff line number Diff line Loading @@ -12193,6 +12193,31 @@ public final class Settings { @TestApi public static final String LOW_POWER_MODE_STICKY = "low_power_sticky"; /** * When a device is unplugged from a changer (or is rebooted), do not re-activate battery * saver even if {@link #LOW_POWER_MODE_STICKY} is 1, if the battery level is equal to or * above this threshold. * * @hide */ public static final String LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL = "low_power_sticky_auto_disable_level"; private static final Validator LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL_VALIDATOR = new SettingsValidators.InclusiveIntegerRangeValidator(0, 100); /** * Whether sticky battery saver should be deactivated once the battery level has reached the * threshold specified by {@link #LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL}. * * @hide */ public static final String LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED = "low_power_sticky_auto_disable_enabled"; private static final Validator LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED_VALIDATOR = new SettingsValidators.DiscreteValueValidator(new String[] {"0", "1"}); /** * Battery level [1-100] at which low power mode automatically turns on. * Pre-Q If 0, it will not automatically turn on. Q and newer it will only automatically Loading @@ -12205,7 +12230,6 @@ public final class Settings { */ public static final String LOW_POWER_MODE_TRIGGER_LEVEL = "low_power_trigger_level"; private static final Validator LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR = new SettingsValidators.InclusiveIntegerRangeValidator(0, 100); Loading Loading @@ -13196,6 +13220,8 @@ public final class Settings { ENCODED_SURROUND_OUTPUT, ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS, LOW_POWER_MODE_TRIGGER_LEVEL, LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, BLUETOOTH_ON, PRIVATE_DNS_MODE, PRIVATE_DNS_SPECIFIER, Loading Loading @@ -13234,6 +13260,10 @@ public final class Settings { VALIDATORS.put(ENCODED_SURROUND_OUTPUT, ENCODED_SURROUND_OUTPUT_VALIDATOR); VALIDATORS.put(ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS, ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS_VALIDATOR); VALIDATORS.put(LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL_VALIDATOR); VALIDATORS.put(LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED_VALIDATOR); VALIDATORS.put(LOW_POWER_MODE_TRIGGER_LEVEL, LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR); VALIDATORS.put(LOW_POWER_MODE_TRIGGER_LEVEL_MAX, LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR); core/proto/android/providers/settings/global.proto +10 −0 Original line number Diff line number Diff line Loading @@ -535,6 +535,16 @@ message GlobalSettingsProto { // Whether automatic battery saver mode is controlled via percentage, // {@link #DYNAMIC_POWER_SAVINGS_ENABLED} or disabled. optional SettingProto automatic_power_saver_mode = 4 [ (android.privacy).dest = DEST_AUTOMATIC]; // If 1, battery saver (low_power_mode) will be re-activated after the device is // unplugged from a charger or rebooted. optional SettingProto sticky_enabled = 5; // Whether sticky battery saver should be deactivated once the battery level has reached the // threshold specified by sticky_disable_level. optional SettingProto sticky_auto_disable_enabled = 6; // When a device is unplugged from a changer (or is rebooted), do not re-activate battery // saver even if {@link #LOW_POWER_MODE_STICKY} is 1, if the battery level is equal to or // above this threshold. optional SettingProto sticky_auto_disable_level = 7; } optional LowPowerMode low_power_mode = 70; Loading core/proto/android/server/powermanagerservice.proto +8 −0 Original line number Diff line number Diff line Loading @@ -350,4 +350,12 @@ message BatterySaverStateMachineProto { // The value of Global.LOW_POWER_MODE_TRIGGER_LEVEL. This is a cached value, so it could // be slightly different from what's in GlobalSettingsProto.LowPowerMode. optional int32 setting_battery_saver_trigger_threshold = 11; // The value of Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED. This is a cached value, so // it could be slightly different from what's in GlobalSettingsProto.LowPowerMode. optional bool setting_battery_saver_sticky_auto_disable_enabled = 12; // The value of Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL. This is a cached value, so it // could be slightly different from what's in GlobalSettingsProto.LowPowerMode. optional int32 setting_battery_saver_sticky_auto_disable_threshold = 13; } packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +15 −7 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.providers.settings; import android.annotation.NonNull; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings.Global; import android.providers.settings.GlobalSettingsProto; import android.providers.settings.SecureSettingsProto; import android.providers.settings.SettingProto; Loading Loading @@ -397,7 +396,7 @@ class SettingsProtoDumpUtil { p.end(certPinToken); dumpSetting(s, p, Global.CHAINED_BATTERY_ATTRIBUTION_ENABLED, Settings.Global.CHAINED_BATTERY_ATTRIBUTION_ENABLED, GlobalSettingsProto.CHAINED_BATTERY_ATTRIBUTION_ENABLED); dumpSetting(s, p, Settings.Global.COMPATIBILITY_MODE, Loading Loading @@ -737,7 +736,7 @@ class SettingsProtoDumpUtil { Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED, GlobalSettingsProto.HEADS_UP_NOTIFICATIONS_ENABLED); dumpSetting(s, p, Global.HIDDEN_API_BLACKLIST_EXEMPTIONS, Settings.Global.HIDDEN_API_BLACKLIST_EXEMPTIONS, GlobalSettingsProto.HIDDEN_API_BLACKLIST_EXEMPTIONS); final long inetCondToken = p.start(GlobalSettingsProto.INET_CONDITION); Loading Loading @@ -832,6 +831,15 @@ class SettingsProtoDumpUtil { dumpSetting(s, p, Settings.Global.AUTOMATIC_POWER_SAVER_MODE, GlobalSettingsProto.LowPowerMode.AUTOMATIC_POWER_SAVER_MODE); dumpSetting(s, p, Settings.Global.LOW_POWER_MODE_STICKY, GlobalSettingsProto.LowPowerMode.STICKY_ENABLED); dumpSetting(s, p, Settings.Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, GlobalSettingsProto.LowPowerMode.STICKY_AUTO_DISABLE_ENABLED); dumpSetting(s, p, Settings.Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, GlobalSettingsProto.LowPowerMode.STICKY_AUTO_DISABLE_LEVEL); p.end(lpmToken); dumpSetting(s, p, Loading Loading @@ -882,7 +890,7 @@ class SettingsProtoDumpUtil { p.end(multiSimToken); dumpSetting(s, p, Global.NATIVE_FLAGS_HEALTH_CHECK_ENABLED, Settings.Global.NATIVE_FLAGS_HEALTH_CHECK_ENABLED, GlobalSettingsProto.NATIVE_FLAGS_HEALTH_CHECK_ENABLED); final long netstatsToken = p.start(GlobalSettingsProto.NETSTATS); Loading Loading @@ -1259,10 +1267,10 @@ class SettingsProtoDumpUtil { final long soundTriggerToken = p.start(GlobalSettingsProto.SOUND_TRIGGER); dumpSetting(s, p, Global.MAX_SOUND_TRIGGER_DETECTION_SERVICE_OPS_PER_DAY, Settings.Global.MAX_SOUND_TRIGGER_DETECTION_SERVICE_OPS_PER_DAY, GlobalSettingsProto.SoundTrigger.MAX_SOUND_TRIGGER_DETECTION_SERVICE_OPS_PER_DAY); dumpSetting(s, p, Global.SOUND_TRIGGER_DETECTION_SERVICE_OP_TIMEOUT, Settings.Global.SOUND_TRIGGER_DETECTION_SERVICE_OP_TIMEOUT, GlobalSettingsProto.SoundTrigger.DETECTION_SERVICE_OP_TIMEOUT_MS); p.end(soundTriggerToken); Loading Loading @@ -1558,7 +1566,7 @@ class SettingsProtoDumpUtil { GlobalSettingsProto.ZRAM_ENABLED); dumpSetting(s, p, Global.APP_OPS_CONSTANTS, Settings.Global.APP_OPS_CONSTANTS, GlobalSettingsProto.APP_OPS_CONSTANTS); p.end(token); Loading services/core/java/com/android/server/power/batterysaver/BatterySaverController.java +1 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ public class BatterySaverController implements BatterySaverPolicyListener { public static final int REASON_SETTING_CHANGED = 8; public static final int REASON_DYNAMIC_POWER_SAVINGS_AUTOMATIC_ON = 9; public static final int REASON_DYNAMIC_POWER_SAVINGS_AUTOMATIC_OFF = 10; public static final int REASON_STICKY_RESTORE_OFF = 13; /** * Plugin interface. All methods are guaranteed to be called on the same (handler) thread. Loading Loading
core/java/android/provider/Settings.java +31 −1 Original line number Diff line number Diff line Loading @@ -12193,6 +12193,31 @@ public final class Settings { @TestApi public static final String LOW_POWER_MODE_STICKY = "low_power_sticky"; /** * When a device is unplugged from a changer (or is rebooted), do not re-activate battery * saver even if {@link #LOW_POWER_MODE_STICKY} is 1, if the battery level is equal to or * above this threshold. * * @hide */ public static final String LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL = "low_power_sticky_auto_disable_level"; private static final Validator LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL_VALIDATOR = new SettingsValidators.InclusiveIntegerRangeValidator(0, 100); /** * Whether sticky battery saver should be deactivated once the battery level has reached the * threshold specified by {@link #LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL}. * * @hide */ public static final String LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED = "low_power_sticky_auto_disable_enabled"; private static final Validator LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED_VALIDATOR = new SettingsValidators.DiscreteValueValidator(new String[] {"0", "1"}); /** * Battery level [1-100] at which low power mode automatically turns on. * Pre-Q If 0, it will not automatically turn on. Q and newer it will only automatically Loading @@ -12205,7 +12230,6 @@ public final class Settings { */ public static final String LOW_POWER_MODE_TRIGGER_LEVEL = "low_power_trigger_level"; private static final Validator LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR = new SettingsValidators.InclusiveIntegerRangeValidator(0, 100); Loading Loading @@ -13196,6 +13220,8 @@ public final class Settings { ENCODED_SURROUND_OUTPUT, ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS, LOW_POWER_MODE_TRIGGER_LEVEL, LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, BLUETOOTH_ON, PRIVATE_DNS_MODE, PRIVATE_DNS_SPECIFIER, Loading Loading @@ -13234,6 +13260,10 @@ public final class Settings { VALIDATORS.put(ENCODED_SURROUND_OUTPUT, ENCODED_SURROUND_OUTPUT_VALIDATOR); VALIDATORS.put(ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS, ENCODED_SURROUND_OUTPUT_ENABLED_FORMATS_VALIDATOR); VALIDATORS.put(LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL_VALIDATOR); VALIDATORS.put(LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED_VALIDATOR); VALIDATORS.put(LOW_POWER_MODE_TRIGGER_LEVEL, LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR); VALIDATORS.put(LOW_POWER_MODE_TRIGGER_LEVEL_MAX, LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR);
core/proto/android/providers/settings/global.proto +10 −0 Original line number Diff line number Diff line Loading @@ -535,6 +535,16 @@ message GlobalSettingsProto { // Whether automatic battery saver mode is controlled via percentage, // {@link #DYNAMIC_POWER_SAVINGS_ENABLED} or disabled. optional SettingProto automatic_power_saver_mode = 4 [ (android.privacy).dest = DEST_AUTOMATIC]; // If 1, battery saver (low_power_mode) will be re-activated after the device is // unplugged from a charger or rebooted. optional SettingProto sticky_enabled = 5; // Whether sticky battery saver should be deactivated once the battery level has reached the // threshold specified by sticky_disable_level. optional SettingProto sticky_auto_disable_enabled = 6; // When a device is unplugged from a changer (or is rebooted), do not re-activate battery // saver even if {@link #LOW_POWER_MODE_STICKY} is 1, if the battery level is equal to or // above this threshold. optional SettingProto sticky_auto_disable_level = 7; } optional LowPowerMode low_power_mode = 70; Loading
core/proto/android/server/powermanagerservice.proto +8 −0 Original line number Diff line number Diff line Loading @@ -350,4 +350,12 @@ message BatterySaverStateMachineProto { // The value of Global.LOW_POWER_MODE_TRIGGER_LEVEL. This is a cached value, so it could // be slightly different from what's in GlobalSettingsProto.LowPowerMode. optional int32 setting_battery_saver_trigger_threshold = 11; // The value of Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED. This is a cached value, so // it could be slightly different from what's in GlobalSettingsProto.LowPowerMode. optional bool setting_battery_saver_sticky_auto_disable_enabled = 12; // The value of Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL. This is a cached value, so it // could be slightly different from what's in GlobalSettingsProto.LowPowerMode. optional int32 setting_battery_saver_sticky_auto_disable_threshold = 13; }
packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +15 −7 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.providers.settings; import android.annotation.NonNull; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings.Global; import android.providers.settings.GlobalSettingsProto; import android.providers.settings.SecureSettingsProto; import android.providers.settings.SettingProto; Loading Loading @@ -397,7 +396,7 @@ class SettingsProtoDumpUtil { p.end(certPinToken); dumpSetting(s, p, Global.CHAINED_BATTERY_ATTRIBUTION_ENABLED, Settings.Global.CHAINED_BATTERY_ATTRIBUTION_ENABLED, GlobalSettingsProto.CHAINED_BATTERY_ATTRIBUTION_ENABLED); dumpSetting(s, p, Settings.Global.COMPATIBILITY_MODE, Loading Loading @@ -737,7 +736,7 @@ class SettingsProtoDumpUtil { Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED, GlobalSettingsProto.HEADS_UP_NOTIFICATIONS_ENABLED); dumpSetting(s, p, Global.HIDDEN_API_BLACKLIST_EXEMPTIONS, Settings.Global.HIDDEN_API_BLACKLIST_EXEMPTIONS, GlobalSettingsProto.HIDDEN_API_BLACKLIST_EXEMPTIONS); final long inetCondToken = p.start(GlobalSettingsProto.INET_CONDITION); Loading Loading @@ -832,6 +831,15 @@ class SettingsProtoDumpUtil { dumpSetting(s, p, Settings.Global.AUTOMATIC_POWER_SAVER_MODE, GlobalSettingsProto.LowPowerMode.AUTOMATIC_POWER_SAVER_MODE); dumpSetting(s, p, Settings.Global.LOW_POWER_MODE_STICKY, GlobalSettingsProto.LowPowerMode.STICKY_ENABLED); dumpSetting(s, p, Settings.Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, GlobalSettingsProto.LowPowerMode.STICKY_AUTO_DISABLE_ENABLED); dumpSetting(s, p, Settings.Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, GlobalSettingsProto.LowPowerMode.STICKY_AUTO_DISABLE_LEVEL); p.end(lpmToken); dumpSetting(s, p, Loading Loading @@ -882,7 +890,7 @@ class SettingsProtoDumpUtil { p.end(multiSimToken); dumpSetting(s, p, Global.NATIVE_FLAGS_HEALTH_CHECK_ENABLED, Settings.Global.NATIVE_FLAGS_HEALTH_CHECK_ENABLED, GlobalSettingsProto.NATIVE_FLAGS_HEALTH_CHECK_ENABLED); final long netstatsToken = p.start(GlobalSettingsProto.NETSTATS); Loading Loading @@ -1259,10 +1267,10 @@ class SettingsProtoDumpUtil { final long soundTriggerToken = p.start(GlobalSettingsProto.SOUND_TRIGGER); dumpSetting(s, p, Global.MAX_SOUND_TRIGGER_DETECTION_SERVICE_OPS_PER_DAY, Settings.Global.MAX_SOUND_TRIGGER_DETECTION_SERVICE_OPS_PER_DAY, GlobalSettingsProto.SoundTrigger.MAX_SOUND_TRIGGER_DETECTION_SERVICE_OPS_PER_DAY); dumpSetting(s, p, Global.SOUND_TRIGGER_DETECTION_SERVICE_OP_TIMEOUT, Settings.Global.SOUND_TRIGGER_DETECTION_SERVICE_OP_TIMEOUT, GlobalSettingsProto.SoundTrigger.DETECTION_SERVICE_OP_TIMEOUT_MS); p.end(soundTriggerToken); Loading Loading @@ -1558,7 +1566,7 @@ class SettingsProtoDumpUtil { GlobalSettingsProto.ZRAM_ENABLED); dumpSetting(s, p, Global.APP_OPS_CONSTANTS, Settings.Global.APP_OPS_CONSTANTS, GlobalSettingsProto.APP_OPS_CONSTANTS); p.end(token); Loading
services/core/java/com/android/server/power/batterysaver/BatterySaverController.java +1 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ public class BatterySaverController implements BatterySaverPolicyListener { public static final int REASON_SETTING_CHANGED = 8; public static final int REASON_DYNAMIC_POWER_SAVINGS_AUTOMATIC_ON = 9; public static final int REASON_DYNAMIC_POWER_SAVINGS_AUTOMATIC_OFF = 10; public static final int REASON_STICKY_RESTORE_OFF = 13; /** * Plugin interface. All methods are guaranteed to be called on the same (handler) thread. Loading