Adjust the notifyNetworkUnrequested on handleRegisterListener
If the MdnsServiceTypeClient was removed when the
SocketCreationCallback#onAllSocketsDestroyed() was called, the
MdnsSocketClientBase#notifyNetworkUnrequested() will not be
called when a listener is unregistered from the
MdnsDiscoveryManager. This is because the serviceTypeClients will
be cleared after the socket is destroyed. However, these dead
listeners will be re-added to the MdnsServiceTypeClient when a
new socket is created. They will then continue to send callbacks
to the NsdService. Therefore, the notifyNetworkUnrequested()
should be moved to the beginning of the handleRegisterListener()
to ensure that the socket unregistration is properly notified.
Original change: https://android-review.git.corp.google.com/c/platform/packages/modules/Connectivity/+/2618620
Bug: 285997766
Change-Id: Iff78d02ad685f187e6906d29851bc857c61a0a53
Test: atest FrameworksNetTests android.net.cts.NsdManagerTest
Merged-In: I31c766305018889f50a7c12c836174c340d01d7f
2 files changed