Fix flaky test RepeatedSetup_KeepChangingPrivateDnsServers

Same as aosp/1262819, this test needs a buffer time to prevent being
flaky. The test running time increases by 700ms as a side effect.

Bug: 150678049
Bug: 152371971
Test: resolv_integration_test passed
Merged-In: I603e2a3b6977bcac06b542bc5312305fe25487fb
Change-Id: Ia6273ddcd039b83a18951a7d23fb6423f6e89c04
(cherry picked from commit 470bcc0e49ad4338a19fd43d5786befbb2d56a51)
diff --git a/tests/resolv_integration_test.cpp b/tests/resolv_integration_test.cpp
index 76857cb..9dda0f1 100644
--- a/tests/resolv_integration_test.cpp
+++ b/tests/resolv_integration_test.cpp
@@ -4355,6 +4355,11 @@
     enum TlsServerState { WORKING, UNSUPPORTED, UNRESPONSIVE };
     const std::string addr1 = getUniqueIPv4Address();
     const std::string addr2 = getUniqueIPv4Address();
+    const auto waitForPrivateDnsStateUpdated = []() {
+        // A buffer time for PrivateDnsConfiguration to update its state. It prevents this test
+        // being flaky. See b/152009023 for the reason.
+        std::this_thread::sleep_for(20ms);
+    };
 
     test::DNSResponder dns1(addr1);
     test::DNSResponder dns2(addr2);
@@ -4408,6 +4413,7 @@
             tls.setHangOnHandshakeForTesting(serverState == UNRESPONSIVE);
             const int connectCountsBefore = tls.acceptConnectionsCount();
 
+            waitForPrivateDnsStateUpdated();
             ResolverParamsParcel parcel = DnsResponderClient::GetDefaultResolverParamsParcel();
             parcel.servers = {config.tlsServer};
             parcel.tlsServers = {config.tlsServer};