adb: Set a hostname for mDNS am: 1fe3cae67e am: f18d33c2c6

am: 0b13090ac7

Change-Id: I84093fc1f5e652e401333c428c9a200de4f02890
This commit is contained in:
Casey Dahlin 2017-03-10 03:16:02 +00:00 committed by android-build-merger
commit 2bde29f5be
1 changed files with 7 additions and 3 deletions

View File

@ -61,9 +61,13 @@ static void setup_mdns_thread(void* /* unused */) {
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 << ").";