From a7fca1d076d9610737a16a123ce728d78a309e76 Mon Sep 17 00:00:00 2001 From: xylophone21 Date: Thu, 10 Feb 2022 11:24:20 +0800 Subject: [PATCH 1/6] fix android dns-sd subtype error, and fix manualcode code pair search issue --- .../java/chip/platform/NsdManagerServiceResolver.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java index 02c0b9662c742c..55f4a7a7210b92 100644 --- a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java +++ b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java @@ -127,7 +127,13 @@ public void publish( String[] subTypes) { NsdServiceInfo serviceInfo = new NsdServiceInfo(); serviceInfo.setServiceName(serviceName); - serviceInfo.setServiceType(type); + + StringBuilder sb = new StringBuilder(type); + for (String subType:subTypes) { + sb.append(","+subType); + } + serviceInfo.setServiceType(sb.toString()); + serviceInfo.setPort(port); Log.i(TAG, "publish serviceName=" + serviceName + " type=" + type + " port=" + port); int cnt = Math.min(textEntriesDatas.length, textEntriesKeys.length); From d586a364abebb394161c9e203547139a5fdff8dd Mon Sep 17 00:00:00 2001 From: xylophone21 Date: Thu, 10 Feb 2022 11:39:44 +0800 Subject: [PATCH 2/6] fix restyled-io and ci errors --- .../android/java/chip/platform/NsdManagerServiceResolver.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java index 55f4a7a7210b92..fed9bee051daf5 100644 --- a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java +++ b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java @@ -129,8 +129,8 @@ public void publish( serviceInfo.setServiceName(serviceName); StringBuilder sb = new StringBuilder(type); - for (String subType:subTypes) { - sb.append(","+subType); + for (String subType : subTypes) { + sb.append("," + subType); } serviceInfo.setServiceType(sb.toString()); From 910d6ee3558798547e8f8174fc5610dff00a8bf4 Mon Sep 17 00:00:00 2001 From: xylophone21 Date: Thu, 10 Feb 2022 15:52:04 +0800 Subject: [PATCH 3/6] using append instead of + --- .../android/java/chip/platform/NsdManagerServiceResolver.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java index fed9bee051daf5..688f8da24b08d8 100644 --- a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java +++ b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java @@ -130,12 +130,12 @@ public void publish( StringBuilder sb = new StringBuilder(type); for (String subType : subTypes) { - sb.append("," + subType); + sb.append(",").append(subType); } serviceInfo.setServiceType(sb.toString()); serviceInfo.setPort(port); - Log.i(TAG, "publish serviceName=" + serviceName + " type=" + type + " port=" + port); + Log.i(TAG, "publish serviceName=" + serviceName + " type=" + sb.toString() + " port=" + port); int cnt = Math.min(textEntriesDatas.length, textEntriesKeys.length); for (int i = 0; i < cnt; i++) { String value = new String(textEntriesDatas[i]); From 69d2be4886381924b6eb9574eef2b6ebcc927416 Mon Sep 17 00:00:00 2001 From: xylophone21 Date: Tue, 15 Feb 2022 11:32:44 +0800 Subject: [PATCH 4/6] added comment about this PR --- .../java/chip/platform/NsdManagerServiceResolver.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java index 688f8da24b08d8..10c514da0a2c1b 100644 --- a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java +++ b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java @@ -128,6 +128,12 @@ public void publish( NsdServiceInfo serviceInfo = new NsdServiceInfo(); serviceInfo.setServiceName(serviceName); + /** + * Note, subtypes registration is using an undocumented feature of android nds-sd service/mDNSResponder + * which MAY STOP WORKING in future Android versions + * Here, set type = "${tyep},${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 + */ StringBuilder sb = new StringBuilder(type); for (String subType : subTypes) { sb.append(",").append(subType); From 7c5e38528b9255bcb06708d54255993b36d3c225 Mon Sep 17 00:00:00 2001 From: xylophone21 Date: Tue, 15 Feb 2022 11:41:53 +0800 Subject: [PATCH 5/6] fix restyled-io and ci errors --- .../chip/platform/NsdManagerServiceResolver.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java index 10c514da0a2c1b..ac3d7d88751d4e 100644 --- a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java +++ b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java @@ -128,12 +128,13 @@ public void publish( NsdServiceInfo serviceInfo = new NsdServiceInfo(); serviceInfo.setServiceName(serviceName); - /** - * Note, subtypes registration is using an undocumented feature of android nds-sd service/mDNSResponder - * which MAY STOP WORKING in future Android versions - * Here, set type = "${tyep},${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 - */ + /** + * Note, subtypes registration is using an undocumented feature of android nds-sd + * service/mDNSResponder which MAY STOP WORKING in future Android versions. Here, set type = + * "${tyep},${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 + */ StringBuilder sb = new StringBuilder(type); for (String subType : subTypes) { sb.append(",").append(subType); From 70d7bad19a4fc4e5c86170b2af6ab7bc252a18a0 Mon Sep 17 00:00:00 2001 From: xylophone21 Date: Tue, 15 Feb 2022 11:50:26 +0800 Subject: [PATCH 6/6] fix typos --- .../android/java/chip/platform/NsdManagerServiceResolver.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java index ac3d7d88751d4e..dbbb9052c710f0 100644 --- a/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java +++ b/src/platform/android/java/chip/platform/NsdManagerServiceResolver.java @@ -129,9 +129,9 @@ public void publish( serviceInfo.setServiceName(serviceName); /** - * Note, subtypes registration is using an undocumented feature of android nds-sd + * 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 = - * "${tyep},${subtypes1},${subtypes2},...", then subtypes1, subtypes2 etc are all registered to + * "${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 */