Prevent division-by-zero error when calculating battery capacity.

am: 415f8b32e8

Change-Id: I1337db6391a9511df52560e8edb8a09260e27c5f
This commit is contained in:
Ying Wai (Daniel) Fan
2017-02-06 22:57:23 +00:00
committed by android-build-merger

View File

@@ -9594,7 +9594,7 @@ public class BatteryStatsImpl extends BatteryStats {
}
doWrite = true;
resetAllStatsLocked();
if (chargeUAh > 0) {
if (chargeUAh > 0 && level > 0) {
// Only use the reported coulomb charge value if it is supported and reported.
mEstimatedBatteryCapacity = (int) ((chargeUAh / 1000) / (level / 100.0));
}