adb: Set a hostname for mDNS am: 1fe3cae67e

am: f18d33c2c6

Change-Id: I1e9a6c54252ded977a6b7ae90d545d6204f89dbd
This commit is contained in:
Casey Dahlin 2017-03-10 01:20:57 +00:00 committed by android-build-merger
commit 0b13090ac7
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 << ").";