Merge "Ipfwd-related commands porting"
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index 0d60d1d..bd0a4c7 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -1222,25 +1222,25 @@
public boolean getIpForwardingEnabled() throws IllegalStateException{
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
- final NativeDaemonEvent event;
try {
- event = mConnector.execute("ipfwd", "status");
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
+ final boolean isEnabled = mNetdService.ipfwdEnabled();
+ return isEnabled;
+ } catch (RemoteException | ServiceSpecificException e) {
+ throw new IllegalStateException(e);
}
-
- // 211 Forwarding enabled
- event.checkCode(IpFwdStatusResult);
- return event.getMessage().endsWith("enabled");
}
@Override
public void setIpForwardingEnabled(boolean enable) {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
try {
- mConnector.execute("ipfwd", enable ? "enable" : "disable", "tethering");
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
+ if (enable) {
+ mNetdService.ipfwdEnableForwarding("tethering");
+ } else {
+ mNetdService.ipfwdDisableForwarding("tethering");
+ }
+ } catch (RemoteException | ServiceSpecificException e) {
+ throw new IllegalStateException(e);
}
}
@@ -1366,11 +1366,14 @@
}
private void modifyInterfaceForward(boolean add, String fromIface, String toIface) {
- final Command cmd = new Command("ipfwd", add ? "add" : "remove", fromIface, toIface);
try {
- mConnector.execute(cmd);
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
+ if (add) {
+ mNetdService.ipfwdAddInterfaceForward(fromIface, toIface);
+ } else {
+ mNetdService.ipfwdRemoveInterfaceForward(fromIface, toIface);
+ }
+ } catch (RemoteException | ServiceSpecificException e) {
+ throw new IllegalStateException(e);
}
}