Merge "Avoid reading network stats when disabled."

This commit is contained in:
Jeff Sharkey
2011-12-14 10:12:17 -08:00
committed by Android (Google) Code Review

View File

@@ -268,6 +268,11 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
} }
public void systemReady() { public void systemReady() {
if (!isBandwidthControlEnabled()) {
Slog.w(TAG, "bandwidth controls disabled, unable to track stats");
return;
}
synchronized (mStatsLock) { synchronized (mStatsLock) {
// read historical network stats from disk, since policy service // read historical network stats from disk, since policy service
// might need them right away. we delay loading detailed UID stats // might need them right away. we delay loading detailed UID stats
@@ -1646,6 +1651,15 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
return telephony.getSubscriberId(); return telephony.getSubscriberId();
} }
private boolean isBandwidthControlEnabled() {
try {
return mNetworkManager.isBandwidthControlEnabled();
} catch (RemoteException e) {
// ignored; service lives in system_server
return false;
}
}
/** /**
* Key uniquely identifying a {@link NetworkStatsHistory} for a UID. * Key uniquely identifying a {@link NetworkStatsHistory} for a UID.
*/ */