Bug 1292655 - Limit BatteryManager chargingTime/dischargingTime precision. r=baku

This commit is contained in:
Tom Schuster 2016-08-16 22:56:21 +02:00
parent a7f164c330
commit 7314ad853b

View File

@ -149,6 +149,11 @@ BatteryManager::UpdateFromBatteryInfo(const hal::BatteryInformation& aBatteryInf
mLevel = lround(mLevel * 10.0) / 10.0;
if (mLevel == 1.0) {
mRemainingTime = mCharging ? kDefaultRemainingTime : kUnknownRemainingTime;
} else if (mRemainingTime != kUnknownRemainingTime) {
// Round the remaining time to a multiple of 15 minutes and never zero
const double MINUTES_15 = 15.0 * 60.0;
mRemainingTime = fmax(lround(mRemainingTime / MINUTES_15) * MINUTES_15,
MINUTES_15);
}
}