Souza NET DTunnel v4.2.6版本的 MD5 值为:9c33be9da88136132d2ea8a79815d093

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


package q5;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
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.os.ext.SdkExtensions;
import android.text.TextUtils;
import android.util.Log;
import com.google.android.gms.internal.measurement.ga;
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.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import javax.security.auth.x500.X500Principal;
public final class m7 extends j5 {
    public static final String[] A = {"firebase_", "google_", "ga_"};
    public static final String[] B = {"_err"};
    public SecureRandom f9090u;
    public final AtomicLong f9091v;
    public int f9092w;
    public v0.d f9093x;
    public Boolean f9094y;
    public Integer f9095z;

    public m7(y4 y4Var) {
        super(y4Var);
        this.f9095z = null;
        this.f9091v = new AtomicLong(0L);
    }

    public static int A0(String str) {
        if ("_ldl".equals(str)) {
            return 2048;
        }
        if ("_id".equals(str)) {
            return 256;
        }
        return ("_lgclid".equals(str) || "_gbraid".equals(str)) ? 100 : 36;
    }

    public static Bundle C(List list) {
        Bundle bundle = new Bundle();
        if (list == null) {
            return bundle;
        }
        Iterator it = list.iterator();
        while (it.hasNext()) {
            j7 j7Var = (j7) it.next();
            String str = j7Var.f9018w;
            String str2 = j7Var.f9015t;
            if (str != null) {
                bundle.putString(str2, str);
            } else {
                Long l10 = j7Var.f9017v;
                if (l10 != null) {
                    bundle.putLong(str2, l10.longValue());
                } else {
                    Double d10 = j7Var.f9020y;
                    if (d10 != null) {
                        bundle.putDouble(str2, d10.doubleValue());
                    }
                }
            }
        }
        return bundle;
    }

    public static String E(int i10, String str, boolean z10) {
        if (str == null) {
            return null;
        }
        if (str.codePointCount(0, str.length()) > i10) {
            if (!z10) {
                return null;
            }
            return androidx.activity.d.p(str.substring(0, str.offsetByCodePoints(0, i10)), "...");
        }
        return str;
    }

    public static MessageDigest E0() {
        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 void G(Bundle bundle, int i10, String str, Object obj) {
        if (l0(i10, bundle)) {
            bundle.putString("_ev", E(40, str, true));
            if (obj != null) {
                if ((obj instanceof String) || (obj instanceof CharSequence)) {
                    bundle.putLong("_el", String.valueOf(obj).length());
                }
            }
        }
    }

    public static void S(i6 i6Var, Bundle bundle, boolean z10) {
        if (bundle == null || i6Var == null || (bundle.containsKey("_sc") && !z10)) {
            if (bundle != null && i6Var == null && z10) {
                bundle.remove("_sn");
                bundle.remove("_sc");
                bundle.remove("_si");
                return;
            }
            return;
        }
        String str = i6Var.f8992a;
        if (str != null) {
            bundle.putString("_sn", str);
        } else {
            bundle.remove("_sn");
        }
        String str2 = i6Var.f8993b;
        if (str2 != null) {
            bundle.putString("_sc", str2);
        } else {
            bundle.remove("_sc");
        }
        bundle.putLong("_si", i6Var.f8994c);
    }

    public static void T(s4.e eVar, String str, int i10, String str2, String str3, int i11) {
        Bundle bundle = new Bundle();
        l0(i10, bundle);
        if (!TextUtils.isEmpty(str2) && !TextUtils.isEmpty(str3)) {
            bundle.putString(str2, str3);
        }
        if (i10 == 6 || i10 == 7 || i10 == 2) {
            bundle.putLong("_el", i11);
        }
        eVar.E(str, "_err", bundle);
    }

    public static boolean W(Context context) {
        ActivityInfo receiverInfo;
        com.bumptech.glide.f.j(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 X(Intent intent) {
        String stringExtra = intent.getStringExtra("android.intent.extra.REFERRER_NAME");
        return "android-app://com.google.android.googlequicksearchbox/https/www.google.com".equals(stringExtra) || "https://www.google.com".equals(stringExtra) || "android-app://com.google.appcrawler".equals(stringExtra);
    }

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

    public static boolean b0(String str, String str2, String str3, String str4) {
        boolean isEmpty = TextUtils.isEmpty(str);
        boolean isEmpty2 = TextUtils.isEmpty(str2);
        if (!isEmpty && !isEmpty2) {
            com.bumptech.glide.f.j(str);
            return !str.equals(str2);
        } else if (isEmpty && isEmpty2) {
            return (TextUtils.isEmpty(str3) || TextUtils.isEmpty(str4)) ? !TextUtils.isEmpty(str4) : !str3.equals(str4);
        } else if (isEmpty || !isEmpty2) {
            return TextUtils.isEmpty(str3) || !str3.equals(str4);
        } else if (TextUtils.isEmpty(str4)) {
            return false;
        } else {
            return TextUtils.isEmpty(str3) || !str3.equals(str4);
        }
    }

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

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

    public static boolean g0(Context context) {
        com.bumptech.glide.f.j(context);
        return p0(context, Build.VERSION.SDK_INT >= 24 ? "com.google.android.gms.measurement.AppMeasurementJobService" : "com.google.android.gms.measurement.AppMeasurementService");
    }

    public static ArrayList k0(List list) {
        if (list == null) {
            return new ArrayList(0);
        }
        ArrayList arrayList = new ArrayList(list.size());
        Iterator it = list.iterator();
        while (it.hasNext()) {
            e eVar = (e) it.next();
            Bundle bundle = new Bundle();
            bundle.putString("app_id", eVar.f8904s);
            bundle.putString("origin", eVar.f8905t);
            bundle.putLong("creation_timestamp", eVar.f8907v);
            bundle.putString("name", eVar.f8906u.f9015t);
            Object c10 = eVar.f8906u.c();
            com.bumptech.glide.f.j(c10);
            p1.l.x(bundle, c10);
            bundle.putBoolean("active", eVar.f8908w);
            String str = eVar.f8909x;
            if (str != null) {
                bundle.putString("trigger_event_name", str);
            }
            v vVar = eVar.f8910y;
            if (vVar != null) {
                bundle.putString("timed_out_event_name", vVar.f9265s);
                t tVar = vVar.f9266t;
                if (tVar != null) {
                    bundle.putBundle("timed_out_event_params", tVar.e());
                }
            }
            bundle.putLong("trigger_timeout", eVar.f8911z);
            v vVar2 = eVar.A;
            if (vVar2 != null) {
                bundle.putString("triggered_event_name", vVar2.f9265s);
                t tVar2 = vVar2.f9266t;
                if (tVar2 != null) {
                    bundle.putBundle("triggered_event_params", tVar2.e());
                }
            }
            bundle.putLong("triggered_timestamp", eVar.f8906u.f9016u);
            bundle.putLong("time_to_live", eVar.B);
            v vVar3 = eVar.C;
            if (vVar3 != null) {
                bundle.putString("expired_event_name", vVar3.f9265s);
                t tVar3 = vVar3.f9266t;
                if (tVar3 != null) {
                    bundle.putBundle("expired_event_params", tVar3.e());
                }
            }
            arrayList.add(bundle);
        }
        return arrayList;
    }

    public static boolean l0(int i10, Bundle bundle) {
        if (bundle != null && bundle.getLong("_err") == 0) {
            bundle.putLong("_err", i10);
            return true;
        }
        return false;
    }

    public static boolean p0(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 boolean r0(String str) {
        String str2 = (String) x.Z.a(null);
        return str2.equals("*") || Arrays.asList(str2.split(",")).contains(str);
    }

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

    public static boolean w0(String str) {
        com.bumptech.glide.f.g(str);
        return str.charAt(0) != '_' || str.equals("_ep");
    }

    public static long y(t tVar) {
        long j10 = 0;
        if (tVar == null) {
            return 0L;
        }
        androidx.datastore.preferences.protobuf.v1 v1Var = new androidx.datastore.preferences.protobuf.v1(tVar);
        while (v1Var.hasNext()) {
            Object obj = tVar.f9223s.get((String) v1Var.next());
            if (obj instanceof Parcelable[]) {
                j10 += ((Parcelable[]) obj).length;
            }
        }
        return j10;
    }

    public static long z(byte[] bArr) {
        boolean z10;
        com.bumptech.glide.f.j(bArr);
        int i10 = 0;
        if (bArr.length > 0) {
            z10 = true;
        } else {
            z10 = false;
        }
        if (z10) {
            long j10 = 0;
            for (int length = bArr.length - 1; length >= 0 && length >= bArr.length - 8; length--) {
                j10 += (bArr[length] & 255) << i10;
                i10 += 8;
            }
            return j10;
        }
        throw new IllegalStateException();
    }

    public final Bundle A(Uri uri, boolean z10, boolean z11) {
        String str;
        String str2;
        String str3;
        String str4;
        String str5;
        String str6;
        String str7;
        String str8;
        String str9;
        String str10;
        if (uri == null) {
            return 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 = z11 ? uri.getQueryParameter("gbraid") : null;
                str6 = uri.getQueryParameter("utm_id");
                str7 = uri.getQueryParameter("dclid");
                str8 = uri.getQueryParameter("srsltid");
                str9 = z10 ? uri.getQueryParameter("sfmc_id") : null;
            } else {
                str = null;
                str2 = null;
                str3 = null;
                str4 = null;
                str5 = null;
                str6 = null;
                str7 = null;
                str8 = null;
                str9 = null;
            }
            if (TextUtils.isEmpty(str) && TextUtils.isEmpty(str2) && TextUtils.isEmpty(str3) && TextUtils.isEmpty(str4) && ((!z11 || TextUtils.isEmpty(str5)) && TextUtils.isEmpty(str6) && TextUtils.isEmpty(str7) && TextUtils.isEmpty(str8) && (!z10 || TextUtils.isEmpty(str9)))) {
                return null;
            }
            Bundle bundle = new Bundle();
            if (TextUtils.isEmpty(str)) {
                str10 = "sfmc_id";
            } else {
                str10 = "sfmc_id";
                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);
            }
            if (z11 && !TextUtils.isEmpty(str5)) {
                bundle.putString("gbraid", str5);
            }
            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(str6)) {
                bundle.putString("campaign_id", str6);
            }
            if (!TextUtils.isEmpty(str7)) {
                bundle.putString("dclid", str7);
            }
            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(str8)) {
                bundle.putString("srsltid", str8);
            }
            if (z10 && !TextUtils.isEmpty(str9)) {
                bundle.putString(str10, str9);
            }
            return bundle;
        } catch (UnsupportedOperationException e10) {
            c().A.c("Install referrer url isn't a hierarchical URI", e10);
            return null;
        }
    }

