Network stats flag to force complete poll.

Devices currently delay collecting UID stats during common operations
like global alerts to reduce parsing load.  Here we introduce a flag
to always collect UID and iface stats together to aid debugging.

Bug: 5321340
Change-Id: Ia8e1daf1a6f9d5f5cf1f64a04b6b6766ee965ab6
This commit is contained in:
Jeff Sharkey
2011-09-14 19:31:04 -07:00
parent 23f0af822a
commit 4d675fdcf6

View File

@@ -34,6 +34,7 @@ import static android.net.NetworkStats.UID_ALL;
import static android.net.NetworkTemplate.buildTemplateMobileAll;
import static android.net.NetworkTemplate.buildTemplateWifi;
import static android.net.TrafficStats.UID_REMOVED;
import static android.provider.Settings.Secure.NETSTATS_FORCE_COMPLETE_POLL;
import static android.provider.Settings.Secure.NETSTATS_NETWORK_BUCKET_DURATION;
import static android.provider.Settings.Secure.NETSTATS_NETWORK_MAX_HISTORY;
import static android.provider.Settings.Secure.NETSTATS_PERSIST_THRESHOLD;
@@ -176,6 +177,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
public long getUidMaxHistory();
public long getTagMaxHistory();
public long getTimeCacheMaxAge();
public boolean getForceCompletePoll();
}
private final Object mStatsLock = new Object();
@@ -682,8 +684,16 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
if (LOGV) Slog.v(TAG, "performPollLocked(flags=0x" + Integer.toHexString(flags) + ")");
final long startRealtime = SystemClock.elapsedRealtime();
final boolean pollNetwork = (flags & FLAG_POLL_NETWORK) != 0;
final boolean pollUid = (flags & FLAG_POLL_UID) != 0;
boolean pollNetwork = (flags & FLAG_POLL_NETWORK) != 0;
boolean pollUid = (flags & FLAG_POLL_UID) != 0;
// when complete poll requested, any partial poll enables everything
final boolean forceCompletePoll = mSettings.getForceCompletePoll();
if (forceCompletePoll && (pollNetwork || pollUid)) {
pollNetwork = true;
pollUid = true;
}
final boolean persistNetwork = (flags & FLAG_PERSIST_NETWORK) != 0;
final boolean persistUid = (flags & FLAG_PERSIST_UID) != 0;
final boolean forcePersist = (flags & FLAG_FORCE_PERSIST) != 0;
@@ -1360,6 +1370,10 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
private long getSecureLong(String name, long def) {
return Settings.Secure.getLong(mResolver, name, def);
}
private boolean getSecureBoolean(String name, boolean def) {
final int defInt = def ? 1 : 0;
return Settings.Secure.getInt(mResolver, name, defInt) != 0;
}
public long getPollInterval() {
return getSecureLong(NETSTATS_POLL_INTERVAL, 30 * MINUTE_IN_MILLIS);
@@ -1385,5 +1399,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
public long getTimeCacheMaxAge() {
return DAY_IN_MILLIS;
}
public boolean getForceCompletePoll() {
return getSecureBoolean(NETSTATS_FORCE_COMPLETE_POLL, false);
}
}
}