Anti Spy v30.16.1.24版本的 MD5 值为:c71fa7f3f1aa08291411b9a5a8b2e65d

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


package c5;

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 com.applovin.sdk.AppLovinEventTypes;
import com.google.android.gms.common.URET;
import com.google.android.gms.internal.ads.hr0;
import com.google.android.gms.internal.ads.zt0;
import com.google.android.gms.internal.measurement.o9;
import com.google.android.gms.internal.measurement.p9;
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.AtomicLong;
import javax.security.auth.x500.X500Principal;
public final class g7 extends f5 {
    public static final String[] f2053i = {"firebase_", "google_", "ga_"};
    public static final String[] f2054j = {"_err"};
    public SecureRandom f2055c;
    public final AtomicLong f2056d;
    public int f2057e;
    public q1.d f2058f;
    public Boolean f2059g;
    public Integer f2060h;

    public g7(y4 y4Var) {
        super(y4Var);
        this.f2060h = null;
        this.f2056d = new AtomicLong(0L);
    }

    public static String C(boolean z10, String str, int i10) {
        if (str == null) {
            return null;
        }
        if (str.codePointCount(0, str.length()) > i10) {
            if (z10) {
                return zt0.m(str.substring(0, str.offsetByCodePoints(0, i10)), "...");
            }
            return null;
        }
        return str;
    }

    public static void D(Bundle bundle, int i10, String str, Object obj) {
        if (j0(i10, bundle)) {
            bundle.putString("_ev", C(true, str, 40));
            if (obj != null) {
                if ((obj instanceof String) || (obj instanceof CharSequence)) {
                    bundle.putLong("_el", String.valueOf(obj).length());
                }
            }
        }
    }

    public static void H(e6 e6Var, Bundle bundle, boolean z10) {
        if (bundle == null || e6Var == null || (bundle.containsKey("_sc") && !z10)) {
            if (bundle != null && e6Var == null && z10) {
                bundle.remove("_sn");
                bundle.remove("_sc");
                bundle.remove("_si");
                return;
            }
            return;
        }
        String str = e6Var.f2017a;
        if (str != null) {
            bundle.putString("_sn", str);
        } else {
            bundle.remove("_sn");
        }
        String str2 = e6Var.f2018b;
        if (str2 != null) {
            bundle.putString("_sc", str2);
        } else {
            bundle.remove("_sc");
        }
        bundle.putLong("_si", e6Var.f2019c);
    }

    public static void I(i7 i7Var, String str, int i10, String str2, String str3, int i11) {
        Bundle bundle = new Bundle();
        j0(i10, bundle);
        if (!TextUtils.isEmpty(str2) && !TextUtils.isEmpty(str3)) {
            bundle.putString(str2, str3);
        }
        if (i10 == 6 || i10 == 7 || i10 == 2) {
            bundle.putLong("_el", i11);
        }
        i7Var.m0(str, "_err", bundle);
    }

