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

Commit b41df442 authored by Todd Poynor's avatar Todd Poynor
Browse files

BatteryService: don't set battery low or critical states if no battery

If device has no battery then never set states "battery low" or
"battery critical".

Bug: 34507420
Test: manual: inspection (with hack to disappear the battery device)
Change-Id: I1eee79032507121de2fa7bf29d1359a29f21d3d0
parent 1acf06a6
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -421,7 +421,9 @@ public final class BatteryService extends SystemService {
        boolean logOutlier = false;
        long dischargeDuration = 0;

        mBatteryLevelCritical = (mHealthInfo.batteryLevel <= mCriticalBatteryLevel);
        mBatteryLevelCritical =
            mHealthInfo.batteryStatus != BatteryManager.BATTERY_STATUS_UNKNOWN
            && mHealthInfo.batteryLevel <= mCriticalBatteryLevel;
        if (mHealthInfo.chargerAcOnline) {
            mPlugType = BatteryManager.BATTERY_PLUGGED_AC;
        } else if (mHealthInfo.chargerUsbOnline) {
@@ -509,6 +511,8 @@ public final class BatteryService extends SystemService {
            if (!mBatteryLevelLow) {
                // Should we now switch in to low battery mode?
                if (mPlugType == BATTERY_PLUGGED_NONE
                        && mHealthInfo.batteryStatus !=
                           BatteryManager.BATTERY_STATUS_UNKNOWN
                        && mHealthInfo.batteryLevel <= mLowBatteryWarningLevel) {
                    mBatteryLevelLow = true;
                }