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

Commit 4a9036bf authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Keep PowerUI low-battery logic in sync with BatteryService.

BatteryService has been updated already.

Bug: 71707409
Test: Manual test with dumpsys activity service com.android.systemui/.SystemUIService

Change-Id: I5a54a209b4929bf70a665e3b539a63d06eca61d4
parent 422a6798
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -131,10 +131,15 @@ public class PowerUI extends SystemUI {
                com.android.internal.R.integer.config_criticalBatteryWarningLevel);

        final ContentResolver resolver = mContext.getContentResolver();
        int defWarnLevel = mContext.getResources().getInteger(
        final int defWarnLevel = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_lowBatteryWarningLevel);
        int warnLevel = Settings.Global.getInt(resolver,
        final int lowPowerModeTriggerLevel = Settings.Global.getInt(resolver,
                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, defWarnLevel);

        // NOTE: Keep the logic in sync with BatteryService.
        // TODO: Propagate this value from BatteryService to system UI, really.
        int warnLevel =  Math.min(defWarnLevel, lowPowerModeTriggerLevel);

        if (warnLevel == 0) {
            warnLevel = defWarnLevel;
        }
+2 −0
Original line number Diff line number Diff line
@@ -298,6 +298,8 @@ public final class BatteryService extends SystemService {
        final int lowPowerModeTriggerLevel = Settings.Global.getInt(resolver,
                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, defWarnLevel);

        // NOTE: Keep the logic in sync with PowerUI.java in systemUI.
        // TODO: Propagate this value from BatteryService to system UI, really.
        mLowBatteryWarningLevel = Math.min(defWarnLevel, lowPowerModeTriggerLevel);

        if (mLowBatteryWarningLevel == 0) {