Apply PrivateDnsValidationObserver to DnsTlsDispatcher
Also aligh the life time of DnsTlsDispatcher with
PrivateDnsConfiguration's so that the DnsTlsDispatcher won't miss
any notification.
Bug: 79727473
Test: cd packages/modules/DnsResolver && atest with the flag on/off
Change-Id: Iaf1c809b79373b6846e6535aa6f0c619f430898c
diff --git a/DnsResolver.cpp b/DnsResolver.cpp
index 5068aef..3d7647d 100644
--- a/DnsResolver.cpp
+++ b/DnsResolver.cpp
@@ -20,6 +20,8 @@
#include "DnsProxyListener.h"
#include "DnsResolverService.h"
+#include "DnsTlsDispatcher.h"
+#include "PrivateDnsConfiguration.h"
#include "netd_resolv/resolv.h"
#include "res_debug.h"
#include "util.h"
@@ -72,6 +74,14 @@
return &instance;
}
+DnsResolver::DnsResolver() {
+ // TODO: make them member variables after fixing the circular dependency:
+ // DnsTlsDispatcher.h -> resolv_private.h -> DnsResolver.h -> DnsTlsDispatcher.h
+ auto& dnsTlsDispatcher = DnsTlsDispatcher::getInstance();
+ auto& privateDnsConfiguration = PrivateDnsConfiguration::getInstance();
+ privateDnsConfiguration.setObserver(&dnsTlsDispatcher);
+}
+
bool DnsResolver::start() {
if (!verifyCallbacks()) {
LOG(ERROR) << __func__ << ": Callback verification failed";