漫漫擼2 v1.3.9版本的 MD5 值为:e07b15db49ff38b958ff7c8268ff1c9b

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


package g.i.a.d.h.b;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.content.pm.Signature;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.gms.measurement.internal.zzab;
import com.google.android.gms.measurement.internal.zzar;
import com.google.android.gms.measurement.internal.zzat;
import com.unity3d.ads.metadata.MediationMetaData;
import g.i.a.d.g.d.zb;
import java.io.ByteArrayInputStream;
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.Objects;
import java.util.Random;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import javax.security.auth.x500.X500Principal;
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
import tv.danmaku.ijk.media.player.IjkMediaCodecInfo;
public final class t9 extends m5 {
    public static final String[] f10909c = {"firebase_", "google_", "ga_"};
    public static final String[] f10910d = {"_err"};
    public SecureRandom f10911e;
    public final AtomicLong f10912f;
    public int f10913g;
    public Integer f10914h;

    public t9(r4 r4Var) {
        super(r4Var);
        this.f10914h = null;
        this.f10912f = new AtomicLong(0L);
    }

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

    public static boolean V(String str) {
        d.u.u.q(str);
        return str.charAt(0) != '_' || str.equals("_ep");
    }

    public static boolean W(Context context) {
        ActivityInfo receiverInfo;
        Objects.requireNonNull(context, "null reference");
        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(Context context) {
        Objects.requireNonNull(context, "null reference");
        return f0(context, "com.google.android.gms.measurement.AppMeasurementJobService");
    }

    public static boolean Y(String str, String str2) {
        if (str == null && str2 == null) {
            return true;
        }
        if (str == null) {
            return false;
        }
        return str.equals(str2);
    }

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

    public static boolean e0(String str, String[] strArr) {
        for (String str2 : strArr) {
            if (Y(str, str2)) {
                return true;
            }
        }
        return false;
    }

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

    public static long m0(byte[] bArr) {
        Objects.requireNonNull(bArr, "null reference");
        int length = bArr.length;
        int i2 = 0;
        d.u.u.y(length > 0);
        long j2 = 0;
        for (int i3 = length - 1; i3 >= 0 && i3 >= bArr.length - 8; i3--) {
            j2 += (bArr[i3] & 255) << i2;
            i2 += 8;
        }
        return j2;
    }

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

    public static ArrayList<Bundle> t(List<zzab> list) {
        if (list == null) {
            return new ArrayList<>(0);
        }
        ArrayList<Bundle> arrayList = new ArrayList<>(list.size());
        for (zzab zzabVar : list) {
            Bundle bundle = new Bundle();
            bundle.putString("app_id", zzabVar.f1745a);
            bundle.putString("origin", zzabVar.f1746b);
            bundle.putLong("creation_timestamp", zzabVar.f1748d);
            bundle.putString(MediationMetaData.KEY_NAME, zzabVar.f1747c.f1762b);
            Object D = zzabVar.f1747c.D();
            Objects.requireNonNull(D, "null reference");
            g.i.a.d.d.o.f.X4(bundle, D);
            bundle.putBoolean("active", zzabVar.f1749e);
            String str = zzabVar.f1750f;
            if (str != null) {
                bundle.putString("trigger_event_name", str);
            }
            zzat zzatVar = zzabVar.f1751g;
            if (zzatVar != null) {
                bundle.putString("timed_out_event_name", zzatVar.f1757a);
                zzar zzarVar = zzatVar.f1758b;
                if (zzarVar != null) {
                    bundle.putBundle("timed_out_event_params", zzarVar.D());
                }
            }
            bundle.putLong("trigger_timeout", zzabVar.f1752h);
            zzat zzatVar2 = zzabVar.f1753i;
            if (zzatVar2 != null) {
                bundle.putString("triggered_event_name", zzatVar2.f1757a);
                zzar zzarVar2 = zzatVar2.f1758b;
                if (zzarVar2 != null) {
                    bundle.putBundle("triggered_event_params", zzarVar2.D());
                }
            }
            bundle.putLong("triggered_timestamp", zzabVar.f1747c.f1763c);
            bundle.putLong("time_to_live", zzabVar.f1754j);
            zzat zzatVar3 = zzabVar.f1755k;
            if (zzatVar3 != null) {
                bundle.putString("expired_event_name", zzatVar3.f1757a);
                zzar zzarVar3 = zzatVar3.f1758b;
                if (zzarVar3 != null) {
                    bundle.putBundle("expired_event_params", zzarVar3.D());
                }
            }
            arrayList.add(bundle);
        }
        return arrayList;
    }

    public static void w(c7 c7Var, Bundle bundle, boolean z) {
        if (bundle != null && c7Var != null) {
            if (!bundle.containsKey("_sc") || z) {
                String str = c7Var.f10407a;
                if (str != null) {
                    bundle.putString("_sn", str);
                } else {
                    bundle.remove("_sn");
                }
                String str2 = c7Var.f10408b;
                if (str2 != null) {
                    bundle.putString("_sc", str2);
                } else {
                    bundle.remove("_sc");
                }
                bundle.putLong("_si", c7Var.f10409c);
                return;
            }
            z = false;
        }
        if (bundle != null && c7Var == null && z) {
            bundle.remove("_sn");
            bundle.remove("_sc");
            bundle.remove("_si");
        }
    }

    public final void A(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) {
            this.f10663a.b().f10583k.c("Not putting event parameter. Invalid value type. name, type", this.f10663a.f10842n.e(str), obj != null ? obj.getClass().getSimpleName() : null);
        }
    }

    public final void B(g.i.a.d.g.d.c1 c1Var, boolean z) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("r", z);
        try {
            c1Var.d(bundle);
        } catch (RemoteException e2) {
            this.f10663a.b().f10581i.b("Error returning boolean value to wrapper", e2);
        }
    }

    public final void C(g.i.a.d.g.d.c1 c1Var, ArrayList<Bundle> arrayList) {
        Bundle bundle = new Bundle();
        bundle.putParcelableArrayList("r", arrayList);
        try {
            c1Var.d(bundle);
        } catch (RemoteException e2) {
            this.f10663a.b().f10581i.b("Error returning bundle list to wrapper", e2);
        }
    }

    public final void D(g.i.a.d.g.d.c1 c1Var, Bundle bundle) {
        try {
            c1Var.d(bundle);
        } catch (RemoteException e2) {
            this.f10663a.b().f10581i.b("Error returning bundle value to wrapper", e2);
        }
    }

    public final void E(g.i.a.d.g.d.c1 c1Var, byte[] bArr) {
        Bundle bundle = new Bundle();
        bundle.putByteArray("r", bArr);
        try {
            c1Var.d(bundle);
        } catch (RemoteException e2) {
            this.f10663a.b().f10581i.b("Error returning byte array to wrapper", e2);
        }
    }

    public final void F(g.i.a.d.g.d.c1 c1Var, int i2) {
        Bundle bundle = new Bundle();
        bundle.putInt("r", i2);
        try {
            c1Var.d(bundle);
        } catch (RemoteException e2) {
            this.f10663a.b().f10581i.b("Error returning int value to wrapper", e2);
        }
    }

    public final void G(g.i.a.d.g.d.c1 c1Var, long j2) {
        Bundle bundle = new Bundle();
        bundle.putLong("r", j2);
        try {
            c1Var.d(bundle);
        } catch (RemoteException e2) {
            this.f10663a.b().f10581i.b("Error returning long value to wrapper", e2);
        }
    }

    public final void H(g.i.a.d.g.d.c1 c1Var, String str) {
        Bundle bundle = new Bundle();
        bundle.putString("r", str);
        try {
            c1Var.d(bundle);
        } catch (RemoteException e2) {
            this.f10663a.b().f10581i.b("Error returning string value to wrapper", e2);
        }
    }

    public final void I(String str, String str2, String str3, Bundle bundle, List<String> list, boolean z) {
        int j0;
        String str4;
        int N;
        if (bundle == null) {
            return;
        }
        f fVar = this.f10663a.f10836h;
        Iterator it = new TreeSet(bundle.keySet()).iterator();
        int i2 = 0;
        while (it.hasNext()) {
            String str5 = (String) it.next();
            if (list == null || !list.contains(str5)) {
                j0 = !z ? j0(str5) : 0;
                if (j0 == 0) {
                    j0 = i0(str5);
                }
            } else {
                j0 = 0;
            }
            if (j0 != 0) {
                v(bundle, j0, str5, j0 == 3 ? str5 : null);
                bundle.remove(str5);
            } else {
                if (S(bundle.get(str5))) {
                    this.f10663a.b().f10583k.d("Nested Bundle parameters are not allowed; discarded. event name, param name, child param name", str2, str3, str5);
                    N = 22;
                    str4 = str5;
                } else {
                    str4 = str5;
                    N = N(str, str2, str5, bundle.get(str5), bundle, list, z, false);
                }
                if (N != 0 && !"_ev".equals(str4)) {
                    v(bundle, N, str4, bundle.get(str4));
                    bundle.remove(str4);
                } else if (V(str4) && !e0(str4, p5.f10792d) && (i2 = i2 + 1) > 0) {
                    this.f10663a.b().f10580h.c("Item cannot contain custom parameters", this.f10663a.f10842n.d(str2), this.f10663a.f10842n.b(bundle));
                    b0(bundle, 23);
                    bundle.remove(str4);
                }
            }
        }
    }

    public final boolean J(String str, String str2, String str3) {
        if (!TextUtils.isEmpty(str)) {
            Objects.requireNonNull(str, "null reference");
            if (str.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$")) {
                return true;
            }
            if (this.f10663a.h()) {
                this.f10663a.b().f10580h.b("Invalid google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI. provided id", j3.t(str));
            }
            return false;
        }
        zb.b();
        if (!this.f10663a.f10836h.v(null, w2.d0) || TextUtils.isEmpty(str3)) {
            if (!TextUtils.isEmpty(str2)) {
                Objects.requireNonNull(str2, "null reference");
                if (str2.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$")) {
                    return true;
                }
                this.f10663a.b().f10580h.b("Invalid admob_app_id. Analytics disabled.", j3.t(str2));
                return false;
            }
            if (this.f10663a.h()) {
                this.f10663a.b().f10580h.a("Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI");
            }
            return false;
        }
        return true;
    }

    public final boolean K(String str, int i2, String str2) {
        if (str2 == null) {
            this.f10663a.b().f10580h.b("Name is required and can't be null. Type", str);
            return false;
        } else if (str2.codePointCount(0, str2.length()) > i2) {
            this.f10663a.b().f10580h.d("Name is too long. Type, maximum supported length, name", str, Integer.valueOf(i2), str2);
            return false;
        } else {
            return true;
        }
    }

    public final boolean L(String str, String[] strArr, String[] strArr2, String str2) {
        if (str2 == null) {
            this.f10663a.b().f10580h.b("Name is required and can't be null. Type", str);
            return false;
        }
        String[] strArr3 = f10909c;
        for (int i2 = 0; i2 < 3; i2++) {
            if (str2.startsWith(strArr3[i2])) {
                this.f10663a.b().f10580h.c("Name starts with reserved prefix. Type, name", str, str2);
                return false;
            }
        }
        if (strArr == null || !e0(str2, strArr)) {
            return true;
        }
        if (strArr2 == null || !e0(str2, strArr2)) {
            this.f10663a.b().f10580h.c("Name is reserved. Type, name", str, str2);
            return false;
        }
        return true;
    }

    public final boolean M(String str, String str2, int i2, Object obj) {
        if (obj != null && !(obj instanceof Long) && !(obj instanceof Float) && !(obj instanceof Integer) && !(obj instanceof Byte) && !(obj instanceof Short) && !(obj instanceof Boolean) && !(obj instanceof Double)) {
            if (!(obj instanceof String) && !(obj instanceof Character) && !(obj instanceof CharSequence)) {
                return false;
            }
            String obj2 = obj.toString();
            if (obj2.codePointCount(0, obj2.length()) > i2) {
                this.f10663a.b().f10583k.d("Value is too long; discarded. Value kind, name, value length", str, str2, Integer.valueOf(obj2.length()));
                return false;
            }
        }
        return true;
    }

    public final int N(String str, String str2, String str3, Object obj, Bundle bundle, List<String> list, boolean z, boolean z2) {
        int i2;
        int i3;
        Parcelable[] parcelableArr;
        int size;
        h();
        if (S(obj)) {
            if (!z2) {
                return 21;
            }
            if (!e0(str3, p5.f10791c)) {
                return 20;
            }
            j8 y = this.f10663a.y();
            y.h();
            y.i();
            if (y.p() && y.f10663a.A().l0() < 200900) {
                return 25;
            }
            f fVar = this.f10663a.f10836h;
            boolean z3 = obj instanceof Parcelable[];
            if (z3) {
                size = ((Parcelable[]) obj).length;
            } else if (obj instanceof ArrayList) {
                size = ((ArrayList) obj).size();
            }
            if (size > 200) {
                this.f10663a.b().f10583k.d("Parameter array is too long; discarded. Value kind, name, array length", "param", str3, Integer.valueOf(size));
                f fVar2 = this.f10663a.f10836h;
                if (z3) {
                    Parcelable[] parcelableArr2 = (Parcelable[]) obj;
                    if (parcelableArr2.length > 200) {
                        bundle.putParcelableArray(str3, (Parcelable[]) Arrays.copyOf(parcelableArr2, 200));
                    }
                } else if (obj instanceof ArrayList) {
                    ArrayList arrayList = (ArrayList) obj;
                    if (arrayList.size() > 200) {
                        bundle.putParcelableArrayList(str3, new ArrayList<>(arrayList.subList(0, 200)));
                    }
                }
                i2 = 17;
                if ((!this.f10663a.f10836h.v(str, w2.S) && U(str2)) || U(str3)) {
                    f fVar3 = this.f10663a.f10836h;
                    i3 = RecyclerView.a0.FLAG_TMP_DETACHED;
                } else {
                    f fVar4 = this.f10663a.f10836h;
                    i3 = 100;
                }
                if (M("param", str3, i3, obj)) {
                    if (z2) {
                        if (obj instanceof Bundle) {
                            I(str, str2, str3, (Bundle) obj, list, z);
                        } else if (obj instanceof Parcelable[]) {
                            for (Parcelable parcelable : (Parcelable[]) obj) {
                                if (!(parcelable instanceof Bundle)) {
                                    this.f10663a.b().f10583k.c("All Parcelable[] elements must be of type Bundle. Value type, name", parcelable.getClass(), str3);
                                    return 4;
                                }
                                I(str, str2, str3, (Bundle) parcelable, list, z);
                            }
                        } else if (!(obj instanceof ArrayList)) {
                            return 4;
                        } else {
                            ArrayList arrayList2 = (ArrayList) obj;
                            int size2 = arrayList2.size();
                            for (int i4 = 0; i4 < size2; i4++) {
                                Object obj2 = arrayList2.get(i4);
                                if (!(obj2 instanceof Bundle)) {
                                    this.f10663a.b().f10583k.c("All ArrayList elements must be of type Bundle. Value type, name", obj2 != null ? obj2.getClass() : "null", str3);
                                    return 4;
                                }
                                I(str, str2, str3, (Bundle) obj2, list, z);
                            }
                        }
                        return i2;
                    }
                    return 4;
                }
                return i2;
            }
        }
        i2 = 0;
        if (!this.f10663a.f10836h.v(str, w2.S)) {
        }
        f fVar42 = this.f10663a.f10836h;
        i3 = 100;
        if (M("param", str3, i3, obj)) {
        }
    }

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

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

    public final boolean Q(String str) {
        h();
        if (g.i.a.d.d.p.b.a(this.f10663a.f10830b).f9728a.checkCallingOrSelfPermission(str) == 0) {
            return true;
        }
        this.f10663a.b().f10585m.b("Permission not granted", str);
        return false;
    }

    public final boolean R(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        String j2 = this.f10663a.f10836h.j("debug.firebase.analytics.app", "");
        b bVar = this.f10663a.f10835g;
        return j2.equals(str);
    }

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

    public final boolean T(Context context, String str) {
        Signature[] signatureArr;
        X500Principal x500Principal = new X500Principal("CN=Android Debug,O=Android,C=US");
        try {
            PackageInfo packageInfo = g.i.a.d.d.p.b.a(context).f9728a.getPackageManager().getPackageInfo(str, 64);
            if (packageInfo == null || (signatureArr = packageInfo.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 e2) {
            this.f10663a.b().f10578f.b("Package name not found", e2);
            return true;
        } catch (CertificateException e3) {
            this.f10663a.b().f10578f.b("Error obtaining certificate", e3);
            return true;
        }
    }

    public final boolean Z(String str, String str2, String str3, String str4) {
        boolean isEmpty = TextUtils.isEmpty(str);
        boolean isEmpty2 = TextUtils.isEmpty(str2);
        if (!isEmpty && !isEmpty2) {
            Objects.requireNonNull(str, "null reference");
            return !str.equals(str2);
        } else if (isEmpty && isEmpty2) {
            return (TextUtils.isEmpty(str3) || TextUtils.isEmpty(str4)) ? !TextUtils.isEmpty(str4) : !str3.equals(str4);
        } else if (isEmpty) {
            return TextUtils.isEmpty(str3) || !str3.equals(str4);
        } else if (TextUtils.isEmpty(str4)) {
            return false;
        } else {
            return TextUtils.isEmpty(str3) || !str3.equals(str4);
        }
    }

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

    public final int c0(String str) {
        if ("_ldl".equals(str)) {
            f fVar = this.f10663a.f10836h;
            return 2048;
        } else if (!"_id".equals(str)) {
            if (this.f10663a.f10836h.v(null, w2.c0) && "_lgclid".equals(str)) {
                f fVar2 = this.f10663a.f10836h;
                return 100;
            }
            f fVar3 = this.f10663a.f10836h;
            return 36;
        } else {
            f fVar4 = this.f10663a.f10836h;
            return RecyclerView.a0.FLAG_TMP_DETACHED;
        }
    }

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

    public final int g0(String str, Object obj) {
        boolean M;
        if ("_ldl".equals(str)) {
            M = M("user property referrer", str, c0(str), obj);
        } else {
            M = M("user property", str, c0(str), obj);
        }
        return M ? 0 : 7;
    }

    public final int h0(String str) {
        if (O("event", str)) {
            if (L("event", o5.f10771a, o5.f10772b, str)) {
                f fVar = this.f10663a.f10836h;
                return !K("event", 40, str) ? 2 : 0;
            }
            return 13;
        }
        return 2;
    }

    @Override
    public final void i() {
        h();
        SecureRandom secureRandom = new SecureRandom();
        long nextLong = secureRandom.nextLong();
        if (nextLong == 0) {
            nextLong = secureRandom.nextLong();
            if (nextLong == 0) {
                this.f10663a.b().f10581i.a("Utils falling back to Random for random id");
            }
        }
        this.f10912f.set(nextLong);
    }

    public final int i0(String str) {
        if (O("event param", str)) {
            if (L("event param", null, null, str)) {
                f fVar = this.f10663a.f10836h;
                return !K("event param", 40, str) ? 3 : 0;
            }
            return 14;
        }
        return 3;
    }

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

    public final int j0(String str) {
        if (P("event param", str)) {
            if (L("event param", null, null, str)) {
                f fVar = this.f10663a.f10836h;
                return !K("event param", 40, str) ? 3 : 0;
            }
            return 14;
        }
        return 3;
    }

    public final int k0(String str) {
        if (O("user property", str)) {
            if (L("user property", q5.f10810a, null, str)) {
                f fVar = this.f10663a.f10836h;
                return !K("user property", 24, str) ? 6 : 0;
            }
            return 15;
        }
        return 6;
    }

    @EnsuresNonNull({"this.apkVersion"})
    public final int l0() {
        if (this.f10914h == null) {
            g.i.a.d.d.d dVar = g.i.a.d.d.d.f9484b;
            Context context = this.f10663a.f10830b;
            Objects.requireNonNull(dVar);
            AtomicBoolean atomicBoolean = g.i.a.d.d.h.f9487a;
            int i2 = 0;
            try {
                i2 = context.getPackageManager().getPackageInfo("com.google.android.gms", 0).versionCode;
            } catch (PackageManager.NameNotFoundException unused) {
                Log.w("GooglePlayServicesUtil", "Google Play services is missing.");
            }
            this.f10914h = Integer.valueOf(i2 / IjkMediaCodecInfo.RANK_MAX);
        }
        return this.f10914h.intValue();
    }

    public final long n0() {
        long andIncrement;
        long j2;
        if (this.f10912f.get() == 0) {
            synchronized (this.f10912f) {
                long nanoTime = System.nanoTime();
                Objects.requireNonNull((g.i.a.d.d.o.c) this.f10663a.f10843o);
                long nextLong = new Random(nanoTime ^ System.currentTimeMillis()).nextLong();
                int i2 = this.f10913g + 1;
                this.f10913g = i2;
                j2 = nextLong + i2;
            }
            return j2;
        }
        synchronized (this.f10912f) {
            this.f10912f.compareAndSet(-1L, 1L);
            andIncrement = this.f10912f.getAndIncrement();
        }
        return andIncrement;
    }

    public final Object o(String str, Object obj) {
        boolean equals = "_ev".equals(str);
        int i2 = RecyclerView.a0.FLAG_TMP_DETACHED;
        if (equals) {
            f fVar = this.f10663a.f10836h;
            return d0(RecyclerView.a0.FLAG_TMP_DETACHED, obj, true, true);
        }
        if (U(str)) {
            f fVar2 = this.f10663a.f10836h;
        } else {
            f fVar3 = this.f10663a.f10836h;
            i2 = 100;
        }
        return d0(i2, obj, false, true);
    }

    public final long o0(long j2, long j3) {
        return ((j3 * 60000) + j2) / 86400000;
    }

    public final Object p(String str, Object obj) {
        if ("_ldl".equals(str)) {
            return d0(c0(str), obj, true, false);
        }
        return d0(c0(str), obj, false, false);
    }

    public final Bundle p0(Uri uri) {
        String str;
        String str2;
        String str3;
        String str4;
        if (uri != null) {
            try {
                if (uri.isHierarchical()) {
                    str = uri.getQueryParameter("utm_campaign");
                    str2 = uri.getQueryParameter("utm_source");
                    str3 = uri.getQueryParameter("utm_medium");
                    str4 = uri.getQueryParameter("gclid");
                } else {
                    str = null;
                    str2 = null;
                    str3 = null;
                    str4 = null;
                }
                if (TextUtils.isEmpty(str) && TextUtils.isEmpty(str2) && TextUtils.isEmpty(str3) && TextUtils.isEmpty(str4)) {
                    return null;
                }
                Bundle bundle = new Bundle();
                if (!TextUtils.isEmpty(str)) {
                    bundle.putString("campaign", str);
                }
                if (!TextUtils.isEmpty(str2)) {
                    bundle.putString("source", str2);
                }
                if (!TextUtils.isEmpty(str3)) {
                    bundle.putString("medium", str3);
                }
                if (!TextUtils.isEmpty(str4)) {
                    bundle.putString("gclid", str4);
                }
                String queryParameter = uri.getQueryParameter("utm_term");
                if (!TextUtils.isEmpty(queryParameter)) {
                    bundle.putString("term", queryParameter);
                }
                String queryParameter2 = uri.getQueryParameter("utm_content");
                if (!TextUtils.isEmpty(queryParameter2)) {
                    bundle.putString("content", queryParameter2);
                }
                String queryParameter3 = uri.getQueryParameter("aclid");
                if (!TextUtils.isEmpty(queryParameter3)) {
                    bundle.putString("aclid", queryParameter3);
                }
                String queryParameter4 = uri.getQueryParameter("cp1");
                if (!TextUtils.isEmpty(queryParameter4)) {
                    bundle.putString("cp1", queryParameter4);
                }
                String queryParameter5 = uri.getQueryParameter("anid");
                if (!TextUtils.isEmpty(queryParameter5)) {
                    bundle.putString("anid", queryParameter5);
                }
                return bundle;
            } catch (UnsupportedOperationException e2) {
                this.f10663a.b().f10581i.b("Install referrer url isn't a hierarchical URI", e2);
            }
        }
        return null;
    }

    public final String q(String str, int i2, boolean z) {
        if (str == null) {
            return null;
        }
        if (str.codePointCount(0, str.length()) > i2) {
            if (z) {
                return String.valueOf(str.substring(0, str.offsetByCodePoints(0, i2))).concat("...");
            }
            return null;
        }
        return str;
    }

    public final Bundle q0(Bundle bundle) {
        Bundle bundle2 = new Bundle();
        if (bundle != null) {
            for (String str : bundle.keySet()) {
                Object o2 = o(str, bundle.get(str));
                if (o2 == null) {
                    this.f10663a.b().f10583k.b("Param value can't be null", this.f10663a.f10842n.e(str));
                } else {
                    A(bundle2, str, o2);
                }
            }
        }
        return bundle2;
    }

    public final Bundle r0(String str, String str2, Bundle bundle, List<String> list, boolean z) {
        int j0;
        List<String> list2 = list;
        boolean e0 = e0(str2, o5.f10774d);
        Bundle bundle2 = new Bundle(bundle);
        int m2 = this.f10663a.f10836h.m();
        Iterator it = new TreeSet(bundle.keySet()).iterator();
        int i2 = 0;
        while (it.hasNext()) {
            String str3 = (String) it.next();
            if (list2 == null || !list2.contains(str3)) {
                j0 = !z ? j0(str3) : 0;
                if (j0 == 0) {
                    j0 = i0(str3);
                }
            } else {
                j0 = 0;
            }
            if (j0 != 0) {
                v(bundle2, j0, str3, j0 == 3 ? str3 : null);
                bundle2.remove(str3);
            } else {
                int N = N(str, str2, str3, bundle.get(str3), bundle2, list, z, e0);
                if (N == 17) {
                    v(bundle2, 17, str3, Boolean.FALSE);
                } else if (N != 0 && !"_ev".equals(str3)) {
                    v(bundle2, N, N == 21 ? str2 : str3, bundle.get(str3));
                    bundle2.remove(str3);
                }
                if (V(str3)) {
                    int i3 = i2 + 1;
                    if (i3 > m2) {
                        StringBuilder sb = new StringBuilder(48);
                        sb.append("Event can't contain more than ");
                        sb.append(m2);
                        sb.append(" params");
                        this.f10663a.b().f10580h.c(sb.toString(), this.f10663a.f10842n.d(str2), this.f10663a.f10842n.b(bundle));
                        b0(bundle2, 5);
                        bundle2.remove(str3);
                    }
                    i2 = i3;
                }
            }
            list2 = list;
        }
        return bundle2;
    }

    @EnsuresNonNull({"this.secureRandom"})
    public final SecureRandom s() {
        h();
        if (this.f10911e == null) {
            this.f10911e = new SecureRandom();
        }
        return this.f10911e;
    }

    public final zzat s0(String str, String str2, Bundle bundle, String str3, long j2, boolean z, boolean z2) {
        Bundle bundle2;
        if (TextUtils.isEmpty(str2)) {
            return null;
        }
        if (h0(str2) == 0) {
            if (bundle != null) {
                bundle2 = new Bundle(bundle);
            } else {
                bundle2 = new Bundle();
            }
            Bundle bundle3 = bundle2;
            bundle3.putString("_o", str3);
            Bundle r0 = r0(str, str2, bundle3, Collections.singletonList("_o"), true);
            if (z) {
                r0 = q0(r0);
            }
            Objects.requireNonNull(r0, "null reference");
            return new zzat(str2, new zzar(r0), str3, j2);
        }
        this.f10663a.b().f10578f.b("Invalid conditional property event name", this.f10663a.f10842n.f(str2));
        throw new IllegalArgumentException();
    }

    public final void u(Bundle bundle, long j2) {
        long j3 = bundle.getLong("_et");
        if (j3 != 0) {
            this.f10663a.b().f10581i.b("Params already contained engagement", Long.valueOf(j3));
        } else {
            j3 = 0;
        }
        bundle.putLong("_et", j2 + j3);
    }

    public final void v(Bundle bundle, int i2, String str, Object obj) {
        if (b0(bundle, i2)) {
            f fVar = this.f10663a.f10836h;
            bundle.putString("_ev", q(str, 40, true));
            if (obj != null) {
                if ((obj instanceof String) || (obj instanceof CharSequence)) {
                    bundle.putLong("_el", obj.toString().length());
                }
            }
        }
    }

    public final void x(Bundle bundle, Bundle bundle2) {
        if (bundle2 == null) {
            return;
        }
        for (String str : bundle2.keySet()) {
            if (!bundle.containsKey(str)) {
                this.f10663a.A().A(bundle, str, bundle2.get(str));
            }
        }
    }

    public final void y(k3 k3Var, int i2) {
        Iterator it = new TreeSet(k3Var.f10623d.keySet()).iterator();
        int i3 = 0;
        while (it.hasNext()) {
            String str = (String) it.next();
            if (V(str) && (i3 = i3 + 1) > i2) {
                StringBuilder sb = new StringBuilder(48);
                sb.append("Event can't contain more than ");
                sb.append(i2);
                sb.append(" params");
                this.f10663a.b().f10580h.c(sb.toString(), this.f10663a.f10842n.d(k3Var.f10620a), this.f10663a.f10842n.b(k3Var.f10623d));
                b0(k3Var.f10623d, 5);
                k3Var.f10623d.remove(str);
            }
        }
    }

    public final void z(s9 s9Var, String str, int i2, String str2, String str3, int i3) {
        Bundle bundle = new Bundle();
        b0(bundle, i2);
        if (!TextUtils.isEmpty(str2) && !TextUtils.isEmpty(str3)) {
            bundle.putString(str2, str3);
        }
        if (i2 == 6 || i2 == 7 || i2 == 2) {
            bundle.putLong("_el", i3);
        }
        s9Var.a(str, "_err", bundle);
    }
}