Merge "Send callback if ip provisioning is interrupted" am: 7d5aae1a55

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2123881

Change-Id: I093b2bfb27bae9500a71b5855c21734a94c249fe
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
James Mattis
2022-06-17 20:13:18 +00:00
committed by Automerger Merge Worker
2 changed files with 15 additions and 4 deletions

View File

@@ -488,8 +488,6 @@ public class EthernetNetworkFactory {
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
// be required due to the capabilities or ipConfiguration values, not all
// capabilities changes require a restart.
@@ -651,6 +649,8 @@ public class EthernetNetworkFactory {
mIpClientCallback.awaitIpClientShutdown();
mIpClient = null;
}
// Send an abort callback if an updateInterface request was in progress.
maybeSendNetworkManagementCallbackForAbort();
mIpClientCallback = null;
if (mNetworkAgent != null) {
@@ -662,7 +662,6 @@ public class EthernetNetworkFactory {
public void destroy() {
mNetworkProvider.unregisterNetworkOffer(mNetworkOfferCallback);
maybeSendNetworkManagementCallbackForAbort();
stop();
mRequests.clear();
}

View File

@@ -92,6 +92,8 @@ public class EthernetNetworkFactoryTest {
private Handler mHandler;
private EthernetNetworkFactory mNetFactory = null;
private IpClientCallbacks mIpClientCallbacks;
private NetworkOfferCallback mNetworkOfferCallback;
private NetworkRequest mRequestToKeepNetworkUp;
@Mock private Context mContext;
@Mock private Resources mResources;
@Mock private EthernetNetworkFactory.Dependencies mDeps;
@@ -244,7 +246,9 @@ public class EthernetNetworkFactoryTest {
ArgumentCaptor<NetworkOfferCallback> captor = ArgumentCaptor.forClass(
NetworkOfferCallback.class);
verify(mNetworkProvider).registerNetworkOffer(any(), any(), any(), captor.capture());
captor.getValue().onNetworkNeeded(createDefaultRequest());
mRequestToKeepNetworkUp = createDefaultRequest();
mNetworkOfferCallback = captor.getValue();
mNetworkOfferCallback.onNetworkNeeded(mRequestToKeepNetworkUp);
verifyStart(ipConfig);
clearInvocations(mDeps);
@@ -624,6 +628,14 @@ public class EthernetNetworkFactoryTest {
() -> mNetFactory.updateInterfaceLinkState(TEST_IFACE, false, NULL_LISTENER));
}
@Test
public void testUpdateInterfaceAbortsOnNetworkUneededRemovesAllRequests() throws Exception {
initEthernetNetworkFactory();
verifyNetworkManagementCallIsAbortedWhenInterrupted(
TEST_IFACE,
() -> mNetworkOfferCallback.onNetworkUnneeded(mRequestToKeepNetworkUp));
}
@Test
public void testUpdateInterfaceCallsListenerCorrectlyOnConcurrentRequests() throws Exception {
initEthernetNetworkFactory();