Merge changes from topic "rway_nullable_nc" am: 930cc5dd8a
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/2008254
Change-Id: Ib30eec9e71791f63a7a5ea9721fde35fba1b8c92
diff --git a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java
index 8ce27a6..875fc10 100644
--- a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -485,7 +485,9 @@
}
mIpConfig = ipConfig;
- setCapabilities(capabilities);
+ if (null != capabilities) {
+ setCapabilities(capabilities);
+ }
// Send an abort callback if a request is filed before the previous one has completed.
maybeSendNetworkManagementCallbackForAbort();
// TODO: Update this logic to only do a restart if required. Although a restart may
diff --git a/service-t/src/com/android/server/ethernet/EthernetServiceImpl.java b/service-t/src/com/android/server/ethernet/EthernetServiceImpl.java
index 7f77e5e..9987b3e 100644
--- a/service-t/src/com/android/server/ethernet/EthernetServiceImpl.java
+++ b/service-t/src/com/android/server/ethernet/EthernetServiceImpl.java
@@ -237,8 +237,8 @@
logIfEthernetNotStarted();
}
- private void validateTestCapabilities(@NonNull final NetworkCapabilities nc) {
- if (nc.hasTransport(TRANSPORT_TEST)) {
+ private void validateTestCapabilities(@Nullable final NetworkCapabilities nc) {
+ if (null != nc && nc.hasTransport(TRANSPORT_TEST)) {
return;
}
throw new IllegalArgumentException(
diff --git a/service-t/src/com/android/server/ethernet/EthernetTracker.java b/service-t/src/com/android/server/ethernet/EthernetTracker.java
index 9070a7e..ea241e1 100644
--- a/service-t/src/com/android/server/ethernet/EthernetTracker.java
+++ b/service-t/src/com/android/server/ethernet/EthernetTracker.java
@@ -233,7 +233,7 @@
@VisibleForTesting(visibility = PACKAGE)
protected void updateConfiguration(@NonNull final String iface,
@NonNull final IpConfiguration ipConfig,
- @NonNull final NetworkCapabilities capabilities,
+ @Nullable final NetworkCapabilities capabilities,
@Nullable final IEthernetNetworkManagementListener listener) {
if (DBG) {
Log.i(TAG, "updateConfiguration, iface: " + iface + ", capabilities: " + capabilities
@@ -241,7 +241,9 @@
}
final IpConfiguration localIpConfig = new IpConfiguration(ipConfig);
writeIpConfiguration(iface, localIpConfig);
- mNetworkCapabilities.put(iface, capabilities);
+ if (null != capabilities) {
+ mNetworkCapabilities.put(iface, capabilities);
+ }
mHandler.post(() -> {
mFactory.updateInterface(iface, localIpConfig, capabilities, listener);
broadcastInterfaceStateChange(iface);
diff --git a/tests/ethernet/java/com/android/server/ethernet/EthernetServiceImplTest.java b/tests/ethernet/java/com/android/server/ethernet/EthernetServiceImplTest.java
index 012f07a..e814c84 100644
--- a/tests/ethernet/java/com/android/server/ethernet/EthernetServiceImplTest.java
+++ b/tests/ethernet/java/com/android/server/ethernet/EthernetServiceImplTest.java
@@ -248,6 +248,18 @@
}
@Test
+ public void testUpdateConfigurationRejectsTestRequestWithNullCapabilities() {
+ enableTestInterface();
+ final EthernetNetworkUpdateRequest request =
+ new EthernetNetworkUpdateRequest
+ .Builder()
+ .setIpConfiguration(new IpConfiguration()).build();
+ assertThrows(IllegalArgumentException.class, () -> {
+ mEthernetServiceImpl.updateConfiguration(TEST_IFACE, request, NULL_LISTENER);
+ });
+ }
+
+ @Test
public void testUpdateConfigurationRejectsInvalidTestRequest() {
enableTestInterface();
assertThrows(IllegalArgumentException.class, () -> {