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

Commit 1d146e44 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Ensure automatic battery saver won't stick

Fixes: 80527470
Test: Manual tests:
Test 1: (make sure automatic BS won't stick)
- Set up automatic battery saver at N%
- Wait until the battery goes below N% -> Battery saver will turn on
- Turn off the device
- Charge it until the battery goes above N%
- Turn on the device
- Make sure battery saver is off.

Test 1: (make sure manual BS will stick)
- Make sure the battery level is above the automatic threshold
- Manually enable BS
- Reboot
- Make sure battery saver is on.

Change-Id: I677fd586f6b25d0200392941cac2d13b57fe10b3
parent 23621e7f
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -141,8 +141,14 @@ public class BatterySaverStateMachine {
        if (DEBUG) {
            Slog.d(TAG, "onBootCompleted");
        }
        // This is called with the power manager lock held. Don't do any
        // Just booted. We don't want LOW_POWER_MODE to be persisted, so just always clear it.
        putGlobalSetting(Global.LOW_POWER_MODE, 0);

        // This is called with the power manager lock held. Don't do anything that may call to
        // upper services. (e.g. don't call into AM directly)
        // So use a BG thread.
        runOnBgThread(() -> {

            final ContentResolver cr = mContext.getContentResolver();
            cr.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.LOW_POWER_MODE),