Banesco VE v1.23.11版本的 MD5 值为:a4aa3f1f54e4fbb4921e2e1235e636aa

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


package t4;

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 android.util.Log;
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.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import javax.security.auth.x500.X500Principal;
public final class s5 extends w3 {
    public static final String[] f10926q = {"firebase_", "google_", "ga_"};
    public static final String[] f10927r = {"_err"};
    public SecureRandom f10928m;
    public final AtomicLong f10929n;
    public int f10930o;
    public Integer f10931p;

    public s5(q3 q3Var) {
        super(q3Var);
        this.f10931p = null;
        this.f10929n = new AtomicLong(0L);
    }

    public static void C(m4 m4Var, Bundle bundle, boolean z6) {
        if (bundle != null && m4Var != null) {
            if (bundle.containsKey("_sc") && !z6) {
                z6 = false;
            } else {
                String str = m4Var.f10761a;
                if (str != null) {
                    bundle.putString("_sn", str);
                } else {
                    bundle.remove("_sn");
                }
                String str2 = m4Var.f10762b;
                if (str2 != null) {
                    bundle.putString("_sc", str2);
                } else {
                    bundle.remove("_sc");
                }
                bundle.putLong("_si", m4Var.f10763c);
                return;
            }
        }
        if (bundle != null && m4Var == null && z6) {
            bundle.remove("_sn");
            bundle.remove("_sc");
            bundle.remove("_si");
        }
    }

    public static void F(r5 r5Var, String str, int i10, String str2, String str3, int i11) {
        Bundle bundle = new Bundle();
        h0(i10, bundle);
        if (!TextUtils.isEmpty(str2) && !TextUtils.isEmpty(str3)) {
            bundle.putString(str2, str3);
        }
        if (i10 == 6 || i10 == 7 || i10 == 2) {
            bundle.putLong("_el", i11);
        }
        r5Var.e(str, bundle);
    }

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

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

    public static boolean c0(String str) {
        com.bumptech.glide.e.k(str);
        if (str.charAt(0) == '_' && !str.equals("_ep")) {
            return false;
        }
        return true;
    }

