diff options
author | Luis Hector Chavez <lhchavez@google.com> | 2018-02-16 14:59:53 -0800 |
---|---|---|
committer | Luis Hector Chavez <lhchavez@google.com> | 2018-02-21 20:25:20 +0000 |
commit | 22d5a7067cc686f84aaed136b80c9491732af23f (patch) | |
tree | 74cc47668b4f7c62d7eb86fbe7e5a177a72887b3 | |
parent | caf5246eb0ad453bc1a1707ce69fab3502b7dccb (diff) | |
download | ethernet-22d5a7067cc686f84aaed136b80c9491732af23f.tar.gz |
Avoid re-creating an IpClient if the network has already started
This change avoids calling start() on needNetworkFor() if an IpClient
object has already been created. This is the case when the interface is
connected from boot, as is the case in Chrome OS.
Bug: 73396557
Test: Networking is 100% stable in Chrome OS
Change-Id: Iaa073d6477aadca2e4e5233b333d717ad82c1f3d
-rw-r--r-- | java/com/android/server/ethernet/EthernetNetworkFactory.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/java/com/android/server/ethernet/EthernetNetworkFactory.java b/java/com/android/server/ethernet/EthernetNetworkFactory.java index 29464b7..d464879 100644 --- a/java/com/android/server/ethernet/EthernetNetworkFactory.java +++ b/java/com/android/server/ethernet/EthernetNetworkFactory.java @@ -280,11 +280,14 @@ public class EthernetNetworkFactory extends NetworkFactory { } private void start() { + if (mIpClient != null) { + if (DBG) Log.d(TAG, "IpClient already started"); + return; + } if (DBG) { Log.d(TAG, String.format("starting IpClient(%s): mNetworkInfo=%s", name, mNetworkInfo)); } - if (mIpClient != null) stop(); mNetworkInfo.setDetailedState(DetailedState.OBTAINING_IPADDR, null, mHwAddress); @@ -325,6 +328,7 @@ public class EthernetNetworkFactory extends NetworkFactory { void onIpLayerStopped(LinkProperties linkProperties) { // 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(); start(); } @@ -338,12 +342,11 @@ public class EthernetNetworkFactory extends NetworkFactory { /** Returns true if state has been modified */ boolean updateLinkState(boolean up) { if (mLinkUp == up) return false; - mLinkUp = up; + + stop(); if (up) { start(); - } else { - stop(); } return true; |