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

Commit 4187603e authored by Xin Guan's avatar Xin Guan
Browse files

Send battery low intent when battery warning boundary changed

If the battery warning boundary is changed and the new boundary is
higher than the current battery level, send the battery low intent too.

Test: manual: inspection (with different boundary level changes)

Change-Id: Ic8b7ebd4052bb757e35ed4e904ea6bddcb23a7ac
parent 3bc51682
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ public final class BatteryService extends SystemService {
    private int mLastInvalidCharger;

    private int mLowBatteryWarningLevel;
    private int mLastLowBatteryWarningLevel;
    private int mLowBatteryCloseWarningLevel;
    private int mShutdownBatteryTemperature;

@@ -313,6 +314,7 @@ public final class BatteryService extends SystemService {
        final ContentResolver resolver = mContext.getContentResolver();
        int defWarnLevel = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_lowBatteryWarningLevel);
        mLastLowBatteryWarningLevel = mLowBatteryWarningLevel;
        mLowBatteryWarningLevel = Settings.Global.getInt(resolver,
                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, defWarnLevel);
        if (mLowBatteryWarningLevel == 0) {
@@ -357,7 +359,8 @@ public final class BatteryService extends SystemService {
        return !plugged
                && mHealthInfo.batteryStatus != BatteryManager.BATTERY_STATUS_UNKNOWN
                && mHealthInfo.batteryLevel <= mLowBatteryWarningLevel
                && (oldPlugged || mLastBatteryLevel > mLowBatteryWarningLevel);
                && (oldPlugged || mLastBatteryLevel > mLowBatteryWarningLevel
                    || mHealthInfo.batteryLevel > mLastLowBatteryWarningLevel);
    }

    private boolean shouldShutdownLocked() {