From af4330f7770cdcc853b5a61a52f49a734635ffc4 Mon Sep 17 00:00:00 2001 From: Benedict Wong Date: Tue, 7 May 2019 19:11:26 -0700 Subject: [PATCH] Check for IPSEC_TUNNELS feature before running CTS tests If tunnel feature does is not present, skip tests. Bug: 117183273 Test: This Change-Id: I62fcc2cbca8bf3d2b70da5646303a7059a0df663 Merged-In: I62fcc2cbca8bf3d2b70da5646303a7059a0df663 (cherry picked from commit 698c99fcf03a4e1afb028ac66852140762a7f2b1) --- .../src/android/net/cts/IpSecManagerTunnelTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/cts/net/src/android/net/cts/IpSecManagerTunnelTest.java b/tests/cts/net/src/android/net/cts/IpSecManagerTunnelTest.java index 5dc9b63b87..c8c99f4a37 100644 --- a/tests/cts/net/src/android/net/cts/IpSecManagerTunnelTest.java +++ b/tests/cts/net/src/android/net/cts/IpSecManagerTunnelTest.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import android.content.pm.PackageManager; import android.net.IpSecAlgorithm; import android.net.IpSecManager; import android.net.IpSecTransform; @@ -56,6 +57,12 @@ public class IpSecManagerTunnelTest extends IpSecBaseTest { setAppop(false); } + private boolean hasTunnelsFeature() { + return getContext() + .getPackageManager() + .hasSystemFeature(PackageManager.FEATURE_IPSEC_TUNNELS); + } + private void setAppop(boolean allow) { // Under normal circumstances, the MANAGE_IPSEC_TUNNELS appop would be auto-granted by the // telephony framework, and the only permission that is sufficient is NETWORK_STACK. So we @@ -69,6 +76,8 @@ public class IpSecManagerTunnelTest extends IpSecBaseTest { } public void testSecurityExceptionsCreateTunnelInterface() throws Exception { + if (!hasTunnelsFeature()) return; + // Ensure we don't have the appop. Permission is not requested in the Manifest setAppop(false); @@ -81,6 +90,8 @@ public class IpSecManagerTunnelTest extends IpSecBaseTest { } public void testSecurityExceptionsBuildTunnelTransform() throws Exception { + if (!hasTunnelsFeature()) return; + // Ensure we don't have the appop. Permission is not requested in the Manifest setAppop(false); @@ -97,6 +108,8 @@ public class IpSecManagerTunnelTest extends IpSecBaseTest { private void checkTunnel(InetAddress inner, InetAddress outer, boolean useEncap) throws Exception { + if (!hasTunnelsFeature()) return; + setAppop(true); int innerPrefixLen = inner instanceof Inet6Address ? IP6_PREFIX_LEN : IP4_PREFIX_LEN;