Merge "Up our DNS server support from 2 > 4"
diff --git a/core/java/android/net/DhcpResults.java b/core/java/android/net/DhcpResults.java
index 2f300de..a3f70da 100644
--- a/core/java/android/net/DhcpResults.java
+++ b/core/java/android/net/DhcpResults.java
@@ -18,6 +18,7 @@
import android.os.Parcelable;
import android.os.Parcel;
+import android.text.TextUtils;
import android.util.Log;
import java.net.InetAddress;
@@ -211,11 +212,13 @@
}
public boolean addDns(String addrString) {
- try {
- linkProperties.addDns(NetworkUtils.numericToInetAddress(addrString));
- } catch (IllegalArgumentException e) {
- Log.e(TAG, "addDns failed with addrString " + addrString);
- return true;
+ if (TextUtils.isEmpty(addrString) == false) {
+ try {
+ linkProperties.addDns(NetworkUtils.numericToInetAddress(addrString));
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "addDns failed with addrString " + addrString);
+ return true;
+ }
}
return false;
}
diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp
index 296add3..f5f22b2 100644
--- a/core/jni/android_net_NetUtils.cpp
+++ b/core/jni/android_net_NetUtils.cpp
@@ -28,23 +28,21 @@
int ifc_disable(const char *ifname);
int ifc_reset_connections(const char *ifname, int reset_mask);
-int dhcp_do_request(const char *ifname,
+int dhcp_do_request(const char * const ifname,
const char *ipaddr,
const char *gateway,
uint32_t *prefixLength,
- const char *dns1,
- const char *dns2,
+ const char *dns[],
const char *server,
uint32_t *lease,
const char *vendorInfo,
const char *domains);
-int dhcp_do_request_renew(const char *ifname,
+int dhcp_do_request_renew(const char * const ifname,
const char *ipaddr,
const char *gateway,
uint32_t *prefixLength,
- const char *dns1,
- const char *dns2,
+ const char *dns[],
const char *server,
uint32_t *lease,
const char *vendorInfo,
@@ -120,6 +118,9 @@
char gateway[PROPERTY_VALUE_MAX];
char dns1[PROPERTY_VALUE_MAX];
char dns2[PROPERTY_VALUE_MAX];
+ char dns3[PROPERTY_VALUE_MAX];
+ char dns4[PROPERTY_VALUE_MAX];
+ const char *dns[5] = {dns1, dns2, dns3, dns4, NULL};
char server[PROPERTY_VALUE_MAX];
uint32_t lease;
char vendorInfo[PROPERTY_VALUE_MAX];
@@ -130,10 +131,10 @@
if (renew) {
result = ::dhcp_do_request_renew(nameStr, ipaddr, gateway, &prefixLength,
- dns1, dns2, server, &lease, vendorInfo, domains);
+ dns, server, &lease, vendorInfo, domains);
} else {
result = ::dhcp_do_request(nameStr, ipaddr, gateway, &prefixLength,
- dns1, dns2, server, &lease, vendorInfo, domains);
+ dns, server, &lease, vendorInfo, domains);
}
env->ReleaseStringUTFChars(ifname, nameStr);
if (result == 0) {
@@ -168,6 +169,15 @@
result = env->CallBooleanMethod(dhcpResults,
dhcpResultsFieldIds.addDns, env->NewStringUTF(dns2));
+
+ if (result == 0) {
+ result = env->CallBooleanMethod(dhcpResults,
+ dhcpResultsFieldIds.addDns, env->NewStringUTF(dns3));
+ if (result == 0) {
+ result = env->CallBooleanMethod(dhcpResults,
+ dhcpResultsFieldIds.addDns, env->NewStringUTF(dns4));
+ }
+ }
}
if (result == 0) {