    public static boolean d0(Context context) {
        ActivityInfo receiverInfo;
        com.bumptech.glide.e.n(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 e0(Context context) {
        ServiceInfo serviceInfo;
        ServiceInfo serviceInfo2;
        com.bumptech.glide.e.n(context);
        if (Build.VERSION.SDK_INT >= 24) {
            try {
                PackageManager packageManager = context.getPackageManager();
                if (packageManager != null && (serviceInfo2 = packageManager.getServiceInfo(new ComponentName(context, "com.google.android.gms.measurement.AppMeasurementJobService"), 0)) != null) {
                    if (serviceInfo2.enabled) {
                        return true;
                    }
                }
            } catch (PackageManager.NameNotFoundException unused) {
            }
            return false;
        }
        try {
            PackageManager packageManager2 = context.getPackageManager();
            if (packageManager2 != null && (serviceInfo = packageManager2.getServiceInfo(new ComponentName(context, "com.google.android.gms.measurement.AppMeasurementService"), 0)) != null) {
                if (serviceInfo.enabled) {
                    return true;
                }
            }
        } catch (PackageManager.NameNotFoundException unused2) {
        }
        return false;
    }

    public static boolean f0(String str, String str2, String str3, String str4) {
        boolean isEmpty = TextUtils.isEmpty(str);
        boolean isEmpty2 = TextUtils.isEmpty(str2);
        if (!isEmpty && !isEmpty2) {
            com.bumptech.glide.e.n(str);
            if (!str.equals(str2)) {
                return true;
            }
            return false;
        } else if (isEmpty && isEmpty2) {
            if (!TextUtils.isEmpty(str3) && !TextUtils.isEmpty(str4)) {
                if (!str3.equals(str4)) {
                    return true;
                }
                return false;
            } else if (!TextUtils.isEmpty(str4)) {
                return true;
            } else {
                return false;
            }
        } else if (!isEmpty) {
            if (TextUtils.isEmpty(str4)) {
                return false;
            }
            if (TextUtils.isEmpty(str3) || !str3.equals(str4)) {
                return true;
            }
            return false;
        } else if (TextUtils.isEmpty(str3) || !str3.equals(str4)) {
            return true;
        } else {
            return false;
        }
    }

    public static byte[] g0(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 h0(int i10, Bundle bundle) {
        if (bundle.getLong("_err") == 0) {
            bundle.putLong("_err", i10);
            return true;
        }
        return false;
    }

    public static boolean k0(String str, String[] strArr) {
        boolean z6;
        com.bumptech.glide.e.n(strArr);
        for (String str2 : strArr) {
            if (str != str2 && (str == null || !str.equals(str2))) {
                z6 = false;
            } else {
                z6 = true;
            }
            if (z6) {
                return true;
            }
        }
        return false;
    }

    public static long r0(byte[] bArr) {
        boolean z6;
        com.bumptech.glide.e.n(bArr);
        int length = bArr.length;
        int i10 = 0;
        if (length > 0) {
            z6 = true;
        } else {
            z6 = false;
        }
        com.bumptech.glide.e.q(z6);
        long j10 = 0;
        for (int i11 = length - 1; i11 >= 0 && i11 >= bArr.length - 8; i11--) {
            j10 += (bArr[i11] & 255) << i10;
            i10 += 8;
        }
        return j10;
    }

    public static String w(String str, int i10, boolean z6) {
        if (str == null) {
            return null;
        }
        if (str.codePointCount(0, str.length()) > i10) {
            if (!z6) {
                return null;
            }
            return String.valueOf(str.substring(0, str.offsetByCodePoints(0, i10))).concat("...");
        }
        return str;
    }

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

    public static ArrayList z(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.f10516k);
            bundle.putString("origin", cVar.f10517l);
            bundle.putLong("creation_timestamp", cVar.f10519n);
            bundle.putString("name", cVar.f10518m.f10856l);
            Object l10 = cVar.f10518m.l();
            com.bumptech.glide.e.n(l10);
            j4.f.W(bundle, l10);
            bundle.putBoolean("active", cVar.f10520o);
            String str = cVar.f10521p;
            if (str != null) {
                bundle.putString("trigger_event_name", str);
            }
            p pVar = cVar.f10522q;
            if (pVar != null) {
                bundle.putString("timed_out_event_name", pVar.f10836k);
                o oVar = pVar.f10837l;
                if (oVar != null) {
                    bundle.putBundle("timed_out_event_params", oVar.l());
                }
            }
            bundle.putLong("trigger_timeout", cVar.f10523r);
            p pVar2 = cVar.f10524s;
            if (pVar2 != null) {
                bundle.putString("triggered_event_name", pVar2.f10836k);
                o oVar2 = pVar2.f10837l;
                if (oVar2 != null) {
                    bundle.putBundle("triggered_event_params", oVar2.l());
                }
            }
            bundle.putLong("triggered_timestamp", cVar.f10518m.f10857m);
            bundle.putLong("time_to_live", cVar.f10525t);
            p pVar3 = cVar.f10526u;
            if (pVar3 != null) {
                bundle.putString("expired_event_name", pVar3.f10836k);
                o oVar3 = pVar3.f10837l;
                if (oVar3 != null) {
                    bundle.putBundle("expired_event_params", oVar3.l());
                }
            }
            arrayList.add(bundle);
        }
        return arrayList;
    }

    public final void A(Bundle bundle, long j10) {
        long j11 = bundle.getLong("_et");
        if (j11 != 0) {
            u2 u2Var = ((q3) this.f6242k).f10879s;
            q3.k(u2Var);
            u2Var.f10950s.b(Long.valueOf(j11), "Params already contained engagement");
        } else {
            j11 = 0;
        }
        bundle.putLong("_et", j10 + j11);
    }

    public final void B(Bundle bundle, int i10, String str, Object obj) {
        if (h0(i10, bundle)) {
            ((q3) this.f6242k).getClass();
            bundle.putString("_ev", w(str, 40, true));
            if (obj != null) {
                if ((obj instanceof String) || (obj instanceof CharSequence)) {
                    bundle.putLong("_el", obj.toString().length());
                }
            }
        }
    }

    public final void D(Bundle bundle, Bundle bundle2) {
        if (bundle2 == null) {
            return;
        }
        for (String str : bundle2.keySet()) {
            if (!bundle.containsKey(str)) {
                s5 s5Var = ((q3) this.f6242k).f10882v;
                q3.i(s5Var);
                s5Var.G(bundle, str, bundle2.get(str));
            }
        }
    }

    public final void E(v2 v2Var, int i10) {
        Object obj = v2Var.f10991e;
        Iterator it = new TreeSet(((Bundle) obj).keySet()).iterator();
        int i11 = 0;
        while (it.hasNext()) {
            String str = (String) it.next();
            if (c0(str) && (i11 = i11 + 1) > i10) {
                q3 q3Var = (q3) this.f6242k;
                u2 u2Var = q3Var.f10879s;
                q3.k(u2Var);
                Bundle bundle = (Bundle) obj;
                u2Var.f10949r.c(q3Var.f10883w.d((String) v2Var.f10989c), q3Var.f10883w.b(bundle), "Event can't contain more than " + i10 + " params");
                h0(5, bundle);
                bundle.remove(str);
            }
        }
    }

    public final void G(Bundle bundle, String str, Object obj) {
        String str2;
        if (bundle == null) {
            return;
        }
        if (obj instanceof Long) {
            bundle.putLong(str, ((Long) obj).longValue());
        } else if (obj instanceof String) {
            bundle.putString(str, String.valueOf(obj));
        } else if (obj instanceof Double) {
            bundle.putDouble(str, ((Double) obj).doubleValue());
        } else if (obj instanceof Bundle[]) {
            bundle.putParcelableArray(str, (Bundle[]) obj);
        } else if (str != null) {
            if (obj != null) {
                str2 = obj.getClass().getSimpleName();
            } else {
                str2 = null;
            }
            Object obj2 = this.f6242k;
            u2 u2Var = ((q3) obj2).f10879s;
            q3.k(u2Var);
            u2Var.f10952u.c(((q3) obj2).f10883w.e(str), str2, "Not putting event parameter. Invalid value type. name, type");
        }
    }

    public final void H(com.google.android.gms.internal.measurement.k0 k0Var, boolean z6) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("r", z6);
        try {
            k0Var.h(bundle);
        } catch (RemoteException e10) {
            u2 u2Var = ((q3) this.f6242k).f10879s;
            q3.k(u2Var);
            u2Var.f10950s.b(e10, "Error returning boolean value to wrapper");
        }
    }

