diff options
author | Patrick Rohr <prohr@google.com> | 2022-03-09 09:38:59 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-09 09:38:59 +0000 |
commit | f3679e11f39dfb61e83215f5ebd075108a16de5c (patch) | |
tree | 73751f6be3ed0c90745534f01e0384b6e43efb43 | |
parent | bc68085effa0229037df46ed73b5ecebdc02bc0f (diff) | |
parent | 524a115dbf4def244764c5bec0b0829a9d62e113 (diff) | |
download | ethernet-f3679e11f39dfb61e83215f5ebd075108a16de5c.tar.gz |
Merge changes from topic "rway_nullable_nc" am: c76027e185 am: 524a115dbf
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/2008254
Change-Id: Idc59c91745ae86babeab8b21c0bb1b3722effcaa
4 files changed, 21 insertions, 5 deletions
diff --git a/java/com/android/server/ethernet/EthernetNetworkFactory.java b/java/com/android/server/ethernet/EthernetNetworkFactory.java index 8ce27a6..875fc10 100644 --- a/java/com/android/server/ethernet/EthernetNetworkFactory.java +++ b/java/com/android/server/ethernet/EthernetNetworkFactory.java @@ -485,7 +485,9 @@ public class EthernetNetworkFactory extends NetworkFactory { } 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/java/com/android/server/ethernet/EthernetServiceImpl.java b/java/com/android/server/ethernet/EthernetServiceImpl.java index 7f77e5e..9987b3e 100644 --- a/java/com/android/server/ethernet/EthernetServiceImpl.java +++ b/java/com/android/server/ethernet/EthernetServiceImpl.java @@ -237,8 +237,8 @@ public class EthernetServiceImpl extends IEthernetManager.Stub { 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/java/com/android/server/ethernet/EthernetTracker.java b/java/com/android/server/ethernet/EthernetTracker.java index 9070a7e..ea241e1 100644 --- a/java/com/android/server/ethernet/EthernetTracker.java +++ b/java/com/android/server/ethernet/EthernetTracker.java @@ -233,7 +233,7 @@ public class EthernetTracker { @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 @@ public class EthernetTracker { } 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/java/com/android/server/ethernet/EthernetServiceImplTest.java b/tests/java/com/android/server/ethernet/EthernetServiceImplTest.java index 012f07a..e814c84 100644 --- a/tests/java/com/android/server/ethernet/EthernetServiceImplTest.java +++ b/tests/java/com/android/server/ethernet/EthernetServiceImplTest.java @@ -248,6 +248,18 @@ public class EthernetServiceImplTest { } @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, () -> { |