Loading api/system-current.txt +4 −0 Original line number Diff line number Diff line Loading @@ -4109,8 +4109,12 @@ package android.os { } public final class PowerManager { method public int getPowerSaveMode(); method public boolean setDynamicPowerSavings(boolean, int); method public boolean setPowerSaveMode(boolean); method public void userActivity(long, int, int); field public static final int POWER_SAVER_MODE_DYNAMIC = 1; // 0x1 field public static final int POWER_SAVER_MODE_PERCENTAGE = 0; // 0x0 field public static final int USER_ACTIVITY_EVENT_ACCESSIBILITY = 3; // 0x3 field public static final int USER_ACTIVITY_EVENT_BUTTON = 1; // 0x1 field public static final int USER_ACTIVITY_EVENT_OTHER = 0; // 0x0 Loading api/test-current.txt +7 −0 Original line number Diff line number Diff line Loading @@ -744,7 +744,11 @@ package android.os { } public final class PowerManager { method public int getPowerSaveMode(); method public boolean setDynamicPowerSavings(boolean, int); method public boolean setPowerSaveMode(boolean); field public static final int POWER_SAVER_MODE_DYNAMIC = 1; // 0x1 field public static final int POWER_SAVER_MODE_PERCENTAGE = 0; // 0x0 } public class Process { Loading Loading @@ -981,6 +985,9 @@ package android.provider { public static final class Settings.Global extends android.provider.Settings.NameValueTable { field public static final java.lang.String AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES = "autofill_compat_mode_allowed_packages"; field public static final java.lang.String AUTOMATIC_POWER_SAVER_MODE = "automatic_power_saver_mode"; field public static final java.lang.String DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD = "dynamic_power_savings_disable_threshold"; field public static final java.lang.String DYNAMIC_POWER_SAVINGS_ENABLED = "dynamic_power_savings_enabled"; field public static final java.lang.String HIDDEN_API_BLACKLIST_EXEMPTIONS = "hidden_api_blacklist_exemptions"; field public static final java.lang.String LOCATION_GLOBAL_KILL_SWITCH = "location_global_kill_switch"; field public static final java.lang.String LOW_POWER_MODE = "low_power"; Loading core/java/android/os/IPowerManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,8 @@ interface IPowerManager boolean isPowerSaveMode(); PowerSaveState getPowerSaveState(int serviceType); boolean setPowerSaveMode(boolean mode); boolean setDynamicPowerSavings(boolean dynamicPowerSavingsEnabled, int disableThreshold); int getPowerSaveMode(); boolean isDeviceIdleMode(); boolean isLightDeviceIdleMode(); Loading core/java/android/os/PowerManager.java +100 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.os; import android.Manifest.permission; import android.annotation.IntDef; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; Loading Loading @@ -1184,6 +1185,105 @@ public final class PowerManager { } } /** * Updates the current state of dynamic power savings and disable threshold. This is * a signal to the system which an app can update to serve as an indicator that * the user will be in a battery critical situation before being able to plug in. * Only apps with the {@link android.Manifest.permission#POWER_SAVER} permission may do this. * This is a device global state, not a per user setting. * * <p>When enabled, the system may enact various measures for reducing power consumption in * order to help ensure that the user will make it to their next charging point. The most * visible of these will be the automatic enabling of battery saver if the user has set * their battery saver mode to "automatic". Note * that this is NOT simply an on/off switch for features, but rather a hint for the * system to consider enacting these power saving features, some of which have additional * logic around when to activate based on this signal. * * <p>The provided threshold is the percentage the system should consider itself safe at given * the current state of the device. The value is an integer representing a battery level. * * <p>The threshold is meant to set an explicit stopping point for dynamic power savings * functionality so that the dynamic power savings itself remains a signal rather than becoming * an on/off switch for a subset of features. * @hide * * @param dynamicPowerSavingsEnabled A signal indicating to the system if it believes the * dynamic power savings behaviors should be activated. * @param disableThreshold When the suggesting app believes it would be safe to disable dynamic * power savings behaviors. * @return True if the update was allowed and succeeded. * * @hide */ @SystemApi @TestApi @RequiresPermission(permission.POWER_SAVER) public boolean setDynamicPowerSavings(boolean dynamicPowerSavingsEnabled, int disableThreshold) { try { return mService.setDynamicPowerSavings(dynamicPowerSavingsEnabled, disableThreshold); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Indicates automatic battery saver toggling by the system will be based on percentage. * * @see PowerManager#getPowerSaveMode() * * @hide */ @SystemApi @TestApi public static final int POWER_SAVER_MODE_PERCENTAGE = 0; /** * Indicates automatic battery saver toggling by the system will be based on the state * of the dynamic power savings signal. * * @see PowerManager#setDynamicPowerSavings(boolean, int) * @see PowerManager#getPowerSaveMode() * * @hide */ @SystemApi @TestApi public static final int POWER_SAVER_MODE_DYNAMIC = 1; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(value = { POWER_SAVER_MODE_PERCENTAGE, POWER_SAVER_MODE_DYNAMIC }) public @interface AutoPowerSaverMode{} /** * Returns the current battery saver control mode. Values it may return are defined in * AutoPowerSaverMode. Note that this is a global device state, not a per user setting. * * @return The current value power saver mode for the system. * * @see AutoPowerSaverMode * @see PowerManager#getPowerSaveMode() * @hide */ @AutoPowerSaverMode @SystemApi @TestApi @RequiresPermission(android.Manifest.permission.POWER_SAVER) public int getPowerSaveMode() { try { return mService.getPowerSaveMode(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Get data about the battery saver mode for a specific service * @param serviceType unique key for the service, one of {@link ServiceType} Loading core/java/android/provider/Settings.java +44 −1 Original line number Diff line number Diff line Loading @@ -11811,14 +11811,54 @@ public final class Settings { /** * Battery level [1-100] at which low power mode automatically turns on. * If 0, it will not automatically turn on. * Pre-Q If 0, it will not automatically turn on. Q and newer it will only automatically * turn on if the {@link #AUTOMATIC_POWER_SAVER_MODE} setting is also set to * {@link android.os.PowerManager.AutoPowerSaverMode#POWER_SAVER_MODE_PERCENTAGE}. * * @see #AUTOMATIC_POWER_SAVER_MODE * @see android.os.PowerManager#getPowerSaveMode() * @hide */ 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); /** * Whether battery saver is currently set to trigger based on percentage, dynamic power * savings trigger, or none. See {@link android.os.PowerManager.AutoPowerSaverMode} for * accepted values. * * @hide */ @TestApi public static final String AUTOMATIC_POWER_SAVER_MODE = "automatic_power_saver_mode"; private static final Validator AUTOMATIC_POWER_SAVER_MODE_VALIDATOR = new SettingsValidators.DiscreteValueValidator(new String[] {"0", "1"}); /** * The setting that backs the disable threshold for the setPowerSavingsWarning api in * PowerManager * * @see android.os.PowerManager#setDynamicPowerSavings(boolean, int) * @hide */ @TestApi public static final String DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD = "dynamic_power_savings_disable_threshold"; private static final Validator DYNAMIC_POWER_SAVINGS_VALIDATOR = new SettingsValidators.InclusiveIntegerRangeValidator(0, 100); /** * The setting which backs the setDynamicPowerSavings api in PowerManager. * * @see android.os.PowerManager#setDynamicPowerSavings(boolean, int) * @hide */ @TestApi public static final String DYNAMIC_POWER_SAVINGS_ENABLED = "dynamic_power_savings_enabled"; /** * The max value for {@link #LOW_POWER_MODE_TRIGGER_LEVEL}. If this setting is not set Loading Loading @@ -12742,6 +12782,9 @@ public final class Settings { 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); VALIDATORS.put(AUTOMATIC_POWER_SAVER_MODE, AUTOMATIC_POWER_SAVER_MODE_VALIDATOR); VALIDATORS.put(DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD, DYNAMIC_POWER_SAVINGS_VALIDATOR); VALIDATORS.put(BLUETOOTH_ON, BLUETOOTH_ON_VALIDATOR); VALIDATORS.put(PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_VALIDATOR); VALIDATORS.put(PRIVATE_DNS_SPECIFIER, PRIVATE_DNS_SPECIFIER_VALIDATOR); Loading Loading
api/system-current.txt +4 −0 Original line number Diff line number Diff line Loading @@ -4109,8 +4109,12 @@ package android.os { } public final class PowerManager { method public int getPowerSaveMode(); method public boolean setDynamicPowerSavings(boolean, int); method public boolean setPowerSaveMode(boolean); method public void userActivity(long, int, int); field public static final int POWER_SAVER_MODE_DYNAMIC = 1; // 0x1 field public static final int POWER_SAVER_MODE_PERCENTAGE = 0; // 0x0 field public static final int USER_ACTIVITY_EVENT_ACCESSIBILITY = 3; // 0x3 field public static final int USER_ACTIVITY_EVENT_BUTTON = 1; // 0x1 field public static final int USER_ACTIVITY_EVENT_OTHER = 0; // 0x0 Loading
api/test-current.txt +7 −0 Original line number Diff line number Diff line Loading @@ -744,7 +744,11 @@ package android.os { } public final class PowerManager { method public int getPowerSaveMode(); method public boolean setDynamicPowerSavings(boolean, int); method public boolean setPowerSaveMode(boolean); field public static final int POWER_SAVER_MODE_DYNAMIC = 1; // 0x1 field public static final int POWER_SAVER_MODE_PERCENTAGE = 0; // 0x0 } public class Process { Loading Loading @@ -981,6 +985,9 @@ package android.provider { public static final class Settings.Global extends android.provider.Settings.NameValueTable { field public static final java.lang.String AUTOFILL_COMPAT_MODE_ALLOWED_PACKAGES = "autofill_compat_mode_allowed_packages"; field public static final java.lang.String AUTOMATIC_POWER_SAVER_MODE = "automatic_power_saver_mode"; field public static final java.lang.String DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD = "dynamic_power_savings_disable_threshold"; field public static final java.lang.String DYNAMIC_POWER_SAVINGS_ENABLED = "dynamic_power_savings_enabled"; field public static final java.lang.String HIDDEN_API_BLACKLIST_EXEMPTIONS = "hidden_api_blacklist_exemptions"; field public static final java.lang.String LOCATION_GLOBAL_KILL_SWITCH = "location_global_kill_switch"; field public static final java.lang.String LOW_POWER_MODE = "low_power"; Loading
core/java/android/os/IPowerManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,8 @@ interface IPowerManager boolean isPowerSaveMode(); PowerSaveState getPowerSaveState(int serviceType); boolean setPowerSaveMode(boolean mode); boolean setDynamicPowerSavings(boolean dynamicPowerSavingsEnabled, int disableThreshold); int getPowerSaveMode(); boolean isDeviceIdleMode(); boolean isLightDeviceIdleMode(); Loading
core/java/android/os/PowerManager.java +100 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.os; import android.Manifest.permission; import android.annotation.IntDef; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; Loading Loading @@ -1184,6 +1185,105 @@ public final class PowerManager { } } /** * Updates the current state of dynamic power savings and disable threshold. This is * a signal to the system which an app can update to serve as an indicator that * the user will be in a battery critical situation before being able to plug in. * Only apps with the {@link android.Manifest.permission#POWER_SAVER} permission may do this. * This is a device global state, not a per user setting. * * <p>When enabled, the system may enact various measures for reducing power consumption in * order to help ensure that the user will make it to their next charging point. The most * visible of these will be the automatic enabling of battery saver if the user has set * their battery saver mode to "automatic". Note * that this is NOT simply an on/off switch for features, but rather a hint for the * system to consider enacting these power saving features, some of which have additional * logic around when to activate based on this signal. * * <p>The provided threshold is the percentage the system should consider itself safe at given * the current state of the device. The value is an integer representing a battery level. * * <p>The threshold is meant to set an explicit stopping point for dynamic power savings * functionality so that the dynamic power savings itself remains a signal rather than becoming * an on/off switch for a subset of features. * @hide * * @param dynamicPowerSavingsEnabled A signal indicating to the system if it believes the * dynamic power savings behaviors should be activated. * @param disableThreshold When the suggesting app believes it would be safe to disable dynamic * power savings behaviors. * @return True if the update was allowed and succeeded. * * @hide */ @SystemApi @TestApi @RequiresPermission(permission.POWER_SAVER) public boolean setDynamicPowerSavings(boolean dynamicPowerSavingsEnabled, int disableThreshold) { try { return mService.setDynamicPowerSavings(dynamicPowerSavingsEnabled, disableThreshold); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Indicates automatic battery saver toggling by the system will be based on percentage. * * @see PowerManager#getPowerSaveMode() * * @hide */ @SystemApi @TestApi public static final int POWER_SAVER_MODE_PERCENTAGE = 0; /** * Indicates automatic battery saver toggling by the system will be based on the state * of the dynamic power savings signal. * * @see PowerManager#setDynamicPowerSavings(boolean, int) * @see PowerManager#getPowerSaveMode() * * @hide */ @SystemApi @TestApi public static final int POWER_SAVER_MODE_DYNAMIC = 1; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(value = { POWER_SAVER_MODE_PERCENTAGE, POWER_SAVER_MODE_DYNAMIC }) public @interface AutoPowerSaverMode{} /** * Returns the current battery saver control mode. Values it may return are defined in * AutoPowerSaverMode. Note that this is a global device state, not a per user setting. * * @return The current value power saver mode for the system. * * @see AutoPowerSaverMode * @see PowerManager#getPowerSaveMode() * @hide */ @AutoPowerSaverMode @SystemApi @TestApi @RequiresPermission(android.Manifest.permission.POWER_SAVER) public int getPowerSaveMode() { try { return mService.getPowerSaveMode(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Get data about the battery saver mode for a specific service * @param serviceType unique key for the service, one of {@link ServiceType} Loading
core/java/android/provider/Settings.java +44 −1 Original line number Diff line number Diff line Loading @@ -11811,14 +11811,54 @@ public final class Settings { /** * Battery level [1-100] at which low power mode automatically turns on. * If 0, it will not automatically turn on. * Pre-Q If 0, it will not automatically turn on. Q and newer it will only automatically * turn on if the {@link #AUTOMATIC_POWER_SAVER_MODE} setting is also set to * {@link android.os.PowerManager.AutoPowerSaverMode#POWER_SAVER_MODE_PERCENTAGE}. * * @see #AUTOMATIC_POWER_SAVER_MODE * @see android.os.PowerManager#getPowerSaveMode() * @hide */ 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); /** * Whether battery saver is currently set to trigger based on percentage, dynamic power * savings trigger, or none. See {@link android.os.PowerManager.AutoPowerSaverMode} for * accepted values. * * @hide */ @TestApi public static final String AUTOMATIC_POWER_SAVER_MODE = "automatic_power_saver_mode"; private static final Validator AUTOMATIC_POWER_SAVER_MODE_VALIDATOR = new SettingsValidators.DiscreteValueValidator(new String[] {"0", "1"}); /** * The setting that backs the disable threshold for the setPowerSavingsWarning api in * PowerManager * * @see android.os.PowerManager#setDynamicPowerSavings(boolean, int) * @hide */ @TestApi public static final String DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD = "dynamic_power_savings_disable_threshold"; private static final Validator DYNAMIC_POWER_SAVINGS_VALIDATOR = new SettingsValidators.InclusiveIntegerRangeValidator(0, 100); /** * The setting which backs the setDynamicPowerSavings api in PowerManager. * * @see android.os.PowerManager#setDynamicPowerSavings(boolean, int) * @hide */ @TestApi public static final String DYNAMIC_POWER_SAVINGS_ENABLED = "dynamic_power_savings_enabled"; /** * The max value for {@link #LOW_POWER_MODE_TRIGGER_LEVEL}. If this setting is not set Loading Loading @@ -12742,6 +12782,9 @@ public final class Settings { 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); VALIDATORS.put(AUTOMATIC_POWER_SAVER_MODE, AUTOMATIC_POWER_SAVER_MODE_VALIDATOR); VALIDATORS.put(DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD, DYNAMIC_POWER_SAVINGS_VALIDATOR); VALIDATORS.put(BLUETOOTH_ON, BLUETOOTH_ON_VALIDATOR); VALIDATORS.put(PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_VALIDATOR); VALIDATORS.put(PRIVATE_DNS_SPECIFIER, PRIVATE_DNS_SPECIFIER_VALIDATOR); Loading