Merge "Use dns proxy a bit." into honeycomb-LTE
This commit is contained in:
committed by
Android (Google) Code Review
commit
9520d6af5a
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1783,8 +1783,19 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
LinkProperties p = nt.getLinkProperties();
|
LinkProperties p = nt.getLinkProperties();
|
||||||
if (p == null) return;
|
if (p == null) return;
|
||||||
Collection<InetAddress> dnses = p.getDnses();
|
Collection<InetAddress> dnses = p.getDnses();
|
||||||
|
try {
|
||||||
|
mNetd.setDnsServersForInterface(p.getInterfaceName(),
|
||||||
|
NetworkUtils.makeStrings(dnses));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Slog.e(TAG, "exception setting dns servers: " + e);
|
||||||
|
}
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
if (mNetConfigs[netType].isDefault()) {
|
if (mNetConfigs[netType].isDefault()) {
|
||||||
|
try {
|
||||||
|
mNetd.setDefaultInterfaceForDns(p.getInterfaceName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
Slog.e(TAG, "exception setting default dns interface: " + e);
|
||||||
|
}
|
||||||
int j = 1;
|
int j = 1;
|
||||||
if (dnses.size() == 0 && mDefaultDns != null) {
|
if (dnses.size() == 0 && mDefaultDns != null) {
|
||||||
String dnsString = mDefaultDns.getHostAddress();
|
String dnsString = mDefaultDns.getHostAddress();
|
||||||
|
|||||||
Reference in New Issue
Block a user