package j6; import android.app.ActivityManager; import android.content.Context; import android.os.Build; import android.text.format.Formatter; import android.util.DisplayMetrics; import android.util.Log; /* loaded from: classes2.dex */ public final class h { /* renamed from: a, reason: collision with root package name */ private final int f11082a; /* renamed from: b, reason: collision with root package name */ private final int f11083b; /* renamed from: c, reason: collision with root package name */ private final Context f11084c; /* renamed from: d, reason: collision with root package name */ private final int f11085d; public static final class a { /* renamed from: i, reason: collision with root package name */ static final int f11086i; /* renamed from: a, reason: collision with root package name */ final Context f11087a; /* renamed from: b, reason: collision with root package name */ ActivityManager f11088b; /* renamed from: c, reason: collision with root package name */ c f11089c; /* renamed from: e, reason: collision with root package name */ float f11091e; /* renamed from: d, reason: collision with root package name */ float f11090d = 2.0f; /* renamed from: f, reason: collision with root package name */ float f11092f = 0.4f; /* renamed from: g, reason: collision with root package name */ float f11093g = 0.33f; /* renamed from: h, reason: collision with root package name */ int f11094h = 4194304; static { f11086i = Build.VERSION.SDK_INT < 26 ? 4 : 1; } public a(Context context) { this.f11091e = f11086i; this.f11087a = context; this.f11088b = (ActivityManager) context.getSystemService("activity"); this.f11089c = new b(context.getResources().getDisplayMetrics()); if (Build.VERSION.SDK_INT < 26 || !h.c(this.f11088b)) { return; } this.f11091e = 0.0f; } public h a() { return new h(this); } } private static final class b implements c { /* renamed from: a, reason: collision with root package name */ private final DisplayMetrics f11095a; b(DisplayMetrics displayMetrics) { this.f11095a = displayMetrics; } @Override // j6.h.c public int a() { return this.f11095a.heightPixels; } @Override // j6.h.c public int b() { return this.f11095a.widthPixels; } } interface c { int a(); int b(); } h(a aVar) { this.f11084c = aVar.f11087a; int i10 = c(aVar.f11088b) ? aVar.f11094h / 2 : aVar.f11094h; this.f11085d = i10; int a10 = a(aVar.f11088b, aVar.f11092f, aVar.f11093g); float b10 = aVar.f11089c.b() * aVar.f11089c.a() * 4; int round = Math.round(aVar.f11091e * b10); int round2 = Math.round(b10 * aVar.f11090d); int i11 = a10 - i10; int i12 = round2 + round; if (i12 <= i11) { this.f11083b = round2; this.f11082a = round; } else { float f10 = i11; float f11 = aVar.f11091e; float f12 = aVar.f11090d; float f13 = f10 / (f11 + f12); this.f11083b = Math.round(f12 * f13); this.f11082a = Math.round(f13 * aVar.f11091e); } if (Log.isLoggable("MemorySizeCalculator", 3)) { StringBuilder sb = new StringBuilder(); sb.append("Calculation complete, Calculated memory cache size: "); sb.append(b(this.f11083b)); sb.append(", pool size: "); sb.append(b(this.f11082a)); sb.append(", byte array size: "); sb.append(b(i10)); sb.append(", memory class limited? "); sb.append(i12 > a10); sb.append(", max size: "); sb.append(b(a10)); sb.append(", memoryClass: "); sb.append(aVar.f11088b.getMemoryClass()); sb.append(", isLowMemoryDevice: "); sb.append(c(aVar.f11088b)); Log.d("MemorySizeCalculator", sb.toString()); } } private static int a(ActivityManager activityManager, float f10, float f11) { float memoryClass = activityManager.getMemoryClass() * 1024 * 1024; if (c(activityManager)) { f10 = f11; } return Math.round(memoryClass * f10); } private String b(int i10) { return Formatter.formatFileSize(this.f11084c, i10); } static boolean c(ActivityManager activityManager) { return activityManager.isLowRamDevice(); } public int d() { return this.f11085d; } public int e() { return this.f11082a; } public int f() { return this.f11083b; } }