package com.apm.insight.k;

import androidx.annotation.Nullable;
import com.apm.insight.CrashType;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.json.JSONArray;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes.dex */
public abstract class c {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private static ConcurrentLinkedQueue<c> f5284a = new ConcurrentLinkedQueue<>();

    /* JADX INFO: renamed from: com.apm.insight.k.c$1, reason: invalid class name */
    public static /* synthetic */ class AnonymousClass1 {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        static final /* synthetic */ int[] f5285a;

        static {
            int[] iArr = new int[CrashType.values().length];
            f5285a = iArr;
            try {
                iArr[CrashType.JAVA.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f5285a[CrashType.LAUNCH.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f5285a[CrashType.NATIVE.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
        }
    }

    public static class a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private JSONObject f5286a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        private JSONObject f5287b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private CrashType f5288c;

        public a(JSONObject jSONObject, CrashType crashType) {
            this.f5288c = crashType;
            if (crashType == CrashType.LAUNCH) {
                this.f5286a = ((JSONArray) jSONObject.opt("data")).optJSONObject(0);
            } else {
                this.f5286a = jSONObject;
            }
            this.f5287b = jSONObject.optJSONObject("header");
        }

        @Nullable
        public final String a() {
            return this.f5286a.optString("crash_thread_name", null);
        }

        public final long b() {
            return this.f5286a.optInt("app_start_time", -1);
        }

        @Nullable
        public final String c() {
            int i10 = AnonymousClass1.f5285a[this.f5288c.ordinal()];
            if (i10 == 1) {
                return this.f5286a.optString("data", null);
            }
            if (i10 == 2) {
                return this.f5286a.optString("stack", null);
            }
            if (i10 != 3) {
                return null;
            }
            return this.f5286a.optString("data", null);
        }
    }

    public static void a(CrashType crashType, JSONObject jSONObject) {
        ConcurrentLinkedQueue<c> concurrentLinkedQueue = f5284a;
        if (concurrentLinkedQueue == null || concurrentLinkedQueue.isEmpty()) {
            return;
        }
        new a(jSONObject, crashType);
        while (!f5284a.isEmpty()) {
            f5284a.poll();
        }
        f5284a = null;
    }
}
