From 48380e413270b9f4ff216f6649d1dc8acdfda45d Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Fri, 15 Jul 2022 16:42:49 +0900 Subject: [PATCH] Revert EXCLUDED_ROUTES to only keep RTN_UNICAST Revert the previous change to filter out all non-RTN_THROW routes when EXCLUDED_ROUTES is disabled, as that behavior is CTS tested for T, and has been used by T for a while. The previous change already ensured that there is no behavior change on S, so this is the safest approach. This fixes HostsideLinkPropertiesGatingTests. Bug: 239046959 Test: atest LinkPropertiesTest CtsHostsideNetworkTests Change-Id: I55e078cdc06341f4957fe7bc743c0022b2c7d3da --- framework/src/android/net/LinkProperties.java | 9 ++++----- tests/common/java/android/net/LinkPropertiesTest.java | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/framework/src/android/net/LinkProperties.java b/framework/src/android/net/LinkProperties.java index 76ca0613e5..b7ee84698c 100644 --- a/framework/src/android/net/LinkProperties.java +++ b/framework/src/android/net/LinkProperties.java @@ -769,16 +769,15 @@ public final class LinkProperties implements Parcelable { // system) will not see it in getRoutes on T+ if they do not have the compat change // enabled (target SDK < T); but this is expected to be rare and typically only affect // tests creating LinkProperties themselves (like CTS v12, which is only running on S). - return Collections.unmodifiableList(getNonThrowRoutes()); + return Collections.unmodifiableList(getUnicastRoutes()); } } /** - * Returns all the {@link RouteInfo} that are not of type {@link RouteInfo#RTN_THROW} set on - * this link. + * Returns all the {@link RouteInfo} of type {@link RouteInfo#RTN_UNICAST} set on this link. */ - private @NonNull List getNonThrowRoutes() { - return CollectionUtils.filter(mRoutes, route -> route.getType() != RouteInfo.RTN_THROW); + private @NonNull List getUnicastRoutes() { + return CollectionUtils.filter(mRoutes, route -> route.getType() == RouteInfo.RTN_UNICAST); } /** diff --git a/tests/common/java/android/net/LinkPropertiesTest.java b/tests/common/java/android/net/LinkPropertiesTest.java index 319dbf420c..9506fc9379 100644 --- a/tests/common/java/android/net/LinkPropertiesTest.java +++ b/tests/common/java/android/net/LinkPropertiesTest.java @@ -1339,12 +1339,12 @@ public class LinkPropertiesTest { assertEquals(0, lp.getRoutes().size()); lp.addRoute(new RouteInfo(new IpPrefix(ADDRV4, 0), RTN_UNREACHABLE)); - assertEquals(1, lp.getRoutes().size()); + assertEquals(0, lp.getRoutes().size()); lp.addRoute(new RouteInfo(new IpPrefix(ADDRV6, 5), RTN_THROW)); - assertEquals(1, lp.getRoutes().size()); + assertEquals(0, lp.getRoutes().size()); lp.addRoute(new RouteInfo(new IpPrefix(ADDRV6, 2), RTN_UNICAST)); - assertEquals(2, lp.getRoutes().size()); + assertEquals(1, lp.getRoutes().size()); } }