Skip to content

Commit bd39932

Browse files
generatedunixname537391475639613meta-codesync[bot]
authored andcommitted
fbandroid/libraries/fbcore/src/main/java/com/facebook/common/webp/WebpSupportStatus.java
Reviewed By: drhill-meta Differential Revision: D91027279 fbshipit-source-id: d5e1c64b0c9de673f80d79797a664ccdc66834c1
1 parent 436ed6b commit bd39932

File tree

1 file changed

+1
-34
lines changed

1 file changed

+1
-34
lines changed

fbcore/src/main/java/com/facebook/common/webp/WebpSupportStatus.java

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@
77

88
package com.facebook.common.webp;
99

10-
import android.graphics.BitmapFactory;
11-
import android.os.Build;
12-
import android.util.Base64;
1310
import com.facebook.infer.annotation.Nullsafe;
1411
import java.io.UnsupportedEncodingException;
1512
import javax.annotation.Nullable;
1613

1714
@Nullsafe(Nullsafe.Mode.LOCAL)
1815
public 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

Comments
 (0)