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