P2X v5.6.5版本的 MD5 值为:c9754e3fb9716daeb935e470461cc2a2

以下内容为反编译后的 t5.java 源代码,内容仅作参考


package y4;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.content.pm.Signature;
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 com.lzy.okgo.cookie.SerializableCookie;
import com.lzy.okgo.model.Priority;
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;

public final class t5 extends t3 {
    public static final String[] x = {"firebase_", "google_", "ga_"};

    public static final String[] f7829y = {"_err"};

    public SecureRandom f7830t;

    public final AtomicLong f7831u;

    public int f7832v;

    public Integer f7833w;

    public t5(n3 n3Var) {
        super(n3Var);
        this.f7833w = null;
        this.f7831u = new AtomicLong(0L);
    }

    public static void B(m4 m4Var, Bundle bundle, boolean z) {
        if (bundle != null && m4Var != null) {
            if (!bundle.containsKey("_sc") || z) {
                String str = m4Var.f7699a;
                if (str != null) {
                    bundle.putString("_sn", str);
                } else {
                    bundle.remove("_sn");
                }
                String str2 = m4Var.f7700b;
                if (str2 != null) {
                    bundle.putString("_sc", str2);
                } else {
                    bundle.remove("_sc");
                }
                bundle.putLong("_si", m4Var.f7701c);
                return;
            }
            z = false;
        }
        if (bundle != null && m4Var == null && z) {
            bundle.remove("_sn");
            bundle.remove("_sc");
            bundle.remove("_si");
        }
    }

    public static void E(s5 s5Var, String str, int i9, String str2, String str3, int i10) {
        Bundle bundle = new Bundle();
        g0(i9, bundle);
        if (!TextUtils.isEmpty(str2) && !TextUtils.isEmpty(str3)) {
            bundle.putString(str2, str3);
        }
        if (i9 == 6 || i9 == 7 || i9 == 2) {
            bundle.putLong("_el", i10);
        }
        s5Var.b(str, bundle);
    }

    public static boolean Y(Object obj) {
        return (obj instanceof Parcelable[]) || (obj instanceof ArrayList) || (obj instanceof Bundle);
    }

    public static boolean a0(String str) {
        return !TextUtils.isEmpty(str) && str.startsWith("_");
    }

    public static boolean b0(String str) {
        kotlin.jvm.internal.f.n(str);
        return str.charAt(0) != '_' || str.equals("_ep");
    }

    public static boolean c0(Context context) {
        ActivityInfo receiverInfo;
        kotlin.jvm.internal.f.s(context);
        try {
            PackageManager packageManager = context.getPackageManager();
            if (packageManager != null && (receiverInfo = packageManager.getReceiverInfo(new ComponentName(context, "com.google.android.gms.measurement.AppMeasurementReceiver"), 0)) != null) {
                if (receiverInfo.enabled) {
                    return true;
                }
            }
        } catch (PackageManager.NameNotFoundException unused) {
        }
        return false;
    }

    public static boolean d0(Context context) {
        kotlin.jvm.internal.f.s(context);
        return k0(context, Build.VERSION.SDK_INT >= 24 ? "com.google.android.gms.measurement.AppMeasurementJobService" : "com.google.android.gms.measurement.AppMeasurementService");
    }

    public static boolean e0(String str, String str2, String str3, String str4) {
        boolean isEmpty = TextUtils.isEmpty(str);
        boolean isEmpty2 = TextUtils.isEmpty(str2);
        if (!isEmpty && !isEmpty2) {
            kotlin.jvm.internal.f.s(str);
            return !str.equals(str2);
        }
        if (isEmpty && isEmpty2) {
            return (TextUtils.isEmpty(str3) || TextUtils.isEmpty(str4)) ? !TextUtils.isEmpty(str4) : !str3.equals(str4);
        }
        if (isEmpty) {
            return TextUtils.isEmpty(str3) || !str3.equals(str4);
        }
        if (TextUtils.isEmpty(str4)) {
            return false;
        }
        return TextUtils.isEmpty(str3) || !str3.equals(str4);
    }

    public static byte[] f0(Parcelable parcelable) {
        if (parcelable == null) {
            return null;
        }
        Parcel obtain = Parcel.obtain();
        try {
            parcelable.writeToParcel(obtain, 0);
            return obtain.marshall();
        } finally {
            obtain.recycle();
        }
    }

    public static final boolean g0(int i9, Bundle bundle) {
        if (bundle.getLong("_err") != 0) {
            return false;
        }
        bundle.putLong("_err", i9);
        return true;
    }

    public static boolean j0(String str, String[] strArr) {
        boolean z;
        kotlin.jvm.internal.f.s(strArr);
        for (Object obj : strArr) {
            if (str != obj && (str == null || !str.equals(obj))) {
                z = false;
            } else {
                z = true;
            }
            if (z) {
                return true;
            }
        }
        return false;
    }

    public static boolean k0(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;
    }

