Skip JsonMacTests for older devices am: efae32b902

Original change: https://android-review.googlesource.com/c/platform/external/wycheproof/+/3309281

Change-Id: If6bfe56f4e4a9683413a7ecd2b40c97bd9eebb73
Signed-off-by: Automerger Merge Worker <[email protected]>
diff --git a/keystore-cts/java/com/google/security/wycheproof/testcases/JsonMacTest.java b/keystore-cts/java/com/google/security/wycheproof/testcases/JsonMacTest.java
index d813d02..a311798 100644
--- a/keystore-cts/java/com/google/security/wycheproof/testcases/JsonMacTest.java
+++ b/keystore-cts/java/com/google/security/wycheproof/testcases/JsonMacTest.java
@@ -29,15 +29,19 @@
 import org.junit.After;
 import org.junit.Test;
 import org.junit.Ignore;
+import android.os.Build;
 import android.security.keystore.KeyProtection;
 import android.security.keystore.KeyProperties;
 import java.io.IOException;
 import android.keystore.cts.util.KeyStoreUtil;
+import android.keystore.cts.util.TestUtils;
+import android.util.Log;
 
 /** This test uses test vectors in JSON format to test MAC primitives. */
 public class JsonMacTest {
   private static final String EXPECTED_PROVIDER_NAME = TestUtil.EXPECTED_CRYPTO_OP_PROVIDER_NAME;
   private static final String KEY_ALIAS_1 = "Key1";
+  private static final String TAG = JsonMacTest.class.getSimpleName();
 
   @After
   public void tearDown() throws Exception {
@@ -135,6 +139,11 @@
         byte[] key = getBytes(testcase, "key");
         byte[] msg = getBytes(testcase, "msg");
         byte[] expectedTag = getBytes(testcase, "tag");
+        // Skip empty bytes on older devices that cannot handle them.
+        if ((msg.length == 0) && (TestUtils.getVendorApiLevel() <= Build.VERSION_CODES.P)) {
+            Log.d(TAG, "Skipping test for unsupported input on pre-Q launch device.");
+            continue;
+        }
         // Strongbox only supports key size from 8 to 32 bytes.
         if (isStrongBox && (key.length < 8 || key.length > 32)) {
           continue;