DoH 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 (3, 2503ms, [TIMEOUT:3 ], 465s) score{71.0}
      8.8.8.8 (4, 1880ms, [NOERROR:1 TIMEOUT:3 ], 468s) score{77.3}
      2001:4860:4860::8844 (9, 15ms, [NOERROR:9 ], 78s) score{99.8}
      2001:4860:4860::8888 <no data> score{100.0}
    over DOH
      2001:4860:4860::8888 (89, 30ms, [NOERROR:89 ], 127s) score{99.7}
    over TLS
      8.8.4.4 <no data> score{100.0}
      8.8.8.8 <no data> score{100.0}
      2001:4860:4860::8844 <no data> score{100.0}
      2001:4860:4860::8888 <no data> score{100.0}
    over TCP
      8.8.4.4 <no data> score{100.0}
      8.8.8.8 <no data> score{100.0}
      2001:4860:4860::8844 <no data> score{100.0}
      2001:4860:4860::8888 <no data> score{100.0}
    over MDNS
      224.0.0.251 <no data> score{100.0}
      ff02::fb <no data> score{100.0}
  TC mode: default
  TransportType: WIFI

Test steps:
a. Default enable strict mode.
b. Turn on WiFi.
c. Turn on Mobile data.
d. Check the output from dumpsys dnsresolver.
e. Expect to see two different statistics with the same DNS server on different NetId.

NetId: 101
    over DOH
      2001:4860:4860::8888 (90, 29ms, [NOERROR:90 ], 7s) score{99.7}
  TransportType: WIFI

NetId: 102
    over DOH
      2001:4860:4860::8888 (2, 33ms, [NOERROR:2 ], 74s) score{99.7}
  TransportType: CELLULAR

Bug: 195092631
Test: checked output in dumpsys dnsresolver
Change-Id: I65c69a850bce352839314833d44c9f165c7ca142
7 files changed
tree: 963b125ec6fecb77fce57357265b1d683fa3063c
  1. aidl_api/
  2. apex/
  3. binder/
  4. include/
  5. tests/
  6. .editorconfig
  7. Android.bp
  8. cbindgen.toml
  9. Dns64Configuration.cpp
  10. Dns64Configuration.h
  11. DnsProxyListener.cpp
  12. DnsProxyListener.h
  13. DnsQueryLog.cpp
  14. DnsQueryLog.h
  15. DnsQueryLogTest.cpp
  16. DnsResolver.cpp
  17. DnsResolver.h
  18. DnsResolverService.cpp
  19. DnsResolverService.h
  20. DnsStats.cpp
  21. DnsStats.h
  22. DnsStatsTest.cpp
  23. DnsTlsDispatcher.cpp
  24. DnsTlsDispatcher.h
  25. DnsTlsQueryMap.cpp
  26. DnsTlsQueryMap.h
  27. DnsTlsServer.cpp
  28. DnsTlsServer.h
  29. DnsTlsSessionCache.cpp
  30. DnsTlsSessionCache.h
  31. DnsTlsSocket.cpp
  32. DnsTlsSocket.h
  33. DnsTlsSocketFactory.h
  34. DnsTlsTransport.cpp
  35. DnsTlsTransport.h
  36. doh.h
  37. doh.rs
  38. Experiments.cpp
  39. Experiments.h
  40. ExperimentsTest.cpp
  41. getaddrinfo.cpp
  42. getaddrinfo.h
  43. gethnamaddr.cpp
  44. gethnamaddr.h
  45. hostent.h
  46. IDnsTlsSocket.h
  47. IDnsTlsSocketFactory.h
  48. IDnsTlsSocketObserver.h
  49. IPrivateDnsServer.h
  50. libnetd_resolv.map.txt
  51. LockedQueue.h
  52. NOTICE
  53. OperationLimiter.h
  54. OperationLimiterTest.cpp
  55. OWNERS
  56. params.h
  57. PREUPLOAD.cfg
  58. PrivateDnsCommon.h
  59. PrivateDnsConfiguration.cpp
  60. PrivateDnsConfiguration.h
  61. PrivateDnsConfigurationTest.cpp
  62. PrivateDnsValidationObserver.h
  63. README-DoT.md
  64. README.md
  65. res_cache.cpp
  66. res_comp.cpp
  67. res_comp.h
  68. res_debug.cpp
  69. res_debug.h
  70. res_mkquery.cpp
  71. res_query.cpp
  72. res_send.cpp
  73. res_send.h
  74. res_stats.cpp
  75. resolv_cache.h
  76. resolv_private.h
  77. resolv_rust_test_config_template.xml
  78. resolv_test_config_template.xml
  79. ResolverController.cpp
  80. ResolverController.h
  81. ResolverEventReporter.cpp
  82. ResolverEventReporter.h
  83. ResolverStats.h
  84. sethostent.cpp
  85. stats.h
  86. stats.proto
  87. TEST_MAPPING
  88. util.cpp
  89. util.h
README.md

Logging

This code uses LOG(X) for logging. Log levels are VERBOSE,DEBUG,INFO,WARNING and ERROR. The default setting is WARNING and logs relate to WARNING and ERROR will be shown. If you want to enable the DEBUG level logs, using following command. adb shell service call dnsresolver 10 i32 1 VERBOSE 0 DEBUG 1 INFO 2 WARNING 3 ERROR 4 Verbose resolver logs could contain PII -- do NOT enable in production builds.