summaryrefslogtreecommitdiffstats
path: root/services
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 /services
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 'services')
-rw-r--r--services/java/com/android/server/ConnectivityService.java4
-rw-r--r--services/java/com/android/server/NetworkManagementService.java20
-rw-r--r--services/java/com/android/server/connectivity/Tethering.java3
3 files changed, 14 insertions, 13 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index c061a83..b7d0a8f 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -286,8 +286,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
com.android.internal.R.string.config_default_dns_server);
}
try {
- mDefaultDns = InetAddress.getByName(dns);
- } catch (UnknownHostException e) {
+ mDefaultDns = NetworkUtils.numericToInetAddress(dns);
+ } catch (IllegalArgumentException e) {
loge("Error setting defaultDns using " + dns);
}
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index eaf68b0..44f5df2 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -270,9 +270,9 @@ class NetworkManagementService extends INetworkManagementService.Stub {
InetAddress addr = null;
int prefixLength = 0;
try {
- addr = InetAddress.getByName(st.nextToken(" "));
- } catch (UnknownHostException uhe) {
- Slog.e(TAG, "Failed to parse ipaddr", uhe);
+ addr = NetworkUtils.numericToInetAddress(st.nextToken(" "));
+ } catch (IllegalArgumentException iae) {
+ Slog.e(TAG, "Failed to parse ipaddr", iae);
}
try {
@@ -451,7 +451,7 @@ class NetworkManagementService extends INetworkManagementService.Stub {
try {
String cmd = "tether dns set";
for (String s : dns) {
- cmd += " " + InetAddress.getByName(s).getHostAddress();
+ cmd += " " + NetworkUtils.numericToInetAddress(s).getHostAddress();
}
try {
mConnector.doCommand(cmd);
@@ -459,7 +459,7 @@ class NetworkManagementService extends INetworkManagementService.Stub {
throw new IllegalStateException(
"Unable to communicate to native daemon for setting tether dns");
}
- } catch (UnknownHostException e) {
+ } catch (IllegalArgumentException e) {
throw new IllegalStateException("Error resolving dns name", e);
}
}
@@ -519,11 +519,11 @@ class NetworkManagementService extends INetworkManagementService.Stub {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
mConnector.doCommand(String.format("pppd attach %s %s %s %s %s", tty,
- InetAddress.getByName(localAddr).getHostAddress(),
- InetAddress.getByName(remoteAddr).getHostAddress(),
- InetAddress.getByName(dns1Addr).getHostAddress(),
- InetAddress.getByName(dns2Addr).getHostAddress()));
- } catch (UnknownHostException e) {
+ NetworkUtils.numericToInetAddress(localAddr).getHostAddress(),
+ NetworkUtils.numericToInetAddress(remoteAddr).getHostAddress(),
+ NetworkUtils.numericToInetAddress(dns1Addr).getHostAddress(),
+ NetworkUtils.numericToInetAddress(dns2Addr).getHostAddress()));
+ } catch (IllegalArgumentException e) {
throw new IllegalStateException("Error resolving addr", e);
} catch (NativeDaemonConnectorException e) {
throw new IllegalStateException("Error communicating to native daemon to attach pppd", e);
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index 1eb5141..5853696 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -34,6 +34,7 @@ import android.net.INetworkManagementEventObserver;
import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.NetworkInfo;
+import android.net.NetworkUtils;
import android.os.Binder;
import android.os.Environment;
import android.os.Handler;
@@ -567,7 +568,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
try {
ifcg = service.getInterfaceConfig(iface);
if (ifcg != null) {
- InetAddress addr = InetAddress.getByName(USB_NEAR_IFACE_ADDR);
+ InetAddress addr = NetworkUtils.numericToInetAddress(USB_NEAR_IFACE_ADDR);
ifcg.addr = new LinkAddress(addr, USB_PREFIX_LENGTH);
if (enabled) {
ifcg.interfaceFlags = ifcg.interfaceFlags.replace("down", "up");