Add reconnect flow when updateIPConfiguration

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
This commit is contained in:
tank.hung
2019-04-04 22:37:49 +08:00
committed by Jay Patel
parent ea26baf9ff
commit f8a95e543f

View File

@@ -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() + "{ "