From 4d9241945bd952b78481863cd57be170b97c1fd6 Mon Sep 17 00:00:00 2001 From: Sharad Binjola Date: Tue, 5 Dec 2023 10:42:05 -0800 Subject: [PATCH] Fix NsdService error due to subtypes on Android 14 --- .../chip/platform/NsdManagerServiceResolver.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java index c01855172fcfe6..cb7766c25102b0 100644 --- a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java +++ b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java @@ -138,20 +138,13 @@ 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); + Log.i(TAG, "publish serviceName=" + serviceName + " type=" + type + " port=" + port); int cnt = Math.min(textEntriesDatas.length, textEntriesKeys.length); for (int i = 0; i < cnt; i++) { String value = new String(textEntriesDatas[i]);