    public final Bundle B(String str, Bundle bundle, List list, boolean z10) {
        int i10;
        int i11;
        String str2;
        String str3;
        m7 m7Var = this;
        boolean c02 = c0(str, j5.f.f6611g);
        if (bundle != null) {
            Bundle bundle2 = new Bundle(bundle);
            if (m().p().f0(201500000)) {
                i10 = 100;
            } else {
                i10 = 25;
            }
            Iterator it = new TreeSet(bundle.keySet()).iterator();
            int i12 = 0;
            while (it.hasNext()) {
                String str4 = (String) it.next();
                if (list != null && list.contains(str4)) {
                    i11 = 0;
                } else {
                    if (!z10) {
                        i11 = m7Var.z0(str4);
                    } else {
                        i11 = 0;
                    }
                    if (i11 == 0) {
                        i11 = m7Var.y0(str4);
                    }
                }
                if (i11 != 0) {
                    if (i11 == 3) {
                        str2 = str4;
                    } else {
                        str2 = null;
                    }
                    G(bundle2, i11, str4, str2);
                    bundle2.remove(str4);
                } else {
                    int w10 = w(str, str4, bundle.get(str4), bundle2, list, z10, c02);
                    if (w10 == 17) {
                        G(bundle2, w10, str4, Boolean.FALSE);
                    } else if (w10 != 0 && !"_ev".equals(str4)) {
                        if (w10 == 21) {
                            str3 = str;
                        } else {
                            str3 = str4;
                        }
                        G(bundle2, w10, str3, bundle.get(str4));
                        bundle2.remove(str4);
                    }
                    if (w0(str4)) {
                        int i13 = i12 + 1;
                        if (i13 > i10) {
                            String h10 = j6.c.h("Event can't contain more than ", i10, " params");
                            d4 c10 = c();
                            c10.f8896z.a(n().b(str), n().a(bundle), h10);
                            l0(5, bundle2);
                            bundle2.remove(str4);
                        }
                        m7Var = this;
                        i12 = i13;
                    }
                }
                m7Var = this;
            }
            return bundle2;
        }
        return null;
    }

    public final long B0() {
        int i10 = (this.f9091v.get() > 0L ? 1 : (this.f9091v.get() == 0L ? 0 : -1));
        synchronized (this.f9091v) {
            if (i10 == 0) {
                long nanoTime = System.nanoTime();
                ((c5.l) e()).getClass();
                long nextLong = new Random(nanoTime ^ System.currentTimeMillis()).nextLong();
                int i11 = this.f9092w + 1;
                this.f9092w = i11;
                return nextLong + i11;
            }
            this.f9091v.compareAndSet(-1L, 1L);
            return this.f9091v.getAndIncrement();
        }
    }

    public final v0.d C0() {
        int i10;
        w0.b bVar;
        if (this.f9093x == null) {
            Context a6 = a();
            q7.a.e("context", a6);
            StringBuilder sb2 = new StringBuilder("AdServicesInfo.version=");
            int i11 = Build.VERSION.SDK_INT;
            t0.a aVar = t0.a.f9969a;
            int i12 = 0;
            if (i11 >= 30) {
                i10 = aVar.a();
            } else {
                i10 = 0;
            }
            sb2.append(i10);
            Log.d("MeasurementManager", sb2.toString());
            if (i11 >= 30) {
                i12 = aVar.a();
            }
            v0.d dVar = null;
            if (i12 >= 5) {
                bVar = new w0.b(a6);
            } else {
                bVar = null;
            }
            if (bVar != null) {
                dVar = new v0.d(bVar);
            }
            this.f9093x = dVar;
        }
        return this.f9093x;
    }

    public final Object D(int i10, Object obj, boolean z10, boolean z11) {
        Parcelable[] parcelableArr;
        Bundle i0;
        if (obj == null) {
            return null;
        }
        if ((obj instanceof Long) || (obj instanceof Double)) {
            return obj;
        }
        if (obj instanceof Integer) {
            return Long.valueOf(((Integer) obj).intValue());
        }
        if (obj instanceof Byte) {
            return Long.valueOf(((Byte) obj).byteValue());
        }
        if (obj instanceof Short) {
            return Long.valueOf(((Short) obj).shortValue());
        }
        if (obj instanceof Boolean) {
            return Long.valueOf(((Boolean) obj).booleanValue() ? 1L : 0L);
        } else if (obj instanceof Float) {
            return Double.valueOf(((Float) obj).doubleValue());
        } else {
            if ((obj instanceof String) || (obj instanceof Character) || (obj instanceof CharSequence)) {
                return E(i10, String.valueOf(obj), z10);
            }
            if (z11 && ((obj instanceof Bundle[]) || (obj instanceof Parcelable[]))) {
                ArrayList arrayList = new ArrayList();
                for (Parcelable parcelable : (Parcelable[]) obj) {
                    if ((parcelable instanceof Bundle) && (i0 = i0((Bundle) parcelable)) != null && !i0.isEmpty()) {
                        arrayList.add(i0);
                    }
                }
                return arrayList.toArray(new Bundle[arrayList.size()]);
            }
            return null;
        }
    }

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

    public final v F(String str, Bundle bundle, String str2, long j10, boolean z10) {
        Bundle bundle2;
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        if (u(str) == 0) {
            if (bundle != null) {
                bundle2 = new Bundle(bundle);
            } else {
                bundle2 = new Bundle();
            }
            bundle2.putString("_o", str2);
            Bundle B2 = B(str, bundle2, Collections.singletonList("_o"), true);
            if (z10) {
                B2 = i0(B2);
            }
            com.bumptech.glide.f.j(B2);
            return new v(str, new t(B2), str2, j10);
        }
        d4 c10 = c();
        c10.f8894x.c("Invalid conditional property event name", n().g(str));
        throw new IllegalArgumentException();
    }

    public final SecureRandom F0() {
        q();
        if (this.f9090u == null) {
            this.f9090u = new SecureRandom();
        }
        return this.f9090u;
    }

    public final boolean G0() {
        q();
        return v0() == 1;
    }

    public final void H(Bundle bundle, long j10) {
        long j11 = bundle.getLong("_et");
        if (j11 != 0) {
            d4 c10 = c();
            c10.A.c("Params already contained engagement", Long.valueOf(j11));
        }
        bundle.putLong("_et", j10 + j11);
    }

    public final void H0() {
        q();
        SecureRandom secureRandom = new SecureRandom();
        long nextLong = secureRandom.nextLong();
        if (nextLong == 0) {
            nextLong = secureRandom.nextLong();
            if (nextLong == 0) {
                c().A.b("Utils falling back to Random for random id");
            }
        }
        this.f9091v.set(nextLong);
    }

    public final void I(Bundle bundle, Bundle bundle2) {
        if (bundle2 == null) {
            return;
        }
        for (String str : bundle2.keySet()) {
            if (!bundle.containsKey(str)) {
                p().J(bundle, str, bundle2.get(str));
            }
        }
    }

