adb: Set a hostname for mDNS am: 1fe3cae67e
am: f18d33c2c6
Change-Id: I1e9a6c54252ded977a6b7ae90d545d6204f89dbd
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 << ").";