package p138.p176.p177.p242.p265.p266;

import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.text.TextUtils;
import java.io.ByteArrayInputStream;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicLong;
import javax.security.auth.x500.X500Principal;
import p000.p001.p002.p003.p004.C0567;
import p138.p176.p177.p242.p246.C4196;
import p138.p176.p177.p242.p246.C4198;
import p138.p176.p177.p242.p246.p251.C4303;
import p138.p176.p177.p242.p246.p253.C4312;
import p138.p176.p177.p242.p246.p255.C4322;
import p138.p176.p177.p242.p258.p263.C4538;
import p138.p176.p177.p242.p258.p263.C4606;
import p138.p176.p177.p242.p258.p263.InterfaceC4385;

/* JADX INFO: renamed from: ދ.ހ.֏.ހ.ބ.֏.ڏ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C4887 extends AbstractC4954 {

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public static final String[] f14701 = {"firebase_", "google_", "ga_"};

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public static final String[] f14702 = {"_err"};

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public SecureRandom f14703;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final AtomicLong f14704;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public int f14705;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public Integer f14706;

    public C4887(C4974 c4974) {
        super(c4974);
        this.f14706 = null;
        this.f14704 = new AtomicLong(0L);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static long m8216(long j, long j2) {
        return ((j2 * 60000) + j) / 86400000;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static long m8217(C4908 c4908) {
        long length = 0;
        if (c4908 == null) {
            return 0L;
        }
        Iterator<String> it = c4908.f14808.keySet().iterator();
        while (it.hasNext()) {
            Object objM8370 = c4908.m8370(it.next());
            if (objM8370 instanceof Parcelable[]) {
                length += (long) ((Parcelable[]) objM8370).length;
            }
        }
        return length;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static long m8218(byte[] bArr) {
        C0567.m1910(bArr);
        int i = 0;
        C0567.m1939(bArr.length > 0);
        long j = 0;
        for (int length = bArr.length - 1; length >= 0 && length >= bArr.length - 8; length--) {
            j += (((long) bArr[length]) & 255) << i;
            i += 8;
        }
        return j;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static Bundle m8219(List<C4999> list) {
        Bundle bundle = new Bundle();
        if (list == null) {
            return bundle;
        }
        for (C4999 c4999 : list) {
            String str = c4999.f15120;
            if (str != null) {
                bundle.putString(c4999.f15117, str);
            } else {
                Long l = c4999.f15119;
                if (l != null) {
                    bundle.putLong(c4999.f15117, l.longValue());
                } else {
                    Double d = c4999.f15122;
                    if (d != null) {
                        bundle.putDouble(c4999.f15117, d.doubleValue());
                    }
                }
            }
        }
        return bundle;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static String m8220(String str, int i, boolean z) {
        if (str == null) {
            return null;
        }
        if (str.codePointCount(0, str.length()) <= i) {
            return str;
        }
        if (z) {
            return String.valueOf(str.substring(0, str.offsetByCodePoints(0, i))).concat("...");
        }
        return null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m8221(Bundle bundle, int i, String str, Object obj) {
        if (m8224(bundle, i)) {
            bundle.putString("_ev", m8220(str, 40, true));
            if (obj != null) {
                C0567.m1910(bundle);
                if ((obj instanceof String) || (obj instanceof CharSequence)) {
                    bundle.putLong("_el", String.valueOf(obj).length());
                }
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m8222(Context context) {
        C0567.m1910(context);
        return Build.VERSION.SDK_INT >= 24 ? m8230(context, "com.google.android.gms.measurement.AppMeasurementJobService") : m8230(context, "com.google.android.gms.measurement.AppMeasurementService");
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m8223(Intent intent) {
        String stringExtra = intent.getStringExtra("android.intent.extra.REFERRER_NAME");
        return "android-app://com.google.android.googlequicksearchbox/https/www.google.com".equals(stringExtra) || "https://www.google.com".equals(stringExtra) || "android-app://com.google.appcrawler".equals(stringExtra);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m8224(Bundle bundle, int i) {
        if (bundle == null || bundle.getLong("_err") != 0) {
            return false;
        }
        bundle.putLong("_err", i);
        return true;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m8225(Object obj) {
        return (obj instanceof Parcelable[]) || (obj instanceof ArrayList) || (obj instanceof Bundle);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m8226(String str, String str2, String str3, String str4) {
        boolean zIsEmpty = TextUtils.isEmpty(str);
        boolean zIsEmpty2 = TextUtils.isEmpty(str2);
        if (!zIsEmpty && !zIsEmpty2) {
            return !str.equals(str2);
        }
        if (zIsEmpty && zIsEmpty2) {
            return (TextUtils.isEmpty(str3) || TextUtils.isEmpty(str4)) ? !TextUtils.isEmpty(str4) : !str3.equals(str4);
        }
        if (zIsEmpty || !zIsEmpty2) {
            return TextUtils.isEmpty(str3) || !str3.equals(str4);
        }
        if (TextUtils.isEmpty(str4)) {
            return false;
        }
        return TextUtils.isEmpty(str3) || !str3.equals(str4);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m8227(String str, String[] strArr) {
        C0567.m1910(strArr);
        for (String str2 : strArr) {
            if (m8232(str, str2)) {
                return true;
            }
        }
        return false;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static byte[] m8228(Parcelable parcelable) {
        if (parcelable == null) {
            return null;
        }
        Parcel parcelObtain = Parcel.obtain();
        try {
            parcelable.writeToParcel(parcelObtain, 0);
            return parcelObtain.marshall();
        } finally {
            parcelObtain.recycle();
        }
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static ArrayList<Bundle> m8229(List<C4891> list) {
        if (list == null) {
            return new ArrayList<>(0);
        }
        ArrayList<Bundle> arrayList = new ArrayList<>(list.size());
        for (C4891 c4891 : list) {
            Bundle bundle = new Bundle();
            bundle.putString("app_id", c4891.f14737);
            bundle.putString("origin", c4891.f14738);
            bundle.putLong("creation_timestamp", c4891.f14740);
            bundle.putString("name", c4891.f14739.f15117);
            C4303.m7087(bundle, c4891.f14739.m8527());
            bundle.putBoolean("active", c4891.f14741);
            String str = c4891.f14742;
            if (str != null) {
                bundle.putString("trigger_event_name", str);
            }
            C4913 c4913 = c4891.f14743;
            if (c4913 != null) {
                bundle.putString("timed_out_event_name", c4913.f14822);
                C4908 c4908 = c4891.f14743.f14823;
                if (c4908 != null) {
                    bundle.putBundle("timed_out_event_params", c4908.m8371());
                }
            }
            bundle.putLong("trigger_timeout", c4891.f14744);
            C4913 c49132 = c4891.f14745;
            if (c49132 != null) {
                bundle.putString("triggered_event_name", c49132.f14822);
                C4908 c49082 = c4891.f14745.f14823;
                if (c49082 != null) {
                    bundle.putBundle("triggered_event_params", c49082.m8371());
                }
            }
            bundle.putLong("triggered_timestamp", c4891.f14739.f15118);
            bundle.putLong("time_to_live", c4891.f14746);
            C4913 c49133 = c4891.f14747;
            if (c49133 != null) {
                bundle.putString("expired_event_name", c49133.f14822);
                C4908 c49083 = c4891.f14747.f14823;
                if (c49083 != null) {
                    bundle.putBundle("expired_event_params", c49083.m8371());
                }
            }
            arrayList.add(bundle);
        }
        return arrayList;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static boolean m8230(Context context, String str) {
        ServiceInfo serviceInfo;
        try {
            PackageManager packageManager = context.getPackageManager();
            if (packageManager != null && (serviceInfo = packageManager.getServiceInfo(new ComponentName(context, str), 0)) != null) {
                if (serviceInfo.enabled) {
                    return true;
                }
            }
        } catch (PackageManager.NameNotFoundException unused) {
        }
        return false;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static Bundle[] m8231(Object obj) {
        if (obj instanceof Bundle) {
            return new Bundle[]{(Bundle) obj};
        }
        if (obj instanceof Parcelable[]) {
            Parcelable[] parcelableArr = (Parcelable[]) obj;
            return (Bundle[]) Arrays.copyOf(parcelableArr, parcelableArr.length, Bundle[].class);
        }
        if (!(obj instanceof ArrayList)) {
            return null;
        }
        ArrayList arrayList = (ArrayList) obj;
        return (Bundle[]) arrayList.toArray(new Bundle[arrayList.size()]);
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static boolean m8232(String str, String str2) {
        if (str == null && str2 == null) {
            return true;
        }
        if (str == null) {
            return false;
        }
        return str.equals(str2);
    }

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public static boolean m8233(String str) {
        C0567.m1926(str);
        return str.charAt(0) != '_' || str.equals("_ep");
    }

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public static boolean m8234(String str) {
        return !TextUtils.isEmpty(str) && str.startsWith("_");
    }

    /* JADX INFO: renamed from: ޔ, reason: contains not printable characters */
    public static MessageDigest m8235() {
        MessageDigest messageDigest;
        for (int i = 0; i < 2; i++) {
            try {
                messageDigest = MessageDigest.getInstance("MD5");
            } catch (NoSuchAlgorithmException unused) {
            }
            if (messageDigest != null) {
                return messageDigest;
            }
        }
        return null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final int m8236(String str) {
        if (!m8264("event", str)) {
            return 2;
        }
        if (m8261("event", C4775.f14397, str)) {
            return !m8257("event", 40, str) ? 2 : 0;
        }
        return 13;
    }

    /* JADX WARN: Removed duplicated region for block: B:53:0x00ca A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:54:0x00cb  */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final int m8237(String str, String str2, String str3, Object obj, Bundle bundle, List<String> list, boolean z, boolean z2) {
        int i;
        int i2;
        mo8008();
        boolean z3 = true;
        if (C4606.m7638() && this.f14588.f15015.m8177(C4915.f14916)) {
            if (m8225(obj)) {
                if (!z2) {
                    return 21;
                }
                if (!m8227(str3, C4830.f14539)) {
                    return 20;
                }
                C4987 c4987M8508 = this.f14588.m8508();
                c4987M8508.mo8008();
                c4987M8508.m8066();
                if (!(!c4987M8508.m8522() || c4987M8508.m8167().m8274() >= 200900)) {
                    return 25;
                }
                if (!m8265("param", str3, 200, obj)) {
                    if (obj instanceof Parcelable[]) {
                        Parcelable[] parcelableArr = (Parcelable[]) obj;
                        if (parcelableArr.length > 200) {
                            bundle.putParcelableArray(str3, (Parcelable[]) Arrays.copyOf(parcelableArr, 200));
                        }
                    } else if (obj instanceof ArrayList) {
                        ArrayList arrayList = (ArrayList) obj;
                        if (arrayList.size() > 200) {
                            bundle.putParcelableArrayList(str3, new ArrayList<>(arrayList.subList(0, 200)));
                        }
                    }
                    i = 17;
                }
            }
            if (!m8259("param", str3, ((this.f14588.f15015.m8183(str, C4915.f14871) || !m8234(str2)) && !m8234(str3)) ? 100 : 256, obj)) {
                return i;
            }
            if (!z2) {
                return 4;
            }
            boolean z4 = C4606.m7638() && this.f14588.f15015.m8177(C4915.f14915);
            if (!(obj instanceof Bundle)) {
                if (!(obj instanceof Parcelable[])) {
                    if (!(obj instanceof ArrayList)) {
                        z3 = false;
                        break;
                    }
                    ArrayList arrayList2 = (ArrayList) obj;
                    int size = arrayList2.size();
                    int i3 = 0;
                    while (i3 < size) {
                        Object obj2 = arrayList2.get(i3);
                        int i4 = i3 + 1;
                        if (!(obj2 instanceof Bundle)) {
                            mo8165().f14449.m8036("All ArrayList elements must be of type Bundle. Value type, name", obj2.getClass(), str3);
                            z3 = false;
                            break;
                        }
                        if (z4) {
                            m8247(str, str2, str3, (Bundle) obj2, list, z);
                        }
                        i3 = i4;
                    }
                } else {
                    Parcelable[] parcelableArr2 = (Parcelable[]) obj;
                    int length = parcelableArr2.length;
                    int i5 = 0;
                    while (i5 < length) {
                        Parcelable parcelable = parcelableArr2[i5];
                        if (!(parcelable instanceof Bundle)) {
                            mo8165().f14449.m8036("All Parcelable[] elements must be of type Bundle. Value type, name", parcelable.getClass(), str3);
                            z3 = false;
                            break;
                        }
                        if (z4) {
                            i2 = i5;
                            m8247(str, str2, str3, (Bundle) parcelable, list, z);
                        } else {
                            i2 = i5;
                        }
                        i5 = i2 + 1;
                    }
                }
            } else if (z4) {
                m8247(str, str2, str3, (Bundle) obj, list, z);
            }
            if (z3) {
                return i;
            }
            return 4;
        }
        if (z2 && !m8265("param", str3, 1000, obj)) {
            return 17;
        }
        i = 0;
        if (!m8259("param", str3, ((this.f14588.f15015.m8183(str, C4915.f14871) || !m8234(str2)) && !m8234(str3)) ? 100 : 256, obj)) {
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Bundle m8238(Uri uri) {
        String queryParameter;
        String queryParameter2;
        String queryParameter3;
        String queryParameter4;
        if (uri == null) {
            return null;
        }
        try {
            if (uri.isHierarchical()) {
                queryParameter = uri.getQueryParameter("utm_campaign");
                queryParameter2 = uri.getQueryParameter("utm_source");
                queryParameter3 = uri.getQueryParameter("utm_medium");
                queryParameter4 = uri.getQueryParameter("gclid");
            } else {
                queryParameter = null;
                queryParameter2 = null;
                queryParameter3 = null;
                queryParameter4 = null;
            }
            if (TextUtils.isEmpty(queryParameter) && TextUtils.isEmpty(queryParameter2) && TextUtils.isEmpty(queryParameter3) && TextUtils.isEmpty(queryParameter4)) {
                return null;
            }
            Bundle bundle = new Bundle();
            if (!TextUtils.isEmpty(queryParameter)) {
                bundle.putString("campaign", queryParameter);
            }
            if (!TextUtils.isEmpty(queryParameter2)) {
                bundle.putString("source", queryParameter2);
            }
            if (!TextUtils.isEmpty(queryParameter3)) {
                bundle.putString("medium", queryParameter3);
            }
            if (!TextUtils.isEmpty(queryParameter4)) {
                bundle.putString("gclid", queryParameter4);
            }
            String queryParameter5 = uri.getQueryParameter("utm_term");
            if (!TextUtils.isEmpty(queryParameter5)) {
                bundle.putString("term", queryParameter5);
            }
            String queryParameter6 = uri.getQueryParameter("utm_content");
            if (!TextUtils.isEmpty(queryParameter6)) {
                bundle.putString("content", queryParameter6);
            }
            String queryParameter7 = uri.getQueryParameter("aclid");
            if (!TextUtils.isEmpty(queryParameter7)) {
                bundle.putString("aclid", queryParameter7);
            }
            String queryParameter8 = uri.getQueryParameter("cp1");
            if (!TextUtils.isEmpty(queryParameter8)) {
                bundle.putString("cp1", queryParameter8);
            }
            String queryParameter9 = uri.getQueryParameter("anid");
            if (!TextUtils.isEmpty(queryParameter9)) {
                bundle.putString("anid", queryParameter9);
            }
            return bundle;
        } catch (UnsupportedOperationException e) {
            mo8165().f14447.m8035("Install referrer url isn't a hierarchical URI", e);
            return null;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Bundle m8239(Bundle bundle) {
        Bundle bundle2 = new Bundle();
        if (bundle != null) {
            for (String str : bundle.keySet()) {
                Object objM8242 = m8242(str, bundle.get(str));
                if (objM8242 == null) {
                    mo8165().f14449.m8035("Param value can't be null", m8161().m8113(str));
                } else {
                    m8246(bundle2, str, objM8242);
                }
            }
        }
        return bundle2;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Bundle m8240(String str, String str2, Bundle bundle, List<String> list, boolean z, boolean z2) {
        int iM8269;
        int i;
        Bundle bundle2;
        String str3;
        int i2;
        boolean z3 = C4606.m7638() && this.f14588.f15015.m8177(C4915.f14916);
        boolean zM8227 = z3 ? m8227(str2, C4775.f14399) : z2;
        if (bundle == null) {
            return null;
        }
        Bundle bundle3 = new Bundle(bundle);
        int iM8185 = this.f14588.f15015.m8185();
        int i3 = 0;
        for (String str4 : this.f14588.f15015.m8183(str, C4915.f14883) ? new TreeSet<>(bundle.keySet()) : bundle.keySet()) {
            if (list == null || !list.contains(str4)) {
                iM8269 = z ? m8269(str4) : 0;
                if (iM8269 == 0) {
                    iM8269 = m8270(str4);
                }
            } else {
                iM8269 = 0;
            }
            if (iM8269 != 0) {
                m8221(bundle3, iM8269, str4, iM8269 == 3 ? str4 : null);
                bundle3.remove(str4);
                i = iM8185;
                bundle2 = bundle3;
            } else {
                i = iM8185;
                Bundle bundle4 = bundle3;
                int iM8237 = m8237(str, str2, str4, bundle.get(str4), bundle3, list, z, zM8227);
                if (z3 && iM8237 == 17) {
                    str3 = str4;
                    bundle2 = bundle4;
                    m8221(bundle2, iM8237, str3, (Object) false);
                } else {
                    str3 = str4;
                    bundle2 = bundle4;
                    if (iM8237 != 0 && !"_ev".equals(str3)) {
                        m8221(bundle2, iM8237, iM8237 == 21 ? str2 : str3, bundle.get(str3));
                        bundle2.remove(str3);
                    }
                }
                if (m8233(str3)) {
                    int i4 = i3 + 1;
                    i2 = i;
                    if (i4 > i2) {
                        StringBuilder sb = new StringBuilder(48);
                        sb.append("Event can't contain more than ");
                        sb.append(i2);
                        sb.append(" params");
                        mo8165().f14446.m8036(sb.toString(), m8161().m8110(str2), m8161().m8109(bundle));
                        m8224(bundle2, 5);
                        bundle2.remove(str3);
                        i3 = i4;
                        iM8185 = i2;
                        bundle3 = bundle2;
                    } else {
                        i3 = i4;
                    }
                } else {
                    i2 = i;
                }
                iM8185 = i2;
                bundle3 = bundle2;
            }
            bundle3 = bundle2;
            iM8185 = i;
        }
        return bundle3;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Object m8241(int i, Object obj, boolean z, boolean z2) {
        if (obj == null) {
            return null;
        }
        if ((obj instanceof Long) || (obj instanceof Double)) {
            return obj;
        }
        if (obj instanceof Integer) {
            return Long.valueOf(((Integer) obj).intValue());
        }
        if (obj instanceof Byte) {
            return Long.valueOf(((Byte) obj).byteValue());
        }
        if (obj instanceof Short) {
            return Long.valueOf(((Short) obj).shortValue());
        }
        if (obj instanceof Boolean) {
            return Long.valueOf(((Boolean) obj).booleanValue() ? 1L : 0L);
        }
        if (obj instanceof Float) {
            return Double.valueOf(((Float) obj).doubleValue());
        }
        if ((obj instanceof String) || (obj instanceof Character) || (obj instanceof CharSequence)) {
            return m8220(String.valueOf(obj), i, z);
        }
        if (!C4606.m7638() || !this.f14588.f15015.m8177(C4915.f14915) || !this.f14588.f15015.m8177(C4915.f14914) || !z2 || (!(obj instanceof Bundle[]) && !(obj instanceof Parcelable[]))) {
            return null;
        }
        ArrayList arrayList = new ArrayList();
        for (Parcelable parcelable : (Parcelable[]) obj) {
            if (parcelable instanceof Bundle) {
                Bundle bundleM8239 = m8239((Bundle) parcelable);
                if (!bundleM8239.isEmpty()) {
                    arrayList.add(bundleM8239);
                }
            }
        }
        return arrayList.toArray(new Bundle[arrayList.size()]);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Object m8242(String str, Object obj) {
        if ("_ev".equals(str)) {
            return m8241(256, obj, true, true);
        }
        return m8241(m8234(str) ? 256 : 100, obj, false, true);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C4913 m8243(String str, String str2, Bundle bundle, String str3, long j) {
        if (TextUtils.isEmpty(str2)) {
            return null;
        }
        if (m8236(str2) != 0) {
            mo8165().f14444.m8035("Invalid conditional property event name", m8161().m8114(str2));
            throw new IllegalArgumentException();
        }
        Bundle bundle2 = bundle != null ? new Bundle(bundle) : new Bundle();
        bundle2.putString("_o", str3);
        return new C4913(str2, new C4908(m8239(m8240(str, str2, bundle2, Collections.singletonList("_o"), false, false))), str3, j);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8244(int i, String str, String str2, int i2) {
        Bundle bundle = new Bundle();
        m8224(bundle, i);
        if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
            bundle.putString(str, str2);
        }
        if (i == 6 || i == 7 || i == 2) {
            bundle.putLong("_el", i2);
        }
        C4974 c4974 = this.f14588;
        C4785 c4785 = c4974.f15014;
        c4974.m8503().m7972("auto", "_err", bundle);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8245(Bundle bundle, long j) {
        long j2 = bundle.getLong("_et");
        if (j2 != 0) {
            mo8165().f14447.m8035("Params already contained engagement", Long.valueOf(j2));
        }
        bundle.putLong("_et", j + j2);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8246(Bundle bundle, String str, Object obj) {
        if (bundle == null) {
            return;
        }
        if (obj instanceof Long) {
            bundle.putLong(str, ((Long) obj).longValue());
            return;
        }
        if (obj instanceof String) {
            bundle.putString(str, String.valueOf(obj));
            return;
        }
        if (obj instanceof Double) {
            bundle.putDouble(str, ((Double) obj).doubleValue());
            return;
        }
        if (C4606.m7638() && this.f14588.f15015.m8177(C4915.f14915) && this.f14588.f15015.m8177(C4915.f14914) && (obj instanceof Bundle[])) {
            bundle.putParcelableArray(str, (Bundle[]) obj);
        } else if (str != null) {
            mo8165().f14449.m8036("Not putting event parameter. Invalid value type. name, type", m8161().m8113(str), obj != null ? obj.getClass().getSimpleName() : null);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8247(String str, String str2, String str3, Bundle bundle, List<String> list, boolean z) {
        int iM8269;
        String str4;
        int iM8237;
        String string;
        if (bundle == null) {
            return;
        }
        boolean zM8177 = this.f14588.f15015.m8177(C4915.f14916);
        int iM8185 = zM8177 ? 0 : this.f14588.f15015.m8185();
        int i = 0;
        for (String str5 : new TreeSet(bundle.keySet())) {
            if (list == null || !list.contains(str5)) {
                iM8269 = z ? m8269(str5) : 0;
                if (iM8269 == 0) {
                    iM8269 = m8270(str5);
                }
            } else {
                iM8269 = 0;
            }
            if (iM8269 != 0) {
                m8221(bundle, iM8269, str5, iM8269 == 3 ? str5 : null);
                bundle.remove(str5);
            } else {
                if (m8225(bundle.get(str5))) {
                    mo8165().f14449.m8037("Nested Bundle parameters are not allowed; discarded. event name, param name, child param name", str2, str3, str5);
                    iM8237 = 22;
                    str4 = str5;
                } else {
                    str4 = str5;
                    iM8237 = m8237(str, str2, str5, bundle.get(str5), bundle, list, z, false);
                }
                if (iM8237 != 0 && !"_ev".equals(str4)) {
                    m8221(bundle, iM8237, str4, bundle.get(str4));
                    bundle.remove(str4);
                } else if (m8233(str4) && (!zM8177 || !m8227(str4, C4830.f14540))) {
                    int i2 = i + 1;
                    if (i2 > iM8185) {
                        if (zM8177) {
                            string = "Item cannot contain custom parameters";
                        } else {
                            StringBuilder sb = new StringBuilder(63);
                            sb.append("Child bundles can't contain more than ");
                            sb.append(iM8185);
                            sb.append(" custom params");
                            string = sb.toString();
                        }
                        mo8165().f14446.m8036(string, m8161().m8110(str2), m8161().m8109(bundle));
                        m8224(bundle, zM8177 ? 23 : 5);
                        bundle.remove(str4);
                    }
                    i = i2;
                }
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8248(InterfaceC4385 interfaceC4385, int i) {
        Bundle bundle = new Bundle();
        bundle.putInt("r", i);
        try {
            interfaceC4385.mo7283(bundle);
        } catch (RemoteException e) {
            this.f14588.mo8165().f14447.m8035("Error returning int value to wrapper", e);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8249(InterfaceC4385 interfaceC4385, long j) {
        Bundle bundle = new Bundle();
        bundle.putLong("r", j);
        try {
            interfaceC4385.mo7283(bundle);
        } catch (RemoteException e) {
            this.f14588.mo8165().f14447.m8035("Error returning long value to wrapper", e);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8250(InterfaceC4385 interfaceC4385, Bundle bundle) {
        try {
            interfaceC4385.mo7283(bundle);
        } catch (RemoteException e) {
            this.f14588.mo8165().f14447.m8035("Error returning bundle value to wrapper", e);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8251(InterfaceC4385 interfaceC4385, String str) {
        Bundle bundle = new Bundle();
        bundle.putString("r", str);
        try {
            interfaceC4385.mo7283(bundle);
        } catch (RemoteException e) {
            this.f14588.mo8165().f14447.m8035("Error returning string value to wrapper", e);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8252(InterfaceC4385 interfaceC4385, ArrayList<Bundle> arrayList) {
        Bundle bundle = new Bundle();
        bundle.putParcelableArrayList("r", arrayList);
        try {
            interfaceC4385.mo7283(bundle);
        } catch (RemoteException e) {
            this.f14588.mo8165().f14447.m8035("Error returning bundle list to wrapper", e);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8253(InterfaceC4385 interfaceC4385, boolean z) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("r", z);
        try {
            interfaceC4385.mo7283(bundle);
        } catch (RemoteException e) {
            this.f14588.mo8165().f14447.m8035("Error returning boolean value to wrapper", e);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8254(InterfaceC4385 interfaceC4385, byte[] bArr) {
        Bundle bundle = new Bundle();
        bundle.putByteArray("r", bArr);
        try {
            interfaceC4385.mo7283(bundle);
        } catch (RemoteException e) {
            this.f14588.mo8165().f14447.m8035("Error returning byte array to wrapper", e);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m8255(Context context, String str) {
        X500Principal x500Principal = new X500Principal("CN=Android Debug,O=Android,C=US");
        try {
            PackageInfo packageInfo = C4322.m7223(context).f13621.getPackageManager().getPackageInfo(str, 64);
            if (packageInfo == null || packageInfo.signatures == null || packageInfo.signatures.length <= 0) {
                return true;
            }
            return ((X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(packageInfo.signatures[0].toByteArray()))).getSubjectX500Principal().equals(x500Principal);
        } catch (PackageManager.NameNotFoundException e) {
            mo8165().f14444.m8035("Package name not found", e);
            return true;
        } catch (CertificateException e2) {
            mo8165().f14444.m8035("Error obtaining certificate", e2);
            return true;
        }
    }

    @SuppressLint({"ApplySharedPref"})
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m8256(String str, double d) {
        try {
            SharedPreferences.Editor editorEdit = this.f14588.f15009.getSharedPreferences("google.analytics.deferred.deeplink.prefs", 0).edit();
            editorEdit.putString("deeplink", str);
            editorEdit.putLong("timestamp", Double.doubleToRawLongBits(d));
            return editorEdit.commit();
        } catch (Exception e) {
            mo8165().f14444.m8035("Failed to persist Deferred Deep Link. exception", e);
            return false;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m8257(String str, int i, String str2) {
        if (str2 == null) {
            mo8165().f14446.m8035("Name is required and can't be null. Type", str);
            return false;
        }
        if (str2.codePointCount(0, str2.length()) <= i) {
            return true;
        }
        mo8165().f14446.m8037("Name is too long. Type, maximum supported length, name", str, Integer.valueOf(i), str2);
        return false;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m8258(String str, String str2) {
        if (str2 == null) {
            mo8165().f14446.m8035("Name is required and can't be null. Type", str);
            return false;
        }
        if (str2.length() == 0) {
            mo8165().f14446.m8035("Name is required and can't be empty. Type", str);
            return false;
        }
        int iCodePointAt = str2.codePointAt(0);
        if (!Character.isLetter(iCodePointAt)) {
            mo8165().f14446.m8036("Name must start with a letter. Type, name", str, str2);
            return false;
        }
        int length = str2.length();
        int iCharCount = Character.charCount(iCodePointAt);
        while (iCharCount < length) {
            int iCodePointAt2 = str2.codePointAt(iCharCount);
            if (iCodePointAt2 != 95 && !Character.isLetterOrDigit(iCodePointAt2)) {
                mo8165().f14446.m8036("Name must consist of letters, digits or _ (underscores). Type, name", str, str2);
                return false;
            }
            iCharCount += Character.charCount(iCodePointAt2);
        }
        return true;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m8259(String str, String str2, int i, Object obj) {
        if (obj != null && !(obj instanceof Long) && !(obj instanceof Float) && !(obj instanceof Integer) && !(obj instanceof Byte) && !(obj instanceof Short) && !(obj instanceof Boolean) && !(obj instanceof Double)) {
            if (!(obj instanceof String) && !(obj instanceof Character) && !(obj instanceof CharSequence)) {
                return false;
            }
            String strValueOf = String.valueOf(obj);
            if (strValueOf.codePointCount(0, strValueOf.length()) > i) {
                mo8165().f14449.m8037("Value is too long; discarded. Value kind, name, value length", str, str2, Integer.valueOf(strValueOf.length()));
                return false;
            }
        }
        return true;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m8260(String str, String str2, String str3) {
        if (!TextUtils.isEmpty(str)) {
            C0567.m1910(str);
            if (str.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$")) {
                return true;
            }
            if (this.f14588.m8506()) {
                mo8165().f14446.m8035("Invalid google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI. provided id", C4794.m8038(str));
            }
            return false;
        }
        if (C4538.m7580() && this.f14588.f15015.m8177(C4915.f14896) && !TextUtils.isEmpty(str3)) {
            return true;
        }
        if (TextUtils.isEmpty(str2)) {
            if (this.f14588.m8506()) {
                mo8165().f14446.m8034("Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI");
            }
            return false;
        }
        C0567.m1910(str2);
        if (str2.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$")) {
            return true;
        }
        mo8165().f14446.m8035("Invalid admob_app_id. Analytics disabled.", C4794.m8038(str2));
        return false;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m8261(String str, String[] strArr, String str2) {
        boolean z;
        if (str2 == null) {
            mo8165().f14446.m8035("Name is required and can't be null. Type", str);
            return false;
        }
        C0567.m1910(str2);
        String[] strArr2 = f14701;
        int length = strArr2.length;
        int i = 0;
        while (true) {
            if (i >= length) {
                z = false;
                break;
            }
            if (str2.startsWith(strArr2[i])) {
                z = true;
                break;
            }
            i++;
        }
        if (z) {
            mo8165().f14446.m8036("Name starts with reserved prefix. Type, name", str, str2);
            return false;
        }
        if (strArr == null || !m8227(str2, strArr)) {
            return true;
        }
        mo8165().f14446.m8036("Name is reserved. Type, name", str, str2);
        return false;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final int m8262(String str) {
        if (!m8264("user property", str)) {
            return 6;
        }
        if (m8261("user property", C4997.f15112, str)) {
            return !m8257("user property", 24, str) ? 6 : 0;
        }
        return 15;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final int m8263(String str, Object obj) {
        return "_ldl".equals(str) ? m8259("user property referrer", str, m8271(str), obj) : m8259("user property", str, m8271(str), obj) ? 0 : 7;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final boolean m8264(String str, String str2) {
        if (str2 == null) {
            mo8165().f14446.m8035("Name is required and can't be null. Type", str);
            return false;
        }
        if (str2.length() == 0) {
            mo8165().f14446.m8035("Name is required and can't be empty. Type", str);
            return false;
        }
        int iCodePointAt = str2.codePointAt(0);
        if (!Character.isLetter(iCodePointAt) && iCodePointAt != 95) {
            mo8165().f14446.m8036("Name must start with a letter or _ (underscore). Type, name", str, str2);
            return false;
        }
        int length = str2.length();
        int iCharCount = Character.charCount(iCodePointAt);
        while (iCharCount < length) {
            int iCodePointAt2 = str2.codePointAt(iCharCount);
            if (iCodePointAt2 != 95 && !Character.isLetterOrDigit(iCodePointAt2)) {
                mo8165().f14446.m8036("Name must consist of letters, digits or _ (underscores). Type, name", str, str2);
                return false;
            }
            iCharCount += Character.charCount(iCodePointAt2);
        }
        return true;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final boolean m8265(String str, String str2, int i, Object obj) {
        int size;
        if (!(obj instanceof Parcelable[])) {
            if (obj instanceof ArrayList) {
                size = ((ArrayList) obj).size();
            }
            return true;
        }
        size = ((Parcelable[]) obj).length;
        if (size > i) {
            mo8165().f14449.m8037("Parameter array is too long; discarded. Value kind, name, array length", str, str2, Integer.valueOf(size));
            return false;
        }
        return true;
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final Object m8266(String str, Object obj) {
        return "_ldl".equals(str) ? m8241(m8271(str), obj, true, false) : m8241(m8271(str), obj, false, false);
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final boolean m8267(String str) {
        mo8008();
        if (C4322.m7223(this.f14588.f15009).f13621.checkCallingOrSelfPermission(str) == 0) {
            return true;
        }
        mo8165().f14451.m8035("Permission not granted", str);
        return false;
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final boolean m8268(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        String strM8176 = this.f14588.f15015.m8176("debug.firebase.analytics.app", "");
        C4785 c4785 = this.f14588.f15014;
        return strM8176.equals(str);
    }

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final int m8269(String str) {
        if (!m8258("event param", str)) {
            return 3;
        }
        if (m8261("event param", (String[]) null, str)) {
            return !m8257("event param", 40, str) ? 3 : 0;
        }
        return 14;
    }

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final int m8270(String str) {
        if (!m8264("event param", str)) {
            return 3;
        }
        if (m8261("event param", (String[]) null, str)) {
            return !m8257("event param", 40, str) ? 3 : 0;
        }
        return 14;
    }

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final int m8271(String str) {
        if ("_ldl".equals(str)) {
            return 2048;
        }
        if ("_id".equals(str)) {
            return 256;
        }
        return (this.f14588.f15015.m8177(C4915.f14893) && "_lgclid".equals(str)) ? 100 : 36;
    }

    @Override // p138.p176.p177.p242.p265.p266.AbstractC4954
    /* JADX INFO: renamed from: ފ */
    public final void mo8198() {
        mo8008();
        SecureRandom secureRandom = new SecureRandom();
        long jNextLong = secureRandom.nextLong();
        if (jNextLong == 0) {
            jNextLong = secureRandom.nextLong();
            if (jNextLong == 0) {
                mo8165().f14447.m8034("Utils falling back to Random for random id");
            }
        }
        this.f14704.set(jNextLong);
    }

    @Override // p138.p176.p177.p242.p265.p266.AbstractC4954
    /* JADX INFO: renamed from: ގ */
    public final boolean mo8009() {
        return true;
    }

    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public final long m8272() {
        long andIncrement;
        long j;
        if (this.f14704.get() != 0) {
            synchronized (this.f14704) {
                this.f14704.compareAndSet(-1L, 1L);
                andIncrement = this.f14704.getAndIncrement();
            }
            return andIncrement;
        }
        synchronized (this.f14704) {
            long jNanoTime = System.nanoTime();
            if (((C4312) this.f14588.f15022) == null) {
                throw null;
            }
            long jNextLong = new Random(jNanoTime ^ System.currentTimeMillis()).nextLong();
            int i = this.f14705 + 1;
            this.f14705 = i;
            j = jNextLong + ((long) i);
        }
        return j;
    }

    /* JADX INFO: renamed from: ޑ, reason: contains not printable characters */
    public final SecureRandom m8273() {
        mo8008();
        if (this.f14703 == null) {
            this.f14703 = new SecureRandom();
        }
        return this.f14703;
    }

    /* JADX INFO: renamed from: ޒ, reason: contains not printable characters */
    public final int m8274() {
        if (this.f14706 == null) {
            C4196 c4196 = C4196.f13406;
            Context context = this.f14588.f15009;
            if (c4196 == null) {
                throw null;
            }
            this.f14706 = Integer.valueOf(C4198.m6850(context) / 1000);
        }
        return this.f14706.intValue();
    }

    /* JADX INFO: renamed from: ޓ, reason: contains not printable characters */
    public final String m8275() {
        byte[] bArr = new byte[16];
        m8273().nextBytes(bArr);
        return String.format(Locale.US, "%032x", new BigInteger(1, bArr));
    }
}
