Skip to content

Commit ddb3934

Browse files
sjuddglide-copybara-robot
authored andcommitted
Update low FD count hardcoded hardware Bitmap blacklist.
PiperOrigin-RevId: 337968955
1 parent 90a657b commit ddb3934

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

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

+29-19
Original file line numberDiff line numberDiff line change
@@ -251,28 +251,38 @@ private static boolean isHardwareConfigDisallowedByB147430447() {
251251
}
252252

253253
private static boolean isHardwareConfigDisallowedByB112551574() {
254-
if (Build.MODEL == null || Build.MODEL.length() < 7) {
254+
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O) {
255255
return false;
256256
}
257-
switch (Build.MODEL.substring(0, 7)) {
258-
case "SM-N935":
259-
// Fall through
260-
case "SM-J720":
261-
// Fall through
262-
case "SM-G960":
263-
// Fall through
264-
case "SM-G965":
265-
// Fall through
266-
case "SM-G935":
267-
// Fall through
268-
case "SM-G930":
269-
// Fall through
270-
case "SM-A520":
271-
// Fall through
272-
return Build.VERSION.SDK_INT == Build.VERSION_CODES.O;
273-
default:
274-
return false;
257+
// This method will only be called once, so simple iteration is reasonable.
258+
for (String prefixOrModelName :
259+
// This is sadly a list of prefixes, not models. We no longer have the data that shows us
260+
// all the explicit models, so we have to live with the prefixes.
261+
Arrays.asList(
262+
// Samsung
263+
"SC-04J",
264+
"SM-N935",
265+
"SM-J720",
266+
"SM-G570F",
267+
"SM-G570M",
268+
"SM-G960",
269+
"SM-G965",
270+
"SM-G935",
271+
"SM-G930",
272+
"SM-A520",
273+
"SM-A720F",
274+
// Moto
275+
"moto e5",
276+
"moto e5 play",
277+
"moto e5 plus",
278+
"moto e5 cruise",
279+
"moto g(6) forge",
280+
"moto g(6) play")) {
281+
if (Build.MODEL.startsWith(prefixOrModelName)) {
282+
return true;
283+
}
275284
}
285+
return false;
276286
}
277287

278288
private int getMaxFdCount() {

library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/HardwareConfigStateTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,8 @@ public void setHardwareConfigIfAllowed_withDisallowedSamsungDevices_OMR1_returns
250250

251251
@Config(sdk = Build.VERSION_CODES.O)
252252
@Test
253-
public void setHardwareConfigIfAllowed_withShortEmptyOrNullModelNames_returnsTrue() {
254-
for (String model :
255-
new String[] {null, ".", "-", "", "S", "SM", "SM-", "SM-G", "SM-G9.", "SM-G93"}) {
253+
public void setHardwareConfigIfAllowed_withShortOrEmptyModelNames_returnsTrue() {
254+
for (String model : new String[] {".", "-", "", "S", "SM", "SM-", "SM-G", "SM-G9.", "SM-G93"}) {
256255
ShadowBuild.setModel(model);
257256
HardwareConfigState state = new HardwareConfigState();
258257
state.unblockHardwareBitmaps();

0 commit comments

Comments
 (0)