Restore private dns host name after testing

The helper method in CtsNetUtils will not restore the private
dns hostname back if the device private dns mode is not strict
mode. It does not cause function break since the host
configuration is useful only when the private dns mode is in
strict mode. But tests should restore the setting back to its
old state to prevent break other tests or erase setttings.

Test: atest android.net.cts.ConnectivityManagerTest and
      check if the private dns server configuration is
      changed or not after testing
Change-Id: I7c85ddac7306c7c3eeac84679d96c4cfb11bd875
diff --git a/tests/cts/net/util/java/android/net/cts/util/CtsNetUtils.java b/tests/cts/net/util/java/android/net/cts/util/CtsNetUtils.java
index fd0cd18..7d9a24b 100644
--- a/tests/cts/net/util/java/android/net/cts/util/CtsNetUtils.java
+++ b/tests/cts/net/util/java/android/net/cts/util/CtsNetUtils.java
@@ -582,6 +582,9 @@
         }
 
         if (mOldPrivateDnsMode != ConnectivitySettingsUtils.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME) {
+            // Also restore hostname even if the value is not used since private dns is not in
+            // the strict mode to prevent setting being changed after test.
+            ConnectivitySettingsUtils.setPrivateDnsHostname(mContext, mOldPrivateDnsSpecifier);
             ConnectivitySettingsUtils.setPrivateDnsMode(mContext, mOldPrivateDnsMode);
             return;
         }