Refactor the ISocketNetLinkMonitor to AbstractSocketNetlink
Test: atest CtsNetTestCases FrameworksNetTests Bug: 279692201 (cherry picked from https://android-review.googlesource.com/q/commit:508e508ca63ce5449929343f28a99788fe7cfb0e) Merged-In: Ie07603ea51dda1ffdeb15f753bda7892d9137766 Change-Id: Ie07603ea51dda1ffdeb15f753bda7892d9137766
This commit is contained in:
committed by
Cherrypicker Worker
parent
d0507db40d
commit
46ab01cce9
@@ -19,7 +19,7 @@ package com.android.server.connectivity.mdns;
|
|||||||
/**
|
/**
|
||||||
* The interface for netlink monitor.
|
* The interface for netlink monitor.
|
||||||
*/
|
*/
|
||||||
public interface ISocketNetLinkMonitor {
|
public interface AbstractSocketNetlink {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the netlink monitor is supported or not. By default, it is not supported.
|
* Returns if the netlink monitor is supported or not. By default, it is not supported.
|
||||||
@@ -74,7 +74,7 @@ public class MdnsSocketProvider {
|
|||||||
@NonNull private final Dependencies mDependencies;
|
@NonNull private final Dependencies mDependencies;
|
||||||
@NonNull private final NetworkCallback mNetworkCallback;
|
@NonNull private final NetworkCallback mNetworkCallback;
|
||||||
@NonNull private final TetheringEventCallback mTetheringEventCallback;
|
@NonNull private final TetheringEventCallback mTetheringEventCallback;
|
||||||
@NonNull private final ISocketNetLinkMonitor mSocketNetlinkMonitor;
|
@NonNull private final AbstractSocketNetlink mSocketNetlinkMonitor;
|
||||||
private final ArrayMap<Network, SocketInfo> mNetworkSockets = new ArrayMap<>();
|
private final ArrayMap<Network, SocketInfo> mNetworkSockets = new ArrayMap<>();
|
||||||
private final ArrayMap<String, SocketInfo> mTetherInterfaceSockets = new ArrayMap<>();
|
private final ArrayMap<String, SocketInfo> mTetherInterfaceSockets = new ArrayMap<>();
|
||||||
private final ArrayMap<Network, LinkProperties> mActiveNetworksLinkProperties =
|
private final ArrayMap<Network, LinkProperties> mActiveNetworksLinkProperties =
|
||||||
@@ -171,7 +171,7 @@ public class MdnsSocketProvider {
|
|||||||
return iface.getIndex();
|
return iface.getIndex();
|
||||||
}
|
}
|
||||||
/*** Creates a SocketNetlinkMonitor */
|
/*** Creates a SocketNetlinkMonitor */
|
||||||
public ISocketNetLinkMonitor createSocketNetlinkMonitor(@NonNull final Handler handler,
|
public AbstractSocketNetlink createSocketNetlinkMonitor(@NonNull final Handler handler,
|
||||||
@NonNull final SharedLog log,
|
@NonNull final SharedLog log,
|
||||||
@NonNull final NetLinkMonitorCallBack cb) {
|
@NonNull final NetLinkMonitorCallBack cb) {
|
||||||
return SocketNetLinkMonitorFactory.createNetLinkMonitor(handler, log, cb);
|
return SocketNetLinkMonitorFactory.createNetLinkMonitor(handler, log, cb);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class SocketNetLinkMonitorFactory {
|
|||||||
/**
|
/**
|
||||||
* Creates a new netlink monitor.
|
* Creates a new netlink monitor.
|
||||||
*/
|
*/
|
||||||
public static ISocketNetLinkMonitor createNetLinkMonitor(@NonNull final Handler handler,
|
public static AbstractSocketNetlink createNetLinkMonitor(@NonNull final Handler handler,
|
||||||
@NonNull SharedLog log, @NonNull MdnsSocketProvider.NetLinkMonitorCallBack cb) {
|
@NonNull SharedLog log, @NonNull MdnsSocketProvider.NetLinkMonitorCallBack cb) {
|
||||||
return new SocketNetlinkMonitor(handler, log, cb);
|
return new SocketNetlinkMonitor(handler, log, cb);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ import com.android.net.module.util.netlink.NetlinkConstants;
|
|||||||
import com.android.net.module.util.netlink.NetlinkMessage;
|
import com.android.net.module.util.netlink.NetlinkMessage;
|
||||||
import com.android.net.module.util.netlink.RtNetlinkAddressMessage;
|
import com.android.net.module.util.netlink.RtNetlinkAddressMessage;
|
||||||
import com.android.net.module.util.netlink.StructIfaddrMsg;
|
import com.android.net.module.util.netlink.StructIfaddrMsg;
|
||||||
import com.android.server.connectivity.mdns.ISocketNetLinkMonitor;
|
import com.android.server.connectivity.mdns.AbstractSocketNetlink;
|
||||||
import com.android.server.connectivity.mdns.MdnsSocketProvider;
|
import com.android.server.connectivity.mdns.MdnsSocketProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The netlink monitor for MdnsSocketProvider.
|
* The netlink monitor for MdnsSocketProvider.
|
||||||
*/
|
*/
|
||||||
public class SocketNetlinkMonitor extends NetlinkMonitor implements ISocketNetLinkMonitor {
|
public class SocketNetlinkMonitor extends NetlinkMonitor implements AbstractSocketNetlink {
|
||||||
|
|
||||||
public static final String TAG = SocketNetlinkMonitor.class.getSimpleName();
|
public static final String TAG = SocketNetlinkMonitor.class.getSimpleName();
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class MdnsSocketProviderTest {
|
|||||||
private NetworkCallback mNetworkCallback;
|
private NetworkCallback mNetworkCallback;
|
||||||
private TetheringEventCallback mTetheringEventCallback;
|
private TetheringEventCallback mTetheringEventCallback;
|
||||||
|
|
||||||
private TestNetLinkMonitor mTestSocketNetLinkMonitor;
|
private TestNetlinkMonitor mTestSocketNetLinkMonitor;
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws IOException {
|
public void setUp() throws IOException {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
@@ -147,7 +147,7 @@ public class MdnsSocketProviderTest {
|
|||||||
doReturn(mTestSocketNetLinkMonitor).when(mDeps).createSocketNetlinkMonitor(any(), any(),
|
doReturn(mTestSocketNetLinkMonitor).when(mDeps).createSocketNetlinkMonitor(any(), any(),
|
||||||
any());
|
any());
|
||||||
doAnswer(inv -> {
|
doAnswer(inv -> {
|
||||||
mTestSocketNetLinkMonitor = new TestNetLinkMonitor(inv.getArgument(0),
|
mTestSocketNetLinkMonitor = new TestNetlinkMonitor(inv.getArgument(0),
|
||||||
inv.getArgument(1),
|
inv.getArgument(1),
|
||||||
inv.getArgument(2));
|
inv.getArgument(2));
|
||||||
return mTestSocketNetLinkMonitor;
|
return mTestSocketNetLinkMonitor;
|
||||||
@@ -174,8 +174,8 @@ public class MdnsSocketProviderTest {
|
|||||||
HandlerUtils.waitForIdle(mHandler, DEFAULT_TIMEOUT);
|
HandlerUtils.waitForIdle(mHandler, DEFAULT_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TestNetLinkMonitor extends SocketNetlinkMonitor {
|
private static class TestNetlinkMonitor extends SocketNetlinkMonitor {
|
||||||
TestNetLinkMonitor(@NonNull Handler handler,
|
TestNetlinkMonitor(@NonNull Handler handler,
|
||||||
@NonNull SharedLog log,
|
@NonNull SharedLog log,
|
||||||
@Nullable MdnsSocketProvider.NetLinkMonitorCallBack cb) {
|
@Nullable MdnsSocketProvider.NetLinkMonitorCallBack cb) {
|
||||||
super(handler, log, cb);
|
super(handler, log, cb);
|
||||||
|
|||||||
Reference in New Issue
Block a user