summaryrefslogtreecommitdiffstats
path: root/core/java/android/net/ConnectivityManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/net/ConnectivityManager.java')
-rw-r--r--core/java/android/net/ConnectivityManager.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 8d1a04c..05ebd07 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -21,6 +21,9 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.os.Binder;
import android.os.RemoteException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
/**
* Class that answers queries about the state of network connectivity. It also
* notifies applications when network connectivity changes. Get an instance
@@ -309,8 +312,29 @@ public class ConnectivityManager
* @return {@code true} on success, {@code false} on failure
*/
public boolean requestRouteToHost(int networkType, int hostAddress) {
+ InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress);
+
+ if (inetAddress == null) {
+ return false;
+ }
+
+ return requestRouteToHostAddress(networkType, inetAddress);
+ }
+
+ /**
+ * Ensure that a network route exists to deliver traffic to the specified
+ * host via the specified network interface. An attempt to add a route that
+ * already exists is ignored, but treated as successful.
+ * @param networkType the type of the network over which traffic to the specified
+ * host is to be routed
+ * @param hostAddress the IP address of the host to which the route is desired
+ * @return {@code true} on success, {@code false} on failure
+ * @hide
+ */
+ public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) {
+ byte[] address = hostAddress.getAddress();
try {
- return mService.requestRouteToHost(networkType, hostAddress);
+ return mService.requestRouteToHostAddress(networkType, address);
} catch (RemoteException e) {
return false;
}