Synchronize the IpClient events am: b63e7aebee
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/1895027 Change-Id: Ia3edc9ea77380f5b4e223a6cf43576f48097d7ee
This commit is contained in:
@@ -481,6 +481,10 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onIpLayerStarted(LinkProperties linkProperties) {
|
void onIpLayerStarted(LinkProperties linkProperties) {
|
||||||
|
if(mIpClient == null) {
|
||||||
|
if (DBG) Log.d(TAG, "IpClient is not initialized.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mNetworkAgent != null) {
|
if (mNetworkAgent != null) {
|
||||||
Log.e(TAG, "Already have a NetworkAgent - aborting new request");
|
Log.e(TAG, "Already have a NetworkAgent - aborting new request");
|
||||||
stop();
|
stop();
|
||||||
@@ -528,6 +532,10 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onIpLayerStopped(LinkProperties linkProperties) {
|
void onIpLayerStopped(LinkProperties linkProperties) {
|
||||||
|
if(mIpClient == null) {
|
||||||
|
if (DBG) Log.d(TAG, "IpClient is not initialized.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
// This cannot happen due to provisioning timeout, because our timeout is 0. It can only
|
// This cannot happen due to provisioning timeout, because our timeout is 0. It can only
|
||||||
// happen if we're provisioned and we lose provisioning.
|
// happen if we're provisioned and we lose provisioning.
|
||||||
stop();
|
stop();
|
||||||
@@ -539,6 +547,10 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateLinkProperties(LinkProperties linkProperties) {
|
void updateLinkProperties(LinkProperties linkProperties) {
|
||||||
|
if(mIpClient == null) {
|
||||||
|
if (DBG) Log.d(TAG, "IpClient is not initialized.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
mLinkProperties = linkProperties;
|
mLinkProperties = linkProperties;
|
||||||
if (mNetworkAgent != null) {
|
if (mNetworkAgent != null) {
|
||||||
mNetworkAgent.sendLinkPropertiesImpl(linkProperties);
|
mNetworkAgent.sendLinkPropertiesImpl(linkProperties);
|
||||||
@@ -546,6 +558,10 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateNeighborLostEvent(String logMsg) {
|
void updateNeighborLostEvent(String logMsg) {
|
||||||
|
if(mIpClient == null) {
|
||||||
|
if (DBG) Log.d(TAG, "IpClient is not initialized.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Log.i(TAG, "updateNeighborLostEvent " + logMsg);
|
Log.i(TAG, "updateNeighborLostEvent " + logMsg);
|
||||||
// Reachability lost will be seen only if the gateway is not reachable.
|
// Reachability lost will be seen only if the gateway is not reachable.
|
||||||
// Since ethernet FW doesn't have the mechanism to scan for new networks
|
// Since ethernet FW doesn't have the mechanism to scan for new networks
|
||||||
|
|||||||
@@ -469,6 +469,59 @@ public class EthernetNetworkFactoryTest {
|
|||||||
verifyRestart(createDefaultIpConfig());
|
verifyRestart(createDefaultIpConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIgnoreOnIpLayerStartedCallbackAfterIpClientHasStopped() throws Exception {
|
||||||
|
createAndVerifyProvisionedInterface(TEST_IFACE);
|
||||||
|
mIpClientCallbacks.onProvisioningFailure(new LinkProperties());
|
||||||
|
mIpClientCallbacks.onProvisioningSuccess(new LinkProperties());
|
||||||
|
mLooper.dispatchAll();
|
||||||
|
verifyStop();
|
||||||
|
|
||||||
|
// ipClient has been shut down first, we should not retry
|
||||||
|
verify(mIpClient, never()).startProvisioning(any());
|
||||||
|
verify(mNetworkAgent, never()).register();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIgnoreOnIpLayerStoppedCallbackAfterIpClientHasStopped() throws Exception {
|
||||||
|
createAndVerifyProvisionedInterface(TEST_IFACE);
|
||||||
|
when(mDeps.getNetworkInterfaceByName(TEST_IFACE)).thenReturn(mInterfaceParams);
|
||||||
|
mIpClientCallbacks.onProvisioningFailure(new LinkProperties());
|
||||||
|
mIpClientCallbacks.onProvisioningFailure(new LinkProperties());
|
||||||
|
mLooper.dispatchAll();
|
||||||
|
verifyStop();
|
||||||
|
|
||||||
|
// ipClient has been shut down first, we should not retry
|
||||||
|
verify(mIpClient).startProvisioning(any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIgnoreLinkPropertiesCallbackAfterIpClientHasStopped() throws Exception {
|
||||||
|
createAndVerifyProvisionedInterface(TEST_IFACE);
|
||||||
|
LinkProperties lp = new LinkProperties();
|
||||||
|
|
||||||
|
mIpClientCallbacks.onProvisioningFailure(lp);
|
||||||
|
mIpClientCallbacks.onLinkPropertiesChange(lp);
|
||||||
|
mLooper.dispatchAll();
|
||||||
|
verifyStop();
|
||||||
|
|
||||||
|
// ipClient has been shut down first, we should not update
|
||||||
|
verify(mNetworkAgent, never()).sendLinkPropertiesImpl(same(lp));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIgnoreNeighborLossCallbackAfterIpClientHasStopped() throws Exception {
|
||||||
|
createAndVerifyProvisionedInterface(TEST_IFACE);
|
||||||
|
mIpClientCallbacks.onProvisioningFailure(new LinkProperties());
|
||||||
|
mIpClientCallbacks.onReachabilityLost("Neighbor Lost");
|
||||||
|
mLooper.dispatchAll();
|
||||||
|
verifyStop();
|
||||||
|
|
||||||
|
// ipClient has been shut down first, we should not update
|
||||||
|
verify(mIpClient, never()).startProvisioning(any());
|
||||||
|
verify(mNetworkAgent, never()).register();
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyRestart(@NonNull final IpConfiguration ipConfig) {
|
private void verifyRestart(@NonNull final IpConfiguration ipConfig) {
|
||||||
verifyStop();
|
verifyStop();
|
||||||
verifyStart(ipConfig);
|
verifyStart(ipConfig);
|
||||||
|
|||||||
Reference in New Issue
Block a user