package ඓ.ῲ.K.ᕣ.ᨨ.ト;

import android.annotation.TargetApi;
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;
import androidx.recyclerview.widget.RecyclerView;
import ඓ.K.K.K.C1293;

/* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.ト.㳳  reason: contains not printable characters */
/* compiled from: MemorySizeCalculator */
public final class C0996 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public final Context f4381;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final int f4382;

    /* renamed from: K  reason: contains not printable characters */
    public final int f4383;

    /* renamed from: 㸾  reason: contains not printable characters */
    public final int f4384;

    /* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.ト.㳳$ʬ  reason: contains not printable characters */
    /* compiled from: MemorySizeCalculator */
    public interface AbstractC0997 {
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.ト.㳳$ῲ  reason: contains not printable characters */
    /* compiled from: MemorySizeCalculator */
    public static final class C0998 implements AbstractC0997 {

        /* renamed from: K  reason: contains not printable characters */
        public final DisplayMetrics f4385;

        public C0998(DisplayMetrics displayMetrics) {
            this.f4385 = displayMetrics;
        }
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.ト.㳳$K  reason: contains not printable characters */
    /* compiled from: MemorySizeCalculator */
    public static final class C0999 {

        /* renamed from: ᨨ  reason: contains not printable characters */
        public static final int f4386 = (Build.VERSION.SDK_INT < 26 ? 4 : 1);

        /* renamed from: ʬ  reason: contains not printable characters */
        public AbstractC0997 f4387;

        /* renamed from: ඓ  reason: contains not printable characters */
        public float f4388 = ((float) f4386);

        /* renamed from: ῲ  reason: contains not printable characters */
        public ActivityManager f4389;

        /* renamed from: ⁱ  reason: contains not printable characters */
        public float f4390 = 0.33f;

        /* renamed from: K  reason: contains not printable characters */
        public final Context f4391;

        /* renamed from: 㴹  reason: contains not printable characters */
        public float f4392 = 0.4f;

        /* renamed from: 㸾  reason: contains not printable characters */
        public float f4393 = 2.0f;

        /* renamed from: 㿎  reason: contains not printable characters */
        public int f4394 = 4194304;

        public C0999(Context context) {
            this.f4391 = context;
            this.f4389 = (ActivityManager) context.getSystemService("activity");
            this.f4387 = new C0998(context.getResources().getDisplayMetrics());
            if (Build.VERSION.SDK_INT >= 26 && C0996.m2801(this.f4389)) {
                this.f4388 = 0.0f;
            }
        }
    }

    public C0996(C0999 k) {
        int i;
        this.f4381 = k.f4391;
        if (m2801(k.f4389)) {
            i = k.f4394 / 2;
        } else {
            i = k.f4394;
        }
        this.f4384 = i;
        ActivityManager activityManager = k.f4389;
        int round = Math.round(((float) (activityManager.getMemoryClass() * RecyclerView.AbstractC0269.FLAG_ADAPTER_FULLUPDATE * RecyclerView.AbstractC0269.FLAG_ADAPTER_FULLUPDATE)) * (m2801(activityManager) ? k.f4390 : k.f4392));
        AbstractC0997 r1 = k.f4387;
        float f = (float) (((C0998) r1).f4385.widthPixels * ((C0998) r1).f4385.heightPixels * 4);
        int round2 = Math.round(k.f4388 * f);
        int round3 = Math.round(f * k.f4393);
        int i2 = round - this.f4384;
        int i3 = round3 + round2;
        if (i3 <= i2) {
            this.f4382 = round3;
            this.f4383 = round2;
        } else {
            float f2 = (float) i2;
            float f3 = k.f4388;
            float f4 = k.f4393;
            float f5 = f2 / (f3 + f4);
            this.f4382 = Math.round(f4 * f5);
            this.f4383 = Math.round(f5 * k.f4388);
        }
        if (Log.isLoggable("MemorySizeCalculator", 3)) {
            StringBuilder r12 = C1293.m3416("Calculation complete, Calculated memory cache size: ");
            r12.append(m2802(this.f4382));
            r12.append(", pool size: ");
            r12.append(m2802(this.f4383));
            r12.append(", byte array size: ");
            r12.append(m2802(this.f4384));
            r12.append(", memory class limited? ");
            r12.append(i3 > round);
            r12.append(", max size: ");
            r12.append(m2802(round));
            r12.append(", memoryClass: ");
            r12.append(k.f4389.getMemoryClass());
            r12.append(", isLowMemoryDevice: ");
            r12.append(m2801(k.f4389));
            Log.d("MemorySizeCalculator", r12.toString());
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final String m2802(int i) {
        return Formatter.formatFileSize(this.f4381, (long) i);
    }

    @TargetApi(19)
    /* renamed from: K  reason: contains not printable characters */
    public static boolean m2801(ActivityManager activityManager) {
        int i = Build.VERSION.SDK_INT;
        return activityManager.isLowRamDevice();
    }
}
