Add MdnsServiceCache

Currently, the mDns discovery services will clear if no listener
registers to that MdnsServiceTypeClient. If an app does discover,
stop discover, resolve, at this point the listener was
unregistered, so the MdnsServiceTypeClient was deleted, and the
service is gone from cache. So this will actually restart
discovery without returning previous results from cache. Thus,
add MdnsServiceCache to store all services and reduce the
duplicated queries.

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