package com.chartboost.sdk.impl;

import android.content.SharedPreferences;
import com.chartboost.sdk.impl.na;
import com.chartboost.sdk.privacy.model.DataUseConsent;
import com.ironsource.y8;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public class q8 {

    /* renamed from: a  reason: collision with root package name */
    public final HashMap f1793a = new HashMap();
    public final SharedPreferences b;
    public final m4 c;

    public HashMap a() {
        return this.f1793a;
    }

    public q8(SharedPreferences sharedPreferences, m4 m4Var) {
        this.b = sharedPreferences;
        this.c = m4Var;
        b();
    }

    public final void c() {
        if (this.b != null) {
            JSONArray jSONArray = new JSONArray();
            for (DataUseConsent dataUseConsent : this.f1793a.values()) {
                jSONArray.put(a(dataUseConsent));
            }
            a(this.b, jSONArray);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:32:0x0077  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00c3 A[Catch: JSONException -> 0x0111, TryCatch #0 {JSONException -> 0x0111, blocks: (B:6:0x0016, B:8:0x0023, B:35:0x007d, B:52:0x00ea, B:53:0x00f4, B:36:0x008b, B:37:0x0095, B:38:0x009f, B:40:0x00ab, B:41:0x00b1, B:43:0x00bd, B:44:0x00c3, B:46:0x00cf, B:47:0x00d5, B:49:0x00e1, B:17:0x004b, B:20:0x0055, B:23:0x005f, B:26:0x0069), top: B:58:0x0016 }] */
    /* JADX WARN: Removed duplicated region for block: B:52:0x00ea A[Catch: JSONException -> 0x0111, TryCatch #0 {JSONException -> 0x0111, blocks: (B:6:0x0016, B:8:0x0023, B:35:0x007d, B:52:0x00ea, B:53:0x00f4, B:36:0x008b, B:37:0x0095, B:38:0x009f, B:40:0x00ab, B:41:0x00b1, B:43:0x00bd, B:44:0x00c3, B:46:0x00cf, B:47:0x00d5, B:49:0x00e1, B:17:0x004b, B:20:0x0055, B:23:0x005f, B:26:0x0069), top: B:58:0x0016 }] */
    /* JADX WARN: Removed duplicated region for block: B:53:0x00f4 A[Catch: JSONException -> 0x0111, TRY_LEAVE, TryCatch #0 {JSONException -> 0x0111, blocks: (B:6:0x0016, B:8:0x0023, B:35:0x007d, B:52:0x00ea, B:53:0x00f4, B:36:0x008b, B:37:0x0095, B:38:0x009f, B:40:0x00ab, B:41:0x00b1, B:43:0x00bd, B:44:0x00c3, B:46:0x00cf, B:47:0x00d5, B:49:0x00e1, B:17:0x004b, B:20:0x0055, B:23:0x005f, B:26:0x0069), top: B:58:0x0016 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void b() {
        /*
            Method dump skipped, instructions count: 281
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: com.chartboost.sdk.impl.q8.b():void");
    }

    public void a(String str) {
        this.f1793a.remove(str);
        c();
    }

    public void b(DataUseConsent dataUseConsent) {
        c7.a("Added privacy standard: " + dataUseConsent.getPrivacyStandard() + " with consent: " + dataUseConsent.getConsent(), null);
        this.f1793a.put(dataUseConsent.getPrivacyStandard(), dataUseConsent);
        c();
    }

    public final void a(SharedPreferences sharedPreferences, JSONArray jSONArray) {
        if (sharedPreferences == null || jSONArray == null) {
            return;
        }
        sharedPreferences.edit().putString("privacy_standards", jSONArray.toString()).apply();
    }

    public final void b(String str) {
        this.c.mo300track(r3.a(na.d.f, str, "", ""));
    }

    public final void a(JSONException jSONException) {
        this.c.mo300track(r3.a(na.d.d, jSONException.getMessage(), "", ""));
    }

    public final JSONObject a(DataUseConsent dataUseConsent) {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("privacyStandard", dataUseConsent.getPrivacyStandard());
            jSONObject.put(y8.i.b0, dataUseConsent.getConsent());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return jSONObject;
    }
}
