Avoid reading network stats when disabled.

Bug: 5518868
Change-Id: Idb5c588b018bf735597ad7ff904ecc69224dd0a0
This commit is contained in:
Jeff Sharkey
2011-12-13 15:38:03 -08:00
parent 36ff7058f6
commit 675c43125f

View File

@@ -268,6 +268,11 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
}
public void systemReady() {
if (!isBandwidthControlEnabled()) {
Slog.w(TAG, "bandwidth controls disabled, unable to track stats");
return;
}
synchronized (mStatsLock) {
// read historical network stats from disk, since policy service
// might need them right away. we delay loading detailed UID stats
@@ -1644,6 +1649,15 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
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.
*/