Use the ServiceTypeClient network for queries
Instead of the network specified in the MdnsSearchOptions, which is often null to request searching on all networks, use the MdnsServiceTypeClient Network to build the queries. When MdnsSearchOptions.network is null, one MdnsServiceTypeClient is created for each mDNS-compatible Network. Each MdnsServiceTypeClient schedules queries with a Network selector. If the Network selector is null, each MdnsServiceTypeClient will post its queries to all networks. Instead, it should be the Network of the MdnsServiceTypeClient. There is one remaining problem when a tethered interface is up: in that case, there will be one MdnsServiceTypeClient for tethered interfaces with a null network, which will still broadcast its queries to all networks. This should be addressed in a follow-up by having MdnsMultinetworkSocketClient only send queries to interfaces that have a null network, when the network selector is null (and not all interfaces). Bug: 283708537 Test: atest (cherry picked from https://android-review.googlesource.com/q/commit:404c1bf7877316df27389aa8a1ac855a25a86c20) Merged-In: If571d7a59c5e55d809eeb1f3d1c4b58684612cdd Change-Id: If571d7a59c5e55d809eeb1f3d1c4b58684612cdd
This commit is contained in:
committed by
Cherrypicker Worker
parent
7fd1e98040
commit
e82a699fc7
@@ -952,7 +952,7 @@ public class MdnsServiceTypeClientTests {
|
||||
currentThreadExecutor.getAndClearLastScheduledRunnable().run();
|
||||
// Send twice for IPv4 and IPv6
|
||||
inOrder.verify(mockSocketClient, times(2)).sendUnicastPacket(srvTxtQueryCaptor.capture(),
|
||||
eq(null) /* network */);
|
||||
eq(mockNetwork));
|
||||
|
||||
final MdnsPacket srvTxtQueryPacket = MdnsPacket.parse(
|
||||
new MdnsPacketReader(srvTxtQueryCaptor.getValue()));
|
||||
@@ -987,7 +987,7 @@ public class MdnsServiceTypeClientTests {
|
||||
ArgumentCaptor.forClass(DatagramPacket.class);
|
||||
currentThreadExecutor.getAndClearLastScheduledRunnable().run();
|
||||
inOrder.verify(mockSocketClient, times(2)).sendMulticastPacket(addressQueryCaptor.capture(),
|
||||
eq(null) /* network */);
|
||||
eq(mockNetwork));
|
||||
|
||||
final MdnsPacket addressQueryPacket = MdnsPacket.parse(
|
||||
new MdnsPacketReader(addressQueryCaptor.getValue()));
|
||||
@@ -1253,17 +1253,17 @@ public class MdnsServiceTypeClientTests {
|
||||
currentThreadExecutor.getAndClearLastScheduledRunnable().run();
|
||||
if (expectsUnicastResponse) {
|
||||
verify(mockSocketClient).sendUnicastPacket(
|
||||
expectedIPv4Packets[index], null /* network */);
|
||||
expectedIPv4Packets[index], mockNetwork);
|
||||
if (multipleSocketDiscovery) {
|
||||
verify(mockSocketClient).sendUnicastPacket(
|
||||
expectedIPv6Packets[index], null /* network */);
|
||||
expectedIPv6Packets[index], mockNetwork);
|
||||
}
|
||||
} else {
|
||||
verify(mockSocketClient).sendMulticastPacket(
|
||||
expectedIPv4Packets[index], null /* network */);
|
||||
expectedIPv4Packets[index], mockNetwork);
|
||||
if (multipleSocketDiscovery) {
|
||||
verify(mockSocketClient).sendMulticastPacket(
|
||||
expectedIPv6Packets[index], null /* network */);
|
||||
expectedIPv6Packets[index], mockNetwork);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user