Enable APFv6 mDNS offload for records without priority
This commit enables APFv6-based mDNS offload for records that lack a
properly configured priority value. While third-party apps cannot
configure priority in the overlay, their mDNS offload use case should
still be supported.
Test: TH
Change-Id: I7c1b291986730c999f5f4415d6dce162ea6bf497
diff --git a/src/android/net/apf/ApfMdnsUtils.java b/src/android/net/apf/ApfMdnsUtils.java
index 393e5fb..6921b46 100644
--- a/src/android/net/apf/ApfMdnsUtils.java
+++ b/src/android/net/apf/ApfMdnsUtils.java
@@ -76,11 +76,6 @@
final List<MdnsOffloadRule> rules = new ArrayList<>();
final Set<MdnsOffloadRule.Matcher> allMatchers = new ArraySet<>();
for (OffloadServiceInfo info : sortedOffloadServiceInfos) {
- // Don't offload the records if the priority is not configured.
- int priority = info.getPriority();
- if (priority == Integer.MAX_VALUE) {
- continue;
- }
List<MdnsOffloadRule.Matcher> matcherGroup = new ArrayList<>();
final OffloadServiceInfo.Key key = info.getKey();
final String[] serviceTypeLabels = CollectionUtils.appendArray(String.class,
diff --git a/tests/unit/src/android/net/apf/ApfMdnsUtilsTest.kt b/tests/unit/src/android/net/apf/ApfMdnsUtilsTest.kt
index 6d54438..11debbc 100644
--- a/tests/unit/src/android/net/apf/ApfMdnsUtilsTest.kt
+++ b/tests/unit/src/android/net/apf/ApfMdnsUtilsTest.kt
@@ -32,7 +32,6 @@
import java.io.IOException
import kotlin.test.assertContentEquals
import kotlin.test.assertFailsWith
-import kotlin.test.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -91,17 +90,10 @@
0, 0).map { it.toByte() }.toByteArray()
@Test
- fun testExtractOffloadReplyRule_noPriorityReturnsEmptySet() {
- val info = createOffloadServiceInfo(Int.MAX_VALUE)
- val rules = extractOffloadReplyRule(listOf(info))
- assertTrue(rules.isEmpty())
- }
-
- @Test
- fun testExtractOffloadReplyRule_extractRulesWithValidPriority() {
+ fun testExtractOffloadReplyRule_extractRules() {
val info1 = createOffloadServiceInfo(10)
val info2 = createOffloadServiceInfo(
- 11,
+ Integer.MAX_VALUE,
testServiceName2,
listOf("a", "b", "c", "d"),
testRawPacket2