From 3741bedee7a03a679f033432a03cf9f206a36200 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Thu, 6 Jan 2011 17:18:23 -0800 Subject: [PATCH] Deprecate a method that formats only IPv4 addresses. Anyone calling this method is probably storing IP addresses in an int, which doesn't make sense anymore. Change-Id: Iba535b66f6cff47ce07b5ecc6427e3b2fd846998 --- core/java/android/net/NetworkUtils.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/core/java/android/net/NetworkUtils.java b/core/java/android/net/NetworkUtils.java index 8a653ddd55..f1bf852956 100644 --- a/core/java/android/net/NetworkUtils.java +++ b/core/java/android/net/NetworkUtils.java @@ -125,24 +125,19 @@ public class NetworkUtils { /** * Convert a IPv4 address from an integer to an InetAddress. - * @param hostAddr is an Int corresponding to the IPv4 address in network byte order - * @return the IP address as an {@code InetAddress}, returns null if - * unable to convert or if the int is an invalid address. + * @param hostAddress an int corresponding to the IPv4 address in network byte order */ public static InetAddress intToInetAddress(int hostAddress) { - InetAddress inetAddress; byte[] addressBytes = { (byte)(0xff & hostAddress), (byte)(0xff & (hostAddress >> 8)), (byte)(0xff & (hostAddress >> 16)), (byte)(0xff & (hostAddress >> 24)) }; try { - inetAddress = InetAddress.getByAddress(addressBytes); - } catch(UnknownHostException e) { - return null; + return InetAddress.getByAddress(addressBytes); + } catch (UnknownHostException e) { + throw new AssertionError(); } - - return inetAddress; } /**