Prevent division-by-zero error when calculating battery capacity.
Bug: 34255953 Change-Id: Ie072cd5dc26faf17e8ab46ea0795750396f087c2 Fixes: 34255953 Test: formula change CL. No existing unit tests found.
This commit is contained in:
committed by
Aaron Whyte
parent
1f8f29968b
commit
415f8b32e8
@@ -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));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user