Cap the low battery threshold at config_lowBatteryWarningLevel (=15)
Currently it doesn't matter because LOW_POWER_MODE_TRIGGER_LEVEL can be 15% at most and config_lowBatteryWarningLevel is 15, but because we'll allow bigger LOW_POWER_MODE_TRIGGER_LEVEL, we don't want to do the low battery warning at a battery level too high. Bug: 71707409 Test: manual test with "dumpsys battery unplug" and "dumpsys battery set level XX" Change-Id: Ibd3646decef243bbed21c148134ab1d3930bea14
This commit is contained in:
@@ -293,10 +293,13 @@ public final class BatteryService extends SystemService {
|
||||
|
||||
private void updateBatteryWarningLevelLocked() {
|
||||
final ContentResolver resolver = mContext.getContentResolver();
|
||||
int defWarnLevel = mContext.getResources().getInteger(
|
||||
final int defWarnLevel = mContext.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_lowBatteryWarningLevel);
|
||||
mLowBatteryWarningLevel = Settings.Global.getInt(resolver,
|
||||
final int lowPowerModeTriggerLevel = Settings.Global.getInt(resolver,
|
||||
Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, defWarnLevel);
|
||||
|
||||
mLowBatteryWarningLevel = Math.min(defWarnLevel, lowPowerModeTriggerLevel);
|
||||
|
||||
if (mLowBatteryWarningLevel == 0) {
|
||||
mLowBatteryWarningLevel = defWarnLevel;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user