Move resolv_init out and make callbacks of libnetd_resolv global

1. Revise init flow of libnetd_resolv
   - A better and generic design for it
2. Rename and make callbacks from netd global
   - libnetd_resolv has multiple components need to use it
   - res* component could use it easily

Bug: 126141549
Test: built, flashed, booted
      system/netd/tests/runtests.sh pass

Change-Id: Iacb4fd708a26fd9c9139a606f0320fc12b4fc7e1
diff --git a/DnsResolverService.cpp b/DnsResolverService.cpp
index adf698b..fa61f9d 100644
--- a/DnsResolverService.cpp
+++ b/DnsResolverService.cpp
@@ -16,6 +16,8 @@
 
 #define LOG_TAG "DnsResolverService"
 
+#include "DnsResolverService.h"
+
 #include <set>
 #include <vector>
 
@@ -26,7 +28,7 @@
 #include <log/log.h>
 #include <private/android_filesystem_config.h>  // AID_SYSTEM
 
-#include "DnsResolverService.h"
+#include "DnsResolver.h"
 #include "NetdPermissions.h"  // PERM_*
 
 using android::base::Join;
@@ -53,10 +55,10 @@
 
 }  // namespace
 
-binder_status_t DnsResolverService::start(const dnsproxylistener_callbacks& callbacks) {
+binder_status_t DnsResolverService::start() {
     // TODO: Add disableBackgroundScheduling(true) after libbinder_ndk support it. b/126506010
     // NetdNativeService does call disableBackgroundScheduling currently, so it is fine now.
-    DnsResolverService* resolverService = new DnsResolverService(callbacks);
+    DnsResolverService* resolverService = new DnsResolverService();
     binder_status_t status =
             AServiceManager_addService(resolverService->asBinder().get(), getServiceName());
     if (status != STATUS_OK) {
@@ -82,7 +84,7 @@
         const std::vector<const char*>& permissions) {
     // TODO: Remove callback and move this to unnamed namespace after libbiner_ndk supports
     // check_permission.
-    if (!mCallbacks.check_calling_permission) {
+    if (!gResNetdCallbacks.check_calling_permission) {
         return ::ndk::ScopedAStatus(AStatus_fromExceptionCodeWithMessage(
                 EX_NULL_POINTER, "check_calling_permission is null"));
     }
@@ -103,7 +105,7 @@
     }
 
     for (const char* permission : permissions) {
-        if (mCallbacks.check_calling_permission(permission)) {
+        if (gResNetdCallbacks.check_calling_permission(permission)) {
             return ::ndk::ScopedAStatus(AStatus_newOk());
         }
     }