package u1; 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: classes.dex */ public final class i { /* renamed from: a, reason: collision with root package name */ private final int f14651a; /* renamed from: b, reason: collision with root package name */ private final int f14652b; /* renamed from: c, reason: collision with root package name */ private final Context f14653c; /* renamed from: d, reason: collision with root package name */ private final int f14654d; public static final class a { /* renamed from: i, reason: collision with root package name */ static final int f14655i; /* renamed from: a, reason: collision with root package name */ final Context f14656a; /* renamed from: b, reason: collision with root package name */ ActivityManager f14657b; /* renamed from: c, reason: collision with root package name */ c f14658c; /* renamed from: e, reason: collision with root package name */ float f14660e; /* renamed from: d, reason: collision with root package name */ float f14659d = 2.0f; /* renamed from: f, reason: collision with root package name */ float f14661f = 0.4f; /* renamed from: g, reason: collision with root package name */ float f14662g = 0.33f; /* renamed from: h, reason: collision with root package name */ int f14663h = 4194304; static { f14655i = Build.VERSION.SDK_INT < 26 ? 4 : 1; } public a(Context context) { this.f14660e = f14655i; this.f14656a = context; this.f14657b = (ActivityManager) context.getSystemService("activity"); this.f14658c = new b(context.getResources().getDisplayMetrics()); if (Build.VERSION.SDK_INT < 26 || !i.e(this.f14657b)) { return; } this.f14660e = 0.0f; } public i a() { return new i(this); } } private static final class b implements c { /* renamed from: a, reason: collision with root package name */ private final DisplayMetrics f14664a; b(DisplayMetrics displayMetrics) { this.f14664a = displayMetrics; } @Override // u1.i.c public int a() { return this.f14664a.heightPixels; } @Override // u1.i.c public int b() { return this.f14664a.widthPixels; } } interface c { int a(); int b(); } i(a aVar) { this.f14653c = aVar.f14656a; int i10 = e(aVar.f14657b) ? aVar.f14663h / 2 : aVar.f14663h; this.f14654d = i10; int c10 = c(aVar.f14657b, aVar.f14661f, aVar.f14662g); float b10 = aVar.f14658c.b() * aVar.f14658c.a() * 4; int round = Math.round(aVar.f14660e * b10); int round2 = Math.round(b10 * aVar.f14659d); int i11 = c10 - i10; int i12 = round2 + round; if (i12 <= i11) { this.f14652b = round2; this.f14651a = round; } else { float f10 = i11; float f11 = aVar.f14660e; float f12 = aVar.f14659d; float f13 = f10 / (f11 + f12); this.f14652b = Math.round(f12 * f13); this.f14651a = Math.round(f13 * aVar.f14660e); } if (Log.isLoggable("MemorySizeCalculator", 3)) { StringBuilder sb = new StringBuilder(); sb.append("Calculation complete, Calculated memory cache size: "); sb.append(f(this.f14652b)); sb.append(", pool size: "); sb.append(f(this.f14651a)); sb.append(", byte array size: "); sb.append(f(i10)); sb.append(", memory class limited? "); sb.append(i12 > c10); sb.append(", max size: "); sb.append(f(c10)); sb.append(", memoryClass: "); sb.append(aVar.f14657b.getMemoryClass()); sb.append(", isLowMemoryDevice: "); sb.append(e(aVar.f14657b)); Log.d("MemorySizeCalculator", sb.toString()); } } private static int c(ActivityManager activityManager, float f10, float f11) { float memoryClass = activityManager.getMemoryClass() * 1024 * 1024; if (e(activityManager)) { f10 = f11; } return Math.round(memoryClass * f10); } static boolean e(ActivityManager activityManager) { return activityManager.isLowRamDevice(); } private String f(int i10) { return Formatter.formatFileSize(this.f14653c, i10); } public int a() { return this.f14654d; } public int b() { return this.f14651a; } public int d() { return this.f14652b; } }