Merge "Drop DEV network stats to save RAM." into lmp-mr1-dev automerge: 49c1527
automerge: a5921b9 * commit 'a5921b9b79a1d95e8a41bd74998cab82b153cb0a': Drop DEV network stats to save RAM.
This commit is contained in:
@@ -45,7 +45,6 @@ import static android.provider.Settings.Global.NETSTATS_DEV_PERSIST_BYTES;
|
||||
import static android.provider.Settings.Global.NETSTATS_DEV_ROTATE_AGE;
|
||||
import static android.provider.Settings.Global.NETSTATS_GLOBAL_ALERT_BYTES;
|
||||
import static android.provider.Settings.Global.NETSTATS_POLL_INTERVAL;
|
||||
import static android.provider.Settings.Global.NETSTATS_REPORT_XT_OVER_DEV;
|
||||
import static android.provider.Settings.Global.NETSTATS_SAMPLE_ENABLED;
|
||||
import static android.provider.Settings.Global.NETSTATS_TIME_CACHE_MAX_AGE;
|
||||
import static android.provider.Settings.Global.NETSTATS_UID_BUCKET_DURATION;
|
||||
@@ -184,7 +183,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
public long getPollInterval();
|
||||
public long getTimeCacheMaxAge();
|
||||
public boolean getSampleEnabled();
|
||||
public boolean getReportXtOverDev();
|
||||
|
||||
public static class Config {
|
||||
public final long bucketDuration;
|
||||
@@ -229,8 +227,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
private NetworkStatsRecorder mUidRecorder;
|
||||
private NetworkStatsRecorder mUidTagRecorder;
|
||||
|
||||
/** Cached {@link #mDevRecorder} stats. */
|
||||
private NetworkStatsCollection mDevStatsCached;
|
||||
/** Cached {@link #mXtRecorder} stats. */
|
||||
private NetworkStatsCollection mXtStatsCached;
|
||||
|
||||
@@ -305,7 +301,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
|
||||
// read historical network stats from disk, since policy service
|
||||
// might need them right away.
|
||||
mDevStatsCached = mDevRecorder.getOrLoadCompleteLocked();
|
||||
mXtStatsCached = mXtRecorder.getOrLoadCompleteLocked();
|
||||
|
||||
// bootstrap initial stats to prevent double-counting later
|
||||
@@ -386,7 +381,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
mUidRecorder = null;
|
||||
mUidTagRecorder = null;
|
||||
|
||||
mDevStatsCached = null;
|
||||
mXtStatsCached = null;
|
||||
|
||||
mSystemReady = false;
|
||||
@@ -523,48 +517,24 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return network summary, splicing between {@link #mDevStatsCached}
|
||||
* and {@link #mXtStatsCached} when appropriate.
|
||||
* Return network summary, splicing between DEV and XT stats when
|
||||
* appropriate.
|
||||
*/
|
||||
private NetworkStats internalGetSummaryForNetwork(
|
||||
NetworkTemplate template, long start, long end) {
|
||||
if (!mSettings.getReportXtOverDev()) {
|
||||
// shortcut when XT reporting disabled
|
||||
return mDevStatsCached.getSummary(template, start, end);
|
||||
}
|
||||
|
||||
// splice stats between DEV and XT, switching over from DEV to XT at
|
||||
// first atomic bucket.
|
||||
final long firstAtomicBucket = mXtStatsCached.getFirstAtomicBucketMillis();
|
||||
final NetworkStats dev = mDevStatsCached.getSummary(
|
||||
template, Math.min(start, firstAtomicBucket), Math.min(end, firstAtomicBucket));
|
||||
final NetworkStats xt = mXtStatsCached.getSummary(
|
||||
template, Math.max(start, firstAtomicBucket), Math.max(end, firstAtomicBucket));
|
||||
|
||||
xt.combineAllValues(dev);
|
||||
return xt;
|
||||
// We've been using pure XT stats long enough that we no longer need to
|
||||
// splice DEV and XT together.
|
||||
return mXtStatsCached.getSummary(template, start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return network history, splicing between {@link #mDevStatsCached}
|
||||
* and {@link #mXtStatsCached} when appropriate.
|
||||
* Return network history, splicing between DEV and XT stats when
|
||||
* appropriate.
|
||||
*/
|
||||
private NetworkStatsHistory internalGetHistoryForNetwork(NetworkTemplate template, int fields) {
|
||||
if (!mSettings.getReportXtOverDev()) {
|
||||
// shortcut when XT reporting disabled
|
||||
return mDevStatsCached.getHistory(template, UID_ALL, SET_ALL, TAG_NONE, fields);
|
||||
}
|
||||
|
||||
// splice stats between DEV and XT, switching over from DEV to XT at
|
||||
// first atomic bucket.
|
||||
final long firstAtomicBucket = mXtStatsCached.getFirstAtomicBucketMillis();
|
||||
final NetworkStatsHistory dev = mDevStatsCached.getHistory(
|
||||
template, UID_ALL, SET_ALL, TAG_NONE, fields, Long.MIN_VALUE, firstAtomicBucket);
|
||||
final NetworkStatsHistory xt = mXtStatsCached.getHistory(
|
||||
template, UID_ALL, SET_ALL, TAG_NONE, fields, firstAtomicBucket, Long.MAX_VALUE);
|
||||
|
||||
xt.recordEntireHistory(dev);
|
||||
return xt;
|
||||
// We've been using pure XT stats long enough that we no longer need to
|
||||
// splice DEV and XT together.
|
||||
return mXtStatsCached.getHistory(template, UID_ALL, SET_ALL, TAG_NONE, fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1329,10 +1299,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
return getGlobalBoolean(NETSTATS_SAMPLE_ENABLED, true);
|
||||
}
|
||||
@Override
|
||||
public boolean getReportXtOverDev() {
|
||||
return getGlobalBoolean(NETSTATS_REPORT_XT_OVER_DEV, true);
|
||||
}
|
||||
@Override
|
||||
public Config getDevConfig() {
|
||||
return new Config(getGlobalLong(NETSTATS_DEV_BUCKET_DURATION, HOUR_IN_MILLIS),
|
||||
getGlobalLong(NETSTATS_DEV_ROTATE_AGE, 15 * DAY_IN_MILLIS),
|
||||
|
||||
Reference in New Issue
Block a user