OSDN Git Service

Correct the formula of battery capacity estimation.
authorYing Wai (Daniel) Fan <danfan@google.com>
Wed, 18 Jan 2017 23:50:19 +0000 (15:50 -0800)
committerAaron Whyte <awhyte@google.com>
Mon, 30 Jan 2017 19:24:43 +0000 (19:24 +0000)
Instead of
  (current charge) * (current battery level percentage)
the formula should be
  (current charge) / (current battery level percentage)
to estimate the charge at 100% battery level.

Bug: 34255953
Fixes: 34255953
Test: formula change CL. No existing unit tests found.
Change-Id: I56ef7af3fb097a3082e0ef24329f522d2a0229cc
(cherry picked from commit 9238b6124c72a216ccbbaa82f5f75828571d5841)

core/java/com/android/internal/os/BatteryStatsImpl.java

index 3b3344e..c0bf825 100644 (file)
@@ -9596,7 +9596,7 @@ public class BatteryStatsImpl extends BatteryStats {
                 resetAllStatsLocked();
                 if (chargeUAh > 0) {
                     // Only use the reported coulomb charge value if it is supported and reported.
-                    mEstimatedBatteryCapacity = (int) ((level / 100.0) * (chargeUAh / 1000));
+                    mEstimatedBatteryCapacity = (int) ((chargeUAh / 1000) / (level / 100.0));
                 }
                 mDischargeStartLevel = level;
                 reset = true;