Skip to content

Commit 4190a04

Browse files
committed
Better assertions when bandwidth module disabled.
Also disable some verbose logging in WifiStateTracker. Bug: 6368329 Change-Id: I9a5219bc1b3fd870468f7de46cdf4f173a437c59
1 parent 7838025 commit 4190a04

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

services/java/com/android/server/net/NetworkStatsService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ private void registerGlobalAlert() {
420420
@Override
421421
public INetworkStatsSession openSession() {
422422
mContext.enforceCallingOrSelfPermission(READ_NETWORK_USAGE_HISTORY, TAG);
423+
assertBandwidthControlEnabled();
423424

424425
// return an IBinder which holds strong references to any loaded stats
425426
// for its lifetime; when caller closes only weak references remain.
@@ -486,6 +487,7 @@ public void close() {
486487
@Override
487488
public long getNetworkTotalBytes(NetworkTemplate template, long start, long end) {
488489
mContext.enforceCallingOrSelfPermission(READ_NETWORK_USAGE_HISTORY, TAG);
490+
assertBandwidthControlEnabled();
489491
return mDevStatsCached.getSummary(template, start, end).getTotalBytes();
490492
}
491493

@@ -494,6 +496,7 @@ public NetworkStats getDataLayerSnapshotForUid(int uid) throws RemoteException {
494496
if (Binder.getCallingUid() != uid) {
495497
mContext.enforceCallingOrSelfPermission(ACCESS_NETWORK_STATE, TAG);
496498
}
499+
assertBandwidthControlEnabled();
497500

498501
// TODO: switch to data layer stats once kernel exports
499502
// for now, read network layer stats and flatten across all ifaces
@@ -565,6 +568,7 @@ public void setUidForeground(int uid, boolean uidForeground) {
565568
@Override
566569
public void forceUpdate() {
567570
mContext.enforceCallingOrSelfPermission(READ_NETWORK_USAGE_HISTORY, TAG);
571+
assertBandwidthControlEnabled();
568572

569573
final long token = Binder.clearCallingIdentity();
570574
try {
@@ -1039,6 +1043,12 @@ public boolean handleMessage(Message msg) {
10391043
}
10401044
};
10411045

1046+
private void assertBandwidthControlEnabled() {
1047+
if (!isBandwidthControlEnabled()) {
1048+
throw new IllegalStateException("Bandwidth module disabled");
1049+
}
1050+
}
1051+
10421052
private boolean isBandwidthControlEnabled() {
10431053
try {
10441054
return mNetworkManager.isBandwidthControlEnabled();

wifi/java/android/net/wifi/WifiStateTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void setUserDataEnable(boolean enabled) {
141141

142142
@Override
143143
public void setPolicyDataEnable(boolean enabled) {
144-
Slog.w(TAG, "ignoring setPolicyDataEnable(" + enabled + ")");
144+
// ignored
145145
}
146146

147147
/**

0 commit comments

Comments
 (0)