Let LinkProperties#getRoutes() keeps returning all routes before T
Starting from T, VpnService supports exclude routes, which will
make the caller to get both of include routes and exclude routes
from LinkProperties#getRoutes(), and it's not expected to get the
exclude routes before T in production code even though the code
returns all routes.
But there is a CTS - LinkPropertiesTest#testRouteAddWithSameKey()
will try to add an exclude route and check if the result of
LinkProperties#getRoutes() contains that exclude route or not.
And the test is failed now since LinkProperties#getRoutes() will
only return include route if compat feature - EXCLUDED_ROUTES is
disabled. (EXCLUDED_ROUTES is enabled starting from target SDK T)
To fix this test failure, let LinkProperties#getRoutes() keeps
returning all routes if SDK is before T. This avoids changing
behavior on S, and even though there is still a behavior change
when upgrading to T, apps are unlikely to be relying on such
behavior, especially outside of tests.
Bug: 238061814
Test: Run "atest CtsNetTestCases:LinkPropertiesTest" on S build
with mainline module which contains this patch.
Change-Id: Iac4362c4fe347ee3f06d5b21b0325fa69a7f27b6
This commit is contained in:
@@ -1312,7 +1312,26 @@ public class LinkPropertiesTest {
|
||||
assertEquals(3, lp.getRoutes().size());
|
||||
}
|
||||
|
||||
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
|
||||
@Test @IgnoreUpTo(Build.VERSION_CODES.R) @IgnoreAfter(Build.VERSION_CODES.S_V2)
|
||||
@CtsNetTestCasesMaxTargetSdk31(reason = "Compat change cannot be overridden when targeting T+")
|
||||
@DisableCompatChanges({LinkProperties.EXCLUDED_ROUTES})
|
||||
public void testExcludedRoutesDisabled_S() {
|
||||
final LinkProperties lp = new LinkProperties();
|
||||
assertEquals(0, lp.getRoutes().size());
|
||||
|
||||
lp.addRoute(new RouteInfo(new IpPrefix(ADDRV4, 0), RTN_UNREACHABLE));
|
||||
assertEquals(1, lp.getRoutes().size());
|
||||
|
||||
lp.addRoute(new RouteInfo(new IpPrefix(ADDRV6, 5), RTN_THROW));
|
||||
// RTN_THROW routes are visible on S when added by the caller (but they are not added by
|
||||
// the system). This is uncommon usage but was tested by CTSv12.
|
||||
assertEquals(2, lp.getRoutes().size());
|
||||
|
||||
lp.addRoute(new RouteInfo(new IpPrefix(ADDRV6, 2), RTN_UNICAST));
|
||||
assertEquals(3, lp.getRoutes().size());
|
||||
}
|
||||
|
||||
@Test @IgnoreUpTo(Build.VERSION_CODES.S_V2)
|
||||
@CtsNetTestCasesMaxTargetSdk31(reason = "Compat change cannot be overridden when targeting T+")
|
||||
@DisableCompatChanges({LinkProperties.EXCLUDED_ROUTES})
|
||||
public void testExcludedRoutesDisabled() {
|
||||
@@ -1320,12 +1339,12 @@ public class LinkPropertiesTest {
|
||||
assertEquals(0, lp.getRoutes().size());
|
||||
|
||||
lp.addRoute(new RouteInfo(new IpPrefix(ADDRV4, 0), RTN_UNREACHABLE));
|
||||
assertEquals(0, lp.getRoutes().size());
|
||||
assertEquals(1, lp.getRoutes().size());
|
||||
|
||||
lp.addRoute(new RouteInfo(new IpPrefix(ADDRV6, 5), RTN_THROW));
|
||||
assertEquals(0, lp.getRoutes().size());
|
||||
assertEquals(1, lp.getRoutes().size());
|
||||
|
||||
lp.addRoute(new RouteInfo(new IpPrefix(ADDRV6, 2), RTN_UNICAST));
|
||||
assertEquals(1, lp.getRoutes().size());
|
||||
assertEquals(2, lp.getRoutes().size());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user