package defpackage;

import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.hardware.SensorManager;
import android.os.Environment;
import android.os.StatFs;
import j$.util.DesugarCollections;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

/* JADX INFO: renamed from: ᵳˁᵥ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C4564 {

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public static final String f17351;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public static final HashMap f17352;

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final C2869 f17353;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final C0680 f17354;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final C3420 f17355;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final Context f17356;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final C3714 f17357;

    static {
        HashMap map = new HashMap();
        f17352 = map;
        AbstractC3653.m8229(5, map, "armeabi", 6, "armeabi-v7a");
        AbstractC3653.m8229(9, map, "arm64-v8a", 0, "x86");
        map.put("x86_64", 1);
        Locale locale = Locale.US;
        f17351 = "Crashlytics Android SDK/20.0.6";
    }

    public C4564(Context context, C2869 c2869, C0680 c0680, C3714 c3714, C3420 c3420) {
        this.f17356 = context;
        this.f17353 = c2869;
        this.f17354 = c0680;
        this.f17357 = c3714;
        this.f17355 = c3420;
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public static C1490 m9647(C4055 c4055, int i) {
        String str = (String) c4055.f15557;
        String str2 = (String) c4055.f15558;
        StackTraceElement[] stackTraceElementArr = (StackTraceElement[]) c4055.f15559;
        int i2 = 0;
        if (stackTraceElementArr == null) {
            stackTraceElementArr = new StackTraceElement[0];
        }
        C4055 c40552 = (C4055) c4055.f15560;
        if (i >= 8) {
            C4055 c40553 = c40552;
            while (c40553 != null) {
                c40553 = (C4055) c40553.f15560;
                i2++;
            }
        }
        int i3 = i2;
        List listM9649 = m9649(stackTraceElementArr, 4);
        if (listM9649 == null) {
            C4935.m10233("Null frames");
            return null;
        }
        byte b = (byte) (0 | 1);
        C1490 c1490M9647 = (c40552 == null || i3 != 0) ? null : m9647(c40552, i + 1);
        if (b == 1) {
            return new C1490(str, str2, listM9649, c1490M9647, i3);
        }
        StringBuilder sb = new StringBuilder();
        if ((b & 1) == 0) {
            sb.append(" overflowCount");
        }
        ᵕᵩʽᵲ.ᵪᵹᵥᵻ(AbstractC3589.m8115("Missing required properties:", sb));
        return null;
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public static C4160 m9648() {
        return new C4160(0L, "0", "0");
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public static List m9649(StackTraceElement[] stackTraceElementArr, int i) {
        ArrayList arrayList = new ArrayList();
        for (StackTraceElement stackTraceElement : stackTraceElementArr) {
            C3683 c3683 = new C3683();
            c3683.f14044 = i;
            c3683.f14047 = (byte) (c3683.f14047 | 4);
            long lineNumber = 0;
            long jMax = stackTraceElement.isNativeMethod() ? Math.max(stackTraceElement.getLineNumber(), 0L) : 0L;
            String str = stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName();
            String fileName = stackTraceElement.getFileName();
            if (!stackTraceElement.isNativeMethod() && stackTraceElement.getLineNumber() > 0) {
                lineNumber = stackTraceElement.getLineNumber();
            }
            c3683.f14045 = jMax;
            byte b = (byte) (c3683.f14047 | 1);
            c3683.f14042 = str;
            c3683.f14043 = fileName;
            c3683.f14046 = lineNumber;
            c3683.f14047 = (byte) (b | 2);
            arrayList.add(c3683.m8301());
        }
        return DesugarCollections.unmodifiableList(arrayList);
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x0043  */
    /* JADX WARN: Removed duplicated region for block: B:29:0x0062  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x0099  */
    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C3136 m9650(int i) {
        boolean z;
        Float fValueOf;
        long j;
        Intent intentRegisterReceiver;
        Context context = this.f17356;
        boolean z2 = false;
        try {
            intentRegisterReceiver = context.registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
        } catch (IllegalStateException unused) {
        }
        if (intentRegisterReceiver != null) {
            int intExtra = intentRegisterReceiver.getIntExtra("status", -1);
            z = intExtra != -1 && (intExtra == 2 || intExtra == 5);
            try {
                int intExtra2 = intentRegisterReceiver.getIntExtra("level", -1);
                int intExtra3 = intentRegisterReceiver.getIntExtra("scale", -1);
                if (intExtra2 != -1 && intExtra3 != -1) {
                    fValueOf = Float.valueOf(intExtra2 / intExtra3);
                }
            } catch (IllegalStateException unused2) {
            }
            Double dValueOf = fValueOf != null ? Double.valueOf(fValueOf.doubleValue()) : null;
            int i2 = (z || fValueOf == null) ? 1 : ((double) fValueOf.floatValue()) < 0.99d ? 2 : 3;
            if (!ᵥˇᵛˎ.ᵞᵛᵘ() && ((SensorManager) context.getSystemService("sensor")).getDefaultSensor(8) != null) {
                z2 = true;
            }
            long j2 = ᵥˇᵛˎ.ːˏᵟᵯ(context);
            ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
            ((ActivityManager) context.getSystemService("activity")).getMemoryInfo(memoryInfo);
            j = j2 - memoryInfo.availMem;
            if (j <= 0) {
                j = 0;
            }
            StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
            long blockSize = statFs.getBlockSize();
            long blockCount = (((long) statFs.getBlockCount()) * blockSize) - (blockSize * ((long) statFs.getAvailableBlocks()));
            C1824 c1824 = new C1824();
            c1824.f7259 = dValueOf;
            c1824.f7256 = i2;
            byte b = (byte) (1 | c1824.f7260);
            c1824.f7257 = z2;
            c1824.f7261 = i;
            c1824.f7258 = j;
            c1824.f7262 = blockCount;
            c1824.f7260 = (byte) (((byte) (((byte) (((byte) (2 | b)) | 4)) | 8)) | 16);
            return c1824.m5008();
        }
        z = false;
        fValueOf = null;
        if (fValueOf != null) {
        }
        if (z) {
        }
        if (!ᵥˇᵛˎ.ᵞᵛᵘ()) {
            z2 = true;
        }
        long j22 = ᵥˇᵛˎ.ːˏᵟᵯ(context);
        ActivityManager.MemoryInfo memoryInfo2 = new ActivityManager.MemoryInfo();
        ((ActivityManager) context.getSystemService("activity")).getMemoryInfo(memoryInfo2);
        j = j22 - memoryInfo2.availMem;
        if (j <= 0) {
        }
        StatFs statFs2 = new StatFs(Environment.getDataDirectory().getPath());
        long blockSize2 = statFs2.getBlockSize();
        long blockCount2 = (((long) statFs2.getBlockCount()) * blockSize2) - (blockSize2 * ((long) statFs2.getAvailableBlocks()));
        C1824 c18242 = new C1824();
        c18242.f7259 = dValueOf;
        c18242.f7256 = i2;
        byte b2 = (byte) (1 | c18242.f7260);
        c18242.f7257 = z2;
        c18242.f7261 = i;
        c18242.f7258 = j;
        c18242.f7262 = blockCount2;
        c18242.f7260 = (byte) (((byte) (((byte) (((byte) (2 | b2)) | 4)) | 8)) | 16);
        return c18242.m5008();
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final List m9651() {
        byte b = (byte) (((byte) (0 | 1)) | 2);
        C0680 c0680 = this.f17354;
        String str = c0680.f3122;
        if (str == null) {
            C4935.m10233("Null name");
            return null;
        }
        String str2 = c0680.f3119;
        if (b == 3) {
            return Collections.singletonList(new C2008(0L, 0L, str, str2));
        }
        StringBuilder sb = new StringBuilder();
        if ((b & 1) == 0) {
            sb.append(" baseAddress");
        }
        if ((b & 2) == 0) {
            sb.append(" size");
        }
        ᵕᵩʽᵲ.ᵪᵹᵥᵻ(AbstractC3589.m8115("Missing required properties:", sb));
        return null;
    }
}
