Merge "NetworkStats: Avoid Division By 0"

This commit is contained in:
Junyu Lai
2021-09-01 06:07:18 +00:00
committed by Gerrit Code Review

View File

@@ -285,7 +285,8 @@ public class NetworkStatsCollection implements FileRotator.Reader, FileRotator.W
combined.getValues(augmentStart, augmentEnd, entry); combined.getValues(augmentStart, augmentEnd, entry);
} }
final long rawBytes = entry.rxBytes + entry.txBytes; final long rawBytes = (entry.rxBytes + entry.txBytes) == 0 ? 1 :
(entry.rxBytes + entry.txBytes);
final long rawRxBytes = entry.rxBytes == 0 ? 1 : entry.rxBytes; final long rawRxBytes = entry.rxBytes == 0 ? 1 : entry.rxBytes;
final long rawTxBytes = entry.txBytes == 0 ? 1 : entry.txBytes; final long rawTxBytes = entry.txBytes == 0 ? 1 : entry.txBytes;
final long targetBytes = augmentPlan.getDataUsageBytes(); final long targetBytes = augmentPlan.getDataUsageBytes();