package z1; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Build; import android.util.Log; import java.io.File; import java.util.Arrays; import java.util.Iterator; import java.util.concurrent.atomic.AtomicBoolean; /* loaded from: classes.dex */ public final class y { /* renamed from: g, reason: collision with root package name */ public static final boolean f15792g; /* renamed from: h, reason: collision with root package name */ public static final boolean f15793h; /* renamed from: i, reason: collision with root package name */ private static final File f15794i; /* renamed from: j, reason: collision with root package name */ private static volatile y f15795j; /* renamed from: k, reason: collision with root package name */ private static volatile int f15796k; /* renamed from: b, reason: collision with root package name */ private final int f15798b; /* renamed from: c, reason: collision with root package name */ private final int f15799c; /* renamed from: d, reason: collision with root package name */ private int f15800d; /* renamed from: e, reason: collision with root package name */ private boolean f15801e = true; /* renamed from: f, reason: collision with root package name */ private final AtomicBoolean f15802f = new AtomicBoolean(false); /* renamed from: a, reason: collision with root package name */ private final boolean f15797a = f(); static { int i10 = Build.VERSION.SDK_INT; f15792g = i10 < 29; f15793h = i10 >= 26; f15794i = new File("/proc/self/fd"); f15796k = -1; } y() { if (Build.VERSION.SDK_INT >= 28) { this.f15798b = 20000; this.f15799c = 0; } else { this.f15798b = 700; this.f15799c = 128; } } private boolean a() { return f15792g && !this.f15802f.get(); } public static y b() { if (f15795j == null) { synchronized (y.class) { if (f15795j == null) { f15795j = new y(); } } } return f15795j; } private int c() { return f15796k != -1 ? f15796k : this.f15798b; } private synchronized boolean d() { boolean z10 = true; int i10 = this.f15800d + 1; this.f15800d = i10; if (i10 >= 50) { this.f15800d = 0; int length = f15794i.list().length; long c10 = c(); if (length >= c10) { z10 = false; } this.f15801e = z10; if (!z10 && Log.isLoggable("Downsampler", 5)) { Log.w("Downsampler", "Excluding HARDWARE bitmap config because we're over the file descriptor limit, file descriptors " + length + ", limit " + c10); } } return this.f15801e; } private static boolean f() { return (g() || h()) ? false : true; } private static boolean g() { if (Build.VERSION.SDK_INT != 26) { return false; } Iterator it = Arrays.asList("SC-04J", "SM-N935", "SM-J720", "SM-G570F", "SM-G570M", "SM-G960", "SM-G965", "SM-G935", "SM-G930", "SM-A520", "SM-A720F", "moto e5", "moto e5 play", "moto e5 plus", "moto e5 cruise", "moto g(6) forge", "moto g(6) play").iterator(); while (it.hasNext()) { if (Build.MODEL.startsWith((String) it.next())) { return true; } } return false; } private static boolean h() { if (Build.VERSION.SDK_INT != 27) { return false; } return Arrays.asList("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").contains(Build.MODEL); } public boolean e(int i10, int i11, boolean z10, boolean z11) { if (!z10) { if (Log.isLoggable("HardwareConfig", 2)) { Log.v("HardwareConfig", "Hardware config disallowed by caller"); } return false; } if (!this.f15797a) { if (Log.isLoggable("HardwareConfig", 2)) { Log.v("HardwareConfig", "Hardware config disallowed by device model"); } return false; } if (!f15793h) { if (Log.isLoggable("HardwareConfig", 2)) { Log.v("HardwareConfig", "Hardware config disallowed by sdk"); } return false; } if (a()) { if (Log.isLoggable("HardwareConfig", 2)) { Log.v("HardwareConfig", "Hardware config disallowed by app state"); } return false; } if (z11) { if (Log.isLoggable("HardwareConfig", 2)) { Log.v("HardwareConfig", "Hardware config disallowed because exif orientation is required"); } return false; } int i12 = this.f15799c; if (i10 < i12) { if (Log.isLoggable("HardwareConfig", 2)) { Log.v("HardwareConfig", "Hardware config disallowed because width is too small"); } return false; } if (i11 < i12) { if (Log.isLoggable("HardwareConfig", 2)) { Log.v("HardwareConfig", "Hardware config disallowed because height is too small"); } return false; } if (d()) { return true; } if (Log.isLoggable("HardwareConfig", 2)) { Log.v("HardwareConfig", "Hardware config disallowed because there are insufficient FDs"); } return false; } boolean i(int i10, int i11, BitmapFactory.Options options, boolean z10, boolean z11) { Bitmap.Config config; boolean e10 = e(i10, i11, z10, z11); if (e10) { config = Bitmap.Config.HARDWARE; options.inPreferredConfig = config; options.inMutable = false; } return e10; } }