Make ADBD announce its presence over mDNS
We now request mdnsd from adb and register a service of type _adb._tcp
for clients to connect to.
Test: Verified service appears in avahi-browse
Bug: 28074466
(cherry picked from 379ac414e4d9f53388d903913022a55695292775)
Change-Id: Ie871b9c8b40e86063cc1e68e8f3e4290ead2d279
diff --git a/daemon/main.cpp b/daemon/main.cpp
index 6382b67..7da94ce 100644
--- a/daemon/main.cpp
+++ b/daemon/main.cpp
@@ -45,6 +45,8 @@
#include "adb_utils.h"
#include "transport.h"
+#include "mdns.h"
+
static const char* root_seclabel = nullptr;
static void drop_capabilities_bounding_set_if_needed(struct minijail *j) {
@@ -140,6 +142,11 @@
}
}
+static void setup_port(int port) {
+ local_init(port);
+ setup_mdns(port);
+}
+
int adbd_main(int server_port) {
umask(0);
@@ -188,10 +195,10 @@
if (sscanf(prop_port.c_str(), "%d", &port) == 1 && port > 0) {
D("using port=%d", port);
// Listen on TCP port specified by service.adb.tcp.port property.
- local_init(port);
+ setup_port(port);
} else if (!is_usb) {
// Listen on default port.
- local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT);
+ setup_port(DEFAULT_ADB_LOCAL_TRANSPORT_PORT);
}
D("adbd_main(): pre init_jdwp()");