77
88package com .facebook .common .webp ;
99
10- import android .graphics .BitmapFactory ;
11- import android .os .Build ;
12- import android .util .Base64 ;
1310import com .facebook .infer .annotation .Nullsafe ;
1411import java .io .UnsupportedEncodingException ;
1512import javax .annotation .Nullable ;
1613
1714@ Nullsafe (Nullsafe .Mode .LOCAL )
1815public class WebpSupportStatus {
19- public static final boolean sIsSimpleWebpSupported =
20- Build .VERSION .SDK_INT >= Build .VERSION_CODES .ICE_CREAM_SANDWICH ;
16+ public static final boolean sIsSimpleWebpSupported = true ;
2117
2218 public static final boolean sIsExtendedWebpSupported = isExtendedWebpSupported ();
2319
@@ -41,11 +37,6 @@ public class WebpSupportStatus {
4137 return loadedWebpBitmapFactory ;
4238 }
4339
44- /** BASE64 encoded extended WebP image. */
45- private static final String VP8X_WEBP_BASE64 =
46- "UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAw"
47- + "AAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==" ;
48-
4940 /**
5041 * Helper method that transforms provided string into its byte representation using ASCII encoding
5142 *
@@ -83,30 +74,6 @@ private static byte[] asciiBytes(String value) {
8374
8475 /** Checks whether underlying platform supports extended WebPs */
8576 private static boolean isExtendedWebpSupported () {
86- // Lossless and extended formats are supported on Android 4.2.1+
87- // Unfortunately SDK_INT is not enough to distinguish 4.2 and 4.2.1
88- // (both are API level 17 (JELLY_BEAN_MR1))
89- if (Build .VERSION .SDK_INT < Build .VERSION_CODES .JELLY_BEAN_MR1 ) {
90- return false ;
91- }
92-
93- if (Build .VERSION .SDK_INT == Build .VERSION_CODES .JELLY_BEAN_MR1 ) {
94- // Let's test if extended webp is supported
95- // To this end we will try to decode bounds of vp8x webp with alpha channel
96- byte [] decodedBytes = Base64 .decode (VP8X_WEBP_BASE64 , Base64 .DEFAULT );
97- BitmapFactory .Options opts = new BitmapFactory .Options ();
98- opts .inJustDecodeBounds = true ;
99- BitmapFactory .decodeByteArray (decodedBytes , 0 , decodedBytes .length , opts );
100-
101- // If Android managed to find appropriate decoder then opts.outHeight and opts.outWidth
102- // should be set. We can not assume that outMimeType is set.
103- // Android guys forgot to update logic for mime types when they introduced support for webp.
104- // For example, on 4.2.2 this field is not set for webp images.
105- if (opts .outHeight != 1 || opts .outWidth != 1 ) {
106- return false ;
107- }
108- }
109-
11077 return true ;
11178 }
11279
0 commit comments