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

Commit 1fe3cae6 authored by Casey Dahlin's avatar Casey Dahlin
Browse files

adb: Set a hostname for mDNS

Now all devices won't appear as "Android." Should make it easier to
multiplex.

Test: Verified locally on a raspberry pi 3
Bug: 28887278
(cherry picked from 815b23319635d264ae0ce2c8c29a5776a57b8051)

Change-Id: Icfd0116477543af6a3049c14d818c1cff7fc3b93
parent 6cd5e0b4
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 << ").";