    public final void I(com.google.android.gms.internal.measurement.k0 k0Var, ArrayList arrayList) {
        Bundle bundle = new Bundle();
        bundle.putParcelableArrayList("r", arrayList);
        try {
            k0Var.h(bundle);
        } catch (RemoteException e10) {
            u2 u2Var = ((q3) this.f6242k).f10879s;
            q3.k(u2Var);
            u2Var.f10950s.b(e10, "Error returning bundle list to wrapper");
        }
    }

    public final void J(com.google.android.gms.internal.measurement.k0 k0Var, Bundle bundle) {
        try {
            k0Var.h(bundle);
        } catch (RemoteException e10) {
            u2 u2Var = ((q3) this.f6242k).f10879s;
            q3.k(u2Var);
            u2Var.f10950s.b(e10, "Error returning bundle value to wrapper");
        }
    }

    public final void K(com.google.android.gms.internal.measurement.k0 k0Var, byte[] bArr) {
        Bundle bundle = new Bundle();
        bundle.putByteArray("r", bArr);
        try {
            k0Var.h(bundle);
        } catch (RemoteException e10) {
            u2 u2Var = ((q3) this.f6242k).f10879s;
            q3.k(u2Var);
            u2Var.f10950s.b(e10, "Error returning byte array to wrapper");
        }
    }

    public final void L(com.google.android.gms.internal.measurement.k0 k0Var, int i10) {
        Bundle bundle = new Bundle();
        bundle.putInt("r", i10);
        try {
            k0Var.h(bundle);
        } catch (RemoteException e10) {
            u2 u2Var = ((q3) this.f6242k).f10879s;
            q3.k(u2Var);
            u2Var.f10950s.b(e10, "Error returning int value to wrapper");
        }
    }

    public final void M(com.google.android.gms.internal.measurement.k0 k0Var, long j10) {
        Bundle bundle = new Bundle();
        bundle.putLong("r", j10);
        try {
            k0Var.h(bundle);
        } catch (RemoteException e10) {
            u2 u2Var = ((q3) this.f6242k).f10879s;
            q3.k(u2Var);
            u2Var.f10950s.b(e10, "Error returning long value to wrapper");
        }
    }

    public final void N(String str, com.google.android.gms.internal.measurement.k0 k0Var) {
        Bundle bundle = new Bundle();
        bundle.putString("r", str);
        try {
            k0Var.h(bundle);
        } catch (RemoteException e10) {
            u2 u2Var = ((q3) this.f6242k).f10879s;
            q3.k(u2Var);
            u2Var.f10950s.b(e10, "Error returning string value to wrapper");
        }
    }

