Bug 710178 - ASSERTION: Battery API: When charging and level at 1.0, remaining time should be 0. Please fix your backend. r=mounir

This commit is contained in:
Makoto Kato 2011-12-19 12:23:13 +09:00
parent 5f4ffe886f
commit b847b80445

View File

@ -223,9 +223,15 @@ GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo)
: ((double)status.BatteryLifePercent) / 100.0;
aBatteryInfo->charging() = (status.ACLineStatus != 0);
if (status.ACLineStatus != 0) {
aBatteryInfo->remainingTime() =
status.BatteryFullLifeTime == (DWORD)-1 ? kUnknownRemainingTime
: status.BatteryFullLifeTime;
if (aBatteryInfo->level() == 1.0) {
// GetSystemPowerStatus API may returns -1 for BatteryFullLifeTime.
// So, if battery is 100%, set kDefaultRemainingTime at force.
aBatteryInfo->remainingTime() = kDefaultRemainingTime;
} else {
aBatteryInfo->remainingTime() =
status.BatteryFullLifeTime == (DWORD)-1 ? kUnknownRemainingTime
: status.BatteryFullLifeTime;
}
} else {
aBatteryInfo->remainingTime() =
status.BatteryLifeTime == (DWORD)-1 ? kUnknownRemainingTime