    public static boolean U(Context context) {
        ActivityInfo receiverInfo;
        e6.h.l(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 V(Intent intent) {
        String stringExtra = intent.getStringExtra("android.intent.extra.REFERRER_NAME");
        if (!"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)) {
            return false;
        }
        return true;
    }

    public static boolean W(Object obj) {
        if (!(obj instanceof Parcelable[]) && !(obj instanceof ArrayList) && !(obj instanceof Bundle)) {
            return false;
        }
        return true;
    }

    public static boolean Z(String str, String str2, String str3, String str4) {
        boolean isEmpty = TextUtils.isEmpty(str);
        boolean isEmpty2 = TextUtils.isEmpty(str2);
        boolean z10 = true;
        if (!isEmpty && !isEmpty2) {
            e6.h.l(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) {
            if (TextUtils.isEmpty(str4)) {
                return false;
            }
            return TextUtils.isEmpty(str3) || !str3.equals(str4);
        } else {
            if (!TextUtils.isEmpty(str3) && str3.equals(str4)) {
                return false;
            }
            return true;
        }
    }

    public static boolean a0(String str, String[] strArr) {
        e6.h.l(strArr);
        for (String str2 : strArr) {
            if (str == str2 || (str != null && str.equals(str2))) {
                return true;
            }
        }
        return false;
    }

    public static byte[] c0(Parcelable parcelable) {
        if (parcelable == null) {
            return null;
        }
        Parcel obtain = Parcel.obtain();
        try {
            parcelable.writeToParcel(obtain, 0);
            byte[] marshall = obtain.marshall();
            obtain.recycle();
            return marshall;
        } catch (Throwable th) {
            obtain.recycle();
            throw th;
        }
    }

    public static boolean e0(Context context) {
        e6.h.l(context);
        return Build.VERSION.SDK_INT >= 24 ? n0(context, "com.google.android.gms.measurement.AppMeasurementJobService") : n0(context, "com.google.android.gms.measurement.AppMeasurementService");
    }

    public static ArrayList i0(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.f1994a);
            bundle.putString("origin", eVar.f1995b);
            bundle.putLong("creation_timestamp", eVar.f1997d);
            bundle.putString("name", eVar.f1996c.f2036b);
            Object g2 = eVar.f1996c.g();
            e6.h.l(g2);
            hr0.U(bundle, g2);
            bundle.putBoolean("active", eVar.f1998n);
            String str = eVar.f1999o;
            if (str != null) {
                bundle.putString("trigger_event_name", str);
            }
            u uVar = eVar.f2000p;
            if (uVar != null) {
                bundle.putString("timed_out_event_name", uVar.f2403a);
                s sVar = uVar.f2404b;
                if (sVar != null) {
                    bundle.putBundle("timed_out_event_params", sVar.l());
                }
            }
            bundle.putLong("trigger_timeout", eVar.f2001q);
            u uVar2 = eVar.f2002r;
            if (uVar2 != null) {
                bundle.putString("triggered_event_name", uVar2.f2403a);
                s sVar2 = uVar2.f2404b;
                if (sVar2 != null) {
                    bundle.putBundle("triggered_event_params", sVar2.l());
                }
            }
            bundle.putLong("triggered_timestamp", eVar.f1996c.f2037c);
            bundle.putLong("time_to_live", eVar.f2003s);
            u uVar3 = eVar.f2004t;
            if (uVar3 != null) {
                bundle.putString("expired_event_name", uVar3.f2403a);
                s sVar3 = uVar3.f2404b;
                if (sVar3 != null) {
                    bundle.putBundle("expired_event_params", sVar3.l());
                }
            }
            arrayList.add(bundle);
        }
        return arrayList;
    }

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

    public static boolean n0(Context context, String str) {
        PackageManager packageManager;
        try {
            packageManager = context.getPackageManager();
        } catch (PackageManager.NameNotFoundException unused) {
        }
        if (packageManager == null) {
            return false;
        }
        ServiceInfo serviceInfo = packageManager.getServiceInfo(new ComponentName(context, str), 0);
        if (serviceInfo != null) {
            if (serviceInfo.enabled) {
                return true;
            }
        }
        return false;
    }

    public static boolean p0(String str) {
        String str2 = (String) w.Z.a(null);
        if (!str2.equals("*") && !Arrays.asList(str2.split(",")).contains(str)) {
            return false;
        }
        return true;
    }

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

    public static boolean u0(String str) {
        e6.h.i(str);
        if (str.charAt(0) == '_' && !str.equals("_ep")) {
            return false;
        }
        return true;
    }

    public static long v(s sVar) {
        long j10 = 0;
        if (sVar == null) {
            return 0L;
        }
        Bundle bundle = sVar.f2335a;
        for (String str : bundle.keySet()) {
            Object obj = bundle.get(str);
            if (obj instanceof Parcelable[]) {
                j10 += ((Parcelable[]) obj).length;
            }
        }
        return j10;
    }

    public static long w(byte[] bArr) {
        e6.h.l(bArr);
        int i10 = 0;
        e6.h.n(bArr.length > 0);
        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;
    }

    public static int w0(String str) {
        if ("_ldl".equals(str)) {
            return 2048;
        }
        if ("_id".equals(str)) {
            return 256;
        }
        if (!"_lgclid".equals(str) && !"_gbraid".equals(str)) {
            return 36;
        }
        return 100;
    }

    public static Bundle z(List list) {
        Bundle bundle = new Bundle();
        if (list == null) {
            return bundle;
        }
        Iterator it = list.iterator();
        while (it.hasNext()) {
            f7 f7Var = (f7) it.next();
            String str = f7Var.f2039n;
            String str2 = f7Var.f2036b;
            if (str != null) {
                bundle.putString(str2, str);
            } else {
                Long l10 = f7Var.f2038d;
                if (l10 != null) {
                    bundle.putLong(str2, l10.longValue());
                } else {
                    Double d10 = f7Var.f2041p;
                    if (d10 != null) {
                        bundle.putDouble(str2, d10.doubleValue());
                    }
                }
            }
        }
        return bundle;
    }

    public static MessageDigest z0() {
        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 final u A(String str, Bundle bundle, String str2, long j10, boolean z10) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        if (t(str) != 0) {
            i().f1952f.a(k().g(str), "Invalid conditional property event name");
            throw new IllegalArgumentException();
        }
        Bundle bundle2 = bundle != null ? new Bundle(bundle) : new Bundle();
        bundle2.putString("_o", str2);
        Bundle y10 = y(str, bundle2, Collections.singletonList("_o"), true);
        if (z10) {
            y10 = g0(y10);
        }
        e6.h.l(y10);
        return new u(str, new s(y10), str2, j10);
    }

    public final SecureRandom A0() {
        n();
        if (this.f2055c == null) {
            this.f2055c = new SecureRandom();
        }
        return this.f2055c;
    }

    public final Object B(int i10, Object obj, boolean z10, boolean z11) {
        Parcelable[] parcelableArr;
        Bundle g02;
        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) {
                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)) {
                    if (z11 && ((obj instanceof Bundle[]) || (obj instanceof Parcelable[]))) {
                        ArrayList arrayList = new ArrayList();
                        boolean z12 = true & false;
                        for (Parcelable parcelable : (Parcelable[]) obj) {
                            if ((parcelable instanceof Bundle) && (g02 = g0((Bundle) parcelable)) != null && !g02.isEmpty()) {
                                arrayList.add(g02);
                            }
                        }
                        return arrayList.toArray(new Bundle[arrayList.size()]);
                    }
                    return null;
                }
                return C(z10, String.valueOf(obj), i10);
            }
        }
        return obj;
    }

    public final void B0() {
        n();
        SecureRandom secureRandom = new SecureRandom();
        long nextLong = secureRandom.nextLong();
        if (nextLong == 0) {
            nextLong = secureRandom.nextLong();
            if (nextLong == 0) {
                i().f1955i.d("Utils falling back to Random for random id");
            }
        }
        this.f2056d.set(nextLong);
    }

    public final void E(Bundle bundle, long j10) {
        long j11 = bundle.getLong("_et");
        if (j11 != 0) {
            c4 i10 = i();
            i10.f1955i.a(Long.valueOf(j11), "Params already contained engagement");
        }
        bundle.putLong("_et", j10 + j11);
    }

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

    public final void G(e4 e4Var, int i10) {
        Iterator it = new TreeSet(((Bundle) e4Var.f2013e).keySet()).iterator();
        int i11 = 0;
        while (it.hasNext()) {
            String str = (String) it.next();
            if (u0(str) && (i11 = i11 + 1) > i10) {
                i().f1954h.b(k().c((String) e4Var.f2011c), zt0.l("Event can't contain more than ", i10, " params"), k().a((Bundle) e4Var.f2013e));
                j0(5, (Bundle) e4Var.f2013e);
                ((Bundle) e4Var.f2013e).remove(str);
            }
        }
    }

    public final void J(com.google.android.gms.internal.measurement.t0 t0Var, int i10) {
        Bundle bundle = new Bundle();
        bundle.putInt("r", i10);
        try {
            t0Var.l0(bundle);
        } catch (RemoteException e10) {
            c4 c4Var = ((y4) this.f17669a).f2545i;
            y4.e(c4Var);
            c4Var.f1955i.a(e10, "Error returning int value to wrapper");
        }
    }

    public final void K(com.google.android.gms.internal.measurement.t0 t0Var, long j10) {
        Bundle bundle = new Bundle();
        bundle.putLong("r", j10);
        try {
            t0Var.l0(bundle);
        } catch (RemoteException e10) {
            c4 c4Var = ((y4) this.f17669a).f2545i;
            y4.e(c4Var);
            c4Var.f1955i.a(e10, "Error returning long value to wrapper");
        }
    }

    public final void L(com.google.android.gms.internal.measurement.t0 t0Var, Bundle bundle) {
        try {
            t0Var.l0(bundle);
        } catch (RemoteException e10) {
            c4 c4Var = ((y4) this.f17669a).f2545i;
            y4.e(c4Var);
            c4Var.f1955i.a(e10, "Error returning bundle value to wrapper");
        }
    }

    public final void M(com.google.android.gms.internal.measurement.t0 t0Var, ArrayList arrayList) {
        Bundle bundle = new Bundle();
        bundle.putParcelableArrayList("r", arrayList);
        try {
            t0Var.l0(bundle);
        } catch (RemoteException e10) {
            c4 c4Var = ((y4) this.f17669a).f2545i;
            y4.e(c4Var);
            c4Var.f1955i.a(e10, "Error returning bundle list to wrapper");
        }
    }

    public final void N(com.google.android.gms.internal.measurement.t0 t0Var, boolean z10) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("r", z10);
        try {
            t0Var.l0(bundle);
        } catch (RemoteException e10) {
            c4 c4Var = ((y4) this.f17669a).f2545i;
            y4.e(c4Var);
            c4Var.f1955i.a(e10, "Error returning boolean value to wrapper");
        }
    }

    public final void O(com.google.android.gms.internal.measurement.t0 t0Var, byte[] bArr) {
        Bundle bundle = new Bundle();
        bundle.putByteArray("r", bArr);
        try {
            t0Var.l0(bundle);
        } catch (RemoteException e10) {
            c4 c4Var = ((y4) this.f17669a).f2545i;
            y4.e(c4Var);
            c4Var.f1955i.a(e10, "Error returning byte array to wrapper");
        }
    }

    public final void P(String str, com.google.android.gms.internal.measurement.t0 t0Var) {
        Bundle bundle = new Bundle();
        bundle.putString("r", str);
        try {
            t0Var.l0(bundle);
        } catch (RemoteException e10) {
            c4 c4Var = ((y4) this.f17669a).f2545i;
            y4.e(c4Var);
            c4Var.f1955i.a(e10, "Error returning string value to wrapper");
        }
    }

    public final void Q(String str, Object obj, Bundle bundle) {
        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;
                i().f1957k.b(k().f(str), "Not putting event parameter. Invalid value type. name, type", simpleName);
            }
        }
    }

    public final void R(String str, String str2, Bundle bundle, List list, boolean z10) {
        int i10;
        String str3;
        int u10;
        if (bundle == null) {
            return;
        }
        f j10 = j();
        j10.getClass();
        ((o9) p9.f12380b.get()).getClass();
        int i11 = (j10.j().y(null, w.A0) && j10.m().d0(231100000)) ? 35 : 0;
        Iterator it = new TreeSet(bundle.keySet()).iterator();
        int i12 = 0;
        while (it.hasNext()) {
            String str4 = (String) it.next();
            if (list == null || !list.contains(str4)) {
                int i13 = 14;
                if (!z10) {
                    if (o0("event param", str4)) {
                        if (!b0("event param", null, null, str4)) {
                            i10 = 14;
                            if (i10 == 0) {
                                if (l0("event param", str4)) {
                                    if (b0("event param", null, null, str4)) {
                                        if (T(40, "event param", str4)) {
                                            i13 = 0;
                                        }
                                    }
                                    i10 = i13;
                                }
                                i13 = 3;
                                i10 = i13;
                            }
                        }
                    }
                    i10 = 3;
                    if (i10 == 0) {
                    }
                }
                i10 = 0;
                if (i10 == 0) {
                }
            } else {
                i10 = 0;
            }
            if (i10 != 0) {
                D(bundle, i10, str4, i10 == 3 ? str4 : null);
                bundle.remove(str4);
            } else {
                if (W(bundle.get(str4))) {
                    i().f1957k.c(str, "Nested Bundle parameters are not allowed; discarded. event name, param name, child param name", str2, str4);
                    u10 = 22;
                    str3 = str4;
                } else {
                    str3 = str4;
                    u10 = u(str, str4, bundle.get(str4), bundle, list, z10, false);
                }
                if (u10 != 0 && !"_ev".equals(str3)) {
                    D(bundle, u10, str3, bundle.get(str3));
                    bundle.remove(str3);
                } else if (u0(str3) && !a0(str3, k5.f2181j)) {
                    int i14 = i12 + 1;
                    if (!d0(231100000)) {
                        i().f1954h.b(k().c(str), "Item array not supported on client's version of Google Play Services (Android Only)", k().a(bundle));
                        j0(23, bundle);
                        bundle.remove(str3);
                    } else if (i14 > i11) {
                        ((o9) p9.f12380b.get()).getClass();
                        if (j().y(null, w.A0)) {
                            c4 i15 = i();
                            i15.f1954h.b(k().c(str), zt0.l("Item can't contain more than ", i11, " item-scoped custom params"), k().a(bundle));
                            j0(28, bundle);
                            bundle.remove(str3);
                        } else {
                            i().f1954h.b(k().c(str), "Item cannot contain custom parameters", k().a(bundle));
                            j0(23, bundle);
                            bundle.remove(str3);
                        }
                    }
                    i12 = i14;
                }
            }
        }
    }

    public final void S(Parcelable[] parcelableArr, int i10, boolean z10) {
        e6.h.l(parcelableArr);
        for (Parcelable parcelable : parcelableArr) {
            Bundle bundle = (Bundle) parcelable;
            Iterator it = new TreeSet(bundle.keySet()).iterator();
            int i11 = 0;
            while (it.hasNext()) {
                String str = (String) it.next();
                if (u0(str) && !a0(str, k5.f2181j) && (i11 = i11 + 1) > i10) {
                    if (z10) {
                        i().f1954h.b(k().f(str), zt0.l("Param can't contain more than ", i10, " item-scoped custom parameters"), k().a(bundle));
                        j0(28, bundle);
                    } else {
                        i().f1954h.b(k().f(str), "Param cannot contain item-scoped custom parameters", k().a(bundle));
                        j0(23, bundle);
                    }
                    bundle.remove(str);
                }
            }
        }
    }

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

    public final boolean X(String str, String str2) {
        boolean isEmpty = TextUtils.isEmpty(str);
        Object obj = this.f17669a;
        if (!isEmpty) {
            e6.h.l(str);
            if (!str.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$")) {
                if (TextUtils.isEmpty(((y4) obj).f2538b)) {
                    c4 i10 = i();
                    i10.f1954h.a(c4.s(str), "Invalid google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI. provided id");
                }
                return false;
            }
        } else if (TextUtils.isEmpty(str2)) {
            if (TextUtils.isEmpty(((y4) obj).f2538b)) {
                i().f1954h.d("Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI");
            }
            return false;
        } else {
            e6.h.l(str2);
            if (!str2.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$")) {
                c4 i11 = i();
                i11.f1954h.a(c4.s(str2), "Invalid admob_app_id. Analytics disabled.");
                return false;
            }
        }
        return true;
    }

    public final boolean Y(String str, String str2, int i10, Object obj) {
        if (obj == null) {
            return true;
        }
        if (!(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) {
                c4 i11 = i();
                i11.f1957k.c(str, "Value is too long; discarded. Value kind, name, value length", str2, Integer.valueOf(valueOf.length()));
                return false;
            }
        }
        return true;
    }

    public final boolean b0(String str, String[] strArr, String[] strArr2, String str2) {
        if (str2 == null) {
            i().f1954h.a(str, "Name is required and can't be null. Type");
            return false;
        }
        String[] strArr3 = f2053i;
        for (int i10 = 0; i10 < 3; i10++) {
            if (str2.startsWith(strArr3[i10])) {
                i().f1954h.b(str, "Name starts with reserved prefix. Type, name", str2);
                return false;
            }
        }
        if (strArr == null || !a0(str2, strArr)) {
            return true;
        }
        if (strArr2 == null || !a0(str2, strArr2)) {
            i().f1954h.b(str, "Name is reserved. Type, name", str2);
            return false;
        }
        return true;
    }

    public final boolean d0(int i10) {
        Boolean bool = ((y4) this.f17669a).q().f2048e;
        return s0() >= i10 / 1000 || !(bool == null || bool.booleanValue());
    }

    public final int f0(String str) {
        if (l0("user property", str)) {
            if (b0("user property", k5.f2176e, null, str)) {
                return !T(24, "user property", str) ? 6 : 0;
            }
            return 15;
        }
        return 6;
    }

    public final Bundle g0(Bundle bundle) {
        Bundle bundle2 = new Bundle();
        if (bundle != null) {
            for (String str : bundle.keySet()) {
                Object h02 = h0(bundle.get(str), str);
                if (h02 == null) {
                    c4 i10 = i();
                    i10.f1957k.a(k().f(str), "Param value can't be null");
                } else {
                    Q(str, h02, bundle2);
                }
            }
        }
        return bundle2;
    }

    public final Object h0(Object obj, String str) {
        boolean equals = "_ev".equals(str);
        Object obj2 = this.f17669a;
        if (equals) {
            return B(Math.max(j().s(((y4) obj2).o().y()), 256), obj, true, true);
        }
        return B(r0(str) ? Math.max(j().s(((y4) obj2).o().y()), 256) : j().s(((y4) obj2).o().y()), obj, false, true);
    }

    public final boolean k0(Context context, String str) {
        Signature[] signatureArr;
        X500Principal x500Principal = new X500Principal("CN=Android Debug,O=Android,C=US");
        try {
            PackageInfo c6 = m4.b.a(context).c(64, str);
            if (c6 != null && (signatureArr = c6.signatures) != null && signatureArr.length > 0) {
                Signature signature = signatureArr[0];
                return ((X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(URET.sigByte))).getSubjectX500Principal().equals(x500Principal);
            }
        } catch (PackageManager.NameNotFoundException e10) {
            i().f1952f.a(e10, "Package name not found");
        } catch (CertificateException e11) {
            i().f1952f.a(e11, "Error obtaining certificate");
        }
        return true;
    }

    public final boolean l0(String str, String str2) {
        if (str2 == null) {
            i().f1954h.a(str, "Name is required and can't be null. Type");
            return false;
        } else if (str2.length() == 0) {
            i().f1954h.a(str, "Name is required and can't be empty. Type");
            return false;
        } else {
            int codePointAt = str2.codePointAt(0);
            if (!Character.isLetter(codePointAt) && codePointAt != 95) {
                i().f1954h.b(str, "Name must start with a letter or _ (underscore). Type, name", str2);
                return false;
            }
            int length = str2.length();
            int charCount = Character.charCount(codePointAt);
            while (charCount < length) {
                int codePointAt2 = str2.codePointAt(charCount);
                if (codePointAt2 != 95 && !Character.isLetterOrDigit(codePointAt2)) {
                    i().f1954h.b(str, "Name must consist of letters, digits or _ (underscores). Type, name", str2);
                    return false;
                }
                charCount += Character.charCount(codePointAt2);
            }
            return true;
        }
    }

    public final Object m0(Object obj, String str) {
        return "_ldl".equals(str) ? B(w0(str), obj, true, false) : B(w0(str), obj, false, false);
    }

    public final boolean o0(String str, String str2) {
        if (str2 == null) {
            i().f1954h.a(str, "Name is required and can't be null. Type");
            return false;
        } else if (str2.length() == 0) {
            i().f1954h.a(str, "Name is required and can't be empty. Type");
            return false;
        } else {
            int codePointAt = str2.codePointAt(0);
            if (!Character.isLetter(codePointAt)) {
                i().f1954h.b(str, "Name must start with a letter. Type, name", str2);
                return false;
            }
            int length = str2.length();
            int charCount = Character.charCount(codePointAt);
            while (charCount < length) {
                int codePointAt2 = str2.codePointAt(charCount);
                if (codePointAt2 != 95 && !Character.isLetterOrDigit(codePointAt2)) {
                    i().f1954h.b(str, "Name must consist of letters, digits or _ (underscores). Type, name", str2);
                    return false;
                }
                charCount += Character.charCount(codePointAt2);
            }
            return true;
        }
    }

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

    public final boolean q0(String str) {
        n();
        if (m4.b.a(a()).f1993a.checkCallingOrSelfPermission(str) == 0) {
            return true;
        }
        i().f1959m.a(str, "Permission not granted");
        return false;
    }

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

    public final int s0() {
        if (this.f2060h == null) {
            f4.f fVar = f4.f.f14113b;
            Context a10 = a();
            fVar.getClass();
            this.f2060h = Integer.valueOf(f4.f.a(a10) / 1000);
        }
        return this.f2060h.intValue();
    }

    public final int t(String str) {
        if (l0("event", str)) {
            if (b0("event", k5.f2172a, k5.f2173b, str)) {
                return !T(40, "event", str) ? 2 : 0;
            }
            return 13;
        }
        return 2;
    }

    public final long t0() {
        int extensionVersion;
        int i10;
        long j10;
        int extensionVersion2;
        Integer num;
        n();
        if (p0(((y4) this.f17669a).o().y())) {
            int i11 = Build.VERSION.SDK_INT;
            boolean z10 = false;
            Integer num2 = null;
            if (i11 < 30) {
                j10 = 4;
            } else {
                extensionVersion = SdkExtensions.getExtensionVersion(30);
                if (extensionVersion < 4) {
                    j10 = 8;
                } else {
                    if (i11 >= 30) {
                        extensionVersion2 = SdkExtensions.getExtensionVersion(30);
                        if (extensionVersion2 > 3) {
                            i10 = SdkExtensions.getExtensionVersion(1000000);
                            j10 = i10 >= ((Integer) w.V.a(null)).intValue() ? 16L : 0L;
                        }
                    }
                    i10 = 0;
                    if (i10 >= ((Integer) w.V.a(null)).intValue()) {
                    }
                }
            }
            if (!q0("android.permission.ACCESS_ADSERVICES_ATTRIBUTION")) {
                j10 |= 2;
            }
            if (j10 == 0) {
                if (this.f2059g == null) {
                    if (this.f2058f == null) {
                        this.f2058f = q1.d.b(a());
                    }
                    q1.d dVar = this.f2058f;
                    if (dVar != null) {
                        try {
                            num = (Integer) dVar.c().get(10000L, TimeUnit.MILLISECONDS);
                            if (num != null) {
                                try {
                                    if (num.intValue() == 1) {
                                        z10 = true;
                                    }
                                } catch (InterruptedException e10) {
                                    e = e10;
                                    num2 = num;
                                    i().f1955i.a(e, "Measurement manager api exception");
                                    this.f2059g = Boolean.FALSE;
                                    num = num2;
                                    i().f1960n.a(num, "Measurement manager api status result");
                                } catch (CancellationException e11) {
                                    e = e11;
                                    num2 = num;
                                    i().f1955i.a(e, "Measurement manager api exception");
                                    this.f2059g = Boolean.FALSE;
                                    num = num2;
                                    i().f1960n.a(num, "Measurement manager api status result");
                                } catch (ExecutionException e12) {
                                    e = e12;
                                    num2 = num;
                                    i().f1955i.a(e, "Measurement manager api exception");
                                    this.f2059g = Boolean.FALSE;
                                    num = num2;
                                    i().f1960n.a(num, "Measurement manager api status result");
                                } catch (TimeoutException e13) {
                                    e = e13;
                                    num2 = num;
                                    i().f1955i.a(e, "Measurement manager api exception");
                                    this.f2059g = Boolean.FALSE;
                                    num = num2;
                                    i().f1960n.a(num, "Measurement manager api status result");
                                }
                            }
                            this.f2059g = Boolean.valueOf(z10);
                        } catch (InterruptedException e14) {
                            e = e14;
                        } catch (CancellationException e15) {
                            e = e15;
                        } catch (ExecutionException e16) {
                            e = e16;
                        } catch (TimeoutException e17) {
                            e = e17;
                        }
                        i().f1960n.a(num, "Measurement manager api status result");
                    }
                    j10 |= 64;
                }
            }
            if (j10 == 0) {
                return 1L;
            }
            return j10;
        }
        return 0L;
    }

    public final int u(String str, String str2, Object obj, Bundle bundle, List list, boolean z10, boolean z11) {
        int i10;
        Parcelable[] parcelableArr;
        int size;
        n();
        boolean W = W(obj);
        Object obj2 = this.f17669a;
        int i11 = 0;
        if (W) {
            if (!z11) {
                return 21;
            }
            if (!a0(str2, k5.f2180i)) {
                return 20;
            }
            g6 q10 = ((y4) obj2).q();
            q10.n();
            q10.v();
            if (q10.J() && q10.m().s0() < 200900) {
                return 25;
            }
            boolean z12 = obj instanceof Parcelable[];
            if (z12) {
                size = ((Parcelable[]) obj).length;
            } else if (obj instanceof ArrayList) {
                size = ((ArrayList) obj).size();
            }
            if (size > 200) {
                i().f1957k.c("param", "Parameter array is too long; discarded. Value kind, name, array length", str2, Integer.valueOf(size));
                if (z12) {
                    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 (Y("param", str2, (!r0(str) || r0(str2)) ? Math.max(j().s(((y4) obj2).o().y()), 256) : j().s(((y4) obj2).o().y()), obj)) {
                    if (z11) {
                        if (obj instanceof Bundle) {
                            R(str, str2, (Bundle) obj, list, z10);
                        } else if (obj instanceof Parcelable[]) {
                            for (Parcelable parcelable : (Parcelable[]) obj) {
                                if (!(parcelable instanceof Bundle)) {
                                    i().f1957k.b(parcelable.getClass(), "All Parcelable[] elements must be of type Bundle. Value type, name", str2);
                                    return 4;
                                }
                                R(str, str2, (Bundle) parcelable, list, z10);
                            }
                        } else if (!(obj instanceof ArrayList)) {
                            return 4;
                        } else {
                            ArrayList arrayList2 = (ArrayList) obj;
                            int size2 = arrayList2.size();
                            while (i11 < size2) {
                                Object obj3 = arrayList2.get(i11);
                                int i12 = i11 + 1;
                                if (!(obj3 instanceof Bundle)) {
                                    i().f1957k.b(obj3 != null ? obj3.getClass() : "null", "All ArrayList elements must be of type Bundle. Value type, name", str2);
                                    return 4;
                                }
                                R(str, str2, (Bundle) obj3, list, z10);
                                i11 = i12;
                            }
                        }
                        return i10;
                    }
                    return 4;
                }
                return i10;
            }
        }
        i10 = 0;
        if (Y("param", str2, (!r0(str) || r0(str2)) ? Math.max(j().s(((y4) obj2).o().y()), 256) : j().s(((y4) obj2).o().y()), obj)) {
        }
    }

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

    public final Bundle x(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(AppLovinEventTypes.USER_VIEWED_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) {
            i().f1955i.a(e10, "Install referrer url isn't a hierarchical URI");
            return null;
        }
    }

    public final long x0() {
        long andIncrement;
        long j10;
        if (this.f2056d.get() != 0) {
            synchronized (this.f2056d) {
                try {
                    this.f2056d.compareAndSet(-1L, 1L);
                    andIncrement = this.f2056d.getAndIncrement();
                } catch (Throwable th) {
                    throw th;
                }
            }
            return andIncrement;
        }
        synchronized (this.f2056d) {
            try {
                long nanoTime = System.nanoTime();
                ((l4.b) f()).getClass();
                long nextLong = new Random(nanoTime ^ System.currentTimeMillis()).nextLong();
                int i10 = this.f2057e + 1;
                this.f2057e = i10;
                j10 = nextLong + i10;
            } catch (Throwable th2) {
                throw th2;
            }
        }
        return j10;
    }

    public final Bundle y(String str, Bundle bundle, List list, boolean z10) {
        int i10;
        boolean a02 = a0(str, k5.f2175d);
        String[] strArr = null;
        if (bundle != null) {
            Bundle bundle2 = new Bundle(bundle);
            int i11 = j().m().d0(201500000) ? 100 : 25;
            Iterator it = new TreeSet(bundle.keySet()).iterator();
            int i12 = 0;
            while (it.hasNext()) {
                String str2 = (String) it.next();
                if (list == null || !list.contains(str2)) {
                    int i13 = 14;
                    if (!z10) {
                        if (o0("event param", str2)) {
                            if (!b0("event param", strArr, strArr, str2)) {
                                i10 = 14;
                                if (i10 == 0) {
                                    if (l0("event param", str2)) {
                                        if (b0("event param", strArr, strArr, str2)) {
                                            if (T(40, "event param", str2)) {
                                                i13 = 0;
                                            }
                                        }
                                        i10 = i13;
                                    }
                                    i13 = 3;
                                    i10 = i13;
                                }
                            }
                        }
                        i10 = 3;
                        if (i10 == 0) {
                        }
                    }
                    i10 = 0;
                    if (i10 == 0) {
                    }
                } else {
                    i10 = 0;
                }
                if (i10 != 0) {
                    D(bundle2, i10, str2, i10 == 3 ? str2 : strArr);
                    bundle2.remove(str2);
                } else {
                    int u10 = u(str, str2, bundle.get(str2), bundle2, list, z10, a02);
                    if (u10 == 17) {
                        D(bundle2, u10, str2, Boolean.FALSE);
                    } else if (u10 != 0 && !"_ev".equals(str2)) {
                        D(bundle2, u10, u10 == 21 ? str : str2, bundle.get(str2));
                        bundle2.remove(str2);
                    }
                    if (u0(str2)) {
                        int i14 = i12 + 1;
                        if (i14 > i11) {
                            i().f1954h.b(k().c(str), zt0.l("Event can't contain more than ", i11, " params"), k().a(bundle));
                            j0(5, bundle2);
                            bundle2.remove(str2);
                        }
                        i12 = i14;
                    }
                }
                strArr = null;
            }
            return bundle2;
        }
        return null;
    }

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