package com.google.android.gms.measurement.internal; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import com.google.android.gms.common.GoogleApiAvailabilityLight; import com.google.android.gms.common.GooglePlayServicesUtilLight; import com.google.android.gms.common.internal.Preconditions; import com.google.android.gms.common.util.CollectionUtils; import com.google.android.gms.common.wrappers.Wrappers; import com.ijm.dataencryption.de.DataDecryptTool; import com.liulishuo.filedownloader.model.FileDownloadModel; import com.tencent.open.SocialConstants; 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.List; import java.util.Locale; import java.util.Random; import java.util.concurrent.atomic.AtomicLong; import javax.security.auth.x500.X500Principal; /* loaded from: classes.dex */ public final class zzfy extends zzcs { private static final String[] g = {"firebase_", "google_", "ga_"}; private SecureRandom c; private final AtomicLong d; private int e; private Integer f; zzfy(zzbw zzbwVar) { super(zzbwVar); this.f = null; this.d = new AtomicLong(0L); } private final boolean d(String str, String str2) { if (str2 == null) { e().t().a("Name is required and can't be null. Type", str); return false; } if (str2.length() == 0) { e().t().a("Name is required and can't be empty. Type", str); return false; } int codePointAt = str2.codePointAt(0); if (!Character.isLetter(codePointAt) && codePointAt != 95) { e().t().a("Name must start with a letter or _ (underscore). 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)) { e().t().a("Name must consist of letters, digits or _ (underscores). Type, name", str, str2); return false; } charCount += Character.charCount(codePointAt2); } return true; } static boolean e(String str) { Preconditions.b(str); return str.charAt(0) != '_' || str.equals("_ep"); } private static boolean f(String str) { Preconditions.a(str); return str.matches("^(1:\\d+:android:[a-f0-9]+|ca-app-pub-.*)$"); } private static int g(String str) { if ("_ldl".equals(str)) { return 2048; } if (FileDownloadModel.ID.equals(str)) { return DataDecryptTool.DECRYPT_ALL_FILE; } return 36; } static boolean h(String str) { return !TextUtils.isEmpty(str) && str.startsWith("_"); } static MessageDigest x() { MessageDigest messageDigest; for (int i = 0; i < 2; i++) { try { messageDigest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException unused) { } if (messageDigest != null) { return messageDigest; } } return null; } final Bundle a(Uri uri) { String str; String str2; String str3; String str4; 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"); } 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(SocialConstants.PARAM_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 e) { e().w().a("Install referrer url isn't a hierarchical URI", e); return null; } } final boolean b(String str, String str2) { if (str2 == null) { e().t().a("Name is required and can't be null. Type", str); return false; } if (str2.length() == 0) { e().t().a("Name is required and can't be empty. Type", str); return false; } int codePointAt = str2.codePointAt(0); if (!Character.isLetter(codePointAt)) { e().t().a("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)) { e().t().a("Name must consist of letters, digits or _ (underscores). Type, name", str, str2); return false; } charCount += Character.charCount(codePointAt2); } return true; } final boolean c(String str, String str2) { if (!TextUtils.isEmpty(str)) { if (f(str)) { return true; } if (this.a.z()) { e().t().a("Invalid google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI. provided id", zzas.a(str)); } return false; } if (TextUtils.isEmpty(str2)) { if (this.a.z()) { e().t().a("Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI"); } return false; } if (f(str2)) { return true; } e().t().a("Invalid admob_app_id. Analytics disabled.", zzas.a(str2)); return false; } @Override // com.google.android.gms.measurement.internal.zzcs protected final boolean q() { return true; } @Override // com.google.android.gms.measurement.internal.zzcs protected final void r() { f(); SecureRandom secureRandom = new SecureRandom(); long nextLong = secureRandom.nextLong(); if (nextLong == 0) { nextLong = secureRandom.nextLong(); if (nextLong == 0) { e().w().a("Utils falling back to Random for random id"); } } this.d.set(nextLong); } public final long t() { long andIncrement; long j; if (this.d.get() != 0) { synchronized (this.d) { this.d.compareAndSet(-1L, 1L); andIncrement = this.d.getAndIncrement(); } return andIncrement; } synchronized (this.d) { long nextLong = new Random(System.nanoTime() ^ d().a()).nextLong(); int i = this.e + 1; this.e = i; j = nextLong + i; } return j; } final SecureRandom u() { f(); if (this.c == null) { this.c = new SecureRandom(); } return this.c; } public final int v() { if (this.f == null) { this.f = Integer.valueOf(GoogleApiAvailabilityLight.a().a(b()) / 1000); } return this.f.intValue(); } final String w() { byte[] bArr = new byte[16]; u().nextBytes(bArr); return String.format(Locale.US, "%032x", new BigInteger(1, bArr)); } static boolean e(String str, String str2) { if (str == null && str2 == null) { return true; } if (str == null) { return false; } return str.equals(str2); } final int b(String str) { if (!d("user property", str)) { return 6; } if (a("user property", zzcw.a, str)) { return !a("user property", 24, str) ? 6 : 0; } return 15; } final Object c(String str, Object obj) { if ("_ldl".equals(str)) { return a(g(str), obj, true); } return a(g(str), obj, false); } final boolean d(String str) { f(); if (Wrappers.a(b()).a(str) == 0) { return true; } e().A().a("Permission not granted", str); return false; } final int b(String str, Object obj) { boolean a; if ("_ldl".equals(str)) { a = a("user property referrer", str, g(str), obj, false); } else { a = a("user property", str, g(str), obj, false); } return a ? 0 : 7; } final boolean c(String str) { if (TextUtils.isEmpty(str)) { return false; } String r = m().r(); c(); return r.equals(str); } private static boolean b(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; } private final boolean c(Context context, String str) { X500Principal x500Principal = new X500Principal("CN=Android Debug,O=Android,C=US"); try { PackageInfo b = Wrappers.a(context).b(str, 64); if (b == null || b.signatures == null || b.signatures.length <= 0) { return true; } return ((X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(b.signatures[0].toByteArray()))).getSubjectX500Principal().equals(x500Principal); } catch (PackageManager.NameNotFoundException e) { e().t().a("Package name not found", e); return true; } catch (CertificateException e2) { e().t().a("Error obtaining certificate", e2); return true; } } public static Bundle b(Bundle bundle) { if (bundle == null) { return new Bundle(); } Bundle bundle2 = new Bundle(bundle); for (String str : bundle2.keySet()) { Object obj = bundle2.get(str); if (obj instanceof Bundle) { bundle2.putBundle(str, new Bundle((Bundle) obj)); } else { int i = 0; if (obj instanceof Parcelable[]) { Parcelable[] parcelableArr = (Parcelable[]) obj; while (i < parcelableArr.length) { if (parcelableArr[i] instanceof Bundle) { parcelableArr[i] = new Bundle((Bundle) parcelableArr[i]); } i++; } } else if (obj instanceof List) { List list = (List) obj; while (i < list.size()) { Object obj2 = list.get(i); if (obj2 instanceof Bundle) { list.set(i, new Bundle((Bundle) obj2)); } i++; } } } } return bundle2; } static boolean a(Intent intent) { String stringExtra = intent.getStringExtra("android.intent.extra.REFERRER_NAME"); return "android-app://com.google.android.googlequicksearchbox/https/www.google.com".equals(stringExtra) || "https://www.google.com".equals(stringExtra) || "android-app://com.google.appcrawler".equals(stringExtra); } final boolean a(String str, String[] strArr, String str2) { boolean z; boolean z2; if (str2 == null) { e().t().a("Name is required and can't be null. Type", str); return false; } Preconditions.a(str2); String[] strArr2 = g; int length = strArr2.length; int i = 0; while (true) { if (i >= length) { z = false; break; } if (str2.startsWith(strArr2[i])) { z = true; break; } i++; } if (z) { e().t().a("Name starts with reserved prefix. Type, name", str, str2); return false; } if (strArr != null) { Preconditions.a(strArr); int length2 = strArr.length; int i2 = 0; while (true) { if (i2 >= length2) { z2 = false; break; } if (e(str2, strArr[i2])) { z2 = true; break; } i2++; } if (z2) { e().t().a("Name is reserved. Type, name", str, str2); return false; } } return true; } final boolean a(String str, int i, String str2) { if (str2 == null) { e().t().a("Name is required and can't be null. Type", str); return false; } if (str2.codePointCount(0, str2.length()) <= i) { return true; } e().t().a("Name is too long. Type, maximum supported length, name", str, Integer.valueOf(i), str2); return false; } final int a(String str) { if (!d("event", str)) { return 2; } if (a("event", zzcu.a, str)) { return !a("event", 40, str) ? 2 : 0; } return 13; } private final boolean a(String str, String str2, int i, Object obj, boolean z) { 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)) { if ((obj instanceof Bundle) && z) { return true; } if ((obj instanceof Parcelable[]) && z) { for (Parcelable parcelable : (Parcelable[]) obj) { if (!(parcelable instanceof Bundle)) { e().w().a("All Parcelable[] elements must be of type Bundle. Value type, name", parcelable.getClass(), str2); return false; } } return true; } if (!(obj instanceof ArrayList) || !z) { return false; } ArrayList arrayList = (ArrayList) obj; int size = arrayList.size(); int i2 = 0; while (i2 < size) { Object obj2 = arrayList.get(i2); i2++; if (!(obj2 instanceof Bundle)) { e().w().a("All ArrayList elements must be of type Bundle. Value type, name", obj2.getClass(), str2); return false; } } return true; } String valueOf = String.valueOf(obj); if (valueOf.codePointCount(0, valueOf.length()) > i) { e().w().a("Value is too long; discarded. Value kind, name, value length", str, str2, Integer.valueOf(valueOf.length())); return false; } } return true; } static boolean a(String str, String str2, String str3, String str4) { boolean isEmpty = TextUtils.isEmpty(str); boolean isEmpty2 = TextUtils.isEmpty(str2); if (!isEmpty && !isEmpty2) { return !str.equals(str2); } if (isEmpty && isEmpty2) { return (TextUtils.isEmpty(str3) || TextUtils.isEmpty(str4)) ? !TextUtils.isEmpty(str4) : !str3.equals(str4); } if (isEmpty || !isEmpty2) { return TextUtils.isEmpty(str3) || !str3.equals(str4); } if (TextUtils.isEmpty(str4)) { return false; } return TextUtils.isEmpty(str3) || !str3.equals(str4); } private static Object a(int i, Object obj, boolean z) { if (obj == null) { return null; } if ((obj instanceof Long) || (obj instanceof Double)) { return obj; } if (obj instanceof Integer) { return Long.valueOf(((Integer) obj).intValue()); } if (obj instanceof Byte) { return Long.valueOf(((Byte) obj).byteValue()); } if (obj instanceof Short) { return Long.valueOf(((Short) obj).shortValue()); } if (obj instanceof Boolean) { return Long.valueOf(((Boolean) obj).booleanValue() ? 1L : 0L); } if (obj instanceof Float) { return Double.valueOf(((Float) obj).doubleValue()); } if ((obj instanceof String) || (obj instanceof Character) || (obj instanceof CharSequence)) { return a(String.valueOf(obj), i, z); } return null; } public static String a(String str, int i, boolean z) { if (str == null) { return null; } if (str.codePointCount(0, str.length()) <= i) { return str; } if (z) { return String.valueOf(str.substring(0, str.offsetByCodePoints(0, i))).concat("..."); } return null; } final Object a(String str, Object obj) { boolean equals = "_ev".equals(str); int i = DataDecryptTool.DECRYPT_ALL_FILE; if (equals) { return a(DataDecryptTool.DECRYPT_ALL_FILE, obj, true); } if (!h(str)) { i = 100; } return a(i, obj, false); } static Bundle[] a(Object obj) { if (obj instanceof Bundle) { return new Bundle[]{(Bundle) obj}; } if (obj instanceof Parcelable[]) { Parcelable[] parcelableArr = (Parcelable[]) obj; return (Bundle[]) Arrays.copyOf(parcelableArr, parcelableArr.length, Bundle[].class); } if (!(obj instanceof ArrayList)) { return null; } ArrayList arrayList = (ArrayList) obj; return (Bundle[]) arrayList.toArray(new Bundle[arrayList.size()]); } /* JADX WARN: Code restructure failed: missing block: B:74:0x0066, code lost: if (a("event param", 40, r14) == false) goto L28; */ /* JADX WARN: Code restructure failed: missing block: B:80:0x004d, code lost: if (a("event param", 40, r14) == false) goto L17; */ /* JADX WARN: Removed duplicated region for block: B:13:0x006f */ /* JADX WARN: Removed duplicated region for block: B:21:0x0086 */ /* JADX WARN: Removed duplicated region for block: B:30:0x00bf */ /* JADX WARN: Removed duplicated region for block: B:68:0x0053 */ /* JADX WARN: Removed duplicated region for block: B:75:0x0069 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ final android.os.Bundle a(java.lang.String r19, java.lang.String r20, android.os.Bundle r21, java.util.List r22, boolean r23, boolean r24) { /* Method dump skipped, instructions count: 370 To view this dump change 'Code comments level' option to 'DEBUG' */ throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.measurement.internal.zzfy.a(java.lang.String, java.lang.String, android.os.Bundle, java.util.List, boolean, boolean):android.os.Bundle"); } private static boolean a(Bundle bundle, int i) { if (bundle.getLong("_err") != 0) { return false; } bundle.putLong("_err", i); return true; } private static void a(Bundle bundle, Object obj) { Preconditions.a(bundle); if (obj != null) { if ((obj instanceof String) || (obj instanceof CharSequence)) { bundle.putLong("_el", String.valueOf(obj).length()); } } } final void a(Bundle bundle, String str, Object obj) { if (bundle == null) { return; } if (obj instanceof Long) { bundle.putLong(str, ((Long) obj).longValue()); return; } if (obj instanceof String) { bundle.putString(str, String.valueOf(obj)); } else if (obj instanceof Double) { bundle.putDouble(str, ((Double) obj).doubleValue()); } else if (str != null) { e().y().a("Not putting event parameter. Invalid value type. name, type", j().b(str), obj != null ? obj.getClass().getSimpleName() : null); } } public final void a(int i, String str, String str2, int i2) { a((String) null, i, str, str2, i2); } final void a(String str, int i, String str2, String str3, int i2) { Bundle bundle = new Bundle(); a(bundle, i); if (m().d(str, zzai.q0)) { if (!TextUtils.isEmpty(str2) && !TextUtils.isEmpty(str3)) { bundle.putString(str2, str3); } } else if (!TextUtils.isEmpty(str2)) { bundle.putString(str2, str3); } if (i == 6 || i == 7 || i == 2) { bundle.putLong("_el", i2); } this.a.c(); this.a.k().b("auto", "_err", bundle); } static long a(byte[] bArr) { Preconditions.a(bArr); int i = 0; Preconditions.b(bArr.length > 0); long j = 0; for (int length = bArr.length - 1; length >= 0 && length >= bArr.length - 8; length--) { j += (bArr[length] & 255) << i; i += 8; } return j; } static boolean a(Context context, boolean z) { Preconditions.a(context); if (Build.VERSION.SDK_INT >= 24) { return b(context, "com.google.android.gms.measurement.AppMeasurementJobService"); } return b(context, "com.google.android.gms.measurement.AppMeasurementService"); } final Bundle a(Bundle bundle) { Bundle bundle2 = new Bundle(); if (bundle != null) { for (String str : bundle.keySet()) { Object a = a(str, bundle.get(str)); if (a == null) { e().w().a("Param value can't be null", j().b(str)); } else { a(bundle2, str, a); } } } return bundle2; } final zzag a(String str, String str2, Bundle bundle, String str3, long j, boolean z, boolean z2) { if (TextUtils.isEmpty(str2)) { return null; } if (a(str2) == 0) { Bundle bundle2 = bundle != null ? new Bundle(bundle) : new Bundle(); bundle2.putString("_o", str3); return new zzag(str2, new zzad(a(a(str, str2, bundle2, CollectionUtils.a("_o"), false, false))), str3, j); } e().t().a("Invalid conditional property event name", j().c(str2)); throw new IllegalArgumentException(); } /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:11:0x0069 -> B:7:0x0076). Please report as a decompilation issue!!! */ final long a(Context context, String str) { f(); Preconditions.a(context); Preconditions.b(str); PackageManager packageManager = context.getPackageManager(); MessageDigest x = x(); long j = -1; if (x == null) { e().t().a("Could not get MD5 instance"); } else { if (packageManager != null) { try { } catch (PackageManager.NameNotFoundException e) { e().t().a("Package name not found", e); } if (!c(context, str)) { PackageInfo b = Wrappers.a(context).b(b().getPackageName(), 64); if (b.signatures != null && b.signatures.length > 0) { j = a(x.digest(b.signatures[0].toByteArray())); } else { e().w().a("Could not get signatures"); } } } j = 0; } return j; } static byte[] a(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 a(int i) { return GoogleApiAvailabilityLight.a().a(b(), GooglePlayServicesUtilLight.GOOGLE_PLAY_SERVICES_VERSION_CODE); } public static long a(long j, long j2) { return (j + (j2 * 60000)) / 86400000; } final void a(Bundle bundle, long j) { long j2 = bundle.getLong("_et"); if (j2 != 0) { e().w().a("Params already contained engagement", Long.valueOf(j2)); } bundle.putLong("_et", j + j2); } }