File tree 1 file changed +15
-1
lines changed
library/src/main/java/com/bumptech/glide/load/resource/bitmap
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 16
16
public final class ParcelFileDescriptorBitmapDecoder
17
17
implements ResourceDecoder <ParcelFileDescriptor , Bitmap > {
18
18
19
+ // 512MB. While I don't have data on the number of valid image files > 512mb, I have determined
20
+ // that virtually all crashes related to Huawei/Honor's DRM checker go away when we don't attempt
21
+ // to decode files larger than this. We could increase this to 1GB safely, but it seems like 512MB
22
+ // might be a little better from a crash reduction perspective. See b/201464175.
23
+ private static final int MAXIMUM_FILE_BYTE_SIZE_FOR_FILE_DESCRIPTOR_DECODER = 512 * 1024 * 1024 ;
24
+
19
25
private final Downsampler downsampler ;
20
26
21
27
public ParcelFileDescriptorBitmapDecoder (Downsampler downsampler ) {
@@ -24,7 +30,15 @@ public ParcelFileDescriptorBitmapDecoder(Downsampler downsampler) {
24
30
25
31
@ Override
26
32
public boolean handles (@ NonNull ParcelFileDescriptor source , @ NonNull Options options ) {
27
- return downsampler .handles (source );
33
+ return isSafeToTryDecoding (source ) && downsampler .handles (source );
34
+ }
35
+
36
+ private boolean isSafeToTryDecoding (@ NonNull ParcelFileDescriptor source ) {
37
+ if ("HUAWEI" .equalsIgnoreCase (Build .MANUFACTURER )
38
+ || "HONOR" .equalsIgnoreCase (Build .MANUFACTURER )) {
39
+ return source .getStatSize () <= MAXIMUM_FILE_BYTE_SIZE_FOR_FILE_DESCRIPTOR_DECODER ;
40
+ }
41
+ return true ;
28
42
}
29
43
30
44
@ Nullable
You can’t perform that action at this time.
0 commit comments