    public static long r0(byte[] bArr) {
        boolean z;
        kotlin.jvm.internal.f.s(bArr);
        int length = bArr.length;
        int i9 = 0;
        if (length > 0) {
            z = true;
        } else {
            z = false;
        }
        if (z) {
            long j9 = 0;
            for (int i10 = length - 1; i10 >= 0 && i10 >= bArr.length - 8; i10--) {
                j9 += (bArr[i10] & 255) << i9;
                i9 += 8;
            }
            return j9;
        }
        throw new IllegalStateException();
    }

    public static String v(int i9, String str, boolean z) {
        if (str == null) {
            return null;
        }
        if (str.codePointCount(0, str.length()) <= i9) {
            return str;
        }
        if (z) {
            return String.valueOf(str.substring(0, str.offsetByCodePoints(0, i9))).concat("...");
        }
        return null;
    }

    public static MessageDigest w() {
        MessageDigest messageDigest;
        for (int i9 = 0; i9 < 2; i9++) {
            try {
                messageDigest = MessageDigest.getInstance("MD5");
            } catch (NoSuchAlgorithmException unused) {
            }
            if (messageDigest != null) {
                return messageDigest;
            }
        }
        return null;
    }

    public static ArrayList y(List list) {
        if (list == null) {
            return new ArrayList(0);
        }
        ArrayList arrayList = new ArrayList(list.size());
        Iterator it = list.iterator();
        while (it.hasNext()) {
            c cVar = (c) it.next();
            Bundle bundle = new Bundle();
            bundle.putString("app_id", cVar.f7523r);
            bundle.putString("origin", cVar.s);
            bundle.putLong("creation_timestamp", cVar.f7525u);
            bundle.putString(SerializableCookie.NAME, cVar.f7524t.s);
            Object f9 = cVar.f7524t.f();
            kotlin.jvm.internal.f.s(f9);
            i6.a1.l(bundle, f9);
            bundle.putBoolean("active", cVar.f7526v);
            String str = cVar.f7527w;
            if (str != null) {
                bundle.putString("trigger_event_name", str);
            }
            p pVar = cVar.x;
            if (pVar != null) {
                bundle.putString("timed_out_event_name", pVar.f7747r);
                o oVar = pVar.s;
                if (oVar != null) {
                    bundle.putBundle("timed_out_event_params", oVar.f());
                }
            }
            bundle.putLong("trigger_timeout", cVar.f7528y);
            p pVar2 = cVar.z;
            if (pVar2 != null) {
                bundle.putString("triggered_event_name", pVar2.f7747r);
                o oVar2 = pVar2.s;
                if (oVar2 != null) {
                    bundle.putBundle("triggered_event_params", oVar2.f());
                }
            }
            bundle.putLong("triggered_timestamp", cVar.f7524t.f7776t);
            bundle.putLong("time_to_live", cVar.A);
            p pVar3 = cVar.B;
            if (pVar3 != null) {
                bundle.putString("expired_event_name", pVar3.f7747r);
                o oVar3 = pVar3.s;
                if (oVar3 != null) {
                    bundle.putBundle("expired_event_params", oVar3.f());
                }
            }
            arrayList.add(bundle);
        }
        return arrayList;
    }

    public final void A(Bundle bundle, int i9, String str, Object obj) {
        if (g0(i9, bundle)) {
            ((n3) this.f4437r).getClass();
            bundle.putString("_ev", v(40, str, true));
            if (obj != null) {
                if ((obj instanceof String) || (obj instanceof CharSequence)) {
                    bundle.putLong("_el", obj.toString().length());
                }
            }
        }
    }

    public final void C(Bundle bundle, Bundle bundle2) {
        if (bundle2 == null) {
            return;
        }
        for (String str : bundle2.keySet()) {
            if (!bundle.containsKey(str)) {
                t5 t5Var = ((n3) this.f4437r).C;
                n3.i(t5Var);
                t5Var.F(bundle, str, bundle2.get(str));
            }
        }
    }

    public final void D(v2 v2Var, int i9) {
        Object obj = v2Var.f7855e;
        Iterator it = new TreeSet(((Bundle) obj).keySet()).iterator();
        int i10 = 0;
        while (it.hasNext()) {
            String str = (String) it.next();
            if (b0(str) && (i10 = i10 + 1) > i9) {
                StringBuilder n9 = android.support.v4.media.b.n("Event can't contain more than ", i9, " params");
                n3 n3Var = (n3) this.f4437r;
                u2 u2Var = n3Var.z;
                n3.k(u2Var);
                Bundle bundle = (Bundle) obj;
                u2Var.f7841y.c(n3Var.D.d((String) v2Var.f7854c), n9.toString(), n3Var.D.b(bundle));
                g0(5, bundle);
                bundle.remove(str);
            }
        }
    }