    public final void O(String str, String str2, Bundle bundle, List list, boolean z6) {
        int i10;
        String str3;
        String str4;
        int S;
        if (bundle == null) {
            return;
        }
        q3 q3Var = (q3) this.f6242k;
        q3Var.getClass();
        Iterator it = new TreeSet(bundle.keySet()).iterator();
        int i11 = 0;
        while (it.hasNext()) {
            String str5 = (String) it.next();
            if (list != null && list.contains(str5)) {
                i10 = 0;
            } else {
                if (!z6) {
                    i10 = o0(str5);
                } else {
                    i10 = 0;
                }
                if (i10 == 0) {
                    i10 = n0(str5);
                }
            }
            if (i10 != 0) {
                if (i10 == 3) {
                    str3 = str5;
                } else {
                    str3 = null;
                }
                B(bundle, i10, str5, str3);
                bundle.remove(str5);
            } else {
                if (Z(bundle.get(str5))) {
                    u2 u2Var = q3Var.f10879s;
                    q3.k(u2Var);
                    u2Var.f10952u.d("Nested Bundle parameters are not allowed; discarded. event name, param name, child param name", str, str2, str5);
                    S = 22;
                    str4 = str5;
                } else {
                    str4 = str5;
                    S = S(str, str5, bundle.get(str5), bundle, list, z6, false);
                }
                if (S != 0 && !"_ev".equals(str4)) {
                    B(bundle, S, str4, bundle.get(str4));
                    bundle.remove(str4);
                } else if (c0(str4) && !k0(str4, com.bumptech.glide.e.f2762o) && (i11 = i11 + 1) > 0) {
                    u2 u2Var2 = q3Var.f10879s;
                    q3.k(u2Var2);
                    u2Var2.f10949r.c(q3Var.f10883w.d(str), q3Var.f10883w.b(bundle), "Item cannot contain custom parameters");
                    h0(23, bundle);
                    bundle.remove(str4);
                }
            }
        }
    }

    public final boolean P(String str, String str2) {
        boolean isEmpty = TextUtils.isEmpty(str);
        Object obj = this.f6242k;
        if (!isEmpty) {
            com.bumptech.glide.e.n(str);
            if (!str.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$")) {
                q3 q3Var = (q3) obj;
                if (TextUtils.isEmpty(q3Var.f10872l)) {
                    u2 u2Var = q3Var.f10879s;
                    q3.k(u2Var);
                    u2Var.f10949r.b(u2.y(str), "Invalid google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI. provided id");
                }
                return false;
            }
            return true;
        } else if (!TextUtils.isEmpty(str2)) {
            com.bumptech.glide.e.n(str2);
            if (!str2.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$")) {
                u2 u2Var2 = ((q3) obj).f10879s;
                q3.k(u2Var2);
                u2Var2.f10949r.b(u2.y(str2), "Invalid admob_app_id. Analytics disabled.");
                return false;
            }
            return true;
        } else {
            q3 q3Var2 = (q3) obj;
            if (TextUtils.isEmpty(q3Var2.f10872l)) {
                u2 u2Var3 = q3Var2.f10879s;
                q3.k(u2Var3);
                u2Var3.f10949r.a("Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI");
            }
            return false;
        }
    }

    public final boolean Q(String str, int i10, String str2) {
        Object obj = this.f6242k;
        if (str2 == null) {
            u2 u2Var = ((q3) obj).f10879s;
            q3.k(u2Var);
            u2Var.f10949r.b(str, "Name is required and can't be null. Type");
            return false;
        } else if (str2.codePointCount(0, str2.length()) > i10) {
            u2 u2Var2 = ((q3) obj).f10879s;
            q3.k(u2Var2);
            u2Var2.f10949r.d("Name is too long. Type, maximum supported length, name", str, Integer.valueOf(i10), str2);
            return false;
        } else {
            return true;
        }
    }

