From f8a95e543f8def8b3a75cc7f59f9fde316beb399 Mon Sep 17 00:00:00 2001 From: "tank.hung" Date: Thu, 4 Apr 2019 22:37:49 +0800 Subject: [PATCH] Add reconnect flow when updateIPConfiguration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: 119085164 Test: manual, test with AndroidTV device Partner gerrit review CL: https://partner-android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/1215654 [Analysis] APP called EthernetManager.setConfiguration API for switch DHCP to Static, setConfiguration’s flow just only update IpConfig finally but have not trigger EthernetNetworkFactory.start(). So Static IP Setting just only take effect when unplug/plug Ethernet Cable or AC Off&On. [Repeat Steps] 1. Connect Ethernet with DHCP and Network access is normal 2. Change IP settings from DHCP to Static and set Static IP. 3. After setting, you can not automatically obtain Static IP. [Recovery Method] Unplug the Ethernet and insert it or AC OFF / ON Change-Id: Idbb6a24ccfa360582f48e4f9369def7fc729fb9f Bug: 112171349 --- .../server/ethernet/EthernetNetworkFactory.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java index b8ed845c2c..6ed1310d2e 100644 --- a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java +++ b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java @@ -376,7 +376,14 @@ public class EthernetNetworkFactory extends NetworkFactory { } void setIpConfig(IpConfiguration ipConfig) { + if (this.mIpConfig.equals(ipConfig)) { + if (DBG) Log.d(TAG, "ipConfig have not changed,so ignore setIpConfig"); + return; + } this.mIpConfig = ipConfig; + if (mNetworkInfo.getDetailedState() != DetailedState.DISCONNECTED) { + restart(); + } } boolean statisified(NetworkCapabilities requestedCapabilities) { @@ -587,6 +594,12 @@ public class EthernetNetworkFactory extends NetworkFactory { } } + void restart(){ + if (DBG) Log.d(TAG, "reconnecting Etherent"); + stop(); + start(); + } + @Override public String toString() { return getClass().getSimpleName() + "{ "