BitmapFactoryTest: add HEIF image test

Bug: b/215693580
Test: atest CtsGraphicsTestCases:android.graphics.cts.BitmapFactoryTest
Change-Id: I04a794ef080939d18ce0137929cb18855587057f
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
index 6fcc5c0..1917b2d 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
@@ -34,6 +34,7 @@
 import android.graphics.BitmapFactory.Options;
 import android.graphics.Color;
 import android.graphics.Rect;
+import android.media.MediaFormat;
 import android.os.Parcel;
 import android.os.ParcelFileDescriptor;
 import android.platform.test.annotations.LargeTest;
@@ -47,6 +48,7 @@
 
 import com.android.compatibility.common.util.BitmapUtils;
 import com.android.compatibility.common.util.CddTest;
+import com.android.compatibility.common.util.MediaUtils;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -60,6 +62,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.RandomAccessFile;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.concurrent.CountDownLatch;
 
 import junitparams.JUnitParamsRunner;
@@ -84,13 +88,18 @@
     }
 
     private Object[] testImages() {
-        return new Object[] {
+        ArrayList<Object> testImages = new ArrayList<>(Arrays.asList(new Object[] {
                 new TestImage(R.drawable.baseline_jpeg, 1280, 960),
                 new TestImage(R.drawable.png_test, 640, 480),
                 new TestImage(R.drawable.gif_test, 320, 240),
                 new TestImage(R.drawable.bmp_test, 320, 240),
-                new TestImage(R.drawable.webp_test, 640, 480),
-        };
+                new TestImage(R.drawable.webp_test, 640, 480)
+        }));
+        if (MediaUtils.hasDecoder(MediaFormat.MIMETYPE_VIDEO_HEVC)) {
+            // HEIF support is optional when HEVC decoder is not supported.
+            testImages.add(new TestImage(R.raw.heifwriter_input, 1920, 1080));
+        }
+        return testImages.toArray(new Object[] {});
     }
 
     private static final int[] RAW_COLORS = new int[] {