Fallback to RGBA_8888 when P010 is not supported

It's possible that a TV does not support P010, which means
the TV is not able to decode 10-bit HEIF to RGBA_1010102.
In this case, falling back to output RGBA_8888 is necessary.

Bug: 276879147
Test: atest BitmapFactory#testDecode10BitHEIF10BitBitmap
      atest ImageDecoderTest#testDecode10BitHeif
Change-Id: I33f7f30cbee0080dc81764c73428dcac3c75ce88
diff --git a/libs/hwui/jni/BitmapFactory.cpp b/libs/hwui/jni/BitmapFactory.cpp
index c57e6f0..38d17de 100644
--- a/libs/hwui/jni/BitmapFactory.cpp
+++ b/libs/hwui/jni/BitmapFactory.cpp
@@ -401,6 +401,14 @@
         decodeColorType = kN32_SkColorType;
     }
 
+    // b/276879147, fallback to RGBA_8888 when decoding HEIF and P010 is not supported.
+    if (decodeColorType == kRGBA_1010102_SkColorType &&
+        codec->getEncodedFormat() == SkEncodedImageFormat::kHEIF &&
+        env->CallStaticBooleanMethod(gImageDecoder_class,
+                                     gImageDecoder_isP010SupportedForHEVCMethodID) == JNI_FALSE) {
+        decodeColorType = kN32_SkColorType;
+    }
+
     sk_sp<SkColorSpace> decodeColorSpace = codec->computeOutputColorSpace(
             decodeColorType, prefColorSpace);