diff options
| author | 2018-09-12 21:44:55 -0700 | |
|---|---|---|
| committer | 2018-09-12 21:44:55 -0700 | |
| commit | 6f517f47087a8976c76d03a5952eb895d8a79d38 (patch) | |
| tree | 7e450291c8e770a08775dd9ce3ea285f13eb4b23 | |
| parent | 3961d1e6533b4eb9d4394ef09b141d33df967aa5 (diff) | |
| parent | 160adaab84bb36153f06c5a8bb48c82acb11fed9 (diff) | |
Merge "Bandwidth-related commands porting" am: 8dc60930ab
am: 160adaab84
Change-Id: I96549ecad3788a7b2c4c18e93dd25b583b8ec580
| -rw-r--r-- | services/core/java/com/android/server/NetworkManagementService.java | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java index c79cf7112109..9c81748ea435 100644 --- a/services/core/java/com/android/server/NetworkManagementService.java +++ b/services/core/java/com/android/server/NetworkManagementService.java @@ -1560,10 +1560,11 @@ public class NetworkManagementService extends INetworkManagementService.Stub 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 @@ public class NetworkManagementService extends INetworkManagementService.Stub 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 @@ public class NetworkManagementService extends INetworkManagementService.Stub 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 @@ public class NetworkManagementService extends INetworkManagementService.Stub 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 @@ public class NetworkManagementService extends INetworkManagementService.Stub 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 @@ public class NetworkManagementService extends INetworkManagementService.Stub 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 @@ public class NetworkManagementService extends INetworkManagementService.Stub quotaList.delete(uid); } } - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } finally { Trace.traceEnd(Trace.TRACE_TAG_NETWORK); } |