Skip to content

Commit 0647c41

Browse files
sjuddglide-copybara-robot
authored andcommittedFeb 3, 2020
Hardcode disallowed device models for hardware Bitmaps from b/147430447
PiperOrigin-RevId: 292986300
1 parent 55a4758 commit 0647c41

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed
 

‎library/src/main/java/com/bumptech/glide/load/resource/bitmap/HardwareConfigState.java

+40-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import androidx.annotation.GuardedBy;
99
import androidx.annotation.VisibleForTesting;
1010
import java.io.File;
11+
import java.util.Arrays;
1112

1213
/**
1314
* State and constants for interacting with {@link android.graphics.Bitmap.Config#HARDWARE} on
@@ -132,8 +133,44 @@ boolean setHardwareConfigIfAllowed(
132133
}
133134

134135
private static boolean isHardwareConfigAllowedByDeviceModel() {
136+
return !isHardwareConfigDisallowedByB112551574() && !isHardwareConfigDisallowedByB147430447();
137+
}
138+
139+
private static boolean isHardwareConfigDisallowedByB147430447() {
140+
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O_MR1) {
141+
return false;
142+
}
143+
// This method will only be called once, so simple iteration is reasonable.
144+
return Arrays.asList(
145+
"ILA X1",
146+
"LG-M250",
147+
"LG-M320",
148+
"LG-Q710AL",
149+
"LG-Q710PL",
150+
"LGM-K121K",
151+
"LGM-K121L",
152+
"LGM-K121S",
153+
"LGM-X320K",
154+
"LGM-X320L",
155+
"LGM-X320S",
156+
"LGM-X401L",
157+
"LGM-X401S",
158+
"LM-Q610.FG",
159+
"LM-Q610.FGN",
160+
"LM-Q617.FG",
161+
"LM-Q617.FGN",
162+
"LM-Q710.FG",
163+
"LM-Q710.FGN",
164+
"LM-X220PM",
165+
"LM-X220QMA",
166+
"LM-X410PM",
167+
"SGINO")
168+
.contains(Build.MODEL);
169+
}
170+
171+
private static boolean isHardwareConfigDisallowedByB112551574() {
135172
if (Build.MODEL == null || Build.MODEL.length() < 7) {
136-
return true;
173+
return false;
137174
}
138175
switch (Build.MODEL.substring(0, 7)) {
139176
case "SM-N935":
@@ -150,9 +187,9 @@ private static boolean isHardwareConfigAllowedByDeviceModel() {
150187
// Fall through
151188
case "SM-A520":
152189
// Fall through
153-
return Build.VERSION.SDK_INT != Build.VERSION_CODES.O;
190+
return Build.VERSION.SDK_INT == Build.VERSION_CODES.O;
154191
default:
155-
return true;
192+
return false;
156193
}
157194
}
158195

0 commit comments

Comments
 (0)
Please sign in to comment.