summaryrefslogtreecommitdiff
path: root/core/java/android/os/PowerManager.java
diff options
context:
space:
mode:
authorKweku Adams <kwekua@google.com>2019-01-14 16:25:08 -0800
committerKweku Adams <kwekua@google.com>2019-01-30 15:38:25 -0800
commit9f488e2eaebc6b2a7aa9ef74ec7fae36db062371 (patch)
tree730749ea63d060c054580f9e5ad855f75df79108 /core/java/android/os/PowerManager.java
parent1ebc40339a7102f95a3938703ff1f20e41c45ed8 (diff)
Adding support for adaptive battery saver.
Adaptive battery saver is a state that can be entered into dynamically without the user turning on full EBS. With this, some features of battery saver can be enabled to save power before the user needs to have EBS turned on. Bug: 119261320 Bug: 32423528 Test: atest android.provider.SettingsBackupTest Test: atest com.android.server.power.PowerManagerServiceTest Test: atest com.android.server.power.batterysaver.BatterySaverPolicyTest Test: atest com.android.server.power.batterysaver.BatterySaverStateMachineTest Test: atest com.android.server.power.batterysaver.BatterySavingStatsTest Test: atest CtsBatterySavingTestCases Change-Id: Ib11ea069828275d788e20cd2e858375eaaea888e
Diffstat (limited to 'core/java/android/os/PowerManager.java')
-rw-r--r--core/java/android/os/PowerManager.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 7f4254e29aaa..0441ba27dcd4 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -640,6 +640,9 @@ public final class PowerManager {
*/
public static final int LOCATION_MODE_FOREGROUND_ONLY = 3;
+ static final int MIN_LOCATION_MODE = LOCATION_MODE_NO_CHANGE;
+ static final int MAX_LOCATION_MODE = LOCATION_MODE_FOREGROUND_ONLY;
+
/**
* @hide
*/
@@ -1272,6 +1275,48 @@ public final class PowerManager {
}
/**
+ * Sets the policy for adaptive power save.
+ *
+ * @return true if there was an effectual change. If full battery saver is enabled or the
+ * adaptive policy is not enabled, then this will return false.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.DEVICE_POWER,
+ android.Manifest.permission.POWER_SAVER
+ })
+ public boolean setAdaptivePowerSavePolicy(@NonNull BatterySaverPolicyConfig config) {
+ try {
+ return mService.setAdaptivePowerSavePolicy(config);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Enables or disables adaptive power save.
+ *
+ * @return true if there was an effectual change. If full battery saver is enabled, then this
+ * will return false.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.DEVICE_POWER,
+ android.Manifest.permission.POWER_SAVER
+ })
+ public boolean setAdaptivePowerSaveEnabled(boolean enabled) {
+ try {
+ return mService.setAdaptivePowerSaveEnabled(enabled);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Indicates automatic battery saver toggling by the system will be based on percentage.
*
* @see PowerManager#getPowerSaveMode()