am f4c231c4: am 76a118dd: Merge "Fix initialization of RouteInfo" into honeycomb-LTE am: a8f3f7c298

Original change: undetermined

Change-Id: I89bbbf657d66b956da36a23038b85b454770eec0
This commit is contained in:
Wink Saville
2021-05-31 04:19:54 +00:00
committed by Automerger Merge Worker

View File

@@ -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;