Disable cache flush bit in existing announcement
Per RFC6762#10.1, the cache flush bit should be false for
existing announcement. Otherwise, the record will be deleted
immediately when receiving this response.
Bug: 299054783
Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I8bf1a5b1914b49720862836abb543b232185f5f5
diff --git a/service-t/src/com/android/server/connectivity/mdns/MdnsRecordRepository.java b/service-t/src/com/android/server/connectivity/mdns/MdnsRecordRepository.java
index 1375279..3ff5501 100644
--- a/service-t/src/com/android/server/connectivity/mdns/MdnsRecordRepository.java
+++ b/service-t/src/com/android/server/connectivity/mdns/MdnsRecordRepository.java
@@ -384,7 +384,9 @@
r -> new MdnsPointerRecord(
r.record.getName(),
0L /* receiptTimeMillis */,
- true /* cacheFlush */,
+ // RFC6762#10.1, the cache flush bit should be false for existing
+ // announcement. Otherwise, the record will be deleted immediately.
+ false /* cacheFlush */,
0L /* ttlMillis */,
r.record.getPointer()));
diff --git a/tests/unit/java/com/android/server/connectivity/mdns/MdnsRecordRepositoryTest.kt b/tests/unit/java/com/android/server/connectivity/mdns/MdnsRecordRepositoryTest.kt
index 0033b5a..d079b50 100644
--- a/tests/unit/java/com/android/server/connectivity/mdns/MdnsRecordRepositoryTest.kt
+++ b/tests/unit/java/com/android/server/connectivity/mdns/MdnsRecordRepositoryTest.kt
@@ -182,7 +182,7 @@
MdnsPointerRecord(
arrayOf("_testservice", "_tcp", "local"),
0L /* receiptTimeMillis */,
- true /* cacheFlush */,
+ false /* cacheFlush */,
0L /* ttlMillis */,
arrayOf("MyTestService", "_testservice", "_tcp", "local"))
), packet.answers)
@@ -211,13 +211,13 @@
MdnsPointerRecord(
arrayOf("_testservice", "_tcp", "local"),
0L /* receiptTimeMillis */,
- true /* cacheFlush */,
+ false /* cacheFlush */,
0L /* ttlMillis */,
arrayOf("MyTestService", "_testservice", "_tcp", "local")),
MdnsPointerRecord(
arrayOf("_subtype", "_sub", "_testservice", "_tcp", "local"),
0L /* receiptTimeMillis */,
- true /* cacheFlush */,
+ false /* cacheFlush */,
0L /* ttlMillis */,
arrayOf("MyTestService", "_testservice", "_tcp", "local")),
), packet.answers)