Merge "Bandwidth-related commands porting"
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index c79cf71..9c81748 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -1560,10 +1560,11 @@
try {
// TODO: support quota shared across interfaces
- mConnector.execute("bandwidth", "setiquota", iface, quotaBytes);
+ mNetdService.bandwidthSetInterfaceQuota(iface, quotaBytes);
+
mActiveQuotas.put(iface, quotaBytes);
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
+ } catch (RemoteException | ServiceSpecificException e) {
+ throw new IllegalStateException(e);
}
synchronized (mTetheringStatsProviders) {
@@ -1594,9 +1595,9 @@
try {
// TODO: support quota shared across interfaces
- mConnector.execute("bandwidth", "removeiquota", iface);
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
+ mNetdService.bandwidthRemoveInterfaceQuota(iface);
+ } catch (RemoteException | ServiceSpecificException e) {
+ throw new IllegalStateException(e);
}
synchronized (mTetheringStatsProviders) {
@@ -1628,10 +1629,10 @@
try {
// TODO: support alert shared across interfaces
- mConnector.execute("bandwidth", "setinterfacealert", iface, alertBytes);
+ mNetdService.bandwidthSetInterfaceAlert(iface, alertBytes);
mActiveAlerts.put(iface, alertBytes);
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
+ } catch (RemoteException | ServiceSpecificException e) {
+ throw new IllegalStateException(e);
}
}
}
@@ -1648,10 +1649,10 @@
try {
// TODO: support alert shared across interfaces
- mConnector.execute("bandwidth", "removeinterfacealert", iface);
+ mNetdService.bandwidthRemoveInterfaceAlert(iface);
mActiveAlerts.remove(iface);
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
+ } catch (RemoteException | ServiceSpecificException e) {
+ throw new IllegalStateException(e);
}
}
}
@@ -1661,18 +1662,15 @@
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
try {
- mConnector.execute("bandwidth", "setglobalalert", alertBytes);
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
+ mNetdService.bandwidthSetGlobalAlert(alertBytes);
+ } catch (RemoteException | ServiceSpecificException e) {
+ throw new IllegalStateException(e);
}
}
private void setUidOnMeteredNetworkList(int uid, boolean blacklist, boolean enable) {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
- final String chain = blacklist ? "naughtyapps" : "niceapps";
- final String suffix = enable ? "add" : "remove";
-
synchronized (mQuotaLock) {
boolean oldEnable;
SparseBooleanArray quotaList;
@@ -1687,7 +1685,19 @@
Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "inetd bandwidth");
try {
- mConnector.execute("bandwidth", suffix + chain, uid);
+ if (blacklist) {
+ if (enable) {
+ mNetdService.bandwidthAddNaughtyApp(uid);
+ } else {
+ mNetdService.bandwidthRemoveNaughtyApp(uid);
+ }
+ } else {
+ if (enable) {
+ mNetdService.bandwidthAddNiceApp(uid);
+ } else {
+ mNetdService.bandwidthRemoveNiceApp(uid);
+ }
+ }
synchronized (mRulesLock) {
if (enable) {
quotaList.put(uid, true);
@@ -1695,8 +1705,8 @@
quotaList.delete(uid);
}
}
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
+ } catch (RemoteException | ServiceSpecificException e) {
+ throw new IllegalStateException(e);
} finally {
Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
}