diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 9277daec7027c..dd0b1ee83e146 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -1165,6 +1165,10 @@ 15 + + + 5 diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index d68681d8c51d7..87fdc1fb575ba 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3463,6 +3463,7 @@ + diff --git a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java index f7b16f8b18db2..c8c05a0f0bb67 100644 --- a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java @@ -22,6 +22,7 @@ import android.content.Intent; import android.os.PowerManager; import android.provider.Settings.Global; import android.provider.Settings.Secure; +import android.text.TextUtils; import android.util.KeyValueListParser; import android.util.Log; import android.util.Slog; @@ -176,4 +177,22 @@ public class BatterySaverUtils { setAutoBatterySaverTriggerLevel(context, level); } } + + /** + * Reverts battery saver schedule mode to none if we are in a bad state where routine mode + * is selected but no app is configured to actually provide the signal. + * @param context a valid context + */ + public static void revertScheduleToNoneIfNeeded(Context context) { + ContentResolver resolver = context.getContentResolver(); + final int currentMode = Global.getInt(resolver, Global.AUTOMATIC_POWER_SAVER_MODE, + PowerManager.POWER_SAVER_MODE_PERCENTAGE); + boolean providerConfigured = !TextUtils.isEmpty(context.getString( + com.android.internal.R.string.config_batterySaverScheduleProvider)); + if (currentMode == PowerManager.POWER_SAVER_MODE_DYNAMIC && !providerConfigured) { + Global.putInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0); + Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVER_MODE, + PowerManager.POWER_SAVER_MODE_PERCENTAGE); + } + } }