summaryrefslogtreecommitdiffstats
path: root/core/java/android/net/LinkProperties.java
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2013-03-08 11:30:39 -0800
committerLorenzo Colitti <lorenzo@google.com>2013-03-08 16:41:25 -0800
commit45b9a5bb93569ca49bbd44f7a518091371687f96 (patch)
tree389bdedc8d3fbdc9c52d73e9eca4a553e546360e /core/java/android/net/LinkProperties.java
parent6916c6ee105e7e91f494ec79c24152fb64d8eed1 (diff)
downloadframeworks_base-45b9a5bb93569ca49bbd44f7a518091371687f96.zip
frameworks_base-45b9a5bb93569ca49bbd44f7a518091371687f96.tar.gz
frameworks_base-45b9a5bb93569ca49bbd44f7a518091371687f96.tar.bz2
RouteInfo changes.
- Add the interface name. - Fix a bug where a default route would match an address of another protocol (e.g., 0.0.0.0/0 would match 2001::). - Tweak the hashCode method. - Write a unit test. Change-Id: Ida8266de440a9b1d9eaa132f182b9f1ce8978c44
Diffstat (limited to 'core/java/android/net/LinkProperties.java')
-rw-r--r--core/java/android/net/LinkProperties.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java
index b9362da..ec8d77e 100644
--- a/core/java/android/net/LinkProperties.java
+++ b/core/java/android/net/LinkProperties.java
@@ -92,6 +92,11 @@ public class LinkProperties implements Parcelable {
public void setInterfaceName(String iface) {
mIfaceName = iface;
+ ArrayList<RouteInfo> newRoutes = new ArrayList<RouteInfo>(mRoutes.size());
+ for (RouteInfo route : mRoutes) {
+ newRoutes.add(routeWithInterface(route));
+ }
+ mRoutes = newRoutes;
}
public String getInterfaceName() {
@@ -130,9 +135,25 @@ public class LinkProperties implements Parcelable {
mDomains = domains;
}
+ private RouteInfo routeWithInterface(RouteInfo route) {
+ return new RouteInfo(
+ route.getDestination(),
+ route.getGateway(),
+ mIfaceName);
+ }
+
public void addRoute(RouteInfo route) {
- if (route != null) mRoutes.add(route);
+ if (route != null) {
+ String routeIface = route.getInterface();
+ if (routeIface != null && !routeIface.equals(mIfaceName)) {
+ throw new IllegalStateException(
+ "Route added with non-matching interface: " + routeIface +
+ " vs. mIfaceName");
+ }
+ mRoutes.add(routeWithInterface(route));
+ }
}
+
public Collection<RouteInfo> getRoutes() {
return Collections.unmodifiableCollection(mRoutes);
}