Deflaky test for DnsResolverTest

It's possible that private DNS setting is not in the state we expected
when we tried to enable strict mode during tests. The problem here is
that there are 2 setting Uris(mode and specifier) relating to strict
mode, each of them might trigger private DNS setting changing evnet in
ConnectivityService.
Previously, we tried to enable strict mode with first set private DNS
mode and then private DNS specifier. This may result in 2 consecutive
private DNS changes events with very short intervals, which caused
conflicts between DnsResolver / NetworkMonitor and lead to flaky tests.

So
0. Use opportunistic as default mode if no default mode existed.
1. Change the order (mode and specifier) for enabling strict mode.
2. Change private DNS mode only when needed.
     (If original mode is "hostname", then we only need to set
     specifier)

Bug: 153624005
Bug: 151122313
Bug: 150952393
Test: atest DnsResolverTest --rerun-until-failure 100
Test: forrest (git_master, cts/networking/gce-all)
Test: forrest (git_rvc-dev, atest CtsNetTestCases)
Test: forrest (git_rvc-dev, mts/dnsresolver/device-all)
Merged-In: I224a6493c87cebaf0bf954c2644e2945ccd50db1
Change-Id: Ib61ad7bd510341366ebbbb72aa451e5809ee3e9d
(cherry picked from commit 7561b1499c1b8da0334b32c0452d49113d9e4806)
3 files changed