Skip to content

Commit b709528

Browse files
jsharkeyAndroid (Google) Code Review
authored andcommitted
Merge "Disable policy when bandwidth module missing." into jb-dev
2 parents c4be1b7 + 8c1dc72 commit b709528

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ public void bindNotificationManager(INotificationManager notifManager) {
319319
}
320320

321321
public void systemReady() {
322+
if (!isBandwidthControlEnabled()) {
323+
Slog.w(TAG, "bandwidth controls disabled, unable to enforce policy");
324+
return;
325+
}
326+
322327
synchronized (mRulesLock) {
323328
// read policy from disk
324329
readPolicyLocked();
@@ -1917,6 +1922,18 @@ private long getTotalBytes(NetworkTemplate template, long start, long end) {
19171922
}
19181923
}
19191924

1925+
private boolean isBandwidthControlEnabled() {
1926+
final long token = Binder.clearCallingIdentity();
1927+
try {
1928+
return mNetworkManager.isBandwidthControlEnabled();
1929+
} catch (RemoteException e) {
1930+
// ignored; service lives in system_server
1931+
return false;
1932+
} finally {
1933+
Binder.restoreCallingIdentity(token);
1934+
}
1935+
}
1936+
19201937
/**
19211938
* Try refreshing {@link #mTime} when stale.
19221939
*/

0 commit comments

Comments
 (0)