Send callback if ip provisioning is interrupted

A callback is expected to be sent on either success or failure when the
EthernetManager#updateConfiguration API is called.

Currently, if this API is called for an active interface and marked
restricted, after the IP provisioning process is started in
EthernetNetworkFactory, the interface will then processe all the
onNetworkUneeded requests for the newly restricted network. Assuming no
apps have requests for this particular network or restricted networks,
the network will be stopped once the outstanding network request count
reaches zero.

If provisioning hasn't completed yet for the original
updateConfiguration call, the original callback will be cleared out on
stop and will never notify the original caller of
EthernetManager#updateConfiguration whose call was aborted.

Bug: 235907515
Test: eth unit and cts tests
Change-Id: I91359272c07e090039049370ba9f438546fce3ad
This commit is contained in:
James Mattis
2022-06-13 22:04:25 -07:00
parent 7f0bdd3bfe
commit 265eba982d
2 changed files with 15 additions and 4 deletions

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();