Merge "Disable policy when bandwidth module missing." into jb-dev

This commit is contained in:
Jeff Sharkey
2012-05-04 14:55:45 -07:00
committed by Android (Google) Code Review

View File

@@ -319,6 +319,11 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
public void systemReady() {
if (!isBandwidthControlEnabled()) {
Slog.w(TAG, "bandwidth controls disabled, unable to enforce policy");
return;
}
synchronized (mRulesLock) {
// read policy from disk
readPolicyLocked();
@@ -1917,6 +1922,18 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
}
private boolean isBandwidthControlEnabled() {
final long token = Binder.clearCallingIdentity();
try {
return mNetworkManager.isBandwidthControlEnabled();
} catch (RemoteException e) {
// ignored; service lives in system_server
return false;
} finally {
Binder.restoreCallingIdentity(token);
}
}
/**
* Try refreshing {@link #mTime} when stale.
*/