Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f18d33c2 authored by Casey Dahlin's avatar Casey Dahlin Committed by android-build-merger
Browse files

adb: Set a hostname for mDNS

am: 1fe3cae6

Change-Id: Iea8700ec13502e58774968cd7383255f769fa105
parents cc9c92fa 1fe3cae6
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -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 << ").";