diff options
author | Remi NGUYEN VAN <reminv@google.com> | 2020-04-30 08:21:46 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-04-30 08:21:46 +0000 |
commit | 2a0b4913ee6c71b25af4e6c81e37bfc93344833e (patch) | |
tree | 291669d3d07ac5c8a7e6e83fdda8da5cfa67422c /src/android/net/ip/IpReachabilityMonitor.java | |
parent | 692fe8d8a911b640fd5c292ccd8130dd85b2be81 (diff) | |
parent | 5f3bb6d04bc1f0d3d80f58d738be7411cd2cd348 (diff) |
Add tests for IpReachabilityMonitor am: 5f3bb6d04b
Change-Id: I4e420dcf03caf4557920947e0ca32c789cfba8c1
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; |