Process all responses if the network is null in MdnsServiceTypeClient

If the network is null in MdnsServiceTypeClient, it should use
MdnsSocketClient for single socket only. So it's expected to
process any response from only the socket (network).

Move the stopDiscovery outside the listener check loop.
Because the stop should only be called once.

Add a test to verify the response processing with a non-null
network MdnsServiceTypeClient

Bug: 265787401
Test: atest FrameworksNetTests
(cherry picked from https://android-review.googlesource.com/q/commit:bdf82a2aa0d7447de75fdcca60734936b926e25e)
Merged-In: I76965302037f050e0ac3b2cfdbaa5a855e2283c7
Change-Id: I76965302037f050e0ac3b2cfdbaa5a855e2283c7
2 files changed