From 0647c410a0a6dc918f56ff3a4105557dc5313477 Mon Sep 17 00:00:00 2001 From: Sam Judd Date: Mon, 3 Feb 2020 13:04:53 -0800 Subject: [PATCH] Hardcode disallowed device models for hardware Bitmaps from b/147430447 PiperOrigin-RevId: 292986300 --- .../resource/bitmap/HardwareConfigState.java | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/HardwareConfigState.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/HardwareConfigState.java index d1243949ae..2adebb68d0 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/HardwareConfigState.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/HardwareConfigState.java @@ -8,6 +8,7 @@ import androidx.annotation.GuardedBy; import androidx.annotation.VisibleForTesting; import java.io.File; +import java.util.Arrays; /** * State and constants for interacting with {@link android.graphics.Bitmap.Config#HARDWARE} on @@ -132,8 +133,44 @@ boolean setHardwareConfigIfAllowed( } private static boolean isHardwareConfigAllowedByDeviceModel() { + return !isHardwareConfigDisallowedByB112551574() && !isHardwareConfigDisallowedByB147430447(); + } + + private static boolean isHardwareConfigDisallowedByB147430447() { + if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O_MR1) { + return false; + } + // This method will only be called once, so simple iteration is reasonable. + return Arrays.asList( + "ILA X1", + "LG-M250", + "LG-M320", + "LG-Q710AL", + "LG-Q710PL", + "LGM-K121K", + "LGM-K121L", + "LGM-K121S", + "LGM-X320K", + "LGM-X320L", + "LGM-X320S", + "LGM-X401L", + "LGM-X401S", + "LM-Q610.FG", + "LM-Q610.FGN", + "LM-Q617.FG", + "LM-Q617.FGN", + "LM-Q710.FG", + "LM-Q710.FGN", + "LM-X220PM", + "LM-X220QMA", + "LM-X410PM", + "SGINO") + .contains(Build.MODEL); + } + + private static boolean isHardwareConfigDisallowedByB112551574() { if (Build.MODEL == null || Build.MODEL.length() < 7) { - return true; + return false; } switch (Build.MODEL.substring(0, 7)) { case "SM-N935": @@ -150,9 +187,9 @@ private static boolean isHardwareConfigAllowedByDeviceModel() { // Fall through case "SM-A520": // Fall through - return Build.VERSION.SDK_INT != Build.VERSION_CODES.O; + return Build.VERSION.SDK_INT == Build.VERSION_CODES.O; default: - return true; + return false; } }