Modularize resolver statistics

The extendibility of the legacy resolver statistics is limited because
it was originally designed for libc, which is hard to implement to
support other types of DNS, e.g. DNS-over-TLS. Therefore, DnsStats
is introduced to manage the statistics in a more general way.

DoT statistics is now available from DnsStats and is shown in
dumpsys dnsresolver.

Example of output from dumpsys dnsresolver:

Server statistics: (total, RTT avg, {rcode:counts}, last update)
  over UDP
    8.8.4.4 <no data>
    8.8.8.8 <no data>
    2001:4860:4860::8844 (7, 2201ms, [NOERROR:4 TIMEOUT:3 ], 2s)
    2001:4860:4860::8888 (3, 11ms, [NOERROR:3 ], 4s)
  over TLS
    <no server>
  over TCP
    8.8.4.4 <no data>
    8.8.8.8 <no data>
    2001:4860:4860::8844 <no data>
    2001:4860:4860::8888 <no data>

Bug: 140286585
Test: atest --include-subdirs packages/modules/DnsResolver
Test: checked output in dumpsys dnsresolver
Change-Id: I73f0108d5e9bb493cf7eda68252f5a0922149a98
diff --git a/PrivateDnsConfiguration.cpp b/PrivateDnsConfiguration.cpp
index 9242222..f59e64e 100644
--- a/PrivateDnsConfiguration.cpp
+++ b/PrivateDnsConfiguration.cpp
@@ -28,6 +28,7 @@
 #include "ResolverEventReporter.h"
 #include "netd_resolv/resolv.h"
 #include "netdutils/BackoffSequence.h"
+#include "resolv_cache.h"
 
 using std::chrono::milliseconds;
 
@@ -95,6 +96,7 @@
     } else {
         mPrivateDnsModes[netId] = PrivateDnsMode::OFF;
         mPrivateDnsTransports.erase(netId);
+        resolv_stats_set_servers_for_dot(netId, {});
         return 0;
     }
 
@@ -126,7 +128,8 @@
             validatePrivateDnsProvider(server, tracker, netId, mark);
         }
     }
-    return 0;
+
+    return resolv_stats_set_servers_for_dot(netId, servers);
 }
 
 PrivateDnsStatus PrivateDnsConfiguration::getStatus(unsigned netId) {