Skip to content

Commit

Permalink
Hardcode and clean up the manual FD override flag in Glide.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 516867999
  • Loading branch information
sjudd authored and glide-copybara-robot committed Mar 15, 2023
1 parent 4196da8 commit 295d92d
Showing 1 changed file with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,18 @@ public final class HardwareConfigState {
// 20k.
private static final int MAXIMUM_FDS_FOR_HARDWARE_CONFIGS_P = 20000;

/** This constant will be removed in a future version without deprecation, avoid using it. */
public static final int NO_MAX_FD_COUNT = -1;
/**
* Some P devices seem to have a more O like FD count, so we'll manually reduce the number of FDs
* we use for hardware bitmaps. See b/139097735.
*/
private static final int REDUCED_MAX_FDS_FOR_HARDWARE_CONFIGS_P = 500;

/**
* @deprecated This constant is unused and will be removed in a future version, avoid using it.
*/
@Deprecated public static final int NO_MAX_FD_COUNT = -1;

private static volatile HardwareConfigState instance;
private static volatile int manualOverrideMaxFdCount = NO_MAX_FD_COUNT;

private static boolean disableHardwareBitmapsOnO;

Expand Down Expand Up @@ -290,10 +297,38 @@ private static boolean isHardwareConfigDisallowedByB112551574() {
return false;
}

private static boolean isHardwareBitmapCountReducedOnApi28ByB139097735() {
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.P) {
return false;
}
for (String prefixOrModelName :
Arrays.asList(
"GM1900",
"GM1901",
"GM1903",
"GM1911",
"GM1915",
"ONEPLUS A3000",
"ONEPLUS A3010",
"ONEPLUS A5010",
"ONEPLUS A5000",
"ONEPLUS A3003",
"ONEPLUS A6000",
"ONEPLUS A6003",
"ONEPLUS A6010",
"ONEPLUS A6013")) {
if (Build.MODEL.startsWith(prefixOrModelName)) {
return true;
}
}
return false;
}

private int getMaxFdCount() {
return manualOverrideMaxFdCount != NO_MAX_FD_COUNT
? manualOverrideMaxFdCount
: sdkBasedMaxFdCount;
if (isHardwareBitmapCountReducedOnApi28ByB139097735()) {
return REDUCED_MAX_FDS_FOR_HARDWARE_CONFIGS_P;
}
return sdkBasedMaxFdCount;
}

private synchronized boolean isFdSizeBelowHardwareLimit() {
Expand Down

0 comments on commit 295d92d

Please sign in to comment.