Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1404787c authored by Ludvig Hansson's avatar Ludvig Hansson Committed by Sijie Chen
Browse files

make battery saver configurable

Add configuration to disable the battery saver.

Bug: 245808850
Fixed: 272527415

Test: atest FrameworksServicesTests:com.android.server.power.PowerManagerServiceTest
atest FrameworksServicesTests:com.android.server.power.NotifierTest

Change-Id: Idb5c42a57e2f77294a7f99cefa86e7c4f9730e41
parent 192ac4d6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2358,6 +2358,7 @@ package android.os {
  public final class PowerManager {
    method public boolean areAutoPowerSaveModesEnabled();
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_LOW_POWER_STANDBY, android.Manifest.permission.DEVICE_POWER}) public void forceLowPowerStandbyActive(boolean);
    method public boolean isBatterySaverSupported();
    field public static final String ACTION_ENHANCED_DISCHARGE_PREDICTION_CHANGED = "android.os.action.ENHANCED_DISCHARGE_PREDICTION_CHANGED";
    field @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public static final int SYSTEM_WAKELOCK = -2147483648; // 0x80000000
  }
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ interface IPowerManager
    boolean isPowerSaveMode();
    PowerSaveState getPowerSaveState(int serviceType);
    boolean setPowerSaveModeEnabled(boolean mode);
    boolean isBatterySaverSupported();
    BatterySaverPolicyConfig getFullPowerSavePolicy();
    boolean setFullPowerSavePolicy(in BatterySaverPolicyConfig config);
    boolean setDynamicPowerSaveHint(boolean powerSaveHint, int disableThreshold);
+14 −0
Original line number Diff line number Diff line
@@ -1935,6 +1935,20 @@ public final class PowerManager {
        }
    }

    /**
     * Returns true if Battery Saver is supported on this device.
     *
     * @hide
     */
    @TestApi
    public boolean isBatterySaverSupported() {
        try {
            return mService.isBatterySaverSupported();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Gets the current policy for full power save mode.
     *
+4 −0
Original line number Diff line number Diff line
@@ -26,6 +26,10 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string translatable="false" name="config_batterySaverDeviceSpecificConfig"></string>

    <!-- Whether or not the device supports battery saver. If false, battery saver will be
     disabled. -->
    <bool name="config_batterySaverSupported">true</bool>

    <!-- Whether or not battery saver should be "sticky" when manually enabled. -->
    <bool name="config_batterySaverStickyBehaviourDisabled">false</bool>

+1 −0
Original line number Diff line number Diff line
@@ -4012,6 +4012,7 @@

  <!-- Battery saver config -->
  <java-symbol type="integer" name="config_lowBatteryAutoTriggerDefaultLevel" />
  <java-symbol type="bool" name="config_batterySaverSupported" />
  <java-symbol type="string" name="config_batterySaverDeviceSpecificConfig" />
  <java-symbol type="bool" name="config_batterySaverStickyBehaviourDisabled" />
  <java-symbol type="integer" name="config_dynamicPowerSavingsDefaultDisableThreshold" />
Loading