diff --git a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java index 48d68d7894..00f6c56849 100644 --- a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java +++ b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java @@ -469,7 +469,9 @@ public class EthernetNetworkFactory { // TODO: Update this logic to only do a restart if required. Although a restart may // be required due to the capabilities or ipConfiguration values, not all // capabilities changes require a restart. - restart(); + if (mIpClient != null) { + restart(); + } } boolean isRestricted() { diff --git a/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt b/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt index 3635b7ba89..1e44440b8a 100644 --- a/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt +++ b/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt @@ -979,4 +979,23 @@ class EthernetManagerTest { cb.eventuallyExpectCapabilities(TEST_CAPS) cb.eventuallyExpectLpForStaticConfig(STATIC_IP_CONFIGURATION.staticIpConfiguration) } + + @Test + fun testUpdateConfiguration_withLinkDown() { + assumeChangingCarrierSupported() + // createInterface without carrier is racy, so create it and then remove carrier. + val iface = createInterface() + val cb = requestNetwork(ETH_REQUEST) + cb.expectAvailable() + + iface.setCarrierEnabled(false) + cb.eventuallyExpectLost() + + updateConfiguration(iface, STATIC_IP_CONFIGURATION, TEST_CAPS).expectResult(iface.name) + cb.assertNoCallback() + + iface.setCarrierEnabled(true) + cb.eventuallyExpectCapabilities(TEST_CAPS) + cb.eventuallyExpectLpForStaticConfig(STATIC_IP_CONFIGURATION.staticIpConfiguration) + } }