diff options
author | Remi NGUYEN VAN <reminv@google.com> | 2020-04-02 14:10:08 +0000 |
---|---|---|
committer | Remi NGUYEN VAN <reminv@google.com> | 2020-04-07 03:07:46 +0000 |
commit | 5f3bb6d04bc1f0d3d80f58d738be7411cd2cd348 (patch) | |
tree | 34fff0d74d9fea659e02112873630c6d0c232965 /src/android/net/ip/IpReachabilityMonitor.java | |
parent | f8783184b025b0ac2353b0f384cee1b3340f2f18 (diff) |
Add tests for IpReachabilityMonitor
The first tests just verify that provisioning is lost if all IPv4/6 DNS
servers or gateways are lost.
Test: atest NetworkStackTests
Bug: 152819907
Merged-In: I8da6a8f4f237ce963c0a1610432d310160fd3f20
Change-Id: I8da6a8f4f237ce963c0a1610432d310160fd3f20
Diffstat (limited to 'src/android/net/ip/IpReachabilityMonitor.java')
-rw-r--r-- | src/android/net/ip/IpReachabilityMonitor.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/android/net/ip/IpReachabilityMonitor.java b/src/android/net/ip/IpReachabilityMonitor.java index 17b1f3c..e1d4548 100644 --- a/src/android/net/ip/IpReachabilityMonitor.java +++ b/src/android/net/ip/IpReachabilityMonitor.java @@ -27,6 +27,7 @@ import android.net.INetd; import android.net.LinkProperties; import android.net.RouteInfo; import android.net.ip.IpNeighborMonitor.NeighborEvent; +import android.net.ip.IpNeighborMonitor.NeighborEventConsumer; import android.net.metrics.IpConnectivityLog; import android.net.metrics.IpReachabilityEvent; import android.net.netlink.StructNdMsg; @@ -154,11 +155,12 @@ public class IpReachabilityMonitor { } /** - * Encapsulates IpReachabilityMonitor depencencies on systems that hinder unit testing. + * Encapsulates IpReachabilityMonitor dependencies on systems that hinder unit testing. * TODO: consider also wrapping MultinetworkPolicyTracker in this interface. */ interface Dependencies { void acquireWakeLock(long durationMs); + IpNeighborMonitor makeIpNeighborMonitor(Handler h, SharedLog log, NeighborEventConsumer cb); static Dependencies makeDefault(Context context, String iface) { final String lockName = TAG + "." + iface; @@ -169,6 +171,11 @@ public class IpReachabilityMonitor { public void acquireWakeLock(long durationMs) { lock.acquire(durationMs); } + + public IpNeighborMonitor makeIpNeighborMonitor(Handler h, SharedLog log, + NeighborEventConsumer cb) { + return new IpNeighborMonitor(h, log, cb); + } }; } } @@ -223,7 +230,7 @@ public class IpReachabilityMonitor { } setNeighbourParametersForSteadyState(); - mIpNeighborMonitor = new IpNeighborMonitor(h, mLog, + mIpNeighborMonitor = mDependencies.makeIpNeighborMonitor(h, mLog, (NeighborEvent event) -> { if (mInterfaceParams.index != event.ifindex) return; if (!mNeighborWatchList.containsKey(event.ip)) return; |