Revert "Implement the stop resolution with MdnsDiscoveryManager"

This reverts commit 6d77c41f2a.

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=aosp-master&target=aosp_cf_x86_64_phone-userdebug&lkgb=9678930&lkbb=9678975&fkbb=9678975, bug b/271400306

Change-Id: I8bfd2b8117ea401df7441116b983f5fe19f63d5d
BUG: 271400306
This commit is contained in:
Ahmad Khalil
2023-03-02 11:43:25 +00:00
committed by Gerrit Code Review
parent 6d77c41f2a
commit 4b8d45a4c1
2 changed files with 19 additions and 60 deletions

View File

@@ -1150,37 +1150,6 @@ public class NsdServiceTest {
argThat(info -> matches(info, new NsdServiceInfo(regInfo.getServiceName(), null))));
}
@Test
public void testStopServiceResolutionWithMdnsDiscoveryManager() {
setMdnsDiscoveryManagerEnabled();
final NsdManager client = connectClient(mService);
final ResolveListener resolveListener = mock(ResolveListener.class);
final Network network = new Network(999);
final String serviceType = "_nsd._service._tcp";
final String constructedServiceType = "_nsd._sub._service._tcp.local";
final ArgumentCaptor<MdnsServiceBrowserListener> listenerCaptor =
ArgumentCaptor.forClass(MdnsServiceBrowserListener.class);
final NsdServiceInfo request = new NsdServiceInfo(SERVICE_NAME, serviceType);
request.setNetwork(network);
client.resolveService(request, resolveListener);
waitForIdle();
verify(mSocketProvider).startMonitoringSockets();
verify(mDiscoveryManager).registerListener(eq(constructedServiceType),
listenerCaptor.capture(), argThat(options -> network.equals(options.getNetwork())));
client.stopServiceResolution(resolveListener);
waitForIdle();
// Verify the listener has been unregistered.
verify(mDiscoveryManager, timeout(TIMEOUT_MS))
.unregisterListener(eq(constructedServiceType), eq(listenerCaptor.getValue()));
verify(resolveListener, timeout(TIMEOUT_MS)).onResolutionStopped(argThat(ns ->
request.getServiceName().equals(ns.getServiceName())
&& request.getServiceType().equals(ns.getServiceType())));
verify(mSocketProvider, timeout(CLEANUP_DELAY_MS + TIMEOUT_MS)).stopMonitoringSockets();
}
private void waitForIdle() {
HandlerUtils.waitForIdle(mHandler, TIMEOUT_MS);
}