diff --git a/services/java/com/android/server/net/NetworkStatsService.java b/services/java/com/android/server/net/NetworkStatsService.java index 871ed682e6..a3decd5f27 100644 --- a/services/java/com/android/server/net/NetworkStatsService.java +++ b/services/java/com/android/server/net/NetworkStatsService.java @@ -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. */