Handle neighbor lost event am: e600bef8f9 am: dab9bb4938
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/1586426 Change-Id: I5c756835916a21838b83923c9406ea01758f6500
This commit is contained in:
@@ -346,6 +346,11 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
mHandler.post(() -> updateLinkProperties(newLp));
|
mHandler.post(() -> updateLinkProperties(newLp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReachabilityLost(String logMsg) {
|
||||||
|
mHandler.post(() -> updateNeighborLostEvent(logMsg));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onQuit() {
|
public void onQuit() {
|
||||||
mIpClient = null;
|
mIpClient = null;
|
||||||
@@ -479,6 +484,17 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateNeighborLostEvent(String logMsg) {
|
||||||
|
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
|
||||||
|
// like WiFi, simply restart.
|
||||||
|
// If there is a better network, that will become default and apps
|
||||||
|
// will be able to use internet. If ethernet gets connected again,
|
||||||
|
// and has backhaul connectivity, it will become default.
|
||||||
|
restart();
|
||||||
|
}
|
||||||
|
|
||||||
/** 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;
|
||||||
|
|||||||
@@ -434,4 +434,20 @@ public class EthernetNetworkFactoryTest {
|
|||||||
ConnectivityManager.TYPE_NONE);
|
ConnectivityManager.TYPE_NONE);
|
||||||
mNetFactory.removeInterface(iface);
|
mNetFactory.removeInterface(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReachabilityLoss() throws Exception {
|
||||||
|
String iface = "eth0";
|
||||||
|
createAndVerifyProvisionedInterface(iface);
|
||||||
|
|
||||||
|
mIpClientCallbacks.onReachabilityLost("ReachabilityLost");
|
||||||
|
mLooper.dispatchAll();
|
||||||
|
|
||||||
|
// Reachability loss should trigger a stop and start, since the interface is still there
|
||||||
|
verify(mIpClient).shutdown();
|
||||||
|
verify(mNetworkAgent).unregister();
|
||||||
|
|
||||||
|
verify(mDeps).makeIpClient(any(Context.class), anyString(), any());
|
||||||
|
verify(mIpClient).startProvisioning(any());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user