From aefac392ea4ae2b22b934bca5fd91b4d1e25d4af Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Fri, 6 Jan 2017 10:25:02 +0900 Subject: [PATCH] Temporarily restore the net.dnsX system properties. This will limit app breakage in dogfood. The plan is to remove these obsolete system properties again in O developer preview builds so that application developers can move away from them. Test: marlin boots and net.dnsX exists and is updated correctly Bug: 33308258 Bug: 33807046 Bug: 34028616 Bug: 34115651 Change-Id: Iaf2fa213c314b7ba251c065b304e7e9869bafe9f --- .../android/server/ConnectivityService.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 7572dfe0c5..f271b08759 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -4597,9 +4597,28 @@ public class ConnectivityService extends IConnectivityManager.Stub } catch (Exception e) { loge("Exception in setDnsConfigurationForNetwork: " + e); } + final NetworkAgentInfo defaultNai = getDefaultNetwork(); + if (defaultNai != null && defaultNai.network.netId == netId) { + setDefaultDnsSystemProperties(dnses); + } flushVmDnsCache(); } + private void setDefaultDnsSystemProperties(Collection dnses) { + int last = 0; + for (InetAddress dns : dnses) { + ++last; + String key = "net.dns" + last; + String value = dns.getHostAddress(); + SystemProperties.set(key, value); + } + for (int i = last + 1; i <= mNumDnsEntries; ++i) { + String key = "net.dns" + i; + SystemProperties.set(key, ""); + } + mNumDnsEntries = last; + } + private String getNetworkPermission(NetworkCapabilities nc) { // TODO: make these permission strings AIDL constants instead. if (!nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED)) { @@ -4816,6 +4835,7 @@ public class ConnectivityService extends IConnectivityManager.Stub notifyLockdownVpn(newNetwork); handleApplyDefaultProxy(newNetwork.linkProperties.getHttpProxy()); updateTcpBufferSizes(newNetwork); + setDefaultDnsSystemProperties(newNetwork.linkProperties.getDnsServers()); } private void processListenRequests(NetworkAgentInfo nai, boolean capabilitiesChanged) {