diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2011-01-26 15:01:16 -0800 |
---|---|---|
committer | Robert Greenwalt <rgreenwalt@google.com> | 2011-01-27 10:49:27 -0800 |
commit | 68e18d23298c62b61844eb296d247df55d45f463 (patch) | |
tree | de0a7132d5d72020fc35fc6d45591aeb762983a9 /core | |
parent | 28059932dc3e541206d156c1d6761496f4cf65a4 (diff) | |
download | frameworks_base-68e18d23298c62b61844eb296d247df55d45f463.zip frameworks_base-68e18d23298c62b61844eb296d247df55d45f463.tar.gz frameworks_base-68e18d23298c62b61844eb296d247df55d45f463.tar.bz2 |
Fix the build
Check for null before trying to make InetAddresses.
Change-Id: I3228eea32eb455437dd76be2de56a913884f3f6e
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/net/DhcpInfoInternal.java | 26 | ||||
-rw-r--r-- | core/java/android/net/NetworkUtils.java | 4 |
2 files changed, 25 insertions, 5 deletions
diff --git a/core/java/android/net/DhcpInfoInternal.java b/core/java/android/net/DhcpInfoInternal.java index 7d9bd52..6e981df 100644 --- a/core/java/android/net/DhcpInfoInternal.java +++ b/core/java/android/net/DhcpInfoInternal.java @@ -16,6 +16,9 @@ package android.net; +import android.text.TextUtils; +import android.util.Log; + import java.net.InetAddress; import java.net.Inet4Address; import java.net.UnknownHostException; @@ -26,6 +29,7 @@ import java.net.UnknownHostException; * @hide */ public class DhcpInfoInternal { + private final static String TAG = "DhcpInfoInternal"; public String ipAddress; public String gateway; public int prefixLength; @@ -65,15 +69,31 @@ public class DhcpInfoInternal { } public LinkAddress makeLinkAddress() { + if (TextUtils.isEmpty(ipAddress)) { + Log.e(TAG, "makeLinkAddress with empty ipAddress"); + return null; + } return new LinkAddress(NetworkUtils.numericToInetAddress(ipAddress), prefixLength); } public LinkProperties makeLinkProperties() { LinkProperties p = new LinkProperties(); p.addLinkAddress(makeLinkAddress()); - p.setGateway(NetworkUtils.numericToInetAddress(gateway)); - p.addDns(NetworkUtils.numericToInetAddress(dns1)); - p.addDns(NetworkUtils.numericToInetAddress(dns2)); + if (TextUtils.isEmpty(gateway) == false) { + p.setGateway(NetworkUtils.numericToInetAddress(gateway)); + } else { + Log.e(TAG, "makeLinkProperties with empty gateway!"); + } + if (TextUtils.isEmpty(dns1) == false) { + p.addDns(NetworkUtils.numericToInetAddress(dns1)); + } else { + Log.e(TAG, "makeLinkProperties with empty dns1!"); + } + if (TextUtils.isEmpty(dns2) == false) { + p.addDns(NetworkUtils.numericToInetAddress(dns2)); + } else { + Log.e(TAG, "makeLinkProperties with empty dns2!"); + } return p; } diff --git a/core/java/android/net/NetworkUtils.java b/core/java/android/net/NetworkUtils.java index 1c48e7d..97f96da 100644 --- a/core/java/android/net/NetworkUtils.java +++ b/core/java/android/net/NetworkUtils.java @@ -162,8 +162,8 @@ public class NetworkUtils { // TODO - do this for real, using a hidden method on InetAddress that aborts // instead of doing dns step if (!InetAddress.isNumeric(addrString)) { - throw new IllegalArgumentException("numericToInetAddress with non numeric: " + - addrString); + throw new IllegalArgumentException("numericToInetAddress with non numeric: '" + + addrString + "'"); } try { return InetAddress.getByName(addrString); |