summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorPatrick Rohr <prohr@google.com>2022-03-14 17:30:18 +0100
committerPatrick Rohr <prohr@google.com>2022-03-16 17:20:36 +0100
commit7e81787e0bf8ee33dec8c4bb7e474ca61c8b9ef1 (patch)
treeef9eae2ed00f36f2d4641fd5cf2e26494dd5d7fc /java
parentc976c676374518c99be54fce008b657dd334944e (diff)
downloadethernet-7e81787e0bf8ee33dec8c4bb7e474ca61c8b9ef1.tar.gz
Add support for Nullable IpConfiguration
Test: atest EthernetServiceTests Change-Id: I6b415ffb2f5825a9dffda1366b60c1e0d26f4e64
Diffstat (limited to 'java')
-rw-r--r--java/com/android/server/ethernet/EthernetNetworkFactory.java11
-rw-r--r--java/com/android/server/ethernet/EthernetTracker.java11
2 files changed, 15 insertions, 7 deletions
diff --git a/java/com/android/server/ethernet/EthernetNetworkFactory.java b/java/com/android/server/ethernet/EthernetNetworkFactory.java
index ce0d77c..ef3abba 100644
--- a/java/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/java/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -233,7 +233,8 @@ public class EthernetNetworkFactory extends NetworkFactory {
* Update a network's configuration and restart it if necessary.
*
* @param ifaceName the interface name of the network to be updated.
- * @param ipConfig the desired {@link IpConfiguration} for the given network.
+ * @param ipConfig the desired {@link IpConfiguration} for the given network or null. If
+ * {@code null} is passed, the existing IpConfiguration is not updated.
* @param capabilities the desired {@link NetworkCapabilities} for the given network. If
* {@code null} is passed, then the network's current
* {@link NetworkCapabilities} will be used in support of existing APIs as
@@ -243,7 +244,7 @@ public class EthernetNetworkFactory extends NetworkFactory {
*/
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
protected void updateInterface(@NonNull final String ifaceName,
- @NonNull final IpConfiguration ipConfig,
+ @Nullable final IpConfiguration ipConfig,
@Nullable final NetworkCapabilities capabilities,
@Nullable final IEthernetNetworkManagementListener listener) {
if (!hasInterface(ifaceName)) {
@@ -499,7 +500,7 @@ public class EthernetNetworkFactory extends NetworkFactory {
mLegacyType = getLegacyType(mCapabilities);
}
- void updateInterface(@NonNull final IpConfiguration ipConfig,
+ void updateInterface(@Nullable final IpConfiguration ipConfig,
@Nullable final NetworkCapabilities capabilities,
@Nullable final IEthernetNetworkManagementListener listener) {
if (DBG) {
@@ -510,7 +511,9 @@ public class EthernetNetworkFactory extends NetworkFactory {
);
}
- mIpConfig = ipConfig;
+ if (null != ipConfig){
+ mIpConfig = ipConfig;
+ }
if (null != capabilities) {
setCapabilities(capabilities);
}
diff --git a/java/com/android/server/ethernet/EthernetTracker.java b/java/com/android/server/ethernet/EthernetTracker.java
index 1b696a4..074c81b 100644
--- a/java/com/android/server/ethernet/EthernetTracker.java
+++ b/java/com/android/server/ethernet/EthernetTracker.java
@@ -289,15 +289,20 @@ public class EthernetTracker {
@VisibleForTesting(visibility = PACKAGE)
protected void updateConfiguration(@NonNull final String iface,
- @NonNull final IpConfiguration ipConfig,
+ @Nullable final IpConfiguration ipConfig,
@Nullable final NetworkCapabilities capabilities,
@Nullable final IEthernetNetworkManagementListener listener) {
if (DBG) {
Log.i(TAG, "updateConfiguration, iface: " + iface + ", capabilities: " + capabilities
+ ", ipConfig: " + ipConfig);
}
- final IpConfiguration localIpConfig = new IpConfiguration(ipConfig);
- writeIpConfiguration(iface, localIpConfig);
+
+ final IpConfiguration localIpConfig = ipConfig == null
+ ? null : new IpConfiguration(ipConfig);
+ if (ipConfig != null) {
+ writeIpConfiguration(iface, localIpConfig);
+ }
+
if (null != capabilities) {
mNetworkCapabilities.put(iface, capabilities);
}