    public final boolean R(String str, String[] strArr, String[] strArr2, String str2) {
        Object obj = this.f6242k;
        if (str2 == null) {
            u2 u2Var = ((q3) obj).f10879s;
            q3.k(u2Var);
            u2Var.f10949r.b(str, "Name is required and can't be null. Type");
            return false;
        }
        String[] strArr3 = f10926q;
        for (int i10 = 0; i10 < 3; i10++) {
            if (str2.startsWith(strArr3[i10])) {
                u2 u2Var2 = ((q3) obj).f10879s;
                q3.k(u2Var2);
                u2Var2.f10949r.c(str, str2, "Name starts with reserved prefix. Type, name");
                return false;
            }
        }
        if (strArr != null && k0(str2, strArr)) {
            if (strArr2 == null || !k0(str2, strArr2)) {
                u2 u2Var3 = ((q3) obj).f10879s;
                q3.k(u2Var3);
                u2Var3.f10949r.c(str, str2, "Name is reserved. Type, name");
                return false;
            }
            return true;
        }
        return true;
    }

    public final int S(String str, String str2, Object obj, Bundle bundle, List list, boolean z6, boolean z10) {
        int i10;
        int i11;
        Object obj2;
        Parcelable[] parcelableArr;
        int size;
        o();
        boolean Z = Z(obj);
        Object obj3 = this.f6242k;
        if (Z) {
            if (z10) {
                if (!k0(str2, com.bumptech.glide.e.f2761n)) {
                    return 20;
                }
                q3 q3Var = (q3) obj3;
                y4 t10 = q3Var.t();
                t10.o();
                t10.p();
                if (t10.x()) {
                    s5 s5Var = ((q3) t10.f6242k).f10882v;
                    q3.i(s5Var);
                    if (s5Var.q0() < 200900) {
                        return 25;
                    }
                }
                q3Var.getClass();
                boolean z11 = obj instanceof Parcelable[];
                if (z11) {
                    size = ((Parcelable[]) obj).length;
                } else if (obj instanceof ArrayList) {
                    size = ((ArrayList) obj).size();
                }
                if (size > 200) {
                    u2 u2Var = q3Var.f10879s;
                    q3.k(u2Var);
                    u2Var.f10952u.d("Parameter array is too long; discarded. Value kind, name, array length", "param", str2, Integer.valueOf(size));
                    q3Var.getClass();
                    if (z11) {
                        Parcelable[] parcelableArr2 = (Parcelable[]) obj;
                        if (parcelableArr2.length > 200) {
                            bundle.putParcelableArray(str2, (Parcelable[]) Arrays.copyOf(parcelableArr2, 200));
                        }
                    } else if (obj instanceof ArrayList) {
                        ArrayList arrayList = (ArrayList) obj;
                        if (arrayList.size() > 200) {
                            bundle.putParcelableArrayList(str2, new ArrayList<>(arrayList.subList(0, 200)));
                        }
                    }
                    i10 = 17;
                    if (b0(str) && !b0(str2)) {
                        ((q3) obj3).getClass();
                        i11 = 100;
                    } else {
                        ((q3) obj3).getClass();
                        i11 = 256;
                    }
                    if (!U(obj, "param", str2, i11)) {
                        return i10;
                    }
                    if (z10) {
                        if (obj instanceof Bundle) {
                            O(str, str2, (Bundle) obj, list, z6);
                        } else if (obj instanceof Parcelable[]) {
                            for (Parcelable parcelable : (Parcelable[]) obj) {
                                if (!(parcelable instanceof Bundle)) {
                                    u2 u2Var2 = ((q3) obj3).f10879s;
                                    q3.k(u2Var2);
                                    u2Var2.f10952u.c(parcelable.getClass(), str2, "All Parcelable[] elements must be of type Bundle. Value type, name");
                                    return 4;
                                }
                                O(str, str2, (Bundle) parcelable, list, z6);
                            }
                        } else if (obj instanceof ArrayList) {
                            ArrayList arrayList2 = (ArrayList) obj;
                            int size2 = arrayList2.size();
                            for (int i12 = 0; i12 < size2; i12++) {
                                Object obj4 = arrayList2.get(i12);
                                if (!(obj4 instanceof Bundle)) {
                                    u2 u2Var3 = ((q3) obj3).f10879s;
                                    q3.k(u2Var3);
                                    if (obj4 != null) {
                                        obj2 = obj4.getClass();
                                    } else {
                                        obj2 = "null";
                                    }
                                    u2Var3.f10952u.c(obj2, str2, "All ArrayList elements must be of type Bundle. Value type, name");
                                    return 4;
                                }
                                O(str, str2, (Bundle) obj4, list, z6);
                            }
                        } else {
                            return 4;
                        }
                        return i10;
                    }
                    return 4;
                }
            } else {
                return 21;
            }
        }
        i10 = 0;
        if (b0(str)) {
        }
        ((q3) obj3).getClass();
        i11 = 256;
        if (!U(obj, "param", str2, i11)) {
        }
    }