    public final void F(Bundle bundle, String str, Object obj) {
        String str2;
        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 (obj instanceof Bundle[]) {
            bundle.putParcelableArray(str, (Bundle[]) obj);
            return;
        }
        if (str != null) {
            if (obj != null) {
                str2 = obj.getClass().getSimpleName();
            } else {
                str2 = null;
            }
            Object obj2 = this.f4437r;
            u2 u2Var = ((n3) obj2).z;
            n3.k(u2Var);
            u2Var.B.c(((n3) obj2).D.e(str), "Not putting event parameter. Invalid value type. name, type", str2);
        }
    }

    public final void G(com.google.android.gms.internal.measurement.l0 l0Var, boolean z) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("r", z);
        try {
            l0Var.n(bundle);
        } catch (RemoteException e7) {
            u2 u2Var = ((n3) this.f4437r).z;
            n3.k(u2Var);
            u2Var.z.b(e7, "Error returning boolean value to wrapper");
        }
    }

    public final void H(com.google.android.gms.internal.measurement.l0 l0Var, ArrayList arrayList) {
        Bundle bundle = new Bundle();
        bundle.putParcelableArrayList("r", arrayList);
        try {
            l0Var.n(bundle);
        } catch (RemoteException e7) {
            u2 u2Var = ((n3) this.f4437r).z;
            n3.k(u2Var);
            u2Var.z.b(e7, "Error returning bundle list to wrapper");
        }
    }

    public final void I(com.google.android.gms.internal.measurement.l0 l0Var, Bundle bundle) {
        try {
            l0Var.n(bundle);
        } catch (RemoteException e7) {
            u2 u2Var = ((n3) this.f4437r).z;
            n3.k(u2Var);
            u2Var.z.b(e7, "Error returning bundle value to wrapper");
        }
    }

    public final void J(com.google.android.gms.internal.measurement.l0 l0Var, byte[] bArr) {
        Bundle bundle = new Bundle();
        bundle.putByteArray("r", bArr);
        try {
            l0Var.n(bundle);
        } catch (RemoteException e7) {
            u2 u2Var = ((n3) this.f4437r).z;
            n3.k(u2Var);
            u2Var.z.b(e7, "Error returning byte array to wrapper");
        }
    }

    public final void K(com.google.android.gms.internal.measurement.l0 l0Var, int i9) {
        Bundle bundle = new Bundle();
        bundle.putInt("r", i9);
        try {
            l0Var.n(bundle);
        } catch (RemoteException e7) {
            u2 u2Var = ((n3) this.f4437r).z;
            n3.k(u2Var);
            u2Var.z.b(e7, "Error returning int value to wrapper");
        }
    }

    public final void L(com.google.android.gms.internal.measurement.l0 l0Var, long j9) {
        Bundle bundle = new Bundle();
        bundle.putLong("r", j9);
        try {
            l0Var.n(bundle);
        } catch (RemoteException e7) {
            u2 u2Var = ((n3) this.f4437r).z;
            n3.k(u2Var);
            u2Var.z.b(e7, "Error returning long value to wrapper");
        }
    }

    public final void M(String str, com.google.android.gms.internal.measurement.l0 l0Var) {
        Bundle bundle = new Bundle();
        bundle.putString("r", str);
        try {
            l0Var.n(bundle);
        } catch (RemoteException e7) {
            u2 u2Var = ((n3) this.f4437r).z;
            n3.k(u2Var);
            u2Var.z.b(e7, "Error returning string value to wrapper");
        }
    }

    public final void N(String str, String str2, Bundle bundle, List list, boolean z) {
        int i9;
        String str3;
        String str4;
        int R;
        if (bundle == null) {
            return;
        }
        n3 n3Var = (n3) this.f4437r;
        n3Var.getClass();
        Iterator it = new TreeSet(bundle.keySet()).iterator();
        int i10 = 0;
        while (it.hasNext()) {
            String str5 = (String) it.next();
            if (list != null && list.contains(str5)) {
                i9 = 0;
            } else {
                if (!z) {
                    i9 = o0(str5);
                } else {
                    i9 = 0;
                }
                if (i9 == 0) {
                    i9 = n0(str5);
                }
            }
            if (i9 != 0) {
                if (i9 == 3) {
                    str3 = str5;
                } else {
                    str3 = null;
                }
                A(bundle, i9, str5, str3);
                bundle.remove(str5);
            } else {
                if (Y(bundle.get(str5))) {
                    u2 u2Var = n3Var.z;
                    n3.k(u2Var);
                    u2Var.B.d("Nested Bundle parameters are not allowed; discarded. event name, param name, child param name", str, str2, str5);
                    R = 22;
                    str4 = str5;
                } else {
                    str4 = str5;
                    R = R(str, str5, bundle.get(str5), bundle, list, z, false);
                }
                if (R != 0 && !"_ev".equals(str4)) {
                    A(bundle, R, str4, bundle.get(str4));
                } else if (b0(str4) && !j0(str4, com.bumptech.glide.c.L) && (i10 = i10 + 1) > 0) {
                    u2 u2Var2 = n3Var.z;
                    n3.k(u2Var2);
                    u2Var2.f7841y.c(n3Var.D.d(str), "Item cannot contain custom parameters", n3Var.D.b(bundle));
                    g0(23, bundle);
                }
                bundle.remove(str4);
            }
        }
    }

    public final boolean O(String str, String str2) {
        boolean isEmpty = TextUtils.isEmpty(str);
        Object obj = this.f4437r;
        if (!isEmpty) {
            kotlin.jvm.internal.f.s(str);
            if (!str.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$")) {
                n3 n3Var = (n3) obj;
                if (TextUtils.isEmpty(n3Var.s)) {
                    u2 u2Var = n3Var.z;
                    n3.k(u2Var);
                    u2Var.f7841y.b(u2.x(str), "Invalid google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI. provided id");
                }
                return false;
            }
            return true;
        }
        if (!TextUtils.isEmpty(str2)) {
            kotlin.jvm.internal.f.s(str2);
            if (!str2.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$")) {
                u2 u2Var2 = ((n3) obj).z;
                n3.k(u2Var2);
                u2Var2.f7841y.b(u2.x(str2), "Invalid admob_app_id. Analytics disabled.");
                return false;
            }
            return true;
        }
        n3 n3Var2 = (n3) obj;
        if (TextUtils.isEmpty(n3Var2.s)) {
            u2 u2Var3 = n3Var2.z;
            n3.k(u2Var3);
            u2Var3.f7841y.a("Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI");
        }
        return false;
    }

    public final boolean P(String str, int i9, String str2) {
        Object obj = this.f4437r;
        if (str2 == null) {
            u2 u2Var = ((n3) obj).z;
            n3.k(u2Var);
            u2Var.f7841y.b(str, "Name is required and can't be null. Type");
            return false;
        }
        if (str2.codePointCount(0, str2.length()) > i9) {
            u2 u2Var2 = ((n3) obj).z;
            n3.k(u2Var2);
            u2Var2.f7841y.d("Name is too long. Type, maximum supported length, name", str, Integer.valueOf(i9), str2);
            return false;
        }
        return true;
    }

    public final boolean Q(String str, String[] strArr, String[] strArr2, String str2) {
        Object obj = this.f4437r;
        if (str2 == null) {
            u2 u2Var = ((n3) obj).z;
            n3.k(u2Var);
            u2Var.f7841y.b(str, "Name is required and can't be null. Type");
            return false;
        }
        String[] strArr3 = x;
        for (int i9 = 0; i9 < 3; i9++) {
            if (str2.startsWith(strArr3[i9])) {
                u2 u2Var2 = ((n3) obj).z;
                n3.k(u2Var2);
                u2Var2.f7841y.c(str, "Name starts with reserved prefix. Type, name", str2);
                return false;
            }
        }
        if (strArr != null && j0(str2, strArr)) {
            if (strArr2 == null || !j0(str2, strArr2)) {
                u2 u2Var3 = ((n3) obj).z;
                n3.k(u2Var3);
                u2Var3.f7841y.c(str, "Name is reserved. Type, name", str2);
                return false;
            }
            return true;
        }
        return true;
    }

    public final int R(String str, String str2, Object obj, Bundle bundle, List list, boolean z, boolean z8) {
        int i9;
        int i10;
        Object obj2;
        String str3;
        s2 s2Var;
        int size;
        o();
        boolean Y = Y(obj);
        Object obj3 = this.f4437r;
        if (Y) {
            if (z8) {
                if (!j0(str2, com.bumptech.glide.c.K)) {
                    return 20;
                }
                n3 n3Var = (n3) obj3;
                y4 t8 = n3Var.t();
                t8.o();
                t8.p();
                if (t8.w()) {
                    t5 t5Var = ((n3) t8.f4437r).C;
                    n3.i(t5Var);
                    if (t5Var.q0() < 200900) {
                        return 25;
                    }
                }
                n3Var.getClass();
                boolean z9 = obj instanceof Parcelable[];
                if (z9) {
                    size = ((Parcelable[]) obj).length;
                } else if (obj instanceof ArrayList) {
                    size = ((ArrayList) obj).size();
                }
                if (size > 200) {
                    u2 u2Var = n3Var.z;
                    n3.k(u2Var);
                    u2Var.B.d("Parameter array is too long; discarded. Value kind, name, array length", "param", str2, Integer.valueOf(size));
                    n3Var.getClass();
                    if (z9) {
                        Parcelable[] parcelableArr = (Parcelable[]) obj;
                        if (parcelableArr.length > 200) {
                            bundle.putParcelableArray(str2, (Parcelable[]) Arrays.copyOf(parcelableArr, 200));
                        }
                    } else if (obj instanceof ArrayList) {
                        ArrayList arrayList = (ArrayList) obj;
                        if (arrayList.size() > 200) {
                            bundle.putParcelableArrayList(str2, new ArrayList<>(arrayList.subList(0, 200)));
                        }
                    }
                    i9 = 17;
                    if (a0(str) && !a0(str2)) {
                        ((n3) obj3).getClass();
                        i10 = 100;
                    } else {
                        ((n3) obj3).getClass();
                        i10 = 256;
                    }
                    if (!T("param", str2, i10, obj)) {
                        return i9;
                    }
                    if (z8) {
                        if (obj instanceof Bundle) {
                            N(str, str2, (Bundle) obj, list, z);
                        } else if (obj instanceof Parcelable[]) {
                            for (Parcelable parcelable : (Parcelable[]) obj) {
                                if (!(parcelable instanceof Bundle)) {
                                    u2 u2Var2 = ((n3) obj3).z;
                                    n3.k(u2Var2);
                                    obj2 = parcelable.getClass();
                                    s2Var = u2Var2.B;
                                    str3 = "All Parcelable[] elements must be of type Bundle. Value type, name";
                                    s2Var.c(obj2, str3, str2);
                                    return 4;
                                }
                                N(str, str2, (Bundle) parcelable, list, z);
                            }
                        } else if (obj instanceof ArrayList) {
                            ArrayList arrayList2 = (ArrayList) obj;
                            int size2 = arrayList2.size();
                            for (int i11 = 0; i11 < size2; i11++) {
                                Object obj4 = arrayList2.get(i11);
                                if (!(obj4 instanceof Bundle)) {
                                    u2 u2Var3 = ((n3) obj3).z;
                                    n3.k(u2Var3);
                                    if (obj4 != null) {
                                        obj2 = obj4.getClass();
                                    } else {
                                        obj2 = "null";
                                    }
                                    str3 = "All ArrayList elements must be of type Bundle. Value type, name";
                                    s2Var = u2Var3.B;
                                    s2Var.c(obj2, str3, str2);
                                    return 4;
                                }
                                N(str, str2, (Bundle) obj4, list, z);
                            }
                        } else {
                            return 4;
                        }
                        return i9;
                    }
                    return 4;
                }
            } else {
                return 21;
            }
        }
        i9 = 0;
        if (a0(str)) {
        }
        ((n3) obj3).getClass();
        i10 = 256;
        if (!T("param", str2, i10, obj)) {
        }
    }

    public final void S() {
        o();
        SecureRandom secureRandom = new SecureRandom();
        long nextLong = secureRandom.nextLong();
        if (nextLong == 0) {
            nextLong = secureRandom.nextLong();
            if (nextLong == 0) {
                u2 u2Var = ((n3) this.f4437r).z;
                n3.k(u2Var);
                u2Var.z.a("Utils falling back to Random for random id");
            }
        }
        this.f7831u.set(nextLong);
    }

    public final boolean T(String str, String str2, int i9, 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 obj2 = obj.toString();
            if (obj2.codePointCount(0, obj2.length()) > i9) {
                u2 u2Var = ((n3) this.f4437r).z;
                n3.k(u2Var);
                u2Var.B.d("Value is too long; discarded. Value kind, name, value length", str, str2, Integer.valueOf(obj2.length()));
                return false;
            }
        }
        return true;
    }

    public final boolean U(String str, String str2) {
        Object obj = this.f4437r;
        if (str2 == null) {
            u2 u2Var = ((n3) obj).z;
            n3.k(u2Var);
            u2Var.f7841y.b(str, "Name is required and can't be null. Type");
            return false;
        }
        if (str2.length() == 0) {
            u2 u2Var2 = ((n3) obj).z;
            n3.k(u2Var2);
            u2Var2.f7841y.b(str, "Name is required and can't be empty. Type");
            return false;
        }
        int codePointAt = str2.codePointAt(0);
        if (!Character.isLetter(codePointAt)) {
            if (codePointAt == 95) {
                codePointAt = 95;
            } else {
                u2 u2Var3 = ((n3) obj).z;
                n3.k(u2Var3);
                u2Var3.f7841y.c(str, "Name must start with a letter or _ (underscore). Type, name", str2);
                return false;
            }
        }
        int length = str2.length();
        int charCount = Character.charCount(codePointAt);
        while (charCount < length) {
            int codePointAt2 = str2.codePointAt(charCount);
            if (codePointAt2 != 95 && !Character.isLetterOrDigit(codePointAt2)) {
                u2 u2Var4 = ((n3) obj).z;
                n3.k(u2Var4);
                u2Var4.f7841y.c(str, "Name must consist of letters, digits or _ (underscores). Type, name", str2);
                return false;
            }
            charCount += Character.charCount(codePointAt2);
        }
        return true;
    }

    public final boolean V(String str, String str2) {
        Object obj = this.f4437r;
        if (str2 == null) {
            u2 u2Var = ((n3) obj).z;
            n3.k(u2Var);
            u2Var.f7841y.b(str, "Name is required and can't be null. Type");
            return false;
        }
        if (str2.length() == 0) {
            u2 u2Var2 = ((n3) obj).z;
            n3.k(u2Var2);
            u2Var2.f7841y.b(str, "Name is required and can't be empty. Type");
            return false;
        }
        int codePointAt = str2.codePointAt(0);
        if (!Character.isLetter(codePointAt)) {
            u2 u2Var3 = ((n3) obj).z;
            n3.k(u2Var3);
            u2Var3.f7841y.c(str, "Name must start with a letter. Type, name", str2);
            return false;
        }
        int length = str2.length();
        int charCount = Character.charCount(codePointAt);
        while (charCount < length) {
            int codePointAt2 = str2.codePointAt(charCount);
            if (codePointAt2 != 95 && !Character.isLetterOrDigit(codePointAt2)) {
                u2 u2Var4 = ((n3) obj).z;
                n3.k(u2Var4);
                u2Var4.f7841y.c(str, "Name must consist of letters, digits or _ (underscores). Type, name", str2);
                return false;
            }
            charCount += Character.charCount(codePointAt2);
        }
        return true;
    }

    public final boolean W(String str) {
        o();
        n3 n3Var = (n3) this.f4437r;
        if (s4.b.a(n3Var.f7721r).f4958r.checkCallingOrSelfPermission(str) == 0) {
            return true;
        }
        u2 u2Var = n3Var.z;
        n3.k(u2Var);
        u2Var.D.b(str, "Permission not granted");
        return false;
    }

    public final boolean X(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        n3 n3Var = (n3) this.f4437r;
        String p8 = n3Var.x.p("debug.firebase.analytics.app");
        n3Var.getClass();
        return p8.equals(str);
    }

    public final boolean Z(Context context, String str) {
        u2 u2Var;
        String str2;
        Signature[] signatureArr;
        Object obj = this.f4437r;
        X500Principal x500Principal = new X500Principal("CN=Android Debug,O=Android,C=US");
        try {
            PackageInfo a5 = s4.b.a(context).a(64, str);
            if (a5 != null && (signatureArr = a5.signatures) != null && signatureArr.length > 0) {
                return ((X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(signatureArr[0].toByteArray()))).getSubjectX500Principal().equals(x500Principal);
            }
            return true;
        } catch (PackageManager.NameNotFoundException e7) {
            e = e7;
            u2Var = ((n3) obj).z;
            n3.k(u2Var);
            str2 = "Package name not found";
            u2Var.f7840w.b(e, str2);
            return true;
        } catch (CertificateException e9) {
            e = e9;
            u2Var = ((n3) obj).z;
            n3.k(u2Var);
            str2 = "Error obtaining certificate";
            u2Var.f7840w.b(e, str2);
            return true;
        }
    }

    public final int h0(String str) {
        boolean equals = "_ldl".equals(str);
        Object obj = this.f4437r;
        if (equals) {
            ((n3) obj).getClass();
            return 2048;
        }
        if ("_id".equals(str)) {
            ((n3) obj).getClass();
            return 256;
        }
        boolean equals2 = "_lgclid".equals(str);
        ((n3) obj).getClass();
        return equals2 ? 100 : 36;
    }

    public final Object i0(int i9, Object obj, boolean z, boolean z8) {
        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(true != ((Boolean) obj).booleanValue() ? 0L : 1L);
        }
        if (obj instanceof Float) {
            return Double.valueOf(((Float) obj).doubleValue());
        }
        if ((obj instanceof String) || (obj instanceof Character) || (obj instanceof CharSequence)) {
            return v(i9, obj.toString(), z);
        }
        if (!z8 || (!(obj instanceof Bundle[]) && !(obj instanceof Parcelable[]))) {
            return null;
        }
        ArrayList arrayList = new ArrayList();
        for (Parcelable parcelable : (Parcelable[]) obj) {
            if (parcelable instanceof Bundle) {
                Bundle u02 = u0((Bundle) parcelable);
                if (!u02.isEmpty()) {
                    arrayList.add(u02);
                }
            }
        }
        return arrayList.toArray(new Bundle[arrayList.size()]);
    }

    public final int l0(Object obj, String str) {
        return T("_ldl".equals(str) ? "user property referrer" : "user property", str, h0(str), obj) ? 0 : 7;
    }

    public final int m0(String str) {
        if (!U("event", str)) {
            return 2;
        }
        if (!Q("event", w.p.h, w.p.f7173i, str)) {
            return 13;
        }
        ((n3) this.f4437r).getClass();
        return !P("event", 40, str) ? 2 : 0;
    }

    public final int n0(String str) {
        if (!U("event param", str)) {
            return 3;
        }
        if (!Q("event param", null, null, str)) {
            return 14;
        }
        ((n3) this.f4437r).getClass();
        return !P("event param", 40, str) ? 3 : 0;
    }

    public final int o0(String str) {
        if (!V("event param", str)) {
            return 3;
        }
        if (!Q("event param", null, null, str)) {
            return 14;
        }
        ((n3) this.f4437r).getClass();
        return !P("event param", 40, str) ? 3 : 0;
    }

    @Override
    public final boolean p() {
        return true;
    }

    public final int p0(String str) {
        if (!U("user property", str)) {
            return 6;
        }
        if (!Q("user property", com.bumptech.glide.d.f1418r, null, str)) {
            return 15;
        }
        ((n3) this.f4437r).getClass();
        return !P("user property", 24, str) ? 6 : 0;
    }

    public final int q0() {
        if (this.f7833w == null) {
            m4.d dVar = m4.d.f5008b;
            Context context = ((n3) this.f4437r).f7721r;
            dVar.getClass();
            boolean z = m4.e.f5009a;
            int i9 = 0;
            try {
                i9 = context.getPackageManager().getPackageInfo("com.google.android.gms", 0).versionCode;
            } catch (PackageManager.NameNotFoundException unused) {
            }
            this.f7833w = Integer.valueOf(i9 / Priority.UI_NORMAL);
        }
        return this.f7833w.intValue();
    }

    public final Object s(Object obj, String str) {
        boolean equals = "_ev".equals(str);
        Object obj2 = this.f4437r;
        if (equals) {
            ((n3) obj2).getClass();
            return i0(256, obj, true, true);
        }
        boolean a02 = a0(str);
        ((n3) obj2).getClass();
        return i0(a02 ? 256 : 100, obj, false, true);
    }

    public final long s0() {
        long j9 = this.f7831u.get();
        synchronized (this.f7831u) {
            if (j9 == 0) {
                long nanoTime = System.nanoTime();
                ((n3) this.f4437r).E.getClass();
                long nextLong = new Random(nanoTime ^ System.currentTimeMillis()).nextLong();
                int i9 = this.f7832v + 1;
                this.f7832v = i9;
                return nextLong + i9;
            }
            this.f7831u.compareAndSet(-1L, 1L);
            return this.f7831u.getAndIncrement();
        }
    }

    public final Object t(Object obj, String str) {
        boolean equals = "_ldl".equals(str);
        int h02 = h0(str);
        return equals ? i0(h02, obj, true, false) : i0(h02, obj, false, false);
    }

    public final Bundle t0(Uri uri) {
        String str;
        String str2;
        String str3;
        String str4;
        String str5;
        String str6;
        String str7;
        if (uri != null) {
            try {
                if (uri.isHierarchical()) {
                    str = uri.getQueryParameter("utm_campaign");
                    str2 = uri.getQueryParameter("utm_source");
                    str3 = uri.getQueryParameter("utm_medium");
                    str4 = uri.getQueryParameter("gclid");
                    str5 = uri.getQueryParameter("utm_id");
                    str6 = uri.getQueryParameter("dclid");
                    str7 = uri.getQueryParameter("srsltid");
                } else {
                    str = null;
                    str2 = null;
                    str3 = null;
                    str4 = null;
                    str5 = null;
                    str6 = null;
                    str7 = null;
                }
                if (TextUtils.isEmpty(str) && TextUtils.isEmpty(str2) && TextUtils.isEmpty(str3) && TextUtils.isEmpty(str4) && TextUtils.isEmpty(str5) && TextUtils.isEmpty(str6) && TextUtils.isEmpty(str7)) {
                    return null;
                }
                Bundle bundle = new Bundle();
                if (!TextUtils.isEmpty(str)) {
                    bundle.putString("campaign", str);
                }
                if (!TextUtils.isEmpty(str2)) {
                    bundle.putString("source", str2);
                }
                if (!TextUtils.isEmpty(str3)) {
                    bundle.putString("medium", str3);
                }
                if (!TextUtils.isEmpty(str4)) {
                    bundle.putString("gclid", str4);
                }
                String queryParameter = uri.getQueryParameter("utm_term");
                if (!TextUtils.isEmpty(queryParameter)) {
                    bundle.putString("term", queryParameter);
                }
                String queryParameter2 = uri.getQueryParameter("utm_content");
                if (!TextUtils.isEmpty(queryParameter2)) {
                    bundle.putString("content", queryParameter2);
                }
                String queryParameter3 = uri.getQueryParameter("aclid");
                if (!TextUtils.isEmpty(queryParameter3)) {
                    bundle.putString("aclid", queryParameter3);
                }
                String queryParameter4 = uri.getQueryParameter("cp1");
                if (!TextUtils.isEmpty(queryParameter4)) {
                    bundle.putString("cp1", queryParameter4);
                }
                String queryParameter5 = uri.getQueryParameter("anid");
                if (!TextUtils.isEmpty(queryParameter5)) {
                    bundle.putString("anid", queryParameter5);
                }
                if (!TextUtils.isEmpty(str5)) {
                    bundle.putString("campaign_id", str5);
                }
                if (!TextUtils.isEmpty(str6)) {
                    bundle.putString("dclid", str6);
                }
                String queryParameter6 = uri.getQueryParameter("utm_source_platform");
                if (!TextUtils.isEmpty(queryParameter6)) {
                    bundle.putString("source_platform", queryParameter6);
                }
                String queryParameter7 = uri.getQueryParameter("utm_creative_format");
                if (!TextUtils.isEmpty(queryParameter7)) {
                    bundle.putString("creative_format", queryParameter7);
                }
                String queryParameter8 = uri.getQueryParameter("utm_marketing_tactic");
                if (!TextUtils.isEmpty(queryParameter8)) {
                    bundle.putString("marketing_tactic", queryParameter8);
                }
                if (!TextUtils.isEmpty(str7)) {
                    bundle.putString("srsltid", str7);
                }
                return bundle;
            } catch (UnsupportedOperationException e7) {
                u2 u2Var = ((n3) this.f4437r).z;
                n3.k(u2Var);
                u2Var.z.b(e7, "Install referrer url isn't a hierarchical URI");
            }
        }
        return null;
    }

    public final String u() {
        byte[] bArr = new byte[16];
        x().nextBytes(bArr);
        return String.format(Locale.US, "%032x", new BigInteger(1, bArr));
    }

    public final Bundle u0(Bundle bundle) {
        Bundle bundle2 = new Bundle();
        if (bundle != null) {
            for (String str : bundle.keySet()) {
                Object s = s(bundle.get(str), str);
                if (s == null) {
                    Object obj = this.f4437r;
                    u2 u2Var = ((n3) obj).z;
                    n3.k(u2Var);
                    u2Var.B.b(((n3) obj).D.e(str), "Param value can't be null");
                } else {
                    F(bundle2, str, s);
                }
            }
        }
        return bundle2;
    }

    public final Bundle v0(String str, Bundle bundle, List list, boolean z) {
        int i9;
        String str2;
        String str3;
        List list2 = list;
        boolean j02 = j0(str, w.p.f7175k);
        if (bundle != null) {
            Bundle bundle2 = new Bundle(bundle);
            n3 n3Var = (n3) this.f4437r;
            int q8 = n3Var.x.q();
            Iterator it = new TreeSet(bundle.keySet()).iterator();
            int i10 = 0;
            while (it.hasNext()) {
                String str4 = (String) it.next();
                if (list2 != null && list2.contains(str4)) {
                    i9 = 0;
                } else {
                    if (!z) {
                        i9 = o0(str4);
                    } else {
                        i9 = 0;
                    }
                    if (i9 == 0) {
                        i9 = n0(str4);
                    }
                }
                if (i9 != 0) {
                    if (i9 == 3) {
                        str3 = str4;
                    } else {
                        str3 = null;
                    }
                    A(bundle2, i9, str4, str3);
                    bundle2.remove(str4);
                } else {
                    int R = R(str, str4, bundle.get(str4), bundle2, list, z, j02);
                    if (R == 17) {
                        A(bundle2, 17, str4, Boolean.FALSE);
                    } else if (R != 0 && !"_ev".equals(str4)) {
                        if (R == 21) {
                            str2 = str;
                        } else {
                            str2 = str4;
                        }
                        A(bundle2, R, str2, bundle.get(str4));
                        bundle2.remove(str4);
                    }
                    if (b0(str4)) {
                        int i11 = i10 + 1;
                        if (i11 > q8) {
                            StringBuilder n9 = android.support.v4.media.b.n("Event can't contain more than ", q8, " params");
                            u2 u2Var = n3Var.z;
                            n3.k(u2Var);
                            String sb = n9.toString();
                            u2Var.f7841y.c(n3Var.D.d(str), sb, n3Var.D.b(bundle));
                            g0(5, bundle2);
                            bundle2.remove(str4);
                        }
                        i10 = i11;
                    }
                }
                list2 = list;
            }
            return bundle2;
        }
        return null;
    }

    public final p w0(String str, Bundle bundle, String str2, long j9, boolean z) {
        Bundle bundle2;
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        if (m0(str) == 0) {
            if (bundle != null) {
                bundle2 = new Bundle(bundle);
            } else {
                bundle2 = new Bundle();
            }
            bundle2.putString("_o", str2);
            Bundle v02 = v0(str, bundle2, Collections.singletonList("_o"), true);
            if (z) {
                v02 = u0(v02);
            }
            kotlin.jvm.internal.f.s(v02);
            return new p(str, new o(v02), str2, j9);
        }
        n3 n3Var = (n3) this.f4437r;
        u2 u2Var = n3Var.z;
        n3.k(u2Var);
        u2Var.f7840w.b(n3Var.D.f(str), "Invalid conditional property event name");
        throw new IllegalArgumentException();
    }

    public final SecureRandom x() {
        o();
        if (this.f7830t == null) {
            this.f7830t = new SecureRandom();
        }
        return this.f7830t;
    }

    public final void z(Bundle bundle, long j9) {
        long j10 = bundle.getLong("_et");
        if (j10 != 0) {
            u2 u2Var = ((n3) this.f4437r).z;
            n3.k(u2Var);
            u2Var.z.b(Long.valueOf(j10), "Params already contained engagement");
        } else {
            j10 = 0;
        }
        bundle.putLong("_et", j9 + j10);
    }
}