Bug 1250106 - Correctly set charging status and remaining time when battery level is rounded to 1.0 r=bz

This commit is contained in:
James Willcox 2016-03-03 10:19:52 -06:00
parent 0ca72f55ed
commit 9176ba0725

View File

@ -140,15 +140,19 @@ BatteryManager::UpdateFromBatteryInfo(const hal::BatteryInformation& aBatteryInf
doc->NodePrincipal()->GetAppStatus(&status);
}
mCharging = aBatteryInfo.charging();
mRemainingTime = aBatteryInfo.remainingTime();
if (!nsContentUtils::IsChromeDoc(doc) &&
status != nsIPrincipal::APP_STATUS_CERTIFIED)
{
mLevel = lround(mLevel * 10.0) / 10.0;
if (mLevel == 1.0) {
mCharging = false;
mRemainingTime = kDefaultRemainingTime;
}
}
mCharging = aBatteryInfo.charging();
mRemainingTime = aBatteryInfo.remainingTime();
// Add some guards to make sure the values are coherent.
if (mLevel == 1.0 && mCharging == true &&
mRemainingTime != kDefaultRemainingTime) {