Fix NetworkMonitor won't do private dns resolution

NetworkMonitor cannot do the private dns resolution due to lack
"mNetworkCapabilities". ConnectivityService will call
NetworkStackService#notifyPrivateDnsChanged() before doing
network validation. After NetworkMonitor received
CMD_PRIVATE_DNS_SETTINGS_CHANGED, it will call
isValidationRequired to check if the validation is required.
But mNetworkCapabilities didn't be set, so the
mPrivateDnsProviderHostname will be set to empty and make
EvaluatingPrivateDnsState doesn't do private dns resolution.

Bug: 129375892
Test: 1. Build pass
      2. atest FrameworksNetTests
      3. atest NetworkStackTests

Change-Id: I637212fb4746bb2e9a2f4a4457fd36c4c2701149
This commit is contained in:
lucaslin
2019-04-03 17:09:28 +08:00
parent 1f041d1443
commit 45e639b041

View File

@@ -6387,6 +6387,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
Slog.wtf(TAG, networkAgent.name() + " connected with null LinkProperties");
}
// NetworkCapabilities need to be set before sending the private DNS config to
// NetworkMonitor, otherwise NetworkMonitor cannot determine if validation is required.
synchronized (networkAgent) {
networkAgent.setNetworkCapabilities(networkAgent.networkCapabilities);
}
handlePerNetworkPrivateDnsConfig(networkAgent, mDnsManager.getPrivateDnsConfig());
updateLinkProperties(networkAgent, new LinkProperties(networkAgent.linkProperties),
null);