STS add NFC skips for devices without NFC

Bug: 182204623
Test: test on a device without NFC. e.g. emulator. Expect ASSUMPTION_FAILURE

Change-Id: I4d51163e4b99c949f3ac6e2a2dc35e6ddec46fc9
Merged-In: I4d51163e4b99c949f3ac6e2a2dc35e6ddec46fc9
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/AdbUtils.java b/hostsidetests/securitybulletin/src/android/security/cts/AdbUtils.java
index f4dd962..a9360ab 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/AdbUtils.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/AdbUtils.java
@@ -49,6 +49,7 @@
 import org.json.JSONObject;
 
 import static org.junit.Assert.*;
+import static org.junit.Assume.*;
 
 public class AdbUtils {
 
@@ -768,4 +769,8 @@
         }
         fail(error.toString());
     }
+
+    public static void assumeHasNfc(ITestDevice device) throws DeviceNotAvailableException {
+        assumeTrue("nfc not available on device", device.hasFeature("android.hardware.nfc"));
+    }
 }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9558.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9558.java
index e051408..a469f9f 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9558.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9558.java
@@ -31,6 +31,7 @@
     @SecurityTest(minPatchLevel = "2018-12")
     @Test
     public void testPocCVE_2018_9558() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2018-9558", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9561.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9561.java
index ad88bb7..8fd2261 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9561.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9561.java
@@ -31,6 +31,7 @@
     @SecurityTest(minPatchLevel = "2019-03")
     @Test
     public void testPocCVE_2018_9561() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2018-9561", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9563.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9563.java
index 8f8b53d..90663fe 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9563.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9563.java
@@ -31,6 +31,7 @@
     @SecurityTest(minPatchLevel = "2019-03")
     @Test
     public void testPocCVE_2018_9563() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2018-9563", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9584.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9584.java
index df21402..5d68ce6 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9584.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9584.java
@@ -32,6 +32,7 @@
     @SecurityTest(minPatchLevel = "2019-01")
     @Test
     public void testPocCVE_2018_9584() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2018-9584", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9585.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9585.java
index bf0ff34..f5d19e4 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9585.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2018_9585.java
@@ -32,6 +32,7 @@
     @SecurityTest(minPatchLevel = "2019-01")
     @Test
     public void testPocCVE_2018_9585() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2018-9585", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2013.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2013.java
index b1899ca..d2f60c7 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2013.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2013.java
@@ -32,6 +32,7 @@
     @SecurityTest(minPatchLevel = "2019-03")
     @Test
     public void testPocCVE_2019_2013() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2019-2013", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2016.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2016.java
index b66a357..9d6dcc8 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2016.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2016.java
@@ -31,6 +31,7 @@
     @SecurityTest(minPatchLevel = "2019-03")
     @Test
     public void testPocCVE_2019_2016() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2019-2016", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2019.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2019.java
index a97c679..cd61170 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2019.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2019.java
@@ -31,6 +31,7 @@
     @SecurityTest(minPatchLevel = "2019-03")
     @Test
     public void testPocCVE_2019_2019() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2019-2019", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2034.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2034.java
index c972d8d..445cc7e 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2034.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2034.java
@@ -31,6 +31,7 @@
     @SecurityTest(minPatchLevel = "2019-04")
     @Test
     public void testPocCVE_2019_2034() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2019-2034", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2099.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2099.java
index 149d385..e20bb5c 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2099.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2099.java
@@ -32,6 +32,7 @@
     @SecurityTest(minPatchLevel = "2019-06")
     @Test
     public void testPocCVE_2019_2099() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2019-2099", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2135.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2135.java
index db98e28..6833243 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2135.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2135.java
@@ -33,6 +33,7 @@
     @SecurityTest(minPatchLevel = "2019-08")
     @Test
     public void testPocCVE_2019_2135() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE_2019_2135", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2206.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2206.java
index 2cda8da..20396ac 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2206.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2206.java
@@ -31,6 +31,7 @@
     @SecurityTest(minPatchLevel = "2019-11")
     @Test
     public void testPocCVE_2019_2206() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2019-2206", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2207.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2207.java
index 6f6c1f4..6f4340c 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2207.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2019_2207.java
@@ -31,6 +31,7 @@
     @SecurityTest(minPatchLevel = "2019-11")
     @Test
     public void testPocCVE_2019_2207() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2019-2207", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0006.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0006.java
index 7b3fb17..efd1e54 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0006.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0006.java
@@ -32,6 +32,7 @@
     @SecurityTest(minPatchLevel = "2020-01")
     @Test
     public void testPocCVE_2020_0006() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2020-0006", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0037.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0037.java
index 4e0a4a6..e624134 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0037.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0037.java
@@ -32,6 +32,7 @@
     @SecurityTest(minPatchLevel = "2020-03")
     @Test
     public void testPocCVE_2020_0037() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2020-0037", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0038.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0038.java
index 6759c30..5731c12 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0038.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0038.java
@@ -32,6 +32,7 @@
     @SecurityTest(minPatchLevel = "2020-03")
     @Test
     public void testPocCVE_2020_0038() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2020-0038", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0039.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0039.java
index f0f3323..7d5ae37 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0039.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0039.java
@@ -32,6 +32,7 @@
     @SecurityTest(minPatchLevel = "2020-03")
     @Test
     public void testPocCVE_2020_0039() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2020-0039", null, getDevice());
     }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0073.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0073.java
index 6596c74..79826e7 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0073.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0073.java
@@ -34,6 +34,7 @@
     @SecurityTest(minPatchLevel = "2020-04")
     @Test
     public void testPocCVE_2020_0073() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only64();
         String binaryName = "CVE-2020-0073";
         String signals[] = {CrashUtils.SIGSEGV, CrashUtils.SIGBUS, CrashUtils.SIGABRT};
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java b/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
index 9538679..56ccaab 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
@@ -61,6 +61,7 @@
     @Test
     @SecurityTest(minPatchLevel = "2019-09")
     public void testPocCVE_2019_2179() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         pocPusher.only32();
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2019-2179", null, getDevice());
     }
@@ -106,6 +107,7 @@
     @Test
     @SecurityTest(minPatchLevel = "2020-11")
     public void testPocCVE_2020_0450() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2020-0450", null, getDevice());
     }
 
@@ -161,6 +163,7 @@
     @Test
     @SecurityTest(minPatchLevel = "2019-08")
     public void testPocCVE_2019_2133() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2019-2133", null, getDevice());
     }
 
@@ -171,6 +174,7 @@
     @Test
     @SecurityTest(minPatchLevel = "2019-08")
     public void testPocCVE_2019_2134() throws Exception {
+        AdbUtils.assumeHasNfc(getDevice());
         AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2019-2134", null, getDevice());
     }