NDC migration to binder ver.

Make ndc communicating with netd via binder

Bug: 65862741
Test: built, flashed, booted
      system/netd/tests/runtests.sh pass
      manual test ndc commands
Change-Id: I9edfda61d8c3a4d7b404a428e7dbb4d08eff62a9
diff --git a/server/main.cpp b/server/main.cpp
index 45b968d..b783ce5 100644
--- a/server/main.cpp
+++ b/server/main.cpp
@@ -37,7 +37,6 @@
 #include <binder/IServiceManager.h>
 #include <netdutils/Stopwatch.h>
 
-#include "CommandListener.h"
 #include "Controllers.h"
 #include "FwmarkServer.h"
 #include "MDnsSdListener.h"
@@ -54,7 +53,6 @@
 using android::IPCThreadState;
 using android::status_t;
 using android::String16;
-using android::net::CommandListener;
 using android::net::FwmarkServer;
 using android::net::gCtls;
 using android::net::gLog;
@@ -105,10 +103,8 @@
     // Before we do anything that could fork, mark CLOEXEC the UNIX sockets that we get from init.
     // FrameworkListener does this on initialization as well, but we only initialize these
     // components after having initialized other subsystems that can fork.
-    for (const auto& sock : { CommandListener::SOCKET_NAME,
-                              DNSPROXYLISTENER_SOCKET_NAME,
-                              FwmarkServer::SOCKET_NAME,
-                              MDnsSdListener::SOCKET_NAME }) {
+    for (const auto& sock :
+         {DNSPROXYLISTENER_SOCKET_NAME, FwmarkServer::SOCKET_NAME, MDnsSdListener::SOCKET_NAME}) {
         setCloseOnExec(sock);
     }
 
@@ -130,20 +126,6 @@
     gCtls = new android::net::Controllers();
     gCtls->init();
 
-    // NetdNativeService must start before CommandListener.
-    // TODO: put NetdNativeService starting back after subsystems started
-    // after migrating CommandListener to NDC, aosp/929861.
-    Stopwatch subTime;
-    status_t ret;
-    if ((ret = NetdNativeService::start()) != android::OK) {
-        ALOGE("Unable to start NetdNativeService: %d", ret);
-        exit(1);
-    }
-    gLog.info("Registering NetdNativeService: %.1fms", subTime.getTimeAndReset());
-
-    CommandListener cl;
-    nm->setBroadcaster((SocketListener *) &cl);
-
     if (nm->start()) {
         ALOGE("Unable to start NetlinkManager (%s)", strerror(errno));
         exit(1);
@@ -187,15 +169,13 @@
         exit(1);
     }
 
-    /*
-     * Now that we're up, we can respond to commands. Starting the listener also tells
-     * NetworkManagementService that we are up and that our binder interface is ready.
-     */
-    if (cl.startListener()) {
-        ALOGE("Unable to start CommandListener (%s)", strerror(errno));
+    Stopwatch subTime;
+    status_t ret;
+    if ((ret = NetdNativeService::start()) != android::OK) {
+        ALOGE("Unable to start NetdNativeService: %d", ret);
         exit(1);
     }
-    gLog.info("Starting CommandListener: %.1fms", subTime.getTimeAndReset());
+    gLog.info("Registering NetdNativeService: %.1fms", subTime.getTimeAndReset());
 
     android::net::process::ScopedPidFile pidFile(PID_FILE_PATH);