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:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user