adb: Set a hostname for mDNS am: 1fe3cae67e am: f18d33c2c6
am: 0b13090ac7
Change-Id: I84093fc1f5e652e401333c428c9a200de4f02890
diff --git a/adb/daemon/mdns.cpp b/adb/daemon/mdns.cpp
index 85c5a07..a8622ae 100644
--- a/adb/daemon/mdns.cpp
+++ b/adb/daemon/mdns.cpp
@@ -61,9 +61,13 @@
start_mdns();
std::lock_guard<std::mutex> lock(mdns_lock);
- auto error = DNSServiceRegister(&mdns_ref, 0, 0, nullptr, "_adb._tcp",
- nullptr, nullptr, htobe16((uint16_t)port),
- 0, nullptr, mdns_callback, nullptr);
+ std::string hostname = "adb-";
+ hostname += android::base::GetProperty("ro.serialno", "unidentified");
+
+ auto error = DNSServiceRegister(&mdns_ref, 0, 0, hostname.c_str(),
+ kADBServiceType, nullptr, nullptr,
+ htobe16((uint16_t)port), 0, nullptr,
+ mdns_callback, nullptr);
if (error != kDNSServiceErr_NoError) {
LOG(ERROR) << "Could not register mDNS service (" << error << ").";