package com.appsflyer.internal;

import android.content.pm.PackageManager;
import android.os.Build;
import com.appsflyer.AppsFlyerLibCore;
import com.appsflyer.AppsFlyerProperties;
import com.appsflyer.ServerParameters;
import com.facebook.devicerequests.internal.DeviceRequestsHelper;
import com.facebook.internal.FetchedAppGateKeepersManager;
import java.text.SimpleDateFormat;
import java.util.Locale;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public final class ae {

    /* renamed from: ˊ  reason: contains not printable characters */
    public static ae f1979;

    /* renamed from: ʻ  reason: contains not printable characters */
    public final String f1980;

    /* renamed from: ʻॱ  reason: contains not printable characters */
    public final String f1981;

    /* renamed from: ʼ  reason: contains not printable characters */
    public final String f1982;

    /* renamed from: ʼॱ  reason: contains not printable characters */
    public final String f1983;

    /* renamed from: ʽ  reason: contains not printable characters */
    public final String f1984;

    /* renamed from: ʽॱ  reason: contains not printable characters */
    public final String f1985;

    /* renamed from: ʾ  reason: contains not printable characters */
    public final String f1986;

    /* renamed from: ʿ  reason: contains not printable characters */
    public final String f1987;

    /* renamed from: ˈ  reason: contains not printable characters */
    public final String f1988;

    /* renamed from: ˉ  reason: contains not printable characters */
    public JSONObject f1989;

    /* renamed from: ˊˊ  reason: contains not printable characters */
    public final String f1990;

    /* renamed from: ˊˋ  reason: contains not printable characters */
    public final String f1991;

    /* renamed from: ˊॱ  reason: contains not printable characters */
    public final String f1992;

    /* renamed from: ˊᐝ  reason: contains not printable characters */
    public JSONArray f1993;

    /* renamed from: ˋ  reason: contains not printable characters */
    public boolean f1994;

    /* renamed from: ˋˊ  reason: contains not printable characters */
    public boolean f1995;

    /* renamed from: ˋˋ  reason: contains not printable characters */
    public boolean f1996;

    /* renamed from: ˋॱ  reason: contains not printable characters */
    public final String f1997;

    /* renamed from: ˋᐝ  reason: contains not printable characters */
    public int f1998;

    /* renamed from: ˌ  reason: contains not printable characters */
    public String f1999;

    /* renamed from: ˎ  reason: contains not printable characters */
    public final String f2000;

    /* renamed from: ˏ  reason: contains not printable characters */
    public boolean f2001;

    /* renamed from: ˏॱ  reason: contains not printable characters */
    public final String f2002;

    /* renamed from: ͺ  reason: contains not printable characters */
    public final String f2003;

    /* renamed from: ॱ  reason: contains not printable characters */
    public final String f2004;

    /* renamed from: ॱˊ  reason: contains not printable characters */
    public final String f2005;

    /* renamed from: ॱˋ  reason: contains not printable characters */
    public final String f2006;

    /* renamed from: ॱˎ  reason: contains not printable characters */
    public final String f2007;

    /* renamed from: ॱॱ  reason: contains not printable characters */
    public final String f2008;

    /* renamed from: ॱᐝ  reason: contains not printable characters */
    public final String f2009;

    /* renamed from: ᐝ  reason: contains not printable characters */
    public final String f2010;

    /* renamed from: ᐝॱ  reason: contains not printable characters */
    public final String f2011;

    public ae() {
        this.f2000 = "brand";
        this.f2004 = DeviceRequestsHelper.DEVICE_INFO_MODEL;
        this.f1980 = "platform";
        this.f1982 = "platform_version";
        this.f2008 = ServerParameters.ADVERTISING_ID_PARAM;
        this.f1984 = "imei";
        this.f2010 = "android_id";
        this.f2005 = FetchedAppGateKeepersManager.APPLICATION_SDK_VERSION;
        this.f1997 = "devkey";
        this.f2003 = "originalAppsFlyerId";
        this.f2002 = "uid";
        this.f1992 = "app_id";
        this.f1981 = "app_version";
        this.f2011 = AppsFlyerProperties.CHANNEL;
        this.f2007 = "preInstall";
        this.f2006 = "data";
        this.f2009 = "r_debugging_off";
        this.f1985 = "r_debugging_on";
        this.f1986 = "public_api_call";
        this.f1983 = "exception";
        this.f1987 = "server_request";
        this.f1988 = "server_response";
        this.f1991 = "yyyy-MM-dd HH:mm:ssZ";
        this.f1990 = "MM-dd HH:mm:ss.SSS";
        this.f1995 = true;
        this.f1998 = 0;
        this.f1999 = "-1";
        this.f1996 = AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.DPM, false);
        this.f2001 = true ^ this.f1996;
        this.f1993 = new JSONArray();
        this.f1998 = 0;
        this.f1994 = false;
    }

    /* renamed from: ʼ  reason: contains not printable characters */
    private synchronized void m1173() {
        this.f1993 = null;
        this.f1993 = new JSONArray();
        this.f1998 = 0;
    }

    /* renamed from: ˋ  reason: contains not printable characters */
    private synchronized void m1174(String str, String str2, String str3, String str4) {
        try {
            this.f1989.put(FetchedAppGateKeepersManager.APPLICATION_SDK_VERSION, str);
            if (str2 != null && str2.length() > 0) {
                this.f1989.put("devkey", str2);
            }
            if (str3 != null && str3.length() > 0) {
                this.f1989.put("originalAppsFlyerId", str3);
            }
            if (str4 != null && str4.length() > 0) {
                this.f1989.put("uid", str4);
            }
        } catch (Throwable unused) {
        }
    }

    /* renamed from: ˊ  reason: contains not printable characters */
    public final synchronized void m1177() {
        m1180("r_debugging_off", new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ", Locale.ENGLISH).format(Long.valueOf(System.currentTimeMillis())), new String[0]);
        this.f1994 = false;
        this.f1995 = false;
    }

    /* renamed from: ˎ  reason: contains not printable characters */
    public final synchronized void m1182(String str) {
        this.f1999 = str;
    }

    /* renamed from: ˏ  reason: contains not printable characters */
    public final synchronized void m1183() {
        this.f1989 = null;
        this.f1993 = null;
        f1979 = null;
    }

    /* JADX WARNING: Exception block dominator not found, dom blocks: [] */
    /* renamed from: ॱ  reason: contains not printable characters */
    public final synchronized String m1184() {
        String str;
        str = null;
        this.f1989.put("data", this.f1993);
        str = this.f1989.toString();
        m1173();
        return str;
    }

    /* renamed from: ˎ  reason: contains not printable characters */
    public final synchronized void m1181() {
        this.f1994 = true;
        m1180("r_debugging_on", new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ", Locale.ENGLISH).format(Long.valueOf(System.currentTimeMillis())), new String[0]);
    }

    /* renamed from: ˏ  reason: contains not printable characters */
    private synchronized void m1176(String str, String str2, String str3, String str4) {
        if (str != null) {
            try {
                if (str.length() > 0) {
                    this.f1989.put("app_id", str);
                }
            } catch (Throwable unused) {
                return;
            }
        }
        if (str2 != null && str2.length() > 0) {
            this.f1989.put("app_version", str2);
        }
        if (str3 != null && str3.length() > 0) {
            this.f1989.put(AppsFlyerProperties.CHANNEL, str3);
        }
        if (str4 != null && str4.length() > 0) {
            this.f1989.put("preInstall", str4);
        }
    }

    /* renamed from: ˎ  reason: contains not printable characters */
    private synchronized void m1175(String str, String str2, String str3, String str4, String str5, String str6) {
        try {
            this.f1989.put("brand", str);
            this.f1989.put(DeviceRequestsHelper.DEVICE_INFO_MODEL, str2);
            this.f1989.put("platform", "Android");
            this.f1989.put("platform_version", str3);
            if (str4 != null && str4.length() > 0) {
                this.f1989.put(ServerParameters.ADVERTISING_ID_PARAM, str4);
            }
            if (str5 != null && str5.length() > 0) {
                this.f1989.put("imei", str5);
            }
            if (str6 != null && str6.length() > 0) {
                this.f1989.put("android_id", str6);
            }
        } catch (Throwable unused) {
        }
    }

    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0070 */
    /* renamed from: ˋ  reason: contains not printable characters */
    public final synchronized void m1179(String str, PackageManager packageManager) {
        AppsFlyerProperties instance = AppsFlyerProperties.getInstance();
        AppsFlyerLibCore instance2 = AppsFlyerLibCore.getInstance();
        String string = instance.getString("remote_debug_static_data");
        if (string != null) {
            this.f1989 = new JSONObject(string);
        } else {
            this.f1989 = new JSONObject();
            m1175(Build.BRAND, Build.MODEL, Build.VERSION.RELEASE, instance.getString(ServerParameters.ADVERTISING_ID_PARAM), instance2.f1896, instance2.f1895);
            m1174("5.0.0.260", instance.getString(AppsFlyerProperties.AF_KEY), instance.getString("KSAppsFlyerId"), instance.getString("uid"));
            try {
                int i = packageManager.getPackageInfo(str, 0).versionCode;
                m1176(str, String.valueOf(i), instance.getString(AppsFlyerProperties.CHANNEL), instance.getString("preInstallName"));
            } catch (Throwable unused) {
            }
            instance.set("remote_debug_static_data", this.f1989.toString());
        }
        try {
            this.f1989.put("launch_counter", this.f1999);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    /* renamed from: ˋ  reason: contains not printable characters */
    public final synchronized void m1178() {
        this.f1995 = false;
        m1173();
    }

    /* renamed from: ˋ  reason: contains not printable characters */
    public final synchronized void m1180(String str, String str2, String... strArr) {
        String str3;
        if ((this.f2001 && (this.f1995 || this.f1994)) && this.f1998 < 98304) {
            try {
                long currentTimeMillis = System.currentTimeMillis();
                String str4 = "";
                if (strArr.length > 0) {
                    StringBuilder sb = new StringBuilder();
                    for (int length = strArr.length - 1; length > 0; length--) {
                        sb.append(strArr[length]);
                        sb.append(", ");
                    }
                    sb.append(strArr[0]);
                    str4 = sb.toString();
                }
                String format = new SimpleDateFormat("MM-dd HH:mm:ss.SSS", Locale.ENGLISH).format(Long.valueOf(currentTimeMillis));
                if (str != null) {
                    str3 = String.format("%18s %5s _/%s [%s] %s %s", format, Long.valueOf(Thread.currentThread().getId()), AppsFlyerLibCore.LOG_TAG, str, str2, str4);
                } else {
                    str3 = String.format("%18s %5s %s/%s %s", format, Long.valueOf(Thread.currentThread().getId()), str2, AppsFlyerLibCore.LOG_TAG, str4);
                }
                this.f1993.put(str3);
                this.f1998 += str3.getBytes().length;
            } catch (Throwable unused) {
            }
        }
    }
}
