Use resolveInstanceName in NsdService
For resolve requests, specify the resolveInstanceName in MdnsSearchOptions. This will cause discovery to send followup queries when TXT/SRV/A/AAAA records are missing; for example if only a PTR record is returned following the discovery probes, or if no discovery probe is sent at all. Test: atest NsdServiceTest Bug: 267570781 Change-Id: Ib18c3afbd1533ada7a78dd8ccac993adb439d014
This commit is contained in:
@@ -763,6 +763,7 @@ public class NsdService extends INsdManager.Stub {
|
||||
final MdnsSearchOptions options = MdnsSearchOptions.newBuilder()
|
||||
.setNetwork(info.getNetwork())
|
||||
.setIsPassiveMode(true)
|
||||
.setResolveInstanceName(info.getServiceName())
|
||||
.build();
|
||||
mMdnsDiscoveryManager.registerListener(
|
||||
resolveServiceType, listener, options);
|
||||
@@ -775,7 +776,7 @@ public class NsdService extends INsdManager.Stub {
|
||||
}
|
||||
|
||||
maybeStartDaemon();
|
||||
if (resolveService(id, args.serviceInfo)) {
|
||||
if (resolveService(id, info)) {
|
||||
clientInfo.mResolvedService = new NsdServiceInfo();
|
||||
storeLegacyRequestMap(clientId, id, clientInfo, msg.what);
|
||||
} else {
|
||||
|
||||
@@ -981,7 +981,9 @@ public class NsdServiceTest {
|
||||
waitForIdle();
|
||||
verify(mSocketProvider).startMonitoringSockets();
|
||||
verify(mDiscoveryManager).registerListener(eq(constructedServiceType),
|
||||
listenerCaptor.capture(), argThat(options -> network.equals(options.getNetwork())));
|
||||
listenerCaptor.capture(), argThat(options ->
|
||||
network.equals(options.getNetwork())
|
||||
&& SERVICE_NAME.equals(options.getResolveInstanceName())));
|
||||
|
||||
final MdnsServiceBrowserListener listener = listenerCaptor.getValue();
|
||||
final MdnsServiceInfo mdnsServiceInfo = new MdnsServiceInfo(
|
||||
|
||||
Reference in New Issue
Block a user