Add new route.hasGateway() api
Fixes issues brought in by change to isHostRoute. isHostRoute was technically correct, but the callers really wanted hasNextHop behavior. bug:8597268 Change-Id: I360761ccfa98b2ba34642f717a78fa71ec1bae4f
This commit is contained in:
@@ -60,6 +60,7 @@ public class RouteInfo implements Parcelable {
|
|||||||
|
|
||||||
private final boolean mIsDefault;
|
private final boolean mIsDefault;
|
||||||
private final boolean mIsHost;
|
private final boolean mIsHost;
|
||||||
|
private final boolean mHasGateway;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a RouteInfo object.
|
* Constructs a RouteInfo object.
|
||||||
@@ -97,6 +98,8 @@ public class RouteInfo implements Parcelable {
|
|||||||
gateway = Inet6Address.ANY;
|
gateway = Inet6Address.ANY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mHasGateway = (!gateway.isAnyLocalAddress());
|
||||||
|
|
||||||
mDestination = new LinkAddress(NetworkUtils.getNetworkPart(destination.getAddress(),
|
mDestination = new LinkAddress(NetworkUtils.getNetworkPart(destination.getAddress(),
|
||||||
destination.getNetworkPrefixLength()), destination.getNetworkPrefixLength());
|
destination.getNetworkPrefixLength()), destination.getNetworkPrefixLength());
|
||||||
mGateway = gateway;
|
mGateway = gateway;
|
||||||
@@ -171,6 +174,10 @@ public class RouteInfo implements Parcelable {
|
|||||||
return mIsHost;
|
return mIsHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasGateway() {
|
||||||
|
return mHasGateway;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String val = "";
|
String val = "";
|
||||||
if (mDestination != null) val = mDestination.toString();
|
if (mDestination != null) val = mDestination.toString();
|
||||||
|
|||||||
@@ -1470,8 +1470,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
loge("Error modifying route - no interface name");
|
loge("Error modifying route - no interface name");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (r.hasGateway()) {
|
||||||
if (r.isHostRoute() == false) {
|
|
||||||
RouteInfo bestRoute = RouteInfo.selectBestRoute(lp.getAllRoutes(), r.getGateway());
|
RouteInfo bestRoute = RouteInfo.selectBestRoute(lp.getAllRoutes(), r.getGateway());
|
||||||
if (bestRoute != null) {
|
if (bestRoute != null) {
|
||||||
if (bestRoute.getGateway().equals(r.getGateway())) {
|
if (bestRoute.getGateway().equals(r.getGateway())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user