Conservatively trim data usage stats.

Instead of trusting NTP time alone, use the most-conservative of
system clock and NTP.

Bug: 5584564
Change-Id: I5dd87fc009959b1cf0a7d660e385a0b1a8be238b
This commit is contained in:
Jeff Sharkey
2011-11-14 18:02:21 -08:00
parent 42f4043633
commit ee0174da5e

View File

@@ -1243,7 +1243,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
// trim any history beyond max
if (mTime.hasCache()) {
final long currentTime = mTime.currentTimeMillis();
final long currentTime = Math.min(
System.currentTimeMillis(), mTime.currentTimeMillis());
final long maxHistory = mSettings.getNetworkMaxHistory();
for (NetworkStatsHistory history : input.values()) {
history.removeBucketsBefore(currentTime - maxHistory);
@@ -1287,7 +1288,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
// trim any history beyond max
if (mTime.hasCache()) {
final long currentTime = mTime.currentTimeMillis();
final long currentTime = Math.min(
System.currentTimeMillis(), mTime.currentTimeMillis());
final long maxUidHistory = mSettings.getUidMaxHistory();
final long maxTagHistory = mSettings.getTagMaxHistory();
for (UidStatsKey key : mUidStats.keySet()) {