Synchronize the IpClient events
If the ipClient is stopped before handling the events in Handler thread, ethernet network factory might end up creating a network agent for a network which is already cleared. This change fixes the issue by handling the events only if ipClient is initialized. Tests: Builds, Boots, EthernetNetworkFactoryTest. Ethernet related test scenarios Bug: 207057937 Change-Id: If7ff7abf5f0dcdb0e94de0502bfdf981f9f20298
This commit is contained in:
@@ -481,6 +481,10 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
||||
}
|
||||
|
||||
void onIpLayerStarted(LinkProperties linkProperties) {
|
||||
if(mIpClient == null) {
|
||||
if (DBG) Log.d(TAG, "IpClient is not initialized.");
|
||||
return;
|
||||
}
|
||||
if (mNetworkAgent != null) {
|
||||
Log.e(TAG, "Already have a NetworkAgent - aborting new request");
|
||||
stop();
|
||||
@@ -528,6 +532,10 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
||||
}
|
||||
|
||||
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
|
||||
// happen if we're provisioned and we lose provisioning.
|
||||
stop();
|
||||
@@ -539,6 +547,10 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
||||
}
|
||||
|
||||
void updateLinkProperties(LinkProperties linkProperties) {
|
||||
if(mIpClient == null) {
|
||||
if (DBG) Log.d(TAG, "IpClient is not initialized.");
|
||||
return;
|
||||
}
|
||||
mLinkProperties = linkProperties;
|
||||
if (mNetworkAgent != null) {
|
||||
mNetworkAgent.sendLinkPropertiesImpl(linkProperties);
|
||||
@@ -546,6 +558,10 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
||||
}
|
||||
|
||||
void updateNeighborLostEvent(String logMsg) {
|
||||
if(mIpClient == null) {
|
||||
if (DBG) Log.d(TAG, "IpClient is not initialized.");
|
||||
return;
|
||||
}
|
||||
Log.i(TAG, "updateNeighborLostEvent " + logMsg);
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user