From fcc56fc1588a9f5f884cd8b3eaa63bcea610f8b5 Mon Sep 17 00:00:00 2001 From: James Mattis Date: Thu, 17 Feb 2022 13:08:20 -0800 Subject: Using a builder for eth requests Updating ethernet classes to use a builder when creating an EthernetNetworkUpdateRequest and also changing to use IpConfiguration instead of StaticIpConfiguration for the UpdateConfiguration API. Bug: 220017952 Bug: 210487893 Bug: 210485380 Test: atest EthernetServiceTests Change-Id: I2647115bf867dfaa3f3dadf00e3c875aa7e8d88f --- .../android/server/ethernet/EthernetServiceImpl.java | 2 +- java/com/android/server/ethernet/EthernetTracker.java | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'java') diff --git a/java/com/android/server/ethernet/EthernetServiceImpl.java b/java/com/android/server/ethernet/EthernetServiceImpl.java index c1c6d3a..fed500f 100644 --- a/java/com/android/server/ethernet/EthernetServiceImpl.java +++ b/java/com/android/server/ethernet/EthernetServiceImpl.java @@ -239,7 +239,7 @@ public class EthernetServiceImpl extends IEthernetManager.Stub { // TODO: validate that iface is listed in overlay config_ethernet_interfaces mTracker.updateConfiguration( - iface, request.getIpConfig(), request.getNetworkCapabilities(), listener); + iface, request.getIpConfiguration(), request.getNetworkCapabilities(), listener); } @Override diff --git a/java/com/android/server/ethernet/EthernetTracker.java b/java/com/android/server/ethernet/EthernetTracker.java index 2571fe6..794b5d1 100644 --- a/java/com/android/server/ethernet/EthernetTracker.java +++ b/java/com/android/server/ethernet/EthernetTracker.java @@ -229,18 +229,18 @@ public class EthernetTracker { @VisibleForTesting(visibility = PACKAGE) protected void updateConfiguration(@NonNull final String iface, - @NonNull final StaticIpConfiguration staticIpConfig, + @NonNull final IpConfiguration ipConfig, @NonNull final NetworkCapabilities capabilities, @Nullable final IEthernetNetworkManagementListener listener) { if (DBG) { Log.i(TAG, "updateConfiguration, iface: " + iface + ", capabilities: " + capabilities - + ", staticIpConfig: " + staticIpConfig); + + ", ipConfig: " + ipConfig); } - final IpConfiguration ipConfig = createIpConfiguration(staticIpConfig); - writeIpConfiguration(iface, ipConfig); + final IpConfiguration localIpConfig = new IpConfiguration(ipConfig); + writeIpConfiguration(iface, localIpConfig); mNetworkCapabilities.put(iface, capabilities); mHandler.post(() -> { - mFactory.updateInterface(iface, ipConfig, capabilities, listener); + mFactory.updateInterface(iface, localIpConfig, capabilities, listener); broadcastInterfaceStateChange(iface); }); } @@ -715,13 +715,9 @@ public class EthernetTracker { return createIpConfiguration(staticIpConfigBuilder.build()); } - static IpConfiguration createIpConfiguration( + private static IpConfiguration createIpConfiguration( @NonNull final StaticIpConfiguration staticIpConfig) { - final IpConfiguration ret = new IpConfiguration(); - ret.setIpAssignment(IpAssignment.STATIC); - ret.setProxySettings(ProxySettings.NONE); - ret.setStaticIpConfiguration(staticIpConfig); - return ret; + return new IpConfiguration.Builder().setStaticIpConfiguration(staticIpConfig).build(); } private IpConfiguration getOrCreateIpConfiguration(String iface) { -- cgit v1.2.3