Bug 710178 - ASSERTION: Battery API: When charging and level at 1.0, remaining time should be 0. Please fix your backend. r=mounir
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 19 Dec 2011 12:23:13 +0900
changeset 84928 5efce975a9e7bef07cf2840268a33fefeff5de41
parent 84927 f8c7652a33bfc3acb086c7829a83e10f6669903a
child 84929 e255fa32719cbe3ff63ce3238ab2b9f601556275
push idunknown
push userunknown
push dateunknown
reviewersmounir
bugs710178
milestone11.0a1
Bug 710178 - ASSERTION: Battery API: When charging and level at 1.0, remaining time should be 0. Please fix your backend. r=mounir
hal/windows/WindowsBattery.cpp
--- a/hal/windows/WindowsBattery.cpp
+++ b/hal/windows/WindowsBattery.cpp
@@ -218,19 +218,25 @@ GetCurrentBatteryInformation(hal::Batter
     return;
   }
 
   aBatteryInfo->level() =
     status.BatteryLifePercent == 255 ? kDefaultLevel
                                      : ((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
                                           : status.BatteryLifeTime;
   }
 }
 
 } // hal_impl