Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment