TopTV v3.0.1版本的 MD5 值为:0fc1b9ce94885bc92edd11a6ee3e5932

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


package c.f.a.c.k.b;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.content.pm.Signature;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.text.TextUtils;
import c.f.a.c.j.h.sb;
import c.f.a.c.j.h.td;
import com.amazonaws.mobileconnectors.s3.transferutility.TransferTable;
import com.amazonaws.services.s3.internal.Constants;
import java.io.ByteArrayInputStream;
import java.net.MalformedURLException;
import java.net.URL;
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.List;
import java.util.Random;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicLong;
import javax.security.auth.x500.X500Principal;
import org.achartengine.chart.TimeChart;
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
public final class ea extends x5 {
    public static final String[] f13417c = {"firebase_", "google_", "ga_"};
    public static final String[] f13418d = {"_err"};
    public static final int f13419e = 0;
    public SecureRandom f13420f;
    public final AtomicLong f13421g;
    public int f13422h;
    public Integer f13423i;

    public ea(c5 c5Var) {
        super(c5Var);
        this.f13423i = null;
        this.f13421g = new AtomicLong(0L);
    }

    public static MessageDigest B() {
        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 long C(byte[] bArr) {
        c.f.a.c.f.q.o.i(bArr);
        int length = bArr.length;
        int i2 = 0;
        c.f.a.c.f.q.o.l(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 boolean D(Context context, boolean z) {
        c.f.a.c.f.q.o.i(context);
        return e0(context, Build.VERSION.SDK_INT >= 24 ? "com.google.android.gms.measurement.AppMeasurementJobService" : "com.google.android.gms.measurement.AppMeasurementService");
    }

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

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

    public static boolean M(String str) {
        return !f13418d[0].equals(str);
    }

    public static ArrayList<Bundle> Y(List<b> list) {
        if (list == null) {
            return new ArrayList<>(0);
        }
        ArrayList<Bundle> arrayList = new ArrayList<>(list.size());
        for (b bVar : list) {
            Bundle bundle = new Bundle();
            bundle.putString("app_id", bVar.f13304b);
            bundle.putString("origin", bVar.f13305c);
            bundle.putLong("creation_timestamp", bVar.f13307e);
            bundle.putString("name", bVar.f13306d.f13298c);
            z5.a(bundle, bVar.f13306d.I());
            bundle.putBoolean("active", bVar.f13308f);
            String str = bVar.f13309g;
            if (str != null) {
                bundle.putString("trigger_event_name", str);
            }
            t tVar = bVar.f13310h;
            if (tVar != null) {
                bundle.putString("timed_out_event_name", tVar.f13877b);
                r rVar = bVar.f13310h.f13878c;
                if (rVar != null) {
                    bundle.putBundle("timed_out_event_params", rVar.K());
                }
            }
            bundle.putLong("trigger_timeout", bVar.f13311i);
            t tVar2 = bVar.f13312j;
            if (tVar2 != null) {
                bundle.putString("triggered_event_name", tVar2.f13877b);
                r rVar2 = bVar.f13312j.f13878c;
                if (rVar2 != null) {
                    bundle.putBundle("triggered_event_params", rVar2.K());
                }
            }
            bundle.putLong("triggered_timestamp", bVar.f13306d.f13299d);
            bundle.putLong("time_to_live", bVar.f13313k);
            t tVar3 = bVar.f13314l;
            if (tVar3 != null) {
                bundle.putString("expired_event_name", tVar3.f13877b);
                r rVar3 = bVar.f13314l.f13878c;
                if (rVar3 != null) {
                    bundle.putBundle("expired_event_params", rVar3.K());
                }
            }
            arrayList.add(bundle);
        }
        return arrayList;
    }

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

    public static final boolean b0(String str) {
        c.f.a.c.f.q.o.i(str);
        return str.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$");
    }

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

    public static boolean f0(String str, String[] strArr) {
        c.f.a.c.f.q.o.i(strArr);
        for (String str2 : strArr) {
            if (G(str, str2)) {
                return true;
            }
        }
        return false;
    }

    public static boolean i0(String str) {
        c.f.a.c.f.q.o.e(str);
        return str.charAt(0) != '_' || str.equals("_ep");
    }

    public final void A(da daVar, String str, int i2, String str2, String str3, int i3) {
        Bundle bundle = new Bundle();
        a0(bundle, i2);
        if (!TextUtils.isEmpty(str2) && !TextUtils.isEmpty(str3)) {
            bundle.putString(str2, str3);
        }
        if (i2 == 6 || i2 == 7 || i2 == 2) {
            bundle.putLong("_el", i3);
        }
        c.f.a.c.j.h.v9.a();
        if (this.f13980a.z().w(null, m3.N0)) {
            daVar.g(str, bundle);
            return;
        }
        this.f13980a.e();
        this.f13980a.F().X("auto", "_err", bundle);
    }

    public final boolean E(String str) {
        g();
        if (c.f.a.c.f.u.c.a(this.f13980a.b()).a(str) == 0) {
            return true;
        }
        this.f13980a.c().v().b("Permission not granted", str);
        return false;
    }

    public final boolean H(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        String D = this.f13980a.z().D();
        this.f13980a.e();
        return D.equals(str);
    }

    public final Bundle I(Bundle bundle) {
        Bundle bundle2 = new Bundle();
        if (bundle != null) {
            for (String str : bundle.keySet()) {
                Object s = s(str, bundle.get(str));
                if (s == null) {
                    this.f13980a.c().t().b("Param value can't be null", this.f13980a.H().q(str));
                } else {
                    z(bundle2, str, s);
                }
            }
        }
        return bundle2;
    }

    public final t J(String str, String str2, Bundle bundle, String str3, long j2, boolean z, boolean z2, boolean z3) {
        if (TextUtils.isEmpty(str2)) {
            return null;
        }
        if (o0(str2, z3) != 0) {
            this.f13980a.c().o().b("Invalid conditional property event name", this.f13980a.H().r(str2));
            throw new IllegalArgumentException();
        }
        Bundle bundle2 = bundle != null ? new Bundle(bundle) : new Bundle();
        bundle2.putString("_o", str3);
        Bundle t = t(str, str2, bundle2, c.f.a.c.f.t.e.b("_o"), false);
        if (z) {
            t = I(t);
        }
        c.f.a.c.f.q.o.i(t);
        return new t(str2, new r(t), str3, j2);
    }

    public final boolean K(Context context, String str) {
        w3 o2;
        String str2;
        Signature[] signatureArr;
        X500Principal x500Principal = new X500Principal("CN=Android Debug,O=Android,C=US");
        try {
            PackageInfo e2 = c.f.a.c.f.u.c.a(context).e(str, 64);
            if (e2 == null || (signatureArr = e2.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 e3) {
            e = e3;
            o2 = this.f13980a.c().o();
            str2 = "Package name not found";
            o2.b(str2, e);
            return true;
        } catch (CertificateException e4) {
            e = e4;
            o2 = this.f13980a.c().o();
            str2 = "Error obtaining certificate";
            o2.b(str2, e);
            return true;
        }
    }

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

    @EnsuresNonNull({"this.apkVersion"})
    public final int N() {
        if (this.f13423i == null) {
            this.f13423i = Integer.valueOf(c.f.a.c.f.f.f().a(this.f13980a.b()) / 1000);
        }
        return this.f13423i.intValue();
    }

    public final int O(int i2) {
        return c.f.a.c.f.f.f().h(this.f13980a.b(), c.f.a.c.f.j.f11916a);
    }

    public final long P(long j2, long j3) {
        return (j2 + (j3 * 60000)) / TimeChart.DAY;
    }

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

    public final void R(td tdVar, String str) {
        Bundle bundle = new Bundle();
        bundle.putString("r", str);
        try {
            tdVar.r1(bundle);
        } catch (RemoteException e2) {
            this.f13980a.c().r().b("Error returning string value to wrapper", e2);
        }
    }

    public final void S(td tdVar, long j2) {
        Bundle bundle = new Bundle();
        bundle.putLong("r", j2);
        try {
            tdVar.r1(bundle);
        } catch (RemoteException e2) {
            this.f13980a.c().r().b("Error returning long value to wrapper", e2);
        }
    }

    public final void T(td tdVar, int i2) {
        Bundle bundle = new Bundle();
        bundle.putInt("r", i2);
        try {
            tdVar.r1(bundle);
        } catch (RemoteException e2) {
            this.f13980a.c().r().b("Error returning int value to wrapper", e2);
        }
    }

    public final void U(td tdVar, byte[] bArr) {
        Bundle bundle = new Bundle();
        bundle.putByteArray("r", bArr);
        try {
            tdVar.r1(bundle);
        } catch (RemoteException e2) {
            this.f13980a.c().r().b("Error returning byte array to wrapper", e2);
        }
    }

    public final void V(td tdVar, boolean z) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("r", z);
        try {
            tdVar.r1(bundle);
        } catch (RemoteException e2) {
            this.f13980a.c().r().b("Error returning boolean value to wrapper", e2);
        }
    }

    public final void W(td tdVar, Bundle bundle) {
        try {
            tdVar.r1(bundle);
        } catch (RemoteException e2) {
            this.f13980a.c().r().b("Error returning bundle value to wrapper", e2);
        }
    }

    public final void X(td tdVar, ArrayList<Bundle> arrayList) {
        Bundle bundle = new Bundle();
        bundle.putParcelableArrayList("r", arrayList);
        try {
            tdVar.r1(bundle);
        } catch (RemoteException e2) {
            this.f13980a.c().r().b("Error returning bundle list to wrapper", e2);
        }
    }

    public final URL Z(long j2, String str, String str2, long j3) {
        try {
            c.f.a.c.f.q.o.e(str2);
            c.f.a.c.f.q.o.e(str);
            String format = String.format("https://www.googleadservices.com/pagead/conversion/app/deeplink?id_type=adid&sdk_version=%s&rdid=%s&bundleid=%s&retry=%s", String.format("v%s.%s", 37000L, Integer.valueOf(N())), str2, str, Long.valueOf(j3));
            if (str.equals(this.f13980a.z().E())) {
                format = format.concat("&ddl_test=1");
            }
            return new URL(format);
        } catch (IllegalArgumentException | MalformedURLException e2) {
            this.f13980a.c().o().b("Failed to create BOW URL for Deferred Deep Link. exception", e2.getMessage());
            return null;
        }
    }

    public final Object c0(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)) {
                return q(String.valueOf(obj), i2, z);
            }
            if (z2 && ((obj instanceof Bundle[]) || (obj instanceof Parcelable[]))) {
                ArrayList arrayList = new ArrayList();
                for (Parcelable parcelable : (Parcelable[]) obj) {
                    if (parcelable instanceof Bundle) {
                        Bundle I = I((Bundle) parcelable);
                        if (!I.isEmpty()) {
                            arrayList.add(I);
                        }
                    }
                }
                return arrayList.toArray(new Bundle[arrayList.size()]);
            }
            return null;
        }
    }

    public final int d0(String str) {
        if ("_ldl".equals(str)) {
            this.f13980a.z();
            return 2048;
        } else if (TransferTable.COLUMN_ID.equals(str)) {
            this.f13980a.z();
            return 256;
        } else if (this.f13980a.z().w(null, m3.h0) && "_lgclid".equals(str)) {
            this.f13980a.z();
            return 100;
        } else {
            this.f13980a.z();
            return 36;
        }
    }

    public final long g0() {
        int i2 = (this.f13421g.get() > 0L ? 1 : (this.f13421g.get() == 0L ? 0 : -1));
        synchronized (this.f13421g) {
            if (i2 != 0) {
                this.f13421g.compareAndSet(-1L, 1L);
                return this.f13421g.getAndIncrement();
            }
            long nextLong = new Random(System.nanoTime() ^ this.f13980a.a().a()).nextLong();
            int i3 = this.f13422h + 1;
            this.f13422h = i3;
            return nextLong + i3;
        }
    }

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

    @EnsuresNonNull({"this.secureRandom"})
    public final SecureRandom h0() {
        g();
        if (this.f13420f == null) {
            this.f13420f = new SecureRandom();
        }
        return this.f13420f;
    }

    @Override
    public final void i() {
        g();
        SecureRandom secureRandom = new SecureRandom();
        long nextLong = secureRandom.nextLong();
        if (nextLong == 0) {
            nextLong = secureRandom.nextLong();
            if (nextLong == 0) {
                this.f13980a.c().r().a("Utils falling back to Random for random id");
            }
        }
        this.f13421g.set(nextLong);
    }

    public final Bundle j0(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.f13980a.c().r().b("Install referrer url isn't a hierarchical URI", e2);
            }
        }
        return null;
    }

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

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

    public final boolean m0(String str, String[] strArr, String[] strArr2, String str2) {
        if (str2 == null) {
            this.f13980a.c().q().b("Name is required and can't be null. Type", str);
            return false;
        }
        c.f.a.c.f.q.o.i(str2);
        String[] strArr3 = f13417c;
        for (int i2 = 0; i2 < 3; i2++) {
            if (str2.startsWith(strArr3[i2])) {
                this.f13980a.c().q().c("Name starts with reserved prefix. Type, name", str, str2);
                return false;
            }
        }
        if (strArr == null || !f0(str2, strArr)) {
            return true;
        }
        if (strArr2 == null || !f0(str2, strArr2)) {
            this.f13980a.c().q().c("Name is reserved. Type, name", str, str2);
            return false;
        }
        return true;
    }

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

    public final boolean o(String str, String str2, String str3) {
        if (!TextUtils.isEmpty(str)) {
            if (b0(str)) {
                return true;
            }
            if (this.f13980a.K()) {
                this.f13980a.c().q().b("Invalid google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI. provided id", y3.x(str));
            }
            return false;
        }
        sb.a();
        if (!this.f13980a.z().w(null, m3.j0) || TextUtils.isEmpty(str3)) {
            if (TextUtils.isEmpty(str2)) {
                if (this.f13980a.K()) {
                    this.f13980a.c().q().a("Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI");
                }
                return false;
            } else if (b0(str2)) {
                return true;
            } else {
                this.f13980a.c().q().b("Invalid admob_app_id. Analytics disabled.", y3.x(str2));
                return false;
            }
        }
        return true;
    }

    public final int o0(String str, boolean z) {
        if (l0("event", str)) {
            if (z) {
                if (!m0("event", a6.f13284a, a6.f13285b, str)) {
                    return 13;
                }
            } else if (!m0("event", a6.f13284a, null, str)) {
                return 13;
            }
            this.f13980a.z();
            return !n0("event", 40, str) ? 2 : 0;
        }
        return 2;
    }

    public final boolean p(String str, String str2, String str3, String str4) {
        boolean isEmpty = TextUtils.isEmpty(str);
        boolean isEmpty2 = TextUtils.isEmpty(str2);
        if (!isEmpty && !isEmpty2) {
            c.f.a.c.f.q.o.i(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) {
            return TextUtils.isEmpty(str3) || !str3.equals(str4);
        } else if (TextUtils.isEmpty(str4)) {
            return false;
        } else {
            return TextUtils.isEmpty(str3) || !str3.equals(str4);
        }
    }

    public final int p0(String str) {
        if (l0("user property", str)) {
            if (m0("user property", c6.f13362a, null, str)) {
                this.f13980a.z();
                return !n0("user property", 24, str) ? 6 : 0;
            }
            return 15;
        }
        return 6;
    }

    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 int q0(String str) {
        if (k0("event param", str)) {
            if (m0("event param", null, null, str)) {
                this.f13980a.z();
                return !n0("event param", 40, str) ? 3 : 0;
            }
            return 14;
        }
        return 3;
    }

    public final int r(String str, String str2, String str3, Object obj, Bundle bundle, List<String> list, boolean z, boolean z2) {
        int i2;
        int i3;
        w3 t;
        Class<?> cls;
        String str4;
        Parcelable[] parcelableArr;
        int size;
        g();
        if (s0(obj)) {
            if (!z2) {
                return 21;
            }
            if (!f0(str3, b6.f13325c)) {
                return 20;
            }
            u8 R = this.f13980a.R();
            R.g();
            R.i();
            if (R.r() && R.f13980a.G().N() < 200900) {
                return 25;
            }
            this.f13980a.z();
            boolean z3 = obj instanceof Parcelable[];
            if (z3) {
                size = ((Parcelable[]) obj).length;
            } else if (obj instanceof ArrayList) {
                size = ((ArrayList) obj).size();
            }
            if (size > 200) {
                this.f13980a.c().t().d("Parameter array is too long; discarded. Value kind, name, array length", "param", str3, Integer.valueOf(size));
                this.f13980a.z();
                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.f13980a.z().w(str, m3.S) || !F(str2)) && !F(str3)) {
                    this.f13980a.z();
                    i3 = 100;
                } else {
                    this.f13980a.z();
                    i3 = 256;
                }
                if (t0("param", str3, i3, obj)) {
                    if (z2) {
                        if (obj instanceof Bundle) {
                            u0(str, str2, str3, (Bundle) obj, list, z);
                        } else if (obj instanceof Parcelable[]) {
                            for (Parcelable parcelable : (Parcelable[]) obj) {
                                if (!(parcelable instanceof Bundle)) {
                                    t = this.f13980a.c().t();
                                    cls = parcelable.getClass();
                                    str4 = "All Parcelable[] elements must be of type Bundle. Value type, name";
                                    t.c(str4, cls, str3);
                                    return 4;
                                }
                                u0(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)) {
                                    t = this.f13980a.c().t();
                                    cls = obj2 != null ? obj2.getClass() : Constants.NULL_VERSION_ID;
                                    str4 = "All ArrayList elements must be of type Bundle. Value type, name";
                                    t.c(str4, cls, str3);
                                    return 4;
                                }
                                u0(str, str2, str3, (Bundle) obj2, list, z);
                            }
                        }
                        return i2;
                    }
                    return 4;
                }
                return i2;
            }
        }
        i2 = 0;
        if (this.f13980a.z().w(str, m3.S)) {
        }
        this.f13980a.z();
        i3 = 100;
        if (t0("param", str3, i3, obj)) {
        }
    }

    public final int r0(String str) {
        if (l0("event param", str)) {
            if (m0("event param", null, null, str)) {
                this.f13980a.z();
                return !n0("event param", 40, str) ? 3 : 0;
            }
            return 14;
        }
        return 3;
    }

    public final Object s(String str, Object obj) {
        int i2 = 256;
        if ("_ev".equals(str)) {
            this.f13980a.z();
            return c0(256, obj, true, true);
        }
        if (F(str)) {
            this.f13980a.z();
        } else {
            this.f13980a.z();
            i2 = 100;
        }
        return c0(i2, obj, false, true);
    }

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

    public final Bundle t(String str, String str2, Bundle bundle, List<String> list, boolean z) {
        int i2;
        String str3;
        boolean f0 = f0(str2, a6.f13287d);
        Bundle bundle2 = new Bundle(bundle);
        int l2 = this.f13980a.z().l();
        int i3 = 0;
        for (String str4 : this.f13980a.z().w(str, m3.Z) ? new TreeSet<>(bundle.keySet()) : bundle.keySet()) {
            if (list == null || !list.contains(str4)) {
                int q0 = z ? q0(str4) : 0;
                if (q0 == 0) {
                    q0 = r0(str4);
                }
                i2 = q0;
            } else {
                i2 = 0;
            }
            if (i2 != 0) {
                w(bundle2, i2, str4, str4, i2 == 3 ? str4 : null);
                bundle2.remove(str4);
            } else {
                int r = r(str, str2, str4, bundle.get(str4), bundle2, list, z, f0);
                if (r == 17) {
                    w(bundle2, 17, str4, str4, Boolean.FALSE);
                } else if (r != 0) {
                    str3 = str4;
                    if (!"_ev".equals(str3)) {
                        w(bundle2, r, r == 21 ? str2 : str3, str3, bundle.get(str3));
                        bundle2.remove(str3);
                    }
                    if (!i0(str3)) {
                        int i4 = i3 + 1;
                        if (i4 > l2) {
                            StringBuilder sb = new StringBuilder(48);
                            sb.append("Event can't contain more than ");
                            sb.append(l2);
                            sb.append(" params");
                            this.f13980a.c().q().c(sb.toString(), this.f13980a.H().p(str2), this.f13980a.H().s(bundle));
                            a0(bundle2, 5);
                            bundle2.remove(str3);
                        }
                        i3 = i4;
                    }
                }
                str3 = str4;
                if (!i0(str3)) {
                }
            }
        }
        return bundle2;
    }

    public final boolean t0(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 valueOf = String.valueOf(obj);
            if (valueOf.codePointCount(0, valueOf.length()) > i2) {
                this.f13980a.c().t().d("Value is too long; discarded. Value kind, name, value length", str, str2, Integer.valueOf(valueOf.length()));
                return false;
            }
        }
        return true;
    }

    public final void u(z3 z3Var, int i2) {
        int i3 = 0;
        for (String str : new TreeSet(z3Var.f14063d.keySet())) {
            if (i0(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.f13980a.c().q().c(sb.toString(), this.f13980a.H().p(z3Var.f14060a), this.f13980a.H().s(z3Var.f14063d));
                a0(z3Var.f14063d, 5);
                z3Var.f14063d.remove(str);
            }
        }
    }

    public final void u0(String str, String str2, String str3, Bundle bundle, List<String> list, boolean z) {
        int i2;
        String str4;
        int r;
        if (bundle == null) {
            return;
        }
        this.f13980a.z();
        int i3 = 0;
        for (String str5 : new TreeSet(bundle.keySet())) {
            if (list == null || !list.contains(str5)) {
                int q0 = z ? q0(str5) : 0;
                if (q0 == 0) {
                    q0 = r0(str5);
                }
                i2 = q0;
            } else {
                i2 = 0;
            }
            if (i2 != 0) {
                w(bundle, i2, str5, str5, i2 == 3 ? str5 : null);
                bundle.remove(str5);
            } else {
                if (s0(bundle.get(str5))) {
                    this.f13980a.c().t().d("Nested Bundle parameters are not allowed; discarded. event name, param name, child param name", str2, str3, str5);
                    str4 = str5;
                    r = 22;
                } else {
                    str4 = str5;
                    r = r(str, str2, str5, bundle.get(str5), bundle, list, z, false);
                }
                if (r != 0 && !"_ev".equals(str4)) {
                    w(bundle, r, str4, str4, bundle.get(str4));
                } else if (i0(str4) && !f0(str4, b6.f13326d) && (i3 = i3 + 1) > 0) {
                    this.f13980a.c().q().c("Item cannot contain custom parameters", this.f13980a.H().p(str2), this.f13980a.H().s(bundle));
                    a0(bundle, 23);
                }
                bundle.remove(str4);
            }
        }
    }

    public final void v(Bundle bundle, Bundle bundle2) {
        if (bundle2 == null) {
            return;
        }
        for (String str : bundle2.keySet()) {
            if (!bundle.containsKey(str)) {
                this.f13980a.G().z(bundle, str, bundle2.get(str));
            }
        }
    }

    public final void w(Bundle bundle, int i2, String str, String str2, Object obj) {
        if (a0(bundle, i2)) {
            this.f13980a.z();
            bundle.putString("_ev", q(str, 40, true));
            if (obj != null) {
                c.f.a.c.f.q.o.i(bundle);
                if ((obj instanceof String) || (obj instanceof CharSequence)) {
                    bundle.putLong("_el", String.valueOf(obj).length());
                }
            }
        }
    }

    public final int x(String str, Object obj) {
        int d0;
        String str2;
        if ("_ldl".equals(str)) {
            d0 = d0(str);
            str2 = "user property referrer";
        } else {
            d0 = d0(str);
            str2 = "user property";
        }
        return t0(str2, str, d0, obj) ? 0 : 7;
    }

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

    public final void z(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.f13980a.c().t().c("Not putting event parameter. Invalid value type. name, type", this.f13980a.H().q(str), obj != null ? obj.getClass().getSimpleName() : null);
        }
    }
}