summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wink Saville <wink@google.com> 2011-05-12 14:08:05 -0700
committer Android Git Automerger <android-git-automerger@android.com> 2011-05-12 14:08:05 -0700
commit1f5e3a1af338d23838de059d7b270e89d54efa00 (patch)
tree9f20653f7bedef59ced1d05887468fbe7a0c6114
parentb856f43ea7a3a5261a93e432e5ea80005e972530 (diff)
parent9c7c87941446cdd1263a87a8c4cc5672082c7e12 (diff)
am 9c7c8794: am 76a118dd: Merge "Fix initialization of RouteInfo" into honeycomb-LTE
* commit '9c7c87941446cdd1263a87a8c4cc5672082c7e12': Fix initialization of RouteInfo
-rw-r--r--core/java/android/net/RouteInfo.java18
1 files changed, 15 insertions, 3 deletions
diff --git a/core/java/android/net/RouteInfo.java b/core/java/android/net/RouteInfo.java
index 9c4e48bd1ee6..39e708a8d96d 100644
--- a/core/java/android/net/RouteInfo.java
+++ b/core/java/android/net/RouteInfo.java
@@ -47,13 +47,25 @@ public class RouteInfo implements Parcelable {
public RouteInfo(LinkAddress destination, InetAddress gateway) {
if (destination == null) {
try {
- if ((gateway != null) || (gateway instanceof Inet4Address)) {
- destination = new LinkAddress(Inet4Address.ANY, 0);
+ if (gateway != null) {
+ if (gateway instanceof Inet4Address) {
+ destination = new LinkAddress(Inet4Address.ANY, 0);
+ } else {
+ destination = new LinkAddress(Inet6Address.ANY, 0);
+ }
} else {
- destination = new LinkAddress(Inet6Address.ANY, 0);
+ // no destination, no gateway. invalid.
+ throw new RuntimeException("Invalid arguments passed in.");
}
} catch (Exception e) {}
}
+ if (gateway == null) {
+ if (destination.getAddress() instanceof Inet4Address) {
+ gateway = Inet4Address.ANY;
+ } else {
+ gateway = Inet6Address.ANY;
+ }
+ }
mDestination = new LinkAddress(NetworkUtils.getNetworkPart(destination.getAddress(),
destination.getNetworkPrefixLength()), destination.getNetworkPrefixLength());
mGateway = gateway;