summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2011-03-02 12:10:51 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-03-02 12:10:51 -0800
commit7e48e76cab10377367b925790cf3a840651009fa (patch)
tree74833222c8eeb9fd4c53711b61999d30761de74a /core
parent76bb1200c2ea08665f33fb0d54023113c19b8286 (diff)
parente590373ea71251cfffc8f22f011e2e6335dce716 (diff)
downloadframeworks_base-7e48e76cab10377367b925790cf3a840651009fa.zip
frameworks_base-7e48e76cab10377367b925790cf3a840651009fa.tar.gz
frameworks_base-7e48e76cab10377367b925790cf3a840651009fa.tar.bz2
Merge "Start using NetworkUtils.numericToInetAddress."
Diffstat (limited to 'core')
-rw-r--r--core/java/android/net/Proxy.java10
-rw-r--r--core/java/android/server/BluetoothPanProfileHandler.java7
-rw-r--r--core/java/com/android/internal/net/DomainNameValidator.java26
3 files changed, 11 insertions, 32 deletions
diff --git a/core/java/android/net/Proxy.java b/core/java/android/net/Proxy.java
index f750122..a408ea0 100644
--- a/core/java/android/net/Proxy.java
+++ b/core/java/android/net/Proxy.java
@@ -233,17 +233,11 @@ public final class Proxy {
if (host.equalsIgnoreCase("localhost")) {
return true;
}
- // Check we have a numeric address so we don't cause a DNS lookup in getByName.
- if (InetAddress.isNumeric(host)) {
- if (InetAddress.getByName(host).isLoopbackAddress()) {
- return true;
- }
+ if (NetworkUtils.numericToInetAddress(host).isLoopbackAddress()) {
+ return true;
}
}
- } catch (UnknownHostException ignored) {
- // Can't happen for a numeric address (InetAddress.getByName).
} catch (IllegalArgumentException iex) {
- // Ignore (URI.create)
}
return false;
}
diff --git a/core/java/android/server/BluetoothPanProfileHandler.java b/core/java/android/server/BluetoothPanProfileHandler.java
index 3f24811..8925856 100644
--- a/core/java/android/server/BluetoothPanProfileHandler.java
+++ b/core/java/android/server/BluetoothPanProfileHandler.java
@@ -28,6 +28,7 @@ import android.content.res.Resources.NotFoundException;
import android.net.ConnectivityManager;
import android.net.InterfaceConfiguration;
import android.net.LinkAddress;
+import android.net.NetworkUtils;
import android.os.IBinder;
import android.os.INetworkManagementService;
import android.os.ServiceManager;
@@ -379,9 +380,9 @@ final class BluetoothPanProfileHandler {
if (ifcg != null) {
InetAddress addr = null;
if (ifcg.addr == null || (addr = ifcg.addr.getAddress()) == null ||
- addr.equals(InetAddress.getByName("0.0.0.0")) ||
- addr.equals(InetAddress.getByName("::0"))) {
- addr = InetAddress.getByName(address);
+ addr.equals(NetworkUtils.numericToInetAddress("0.0.0.0")) ||
+ addr.equals(NetworkUtils.numericToInetAddress("::0"))) {
+ addr = NetworkUtils.numericToInetAddress(address);
}
ifcg.interfaceFlags = ifcg.interfaceFlags.replace("down", "up");
ifcg.addr = new LinkAddress(addr, BLUETOOTH_PREFIX_LENGTH);
diff --git a/core/java/com/android/internal/net/DomainNameValidator.java b/core/java/com/android/internal/net/DomainNameValidator.java
index dbd5019..36973f1 100644
--- a/core/java/com/android/internal/net/DomainNameValidator.java
+++ b/core/java/com/android/internal/net/DomainNameValidator.java
@@ -15,12 +15,11 @@
*/
package com.android.internal.net;
-
+import android.net.NetworkUtils;
import android.util.Config;
import android.util.Log;
import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
import java.util.Collection;
@@ -38,13 +37,6 @@ public class DomainNameValidator {
private static final boolean DEBUG = false;
private static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV;
- private static Pattern QUICK_IP_PATTERN;
- static {
- try {
- QUICK_IP_PATTERN = Pattern.compile("^[a-f0-9\\.:]+$");
- } catch (PatternSyntaxException e) {}
- }
-
private static final int ALT_DNS_NAME = 2;
private static final int ALT_IPA_NAME = 7;
@@ -75,19 +67,11 @@ public class DomainNameValidator {
if (rval) {
try {
// do a quick-dirty IP match first to avoid DNS lookup
- rval = QUICK_IP_PATTERN.matcher(domain).matches();
- if (rval) {
- rval = domain.equals(
- InetAddress.getByName(domain).getHostAddress());
- }
- } catch (UnknownHostException e) {
- String errorMessage = e.getMessage();
- if (errorMessage == null) {
- errorMessage = "unknown host exception";
- }
-
+ rval = domain.equals(
+ NetworkUtils.numericToInetAddress(domain).getHostAddress());
+ } catch (IllegalArgumentException e) {
if (LOG_ENABLED) {
- Log.v(TAG, "DomainNameValidator.isIpAddress(): " + errorMessage);
+ Log.v(TAG, "DomainNameValidator.isIpAddress(): " + e);
}
rval = false;