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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user