Skip to content

Commit

Permalink
Fix NsdService error due to subtypes on Android 14
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadb-amazon committed Dec 5, 2023
1 parent 2675b00 commit 4a194b4
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,10 @@ public void publish(
serviceInfo.setServiceName(serviceName);

/**
* Note, subtypes registration is using an undocumented feature of android dns-sd
* service/mDNSResponder which MAY STOP WORKING in future Android versions. Here, set type =
* "${type},${subtypes1},${subtypes2},...", then subtypes1, subtypes2 etc are all registered to
* this dns-sd server, we can usd `dns-sd -B ${type},${subtypes}` or avahi-browse
* ${subtypes}._sub.${type} -r to browser it
* TODO: Add subtypes registration when the Android NsdManager provides a documented mechanism
* to publish them. See https://issuetracker.google.com/u/3/issues/314256875
*/
StringBuilder sb = new StringBuilder(type);
for (String subType : subTypes) {
sb.append(",").append(subType);
}
serviceInfo.setServiceType(sb.toString());
serviceInfo.setServiceType(type);

serviceInfo.setPort(port);
Log.i(TAG, "publish serviceName=" + serviceName + " type=" + sb.toString() + " port=" + port);
Expand Down

0 comments on commit 4a194b4

Please sign in to comment.