Send empty LinkProperties when entering StoppedState.

Test: as follows
    - built
    - flashed
    - booted
    - runtest frameworks-net passes
    - changing from DHCPv4 to static while continuously pinging the
      default gateway works jsut fine
    - dumpsys log shows that during the change we send the empty LP:
  12-06 08:46:51.085 - CMD_ON_QUIT wlan0/23 0 0 null [rcvd_in=StoppingState, proc_in=StoppingState]
  12-06 08:46:51.092 - INVOKE onLinkPropertiesChange({{InterfaceName: wlan0 LinkAddresses: []  Routes: [] DnsAddresses: [] Domains: null MTU: 0}})

Bug: 69800563
Change-Id: I01047e9a72fce718a167c592bf14406c3bab3ba9
This commit is contained in:
Erik Kline
2017-12-06 13:37:09 +09:00
parent 86c9951383
commit b3f9f4a305
2 changed files with 9 additions and 2 deletions

View File

@@ -163,10 +163,10 @@ public class IpClient extends StateMachine {
// TODO: Find an lighter weight approach.
private class LoggingCallbackWrapper extends Callback {
private static final String PREFIX = "INVOKE ";
private Callback mCallback;
private final Callback mCallback;
public LoggingCallbackWrapper(Callback callback) {
mCallback = callback;
mCallback = (callback != null) ? callback : new Callback();
}
private void log(String msg) {
@@ -1273,6 +1273,7 @@ public class IpClient extends StateMachine {
stopAllIP();
resetLinkProperties();
mCallback.onLinkPropertiesChange(new LinkProperties(mLinkProperties));
if (mStartTimeMillis > 0) {
recordMetric(IpManagerEvent.COMPLETE_LIFECYCLE);
mStartTimeMillis = 0;

View File

@@ -69,6 +69,8 @@ import java.util.Set;
/**
* Tests for IpManager.
*
* TODO: Rename to IpClientTest.
*/
@RunWith(AndroidJUnit4.class)
@SmallTest
@@ -111,6 +113,10 @@ public class IpManagerTest {
verify(mNMService, times(1)).registerObserver(arg.capture());
mObserver = arg.getValue();
reset(mNMService);
final LinkProperties emptyLp = new LinkProperties();
emptyLp.setInterfaceName(ifname);
verify(mCb, timeout(100)).onLinkPropertiesChange(eq(emptyLp));
reset(mCb);
return ipm;
}