    public final void T() {
        o();
        SecureRandom secureRandom = new SecureRandom();
        long nextLong = secureRandom.nextLong();
        if (nextLong == 0) {
            nextLong = secureRandom.nextLong();
            if (nextLong == 0) {
                u2 u2Var = ((q3) this.f6242k).f10879s;
                q3.k(u2Var);
                u2Var.f10950s.a("Utils falling back to Random for random id");
            }
        }
        this.f10929n.set(nextLong);
    }

    public final boolean U(Object obj, String str, String str2, int i10) {
        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()) > i10) {
                u2 u2Var = ((q3) this.f6242k).f10879s;
                q3.k(u2Var);
                u2Var.f10952u.d("Value is too long; discarded. Value kind, name, value length", str, str2, Integer.valueOf(obj2.length()));
                return false;
            }
        }
        return true;
    }

    public final boolean V(String str, String str2) {
        Object obj = this.f6242k;
        if (str2 == null) {
            u2 u2Var = ((q3) obj).f10879s;
            q3.k(u2Var);
            u2Var.f10949r.b(str, "Name is required and can't be null. Type");
            return false;
        } else if (str2.length() == 0) {
            u2 u2Var2 = ((q3) obj).f10879s;
            q3.k(u2Var2);
            u2Var2.f10949r.b(str, "Name is required and can't be empty. Type");
            return false;
        } else {
            int codePointAt = str2.codePointAt(0);
            if (!Character.isLetter(codePointAt)) {
                if (codePointAt == 95) {
                    codePointAt = 95;
                } else {
                    u2 u2Var3 = ((q3) obj).f10879s;
                    q3.k(u2Var3);
                    u2Var3.f10949r.c(str, str2, "Name must start with a letter or _ (underscore). Type, name");
                    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 = ((q3) obj).f10879s;
                    q3.k(u2Var4);
                    u2Var4.f10949r.c(str, str2, "Name must consist of letters, digits or _ (underscores). Type, name");
                    return false;
                }
                charCount += Character.charCount(codePointAt2);
            }
            return true;
        }
    }

    public final boolean W(String str, String str2) {
        Object obj = this.f6242k;
        if (str2 == null) {
            u2 u2Var = ((q3) obj).f10879s;
            q3.k(u2Var);
            u2Var.f10949r.b(str, "Name is required and can't be null. Type");
            return false;
        } else if (str2.length() == 0) {
            u2 u2Var2 = ((q3) obj).f10879s;
            q3.k(u2Var2);
            u2Var2.f10949r.b(str, "Name is required and can't be empty. Type");
            return false;
        } else {
            int codePointAt = str2.codePointAt(0);
            if (!Character.isLetter(codePointAt)) {
                u2 u2Var3 = ((q3) obj).f10879s;
                q3.k(u2Var3);
                u2Var3.f10949r.c(str, str2, "Name must start with a letter. Type, name");
                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 = ((q3) obj).f10879s;
                    q3.k(u2Var4);
                    u2Var4.f10949r.c(str, str2, "Name must consist of letters, digits or _ (underscores). Type, name");
                    return false;
                }
                charCount += Character.charCount(codePointAt2);
            }
            return true;
        }
    }

    public final boolean X(String str) {
        o();
        q3 q3Var = (q3) this.f6242k;
        if (h4.b.a(q3Var.f10871k).f528l.checkCallingOrSelfPermission(str) == 0) {
            return true;
        }
        u2 u2Var = q3Var.f10879s;
        q3.k(u2Var);
        u2Var.f10954w.b(str, "Permission not granted");
        return false;
    }

    public final boolean Y(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        q3 q3Var = (q3) this.f6242k;
        String p10 = q3Var.f10877q.p("debug.firebase.analytics.app");
        q3Var.getClass();
        return p10.equals(str);
    }

    public final boolean a0(Context context, String str) {
        Signature[] signatureArr;
        Object obj = this.f6242k;
        X500Principal x500Principal = new X500Principal("CN=Android Debug,O=Android,C=US");
        try {
            PackageInfo e10 = h4.b.a(context).e(str, 64);
            if (e10 != null && (signatureArr = e10.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 e11) {
            u2 u2Var = ((q3) obj).f10879s;
            q3.k(u2Var);
            u2Var.f10947p.b(e11, "Package name not found");
            return true;
        } catch (CertificateException e12) {
            u2 u2Var2 = ((q3) obj).f10879s;
            q3.k(u2Var2);
            u2Var2.f10947p.b(e12, "Error obtaining certificate");
            return true;
        }
    }

    public final int i0(String str) {
        boolean equals = "_ldl".equals(str);
        Object obj = this.f6242k;
        if (equals) {
            ((q3) obj).getClass();
            return 2048;
        } else if ("_id".equals(str)) {
            ((q3) obj).getClass();
            return 256;
        } else if ("_lgclid".equals(str)) {
            ((q3) obj).getClass();
            return 100;
        } else {
            ((q3) obj).getClass();
            return 36;
        }
    }

    public final Object j0(int i10, Object obj, boolean z6, boolean z10) {
        Parcelable[] parcelableArr;
        long j10;
        if (obj == null) {
            return null;
        }
        if (!(obj instanceof Long) && !(obj instanceof Double)) {
            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) {
                if (true != ((Boolean) obj).booleanValue()) {
                    j10 = 0;
                } else {
                    j10 = 1;
                }
                return Long.valueOf(j10);
            } else if (obj instanceof Float) {
                return Double.valueOf(((Float) obj).doubleValue());
            } else {
                if (!(obj instanceof String) && !(obj instanceof Character) && !(obj instanceof CharSequence)) {
                    if (!z10 || (!(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()]);
                }
                return w(obj.toString(), i10, z6);
            }
        }
        return obj;
    }

    public final int l0(Object obj, String str) {
        boolean U;
        if ("_ldl".equals(str)) {
            U = U(obj, "user property referrer", str, i0(str));
        } else {
            U = U(obj, "user property", str, i0(str));
        }
        if (U) {
            return 0;
        }
        return 7;
    }

    public final int m0(String str) {
        if (!V("event", str)) {
            return 2;
        }
        if (!R("event", com.bumptech.glide.d.f2744o, com.bumptech.glide.d.f2745p, str)) {
            return 13;
        }
        ((q3) this.f6242k).getClass();
        if (!Q("event", 40, str)) {
            return 2;
        }
        return 0;
    }

    public final int n0(String str) {
        if (!V("event param", str)) {
            return 3;
        }
        if (!R("event param", null, null, str)) {
            return 14;
        }
        ((q3) this.f6242k).getClass();
        if (!Q("event param", 40, str)) {
            return 3;
        }
        return 0;
    }

    public final int o0(String str) {
        if (!W("event param", str)) {
            return 3;
        }
        if (!R("event param", null, null, str)) {
            return 14;
        }
        ((q3) this.f6242k).getClass();
        if (!Q("event param", 40, str)) {
            return 3;
        }
        return 0;
    }

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

    public final int p0(String str) {
        if (!V("user property", str)) {
            return 6;
        }
        if (!R("user property", com.google.android.gms.internal.measurement.k3.f3089p, null, str)) {
            return 15;
        }
        ((q3) this.f6242k).getClass();
        if (!Q("user property", 24, str)) {
            return 6;
        }
        return 0;
    }

    public final int q0() {
        if (this.f10931p == null) {
            y3.f fVar = y3.f.f12687b;
            Context context = ((q3) this.f6242k).f10871k;
            fVar.getClass();
            AtomicBoolean atomicBoolean = y3.i.f12689a;
            int i10 = 0;
            try {
                i10 = context.getPackageManager().getPackageInfo("com.google.android.gms", 0).versionCode;
            } catch (PackageManager.NameNotFoundException unused) {
                Log.w("GooglePlayServicesUtil", "Google Play services is missing.");
            }
            this.f10931p = Integer.valueOf(i10 / 1000);
        }
        return this.f10931p.intValue();
    }

    public final long s0() {
        long andIncrement;
        long j10;
        if (this.f10929n.get() == 0) {
            synchronized (this.f10929n) {
                long nanoTime = System.nanoTime();
                ((q3) this.f6242k).f10884x.getClass();
                long nextLong = new Random(nanoTime ^ System.currentTimeMillis()).nextLong();
                int i10 = this.f10930o + 1;
                this.f10930o = i10;
                j10 = nextLong + i10;
            }
            return j10;
        }
        synchronized (this.f10929n) {
            this.f10929n.compareAndSet(-1L, 1L);
            andIncrement = this.f10929n.getAndIncrement();
        }
        return andIncrement;
    }

    public final Object t(Object obj, String str) {
        boolean equals = "_ev".equals(str);
        int i10 = 256;
        Object obj2 = this.f6242k;
        if (equals) {
            ((q3) obj2).getClass();
            return j0(256, obj, true, true);
        }
        if (b0(str)) {
            ((q3) obj2).getClass();
        } else {
            ((q3) obj2).getClass();
            i10 = 100;
        }
        return j0(i10, obj, false, true);
    }

    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 e10) {
                u2 u2Var = ((q3) this.f6242k).f10879s;
                q3.k(u2Var);
                u2Var.f10950s.b(e10, "Install referrer url isn't a hierarchical URI");
            }
        }
        return null;
    }

    public final Object u(Object obj, String str) {
        if ("_ldl".equals(str)) {
            return j0(i0(str), obj, true, false);
        }
        return j0(i0(str), obj, false, false);
    }

    public final Bundle u0(Bundle bundle) {
        Bundle bundle2 = new Bundle();
        if (bundle != null) {
            for (String str : bundle.keySet()) {
                Object t10 = t(bundle.get(str), str);
                if (t10 == null) {
                    Object obj = this.f6242k;
                    u2 u2Var = ((q3) obj).f10879s;
                    q3.k(u2Var);
                    u2Var.f10952u.b(((q3) obj).f10883w.e(str), "Param value can't be null");
                } else {
                    G(bundle2, str, t10);
                }
            }
        }
        return bundle2;
    }

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

    public final Bundle v0(String str, Bundle bundle, List list, boolean z6) {
        int i10;
        int i11;
        String str2;
        String str3;
        List list2 = list;
        boolean k02 = k0(str, com.bumptech.glide.d.f2747r);
        if (bundle != null) {
            Bundle bundle2 = new Bundle(bundle);
            q3 q3Var = (q3) this.f6242k;
            int s7 = q3Var.f10877q.s();
            Iterator it = new TreeSet(bundle.keySet()).iterator();
            int i12 = 0;
            while (it.hasNext()) {
                String str4 = (String) it.next();
                if (list2 != null && list2.contains(str4)) {
                    i10 = 0;
                } else {
                    if (!z6) {
                        i10 = o0(str4);
                    } else {
                        i10 = 0;
                    }
                    if (i10 == 0) {
                        i10 = n0(str4);
                    }
                }
                if (i10 != 0) {
                    if (i10 == 3) {
                        str3 = str4;
                    } else {
                        str3 = null;
                    }
                    B(bundle2, i10, str4, str3);
                    bundle2.remove(str4);
                    i11 = s7;
                } else {
                    i11 = s7;
                    int S = S(str, str4, bundle.get(str4), bundle2, list, z6, k02);
                    if (S == 17) {
                        B(bundle2, 17, str4, Boolean.FALSE);
                    } else if (S != 0 && !"_ev".equals(str4)) {
                        if (S == 21) {
                            str2 = str;
                        } else {
                            str2 = str4;
                        }
                        B(bundle2, S, str2, bundle.get(str4));
                        bundle2.remove(str4);
                    }
                    if (c0(str4)) {
                        int i13 = i12 + 1;
                        if (i13 > i11) {
                            u2 u2Var = q3Var.f10879s;
                            q3.k(u2Var);
                            u2Var.f10949r.c(q3Var.f10883w.d(str), q3Var.f10883w.b(bundle), "Event can't contain more than " + i11 + " params");
                            h0(5, bundle2);
                            bundle2.remove(str4);
                        }
                        i12 = i13;
                    }
                }
                s7 = i11;
                list2 = list;
            }
            return bundle2;
        }
        return null;
    }

    public final p w0(String str, Bundle bundle, String str2, long j10, boolean z6) {
        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 (z6) {
                v02 = u0(v02);
            }
            com.bumptech.glide.e.n(v02);
            return new p(str, new o(v02), str2, j10);
        }
        q3 q3Var = (q3) this.f6242k;
        u2 u2Var = q3Var.f10879s;
        q3.k(u2Var);
        u2Var.f10947p.b(q3Var.f10883w.f(str), "Invalid conditional property event name");
        throw new IllegalArgumentException();
    }

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