Avoid re-creating an IpClient if the network has already started am: de93b3eb05
am: e340642858
Change-Id: I7da9c17743455abc21096cdd365e316d3376e4ad
This commit is contained in:
@@ -280,11 +280,14 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void start() {
|
private void start() {
|
||||||
|
if (mIpClient != null) {
|
||||||
|
if (DBG) Log.d(TAG, "IpClient already started");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Log.d(TAG, String.format("starting IpClient(%s): mNetworkInfo=%s", name,
|
Log.d(TAG, String.format("starting IpClient(%s): mNetworkInfo=%s", name,
|
||||||
mNetworkInfo));
|
mNetworkInfo));
|
||||||
}
|
}
|
||||||
if (mIpClient != null) stop();
|
|
||||||
|
|
||||||
mNetworkInfo.setDetailedState(DetailedState.OBTAINING_IPADDR, null, mHwAddress);
|
mNetworkInfo.setDetailedState(DetailedState.OBTAINING_IPADDR, null, mHwAddress);
|
||||||
|
|
||||||
@@ -325,6 +328,7 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
void onIpLayerStopped(LinkProperties linkProperties) {
|
void onIpLayerStopped(LinkProperties linkProperties) {
|
||||||
// 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();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,12 +342,11 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
/** Returns true if state has been modified */
|
/** Returns true if state has been modified */
|
||||||
boolean updateLinkState(boolean up) {
|
boolean updateLinkState(boolean up) {
|
||||||
if (mLinkUp == up) return false;
|
if (mLinkUp == up) return false;
|
||||||
|
|
||||||
mLinkUp = up;
|
mLinkUp = up;
|
||||||
|
|
||||||
|
stop();
|
||||||
if (up) {
|
if (up) {
|
||||||
start();
|
start();
|
||||||
} else {
|
|
||||||
stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user