summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/net/NetworkStatsService.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2011-06-29 10:45:16 -0700
committerJeff Sharkey <jsharkey@android.com>2011-06-30 15:47:51 -0700
commit350083e36b9db6062e165954403ef921ff3dfdad (patch)
treec2b006eeb3225090024c41321752b380b36ee22b /services/java/com/android/server/net/NetworkStatsService.java
parent428e84388af3695cb19549bdb107e2b88afd3708 (diff)
downloadframeworks_base-350083e36b9db6062e165954403ef921ff3dfdad.zip
frameworks_base-350083e36b9db6062e165954403ef921ff3dfdad.tar.gz
frameworks_base-350083e36b9db6062e165954403ef921ff3dfdad.tar.bz2
Migrate bandwidth control to NMS, omit history.
Both stats and policy make NMS calls that depend on bandwidth control being enabled, so move enable/disable into NMS and drop calls when disabled. This avoids throwing heavy ISE exceptions when disabled. Only include recent data when writing NetworkStatsHistory as part of dumpsys call. Introduce manual poll event for Settings UI. Bug: 4982115, 4770435, 4515856 Change-Id: I257820b057af2f0f99c736fb4f61e55b9fdc3e66
Diffstat (limited to 'services/java/com/android/server/net/NetworkStatsService.java')
-rw-r--r--services/java/com/android/server/net/NetworkStatsService.java39
1 files changed, 13 insertions, 26 deletions
diff --git a/services/java/com/android/server/net/NetworkStatsService.java b/services/java/com/android/server/net/NetworkStatsService.java
index 7610a11..b4bd176 100644
--- a/services/java/com/android/server/net/NetworkStatsService.java
+++ b/services/java/com/android/server/net/NetworkStatsService.java
@@ -134,7 +134,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
* Settings that can be changed externally.
*/
public interface NetworkStatsSettings {
- public boolean getEnabled();
public long getPollInterval();
public long getPersistThreshold();
public long getNetworkBucketDuration();
@@ -207,20 +206,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
}
public void systemReady() {
- if (mSettings.getEnabled()) {
- try {
- // enable low-level bandwidth stats and control
- // TODO: consider shipping with this enabled by default
- mNetworkManager.setBandwidthControlEnabled(true);
- } catch (RemoteException e) {
- Slog.e(TAG, "problem talking to netd while enabling bandwidth controls", e);
- } catch (NativeDaemonConnectorException ndce) {
- Slog.e(TAG, "problem enabling bandwidth controls", ndce);
- }
- } else {
- Slog.w(TAG, "detailed network stats disabled");
- }
-
synchronized (mStatsLock) {
// read historical network stats from disk, since policy service
// might need them right away. we delay loading detailed UID stats
@@ -389,6 +374,15 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
}
}
+ @Override
+ public void forceUpdate() {
+ mContext.enforceCallingOrSelfPermission(READ_NETWORK_USAGE_HISTORY, TAG);
+
+ synchronized (mStatsLock) {
+ performPollLocked(true, false);
+ }
+ }
+
/**
* Receiver that watches for {@link IConnectivityManager} to claim network
* interfaces. Used to associate {@link TelephonyManager#getSubscriberId()}
@@ -905,6 +899,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
argSet.add(arg);
}
+ final boolean fullHistory = argSet.contains("full");
+
synchronized (mStatsLock) {
// TODO: remove this testing code, since it corrupts stats
if (argSet.contains("generate")) {
@@ -930,7 +926,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
for (NetworkIdentitySet ident : mNetworkStats.keySet()) {
final NetworkStatsHistory history = mNetworkStats.get(ident);
pw.print(" ident="); pw.println(ident.toString());
- history.dump(" ", pw);
+ history.dump(" ", pw, fullHistory);
}
if (argSet.contains("detail")) {
@@ -950,7 +946,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
final NetworkStatsHistory history = uidStats.valueAt(i);
pw.print(" UID="); pw.print(uid);
pw.print(" tag="); pw.println(tag);
- history.dump(" ", pw);
+ history.dump(" ", pw, fullHistory);
}
}
}
@@ -1058,15 +1054,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
return Settings.Secure.getLong(mResolver, name, def);
}
- public boolean getEnabled() {
- if (!new File("/proc/net/xt_qtaguid/ctrl").exists()) {
- Slog.w(TAG, "kernel does not support bandwidth control");
- return false;
- }
- // TODO: once things stabilize, enable by default.
- // For now: ./vendor/google/tools/override-gservices secure:netstats_enabled=1
- return Settings.Secure.getInt(mResolver, NETSTATS_ENABLED, 0) != 0;
- }
public long getPollInterval() {
return getSecureLong(NETSTATS_POLL_INTERVAL, 15 * MINUTE_IN_MILLIS);
}