Loading apishim/common/com/android/networkstack/apishim/ShimUtils.java +7 −0 Original line number Diff line number Diff line Loading @@ -42,4 +42,11 @@ public final class ShimUtils { + ("REL".equals(Build.VERSION.CODENAME) ? 0 : 1); return devApiLevel > apiLevel; } /** * Check whether the device supports in-development or final R networking APIs. */ public static boolean isAtLeastR() { return isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q); } } tests/integration/src/android/net/ip/IpClientIntegrationTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -654,7 +654,7 @@ public class IpClientIntegrationTest { } private void assertNoHostname(String hostname) { if (ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) { if (ShimUtils.isAtLeastR()) { assertNull(hostname); } else { // Until Q, if no hostname is set, the device falls back to the hostname set via Loading Loading @@ -1809,7 +1809,7 @@ public class IpClientIntegrationTest { // Ensure that the URL was set as expected in the callbacks. // Can't verify the URL up to Q as there is no such attribute in LinkProperties. if (!ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) return; if (!ShimUtils.isAtLeastR()) return; verify(mCb).onLinkPropertiesChange(captor.capture()); assertTrue(captor.getAllValues().stream().anyMatch( lp -> Objects.equals(expectedUrl, lp.getCaptivePortalApiUrl()))); Loading tests/unit/src/android/net/netlink/InetDiagSocketTest.java +2 −3 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ import android.app.Instrumentation; import android.content.Context; import android.net.ConnectivityManager; import android.net.netlink.StructNlMsgHdr; import android.os.Build; import android.os.Process; import android.system.Os; Loading Loading @@ -196,7 +195,7 @@ public class InetDiagSocketTest { @Test public void testGetConnectionOwnerUid() throws Exception { // Skip the test for API <= Q, as b/141603906 this was only fixed in Q-QPR2 assumeTrue(ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)); assumeTrue(ShimUtils.isAtLeastR()); checkGetConnectionOwnerUid("::", null); checkGetConnectionOwnerUid("::", "::"); checkGetConnectionOwnerUid("0.0.0.0", null); Loading @@ -211,7 +210,7 @@ public class InetDiagSocketTest { @Test public void testB141603906() throws Exception { // Skip the test for API <= Q, as b/141603906 this was only fixed in Q-QPR2 assumeTrue(ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)); assumeTrue(ShimUtils.isAtLeastR()); final InetSocketAddress src = new InetSocketAddress(0); final InetSocketAddress dst = new InetSocketAddress(0); final int numThreads = 8; Loading tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -795,7 +795,7 @@ public class NetworkMonitorTest { private static CellIdentityGsm makeCellIdentityGsm(int lac, int cid, int arfcn, int bsic, String mccStr, String mncStr, String alphal, String alphas) throws ReflectiveOperationException { if (ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) { if (ShimUtils.isAtLeastR()) { return new CellIdentityGsm(lac, cid, arfcn, bsic, mccStr, mncStr, alphal, alphas, Collections.emptyList() /* additionalPlmns */); } else { Loading @@ -810,7 +810,7 @@ public class NetworkMonitorTest { private static CellIdentityLte makeCellIdentityLte(int ci, int pci, int tac, int earfcn, int bandwidth, String mccStr, String mncStr, String alphal, String alphas) throws ReflectiveOperationException { if (ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) { if (ShimUtils.isAtLeastR()) { return new CellIdentityLte(ci, pci, tac, earfcn, new int[] {} /* bands */, bandwidth, mccStr, mncStr, alphal, alphas, Collections.emptyList() /* additionalPlmns */, null /* csgInfo */); Loading Loading @@ -1707,13 +1707,13 @@ public class NetworkMonitorTest { @Test public void testDismissPortalInValidatedNetworkEnabledOsSupported() throws Exception { assumeTrue(ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)); assumeTrue(ShimUtils.isAtLeastR()); testDismissPortalInValidatedNetworkEnabled(TEST_LOGIN_URL); } @Test public void testDismissPortalInValidatedNetworkEnabledOsNotSupported() throws Exception { assumeFalse(ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)); assumeFalse(ShimUtils.isAtLeastR()); testDismissPortalInValidatedNetworkEnabled(TEST_HTTP_URL); } Loading Loading
apishim/common/com/android/networkstack/apishim/ShimUtils.java +7 −0 Original line number Diff line number Diff line Loading @@ -42,4 +42,11 @@ public final class ShimUtils { + ("REL".equals(Build.VERSION.CODENAME) ? 0 : 1); return devApiLevel > apiLevel; } /** * Check whether the device supports in-development or final R networking APIs. */ public static boolean isAtLeastR() { return isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q); } }
tests/integration/src/android/net/ip/IpClientIntegrationTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -654,7 +654,7 @@ public class IpClientIntegrationTest { } private void assertNoHostname(String hostname) { if (ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) { if (ShimUtils.isAtLeastR()) { assertNull(hostname); } else { // Until Q, if no hostname is set, the device falls back to the hostname set via Loading Loading @@ -1809,7 +1809,7 @@ public class IpClientIntegrationTest { // Ensure that the URL was set as expected in the callbacks. // Can't verify the URL up to Q as there is no such attribute in LinkProperties. if (!ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) return; if (!ShimUtils.isAtLeastR()) return; verify(mCb).onLinkPropertiesChange(captor.capture()); assertTrue(captor.getAllValues().stream().anyMatch( lp -> Objects.equals(expectedUrl, lp.getCaptivePortalApiUrl()))); Loading
tests/unit/src/android/net/netlink/InetDiagSocketTest.java +2 −3 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ import android.app.Instrumentation; import android.content.Context; import android.net.ConnectivityManager; import android.net.netlink.StructNlMsgHdr; import android.os.Build; import android.os.Process; import android.system.Os; Loading Loading @@ -196,7 +195,7 @@ public class InetDiagSocketTest { @Test public void testGetConnectionOwnerUid() throws Exception { // Skip the test for API <= Q, as b/141603906 this was only fixed in Q-QPR2 assumeTrue(ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)); assumeTrue(ShimUtils.isAtLeastR()); checkGetConnectionOwnerUid("::", null); checkGetConnectionOwnerUid("::", "::"); checkGetConnectionOwnerUid("0.0.0.0", null); Loading @@ -211,7 +210,7 @@ public class InetDiagSocketTest { @Test public void testB141603906() throws Exception { // Skip the test for API <= Q, as b/141603906 this was only fixed in Q-QPR2 assumeTrue(ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)); assumeTrue(ShimUtils.isAtLeastR()); final InetSocketAddress src = new InetSocketAddress(0); final InetSocketAddress dst = new InetSocketAddress(0); final int numThreads = 8; Loading
tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -795,7 +795,7 @@ public class NetworkMonitorTest { private static CellIdentityGsm makeCellIdentityGsm(int lac, int cid, int arfcn, int bsic, String mccStr, String mncStr, String alphal, String alphas) throws ReflectiveOperationException { if (ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) { if (ShimUtils.isAtLeastR()) { return new CellIdentityGsm(lac, cid, arfcn, bsic, mccStr, mncStr, alphal, alphas, Collections.emptyList() /* additionalPlmns */); } else { Loading @@ -810,7 +810,7 @@ public class NetworkMonitorTest { private static CellIdentityLte makeCellIdentityLte(int ci, int pci, int tac, int earfcn, int bandwidth, String mccStr, String mncStr, String alphal, String alphas) throws ReflectiveOperationException { if (ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) { if (ShimUtils.isAtLeastR()) { return new CellIdentityLte(ci, pci, tac, earfcn, new int[] {} /* bands */, bandwidth, mccStr, mncStr, alphal, alphas, Collections.emptyList() /* additionalPlmns */, null /* csgInfo */); Loading Loading @@ -1707,13 +1707,13 @@ public class NetworkMonitorTest { @Test public void testDismissPortalInValidatedNetworkEnabledOsSupported() throws Exception { assumeTrue(ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)); assumeTrue(ShimUtils.isAtLeastR()); testDismissPortalInValidatedNetworkEnabled(TEST_LOGIN_URL); } @Test public void testDismissPortalInValidatedNetworkEnabledOsNotSupported() throws Exception { assumeFalse(ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)); assumeFalse(ShimUtils.isAtLeastR()); testDismissPortalInValidatedNetworkEnabled(TEST_HTTP_URL); } Loading