Merge "Prevent division-by-zero error when calculating battery capacity." into cw-f-dev

This commit is contained in:
Aaron Whyte
2017-02-06 22:49:32 +00:00
committed by Android (Google) Code Review

View File

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