package com.appsflyer;

import com.appsflyer.internal.ae;
import org.json.JSONException;
import org.json.JSONObject;

public class ServerConfigHandler {
    public static String getUrl(String str) {
        return String.format(str, AppsFlyerLib.getInstance().getHostPrefix(), AppsFlyerLibCore.getInstance().getHostName());
    }

    /* JADX WARNING: Removed duplicated region for block: B:24:0x005f  */
    /* JADX WARNING: Removed duplicated region for block: B:27:0x006f  */
    /* JADX WARNING: Removed duplicated region for block: B:33:0x0081  */
    /* JADX WARNING: Removed duplicated region for block: B:36:0x0091  */
    /* renamed from: ˎ  reason: contains not printable characters */
    public static JSONObject m1161(String str) {
        JSONObject jSONObject;
        Throwable th;
        try {
            jSONObject = new JSONObject(str);
            try {
                boolean z = AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.DPM, false);
                if (!jSONObject.optBoolean("monitor", false) || z) {
                    if (ae.f1979 == null) {
                        ae.f1979 = new ae();
                    }
                    ae.f1979.m1178();
                    if (ae.f1979 == null) {
                        ae.f1979 = new ae();
                    }
                    ae.f1979.m1177();
                    return jSONObject;
                }
                if (ae.f1979 == null) {
                    ae.f1979 = new ae();
                }
                ae.f1979.m1181();
                return jSONObject;
            } catch (JSONException unused) {
                if (ae.f1979 == null) {
                    ae.f1979 = new ae();
                }
                ae.f1979.m1178();
                if (ae.f1979 == null) {
                    ae.f1979 = new ae();
                }
                ae.f1979.m1177();
                return jSONObject;
            } catch (Throwable th2) {
                th = th2;
                AFLogger.afErrorLog(th.getMessage(), th);
                if (ae.f1979 == null) {
                    ae.f1979 = new ae();
                }
                ae.f1979.m1178();
                if (ae.f1979 == null) {
                    ae.f1979 = new ae();
                }
                ae.f1979.m1177();
                return jSONObject;
            }
        } catch (JSONException unused2) {
            jSONObject = null;
            if (ae.f1979 == null) {
            }
            ae.f1979.m1178();
            if (ae.f1979 == null) {
            }
            ae.f1979.m1177();
            return jSONObject;
        } catch (Throwable th3) {
            th = th3;
            jSONObject = null;
            AFLogger.afErrorLog(th.getMessage(), th);
            if (ae.f1979 == null) {
            }
            ae.f1979.m1178();
            if (ae.f1979 == null) {
            }
            ae.f1979.m1177();
            return jSONObject;
        }
    }
}
