Bug 754305 - SUTAgent should always print ipv4 address. r=jmaher

This commit is contained in:
William Lachance 2012-05-14 19:01:05 -04:00
parent 8a77bd6592
commit db1eb2f1dc

View File

@ -40,6 +40,7 @@ package com.mozilla.SUTAgentAndroid;
import java.io.File; import java.io.File;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.InetAddress; import java.net.InetAddress;
import org.apache.http.conn.util.InetAddressUtils;
import java.net.NetworkInterface; import java.net.NetworkInterface;
import java.net.SocketException; import java.net.SocketException;
import java.util.Enumeration; import java.util.Enumeration;
@ -665,7 +666,7 @@ public class SUTAgentAndroid extends Activity
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();)
{ {
InetAddress inetAddress = enumIpAddr.nextElement(); InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) if (!inetAddress.isLoopbackAddress() && InetAddressUtils.isIPv4Address(inetAddress.getHostAddress()))
{ {
return inetAddress.getHostAddress().toString(); return inetAddress.getHostAddress().toString();
} }