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

Commit 45a772e4 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Update the comment on LOW_POWER_MODE_TRIGGER_LEVEL in PowerUI

I originally envisioned to keep this logic and the one in the
battery service (which decides when to send a LOW_BATTERY broadcast)
in sync.

However, because this PowerUI logic decides when to show the "battery low"
notification, and showing the notification when the battery level
is still 50% doesn't really make sense even when the battery saver
starts at 50%, so let's only cap the value in PowerUI.

So if LOW_POWER_MODE_TRIGGER_LEVEL is 50,
- Battery saver kicks in at battery level 50%
- LOW_BATTERY broadcast is also sent at 50%

- But we don't show the "battery low" notification until 15% still.

(I'll talk with the PM and we might tweak the details.)

Bug: 71707409
Test: build & boot
Change-Id: I162dc722a6f634e5844ed81385a8463797634a02
parent 64dd7468
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -10750,14 +10750,14 @@ public final class Settings {
        public static final String LOW_POWER_MODE = "low_power";

        /**
         * Battery level [1-99] at which low power mode automatically turns on.
         * Battery level [1-100] at which low power mode automatically turns on.
         * If 0, it will not automatically turn on.
         * @hide
         */
        public static final String LOW_POWER_MODE_TRIGGER_LEVEL = "low_power_trigger_level";

        private static final Validator LOW_POWER_MODE_TRIGGER_LEVEL_VALIDATOR =
                new SettingsValidators.InclusiveIntegerRangeValidator(0, 99);
                new SettingsValidators.InclusiveIntegerRangeValidator(0, 100);

         /**
         * If not 0, the activity manager will aggressively finish activities and
+6 −2
Original line number Diff line number Diff line
@@ -141,8 +141,12 @@ public class PowerUI extends SystemUI {
        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.
        // Note LOW_POWER_MODE_TRIGGER_LEVEL can take any value between 0 and 100, but
        // for the UI purposes, let's cap it at 15% -- i.e. even if the trigger level is higher
        // like 50%, let's not show the "low battery" notification until it hits
        // config_lowBatteryWarningLevel, which is 15% by default.
        // LOW_POWER_MODE_TRIGGER_LEVEL is still used in other places as-is. For example, if it's
        // 50, then battery saver kicks in when the battery level hits 50%.
        int warnLevel =  Math.min(defWarnLevel, lowPowerModeTriggerLevel);

        if (warnLevel == 0) {