resolved conflicts for merge of aaf31586 to master

Change-Id: I9e8faaa94f9b251a9c003dc6b9a3e2a97c4564a9
This commit is contained in:
Robert Greenwalt
2011-07-25 16:06:25 -07:00
2 changed files with 33 additions and 3 deletions

View File

@@ -20,6 +20,7 @@ import java.net.InetAddress;
import java.net.Inet4Address; import java.net.Inet4Address;
import java.net.Inet6Address; import java.net.Inet6Address;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.Collection;
import android.util.Log; import android.util.Log;
@@ -235,4 +236,18 @@ public class NetworkUtils {
throw new IllegalArgumentException(e); throw new IllegalArgumentException(e);
} }
} }
/**
* Create a string array of host addresses from a collection of InetAddresses
* @param addrs a Collection of InetAddresses
* @return an array of Strings containing their host addresses
*/
public static String[] makeStrings(Collection<InetAddress> addrs) {
String[] result = new String[addrs.size()];
int i = 0;
for (InetAddress addr : addrs) {
result[i++] = addr.getHostAddress();
}
return result;
}
} }

View File

@@ -1926,7 +1926,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
} }
// Caller must grab mDnsLock. // Caller must grab mDnsLock.
private boolean updateDns(String network, Collection<InetAddress> dnses, String domains) { private boolean updateDns(String network, String iface,
Collection<InetAddress> dnses, String domains) {
boolean changed = false; boolean changed = false;
int last = 0; int last = 0;
if (dnses.size() == 0 && mDefaultDns != null) { if (dnses.size() == 0 && mDefaultDns != null) {
@@ -1962,6 +1963,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
} }
mNumDnsEntries = last; mNumDnsEntries = last;
if (changed) {
try {
mNetd.setDnsServersForInterface(iface, NetworkUtils.makeStrings(dnses));
mNetd.setDefaultInterfaceForDns(iface);
} catch (Exception e) {
Slog.e(TAG, "exception setting default dns interface: " + e);
}
}
if (!domains.equals(SystemProperties.get("net.dns.search"))) { if (!domains.equals(SystemProperties.get("net.dns.search"))) {
SystemProperties.set("net.dns.search", domains); SystemProperties.set("net.dns.search", domains);
changed = true; changed = true;
@@ -1981,10 +1990,16 @@ public class ConnectivityService extends IConnectivityManager.Stub {
String network = nt.getNetworkInfo().getTypeName(); String network = nt.getNetworkInfo().getTypeName();
synchronized (mDnsLock) { synchronized (mDnsLock) {
if (!mDnsOverridden) { if (!mDnsOverridden) {
changed = updateDns(network, dnses, ""); changed = updateDns(network, p.getInterfaceName(), dnses, "");
} }
} }
} else { } else {
try {
mNetd.setDnsServersForInterface(Integer.toString(netType),
NetworkUtils.makeStrings(dnses));
} catch (Exception e) {
Slog.e(TAG, "exception setting dns servers: " + e);
}
// set per-pid dns for attached secondary nets // set per-pid dns for attached secondary nets
List pids = mNetRequestersPids[netType]; List pids = mNetRequestersPids[netType];
for (int y=0; y< pids.size(); y++) { for (int y=0; y< pids.size(); y++) {
@@ -2686,7 +2701,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
// Apply DNS changes. // Apply DNS changes.
boolean changed = false; boolean changed = false;
synchronized (mDnsLock) { synchronized (mDnsLock) {
changed = updateDns("VPN", addresses, domains); changed = updateDns("VPN", "VPN", addresses, domains);
mDnsOverridden = true; mDnsOverridden = true;
} }
if (changed) { if (changed) {