    public final void J(Bundle bundle, String str, Object obj) {
        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) {
            String simpleName = obj != null ? obj.getClass().getSimpleName() : null;
            c().C.a(n().f(str), simpleName, "Not putting event parameter. Invalid value type. name, type");
        }
    }

    public final void K(com.google.android.gms.internal.measurement.t0 t0Var, int i10) {
        Bundle bundle = new Bundle();
        bundle.putInt("r", i10);
        try {
            t0Var.d(bundle);
        } catch (RemoteException e10) {
            d4 d4Var = ((y4) this.f10942s).A;
            y4.i(d4Var);
            d4Var.A.c("Error returning int value to wrapper", e10);
        }
    }

    public final void L(com.google.android.gms.internal.measurement.t0 t0Var, long j10) {
        Bundle bundle = new Bundle();
        bundle.putLong("r", j10);
        try {
            t0Var.d(bundle);
        } catch (RemoteException e10) {
            d4 d4Var = ((y4) this.f10942s).A;
            y4.i(d4Var);
            d4Var.A.c("Error returning long value to wrapper", e10);
        }
    }

    public final void M(com.google.android.gms.internal.measurement.t0 t0Var, ArrayList arrayList) {
        Bundle bundle = new Bundle();
        bundle.putParcelableArrayList("r", arrayList);
        try {
            t0Var.d(bundle);
        } catch (RemoteException e10) {
            d4 d4Var = ((y4) this.f10942s).A;
            y4.i(d4Var);
            d4Var.A.c("Error returning bundle list to wrapper", e10);
        }
    }

    public final void N(com.google.android.gms.internal.measurement.t0 t0Var, boolean z10) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("r", z10);
        try {
            t0Var.d(bundle);
        } catch (RemoteException e10) {
            d4 d4Var = ((y4) this.f10942s).A;
            y4.i(d4Var);
            d4Var.A.c("Error returning boolean value to wrapper", e10);
        }
    }

    public final void O(com.google.android.gms.internal.measurement.t0 t0Var, byte[] bArr) {
        Bundle bundle = new Bundle();
        bundle.putByteArray("r", bArr);
        try {
            t0Var.d(bundle);
        } catch (RemoteException e10) {
            d4 d4Var = ((y4) this.f10942s).A;
            y4.i(d4Var);
            d4Var.A.c("Error returning byte array to wrapper", e10);
        }
    }

    public final void P(String str, com.google.android.gms.internal.measurement.t0 t0Var) {
        Bundle bundle = new Bundle();
        bundle.putString("r", str);
        try {
            t0Var.d(bundle);
        } catch (RemoteException e10) {
            d4 d4Var = ((y4) this.f10942s).A;
            y4.i(d4Var);
            d4Var.A.c("Error returning string value to wrapper", e10);
        }
    }

    public final void Q(String str, String str2, Bundle bundle, List list, boolean z10) {
        int i10;
        int i11;
        String str3;
        int w10;
        String str4;
        String b8;
        String a6;
        f4 f4Var;
        String str5;
        String str6;
        if (bundle == null) {
            return;
        }
        f m10 = m();
        m10.getClass();
        ga.b();
        String str7 = null;
        if (m10.m().z(null, x.A0) && m10.p().f0(231100000)) {
            i10 = 35;
        } else {
            i10 = 0;
        }
        Iterator it = new TreeSet(bundle.keySet()).iterator();
        int i12 = 0;
        while (it.hasNext()) {
            String str8 = (String) it.next();
            if (list != null && list.contains(str8)) {
                i11 = 0;
            } else {
                if (!z10) {
                    i11 = z0(str8);
                } else {
                    i11 = 0;
                }
                if (i11 == 0) {
                    i11 = y0(str8);
                }
            }
            if (i11 != 0) {
                if (i11 == 3) {
                    str6 = str8;
                } else {
                    str6 = str7;
                }
                G(bundle, i11, str8, str6);
                bundle.remove(str8);
                str4 = str7;
            } else {
                if (Y(bundle.get(str8))) {
                    c().C.d("Nested Bundle parameters are not allowed; discarded. event name, param name, child param name", str, str2, str8);
                    w10 = 22;
                    str3 = str8;
                } else {
                    str3 = str8;
                    w10 = w(str, str8, bundle.get(str8), bundle, list, z10, false);
                }
                if (w10 != 0 && !"_ev".equals(str3)) {
                    G(bundle, w10, str3, bundle.get(str3));
                    bundle.remove(str3);
                } else if (w0(str3) && !c0(str3, h5.a.f5770l)) {
                    int i13 = i12 + 1;
                    int i14 = 23;
                    if (!f0(231100000)) {
                        d4 c10 = c();
                        b8 = n().b(str);
                        String a10 = n().a(bundle);
                        f4Var = c10.f8896z;
                        str5 = "Item array not supported on client's version of Google Play Services (Android Only)";
                        a6 = a10;
                        str4 = null;
                    } else if (i13 > i10) {
                        ga.b();
                        str4 = null;
                        if (m().z(null, x.A0)) {
                            d4 c11 = c();
                            String h10 = j6.c.h("Item can't contain more than ", i10, " item-scoped custom params");
                            c11.f8896z.a(n().b(str), n().a(bundle), h10);
                            i14 = 28;
                            l0(i14, bundle);
                            bundle.remove(str3);
                            i12 = i13;
                        } else {
                            d4 c12 = c();
                            b8 = n().b(str);
                            a6 = n().a(bundle);
                            f4Var = c12.f8896z;
                            str5 = "Item cannot contain custom parameters";
                        }
                    } else {
                        str4 = null;
                        i12 = i13;
                    }
                    f4Var.a(b8, a6, str5);
                    l0(i14, bundle);
                    bundle.remove(str3);
                    i12 = i13;
                }
                str4 = null;
            }
            str7 = str4;
        }
    }

    public final void R(h4 h4Var, int i10) {
        Object obj = h4Var.f8964e;
        Iterator it = new TreeSet(((Bundle) obj).keySet()).iterator();
        int i11 = 0;
        while (it.hasNext()) {
            String str = (String) it.next();
            if (w0(str) && (i11 = i11 + 1) > i10) {
                Bundle bundle = (Bundle) obj;
                c().f8896z.a(n().b((String) h4Var.f8962c), n().a(bundle), j6.c.h("Event can't contain more than ", i10, " params"));
                l0(5, bundle);
                bundle.remove(str);
            }
        }
    }

    public final void U(Parcelable[] parcelableArr, int i10, boolean z10) {
        int i11;
        com.bumptech.glide.f.j(parcelableArr);
        for (Parcelable parcelable : parcelableArr) {
            Bundle bundle = (Bundle) parcelable;
            Iterator it = new TreeSet(bundle.keySet()).iterator();
            int i12 = 0;
            while (it.hasNext()) {
                String str = (String) it.next();
                if (w0(str) && !c0(str, h5.a.f5770l) && (i12 = i12 + 1) > i10) {
                    f4 f4Var = c().f8896z;
                    if (z10) {
                        f4Var.a(n().f(str), n().a(bundle), j6.c.h("Param can't contain more than ", i10, " item-scoped custom parameters"));
                        i11 = 28;
                    } else {
                        f4Var.a(n().f(str), n().a(bundle), "Param cannot contain item-scoped custom parameters");
                        i11 = 23;
                    }
                    l0(i11, bundle);
                    bundle.remove(str);
                }
            }
        }
    }

    public final boolean V(int i10, String str, String str2) {
        if (str2 == null) {
            c().f8896z.c("Name is required and can't be null. Type", str);
            return false;
        } else if (str2.codePointCount(0, str2.length()) > i10) {
            d4 c10 = c();
            c10.f8896z.d("Name is too long. Type, maximum supported length, name", str, Integer.valueOf(i10), str2);
            return false;
        } else {
            return true;
        }
    }

    public final boolean Z(String str, String str2) {
        boolean isEmpty = TextUtils.isEmpty(str);
        Object obj = this.f10942s;
        if (!isEmpty) {
            com.bumptech.glide.f.j(str);
            if (!str.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$")) {
                if (TextUtils.isEmpty(((y4) obj).f9398t)) {
                    d4 c10 = c();
                    c10.f8896z.c("Invalid google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI. provided id", d4.w(str));
                }
                return false;
            }
            return true;
        } else if (!TextUtils.isEmpty(str2)) {
            com.bumptech.glide.f.j(str2);
            if (!str2.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$")) {
                d4 c11 = c();
                c11.f8896z.c("Invalid admob_app_id. Analytics disabled.", d4.w(str2));
                return false;
            }
            return true;
        } else {
            if (TextUtils.isEmpty(((y4) obj).f9398t)) {
                c().f8896z.b("Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI");
            }
            return false;
        }
    }

    public final boolean a0(String str, String str2, int i10, 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 valueOf = String.valueOf(obj);
            if (valueOf.codePointCount(0, valueOf.length()) > i10) {
                d4 c10 = c();
                c10.C.d("Value is too long; discarded. Value kind, name, value length", str, str2, Integer.valueOf(valueOf.length()));
                return false;
            }
        }
        return true;
    }

    public final boolean d0(String str, String[] strArr, String[] strArr2, String str2) {
        boolean z10;
        if (str2 == null) {
            c().f8896z.c("Name is required and can't be null. Type", str);
            return false;
        }
        String[] strArr3 = A;
        int i10 = 0;
        while (true) {
            if (i10 >= 3) {
                z10 = false;
                break;
            } else if (str2.startsWith(strArr3[i10])) {
                z10 = true;
                break;
            } else {
                i10++;
            }
        }
        if (z10) {
            c().f8896z.a(str, str2, "Name starts with reserved prefix. Type, name");
            return false;
        } else if (strArr == null || !c0(str2, strArr) || (strArr2 != null && c0(str2, strArr2))) {
            return true;
        } else {
            c().f8896z.a(str, str2, "Name is reserved. Type, name");
            return false;
        }
    }

    public final boolean f0(int i10) {
        Boolean bool = ((y4) this.f10942s).r().f9086w;
        if (t0() < i10 / 1000) {
            if (bool == null || bool.booleanValue()) {
                return false;
            }
            return true;
        }
        return true;
    }

    public final int h0(String str) {
        if (!n0("user property", str)) {
            return 6;
        }
        if (!d0("user property", jb.a.f6766c, null, str)) {
            return 15;
        }
        if (!V(24, "user property", str)) {
            return 6;
        }
        return 0;
    }

    public final Bundle i0(Bundle bundle) {
        Bundle bundle2 = new Bundle();
        if (bundle != null) {
            for (String str : bundle.keySet()) {
                Object j02 = j0(str, bundle.get(str));
                if (j02 == null) {
                    d4 c10 = c();
                    c10.C.c("Param value can't be null", n().f(str));
                } else {
                    J(bundle2, str, j02);
                }
            }
        }
        return bundle2;
    }

    public final Object j0(String str, Object obj) {
        int t10;
        boolean equals = "_ev".equals(str);
        Object obj2 = this.f10942s;
        if (equals) {
            return D(Math.max(m().t(((y4) obj2).p().B()), 256), obj, true, true);
        }
        if (u0(str)) {
            t10 = Math.max(m().t(((y4) obj2).p().B()), 256);
        } else {
            t10 = m().t(((y4) obj2).p().B());
        }
        return D(t10, obj, false, true);
    }

    public final boolean m0(Context context, String str) {
        d4 c10;
        String str2;
        Signature[] signatureArr;
        X500Principal x500Principal = new X500Principal("CN=Android Debug,O=Android,C=US");
        try {
            PackageInfo c11 = h5.b.a(context).c(str, 64);
            if (c11 == null || (signatureArr = c11.signatures) == null || signatureArr.length <= 0) {
                return true;
            }
            return ((X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(signatureArr[0].toByteArray()))).getSubjectX500Principal().equals(x500Principal);
        } catch (PackageManager.NameNotFoundException e10) {
            e = e10;
            c10 = c();
            str2 = "Package name not found";
            c10.f8894x.c(str2, e);
            return true;
        } catch (CertificateException e11) {
            e = e11;
            c10 = c();
            str2 = "Error obtaining certificate";
            c10.f8894x.c(str2, e);
            return true;
        }
    }

    public final boolean n0(String str, String str2) {
        if (str2 == null) {
            c().f8896z.c("Name is required and can't be null. Type", str);
            return false;
        } else if (str2.length() == 0) {
            c().f8896z.c("Name is required and can't be empty. Type", str);
            return false;
        } else {
            int codePointAt = str2.codePointAt(0);
            if (!Character.isLetter(codePointAt) && codePointAt != 95) {
                c().f8896z.a(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)) {
                    c().f8896z.a(str, str2, "Name must consist of letters, digits or _ (underscores). Type, name");
                    return false;
                }
                charCount += Character.charCount(codePointAt2);
            }
            return true;
        }
    }

    public final Object o0(String str, Object obj) {
        boolean equals = "_ldl".equals(str);
        int A0 = A0(str);
        return equals ? D(A0, obj, true, false) : D(A0, obj, false, false);
    }

    public final boolean q0(String str, String str2) {
        if (str2 == null) {
            c().f8896z.c("Name is required and can't be null. Type", str);
            return false;
        } else if (str2.length() == 0) {
            c().f8896z.c("Name is required and can't be empty. Type", str);
            return false;
        } else {
            int codePointAt = str2.codePointAt(0);
            if (!Character.isLetter(codePointAt)) {
                c().f8896z.a(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)) {
                    c().f8896z.a(str, str2, "Name must consist of letters, digits or _ (underscores). Type, name");
                    return false;
                }
                charCount += Character.charCount(codePointAt2);
            }
            return true;
        }
    }

    public final boolean s0(String str) {
        q();
        if (h5.b.a(a()).f1477t.checkCallingOrSelfPermission(str) == 0) {
            return true;
        }
        c().E.c("Permission not granted", str);
        return false;
    }

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

    public final int t0() {
        if (this.f9095z == null) {
            z4.f fVar = z4.f.f11661b;
            Context a6 = a();
            fVar.getClass();
            AtomicBoolean atomicBoolean = z4.i.f11663a;
            int i10 = 0;
            try {
                i10 = a6.getPackageManager().getPackageInfo("com.google.android.gms", 0).versionCode;
            } catch (PackageManager.NameNotFoundException unused) {
                Log.w("GooglePlayServicesUtil", "Google Play services is missing.");
            }
            this.f9095z = Integer.valueOf(i10 / 1000);
        }
        return this.f9095z.intValue();
    }

    public final int u(String str) {
        if (n0("event", str)) {
            if (d0("event", j5.f.f6608d, j5.f.f6609e, str)) {
                return !V(40, "event", str) ? 2 : 0;
            }
            return 13;
        }
        return 2;
    }

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

    public final long v0() {
        int extensionVersion;
        int i10;
        long j10;
        int extensionVersion2;
        Object e10;
        Integer num;
        q();
        if (!r0(((y4) this.f10942s).p().B())) {
            return 0L;
        }
        int i11 = Build.VERSION.SDK_INT;
        boolean z10 = false;
        Integer num2 = null;
        if (i11 >= 30) {
            extensionVersion = SdkExtensions.getExtensionVersion(30);
            if (extensionVersion < 4) {
                j10 = 8;
            } else {
                if (i11 >= 30) {
                    extensionVersion2 = SdkExtensions.getExtensionVersion(30);
                    if (extensionVersion2 > 3) {
                        i10 = SdkExtensions.getExtensionVersion(1000000);
                        if (i10 >= ((Integer) x.V.a(null)).intValue()) {
                            j10 = 16;
                        } else {
                            j10 = 0;
                        }
                    }
                }
                i10 = 0;
                if (i10 >= ((Integer) x.V.a(null)).intValue()) {
                }
            }
        } else {
            j10 = 4;
        }
        if (!s0("android.permission.ACCESS_ADSERVICES_ATTRIBUTION")) {
            j10 |= 2;
        }
        if (j10 == 0) {
            if (this.f9094y == null) {
                v0.d C0 = C0();
                if (C0 != null) {
                    try {
                        num = (Integer) C0.b().get(10000L, TimeUnit.MILLISECONDS);
                        if (num != null) {
                            try {
                                if (num.intValue() == 1) {
                                    z10 = true;
                                }
                            } catch (InterruptedException | CancellationException | ExecutionException | TimeoutException e11) {
                                e10 = e11;
                                num2 = num;
                                c().A.c("Measurement manager api exception", e10);
                                this.f9094y = Boolean.FALSE;
                                num = num2;
                                c().F.c("Measurement manager api status result", num);
                                z10 = this.f9094y.booleanValue();
                                if (!z10) {
                                }
                                if (j10 != 0) {
                                }
                            }
                        }
                        this.f9094y = Boolean.valueOf(z10);
                    } catch (InterruptedException | CancellationException | ExecutionException | TimeoutException e12) {
                        e10 = e12;
                    }
                    c().F.c("Measurement manager api status result", num);
                }
                if (!z10) {
                    j10 |= 64;
                }
            }
            z10 = this.f9094y.booleanValue();
            if (!z10) {
            }
        }
        if (j10 != 0) {
            return 1L;
        }
        return j10;
    }

    public final int w(String str, String str2, Object obj, Bundle bundle, List list, boolean z10, boolean z11) {
        int i10;
        Parcelable[] parcelableArr;
        int size;
        boolean z12;
        q();
        boolean Y = Y(obj);
        Object obj2 = this.f10942s;
        boolean z13 = true;
        if (Y) {
            if (!z11) {
                return 21;
            }
            if (!c0(str2, h5.a.f5769k)) {
                return 20;
            }
            m6 r10 = ((y4) obj2).r();
            r10.q();
            r10.y();
            if (!(!r10.M() || r10.p().t0() >= 200900)) {
                return 25;
            }
            boolean z14 = obj instanceof Parcelable[];
            if (z14) {
                size = ((Parcelable[]) obj).length;
            } else {
                if (obj instanceof ArrayList) {
                    size = ((ArrayList) obj).size();
                }
                z12 = true;
                if (!z12) {
                    if (z14) {
                        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 (a0("param", str2, (!u0(str) || u0(str2)) ? Math.max(m().t(((y4) obj2).p().B()), 256) : m().t(((y4) obj2).p().B()), obj)) {
                        if (z11) {
                            if (!(obj instanceof Bundle)) {
                                if (!(obj instanceof Parcelable[])) {
                                    if (obj instanceof ArrayList) {
                                        ArrayList arrayList2 = (ArrayList) obj;
                                        int size2 = arrayList2.size();
                                        int i11 = 0;
                                        while (i11 < size2) {
                                            Object obj3 = arrayList2.get(i11);
                                            int i12 = i11 + 1;
                                            if (obj3 instanceof Bundle) {
                                                Q(str, str2, (Bundle) obj3, list, z10);
                                                i11 = i12;
                                            } else {
                                                c().C.a(obj3 != null ? obj3.getClass() : "null", str2, "All ArrayList elements must be of type Bundle. Value type, name");
                                            }
                                        }
                                    }
                                    z13 = false;
                                    break;
                                }
                                for (Parcelable parcelable : (Parcelable[]) obj) {
                                    if (!(parcelable instanceof Bundle)) {
                                        c().C.a(parcelable.getClass(), str2, "All Parcelable[] elements must be of type Bundle. Value type, name");
                                        z13 = false;
                                        break;
                                    }
                                    Q(str, str2, (Bundle) parcelable, list, z10);
                                }
                            } else {
                                Q(str, str2, (Bundle) obj, list, z10);
                            }
                            if (z13) {
                                return i10;
                            }
                            return 4;
                        }
                        return 4;
                    }
                    return i10;
                }
            }
            if (size > 200) {
                c().C.d("Parameter array is too long; discarded. Value kind, name, array length", "param", str2, Integer.valueOf(size));
                z12 = false;
                if (!z12) {
                }
            }
            z12 = true;
            if (!z12) {
            }
        }
        i10 = 0;
        if (a0("param", str2, (!u0(str) || u0(str2)) ? Math.max(m().t(((y4) obj2).p().B()), 256) : m().t(((y4) obj2).p().B()), obj)) {
        }
    }

    public final boolean x0(String str) {
        List<ResolveInfo> queryIntentActivities;
        return (TextUtils.isEmpty(str) || (queryIntentActivities = a().getPackageManager().queryIntentActivities(new Intent("android.intent.action.VIEW", Uri.parse(str)), 0)) == null || queryIntentActivities.isEmpty()) ? false : true;
    }

    public final int y0(String str) {
        if (!n0("event param", str)) {
            return 3;
        }
        if (!d0("event param", null, null, str)) {
            return 14;
        }
        if (!V(40, "event param", str)) {
            return 3;
        }
        return 0;
    }

    public final int z0(String str) {
        if (!q0("event param", str)) {
            return 3;
        }
        if (!d0("event param", null, null, str)) {
            return 14;
        }
        if (!V(40, "event param", str)) {
            return 3;
        }
        return 0;
    }
}