Remove cached services when the network is disconnected or unrequested
The services in the cache are no longer useful after the network
is disconnected. Because either the Network object or the
interface index will change after the network is reconnected,
these cached services won't be used for any discovery/resolution/
service info callback requests. Therefore, these cached services
should be removed after the network is disconnected. Otherwise,
these useless cached services will occupy memory until the device
is rebooted.
In addition, the cached service may not be reliable after the
last listener is unregistered. Because the socket is
disconnected, the service type client won't receive any updates
for the services. Therefore, remove these cached services after
exceeding the keeping time.
Bug: 355421878
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I06ff320fec84f71dc2ed742c50fa46f25c284170
6 files changed