package com.google.android.gms.measurement.internal; import android.app.Application; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; import android.util.Pair; import androidx.annotation.VisibleForTesting; import androidx.annotation.WorkerThread; import com.facebook.gamingservices.cloudgaming.internal.SDKConstants; import com.google.android.gms.common.internal.Preconditions; import com.google.android.gms.common.util.Clock; import com.google.android.gms.common.util.DefaultClock; import com.google.android.gms.common.wrappers.Wrappers; import com.google.android.gms.internal.measurement.zzok; import java.net.URL; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes3.dex */ public class zzhj implements zzil { private static volatile zzhj zzb; @VisibleForTesting final long zza; private Boolean zzaa; private long zzab; private volatile Boolean zzac; @VisibleForTesting private Boolean zzad; @VisibleForTesting private Boolean zzae; private volatile boolean zzaf; private int zzag; private int zzah; private final Context zzc; private final String zzd; private final String zze; private final String zzf; private final boolean zzg; private final zzad zzh; private final zzae zzi; private final zzgl zzj; private final zzfw zzk; private final zzhg zzl; private final zzml zzm; private final zznt zzn; private final zzfv zzo; private final Clock zzp; private final zzks zzq; private final zziz zzr; private final zza zzs; private final zzkn zzt; private final String zzu; private zzft zzv; private zzlb zzw; private zzaz zzx; private zzfq zzy; private boolean zzz = false; private AtomicInteger zzai = new AtomicInteger(0); @Override // com.google.android.gms.measurement.internal.zzil public final Context zza() { return this.zzc; } public final void zzaa() { this.zzag++; } public final boolean zzag() { return this.zzg; } @Override // com.google.android.gms.measurement.internal.zzil public final Clock zzb() { return this.zzp; } @Override // com.google.android.gms.measurement.internal.zzil public final zzad zzd() { return this.zzh; } public final zzae zzf() { return this.zzi; } public final zzfv zzk() { return this.zzo; } public final zzhg zzo() { return this.zzl; } public final String zzu() { return this.zzd; } public final String zzv() { return this.zze; } public final String zzw() { return this.zzf; } public final String zzx() { return this.zzu; } @WorkerThread public final int zzc() { zzl().zzt(); if (this.zzi.zzw()) { return 1; } Boolean bool = this.zzae; if (bool != null && bool.booleanValue()) { return 2; } if (!zzad()) { return 8; } Boolean zzv = zzn().zzv(); if (zzv != null) { return zzv.booleanValue() ? 0 : 3; } Boolean zzf = this.zzi.zzf("firebase_analytics_collection_enabled"); if (zzf != null) { return zzf.booleanValue() ? 0 : 4; } Boolean bool2 = this.zzad; return bool2 != null ? bool2.booleanValue() ? 0 : 5 : (this.zzac == null || this.zzac.booleanValue()) ? 0 : 7; } public final zza zze() { zza zzaVar = this.zzs; if (zzaVar != null) { return zzaVar; } throw new IllegalStateException("Component not created"); } public final zzaz zzg() { zza((zzim) this.zzx); return this.zzx; } public final zzfq zzh() { zza((zzg) this.zzy); return this.zzy; } public final zzft zzi() { zza((zzg) this.zzv); return this.zzv; } @Override // com.google.android.gms.measurement.internal.zzil public final zzfw zzj() { zza((zzim) this.zzk); return this.zzk; } public final zzfw zzm() { zzfw zzfwVar = this.zzk; if (zzfwVar == null || !zzfwVar.zzaf()) { return null; } return this.zzk; } public final zzgl zzn() { zza((zzij) this.zzj); return this.zzj; } @Override // com.google.android.gms.measurement.internal.zzil public final zzhg zzl() { zza((zzim) this.zzl); return this.zzl; } public static zzhj zza(Context context, com.google.android.gms.internal.measurement.zzdl zzdlVar, Long l) { Bundle bundle; if (zzdlVar != null && (zzdlVar.zze == null || zzdlVar.zzf == null)) { zzdlVar = new com.google.android.gms.internal.measurement.zzdl(zzdlVar.zza, zzdlVar.zzb, zzdlVar.zzc, zzdlVar.zzd, null, null, zzdlVar.zzg, null); } Preconditions.checkNotNull(context); Preconditions.checkNotNull(context.getApplicationContext()); if (zzb == null) { synchronized (zzhj.class) { try { if (zzb == null) { zzb = new zzhj(new zzix(context, zzdlVar, l)); } } finally { } } } else if (zzdlVar != null && (bundle = zzdlVar.zzg) != null && bundle.containsKey("dataCollectionDefaultEnabled")) { Preconditions.checkNotNull(zzb); zzb.zza(zzdlVar.zzg.getBoolean("dataCollectionDefaultEnabled")); } Preconditions.checkNotNull(zzb); return zzb; } public final zziz zzp() { zza((zzg) this.zzr); return this.zzr; } private final zzkn zzai() { zza((zzim) this.zzt); return this.zzt; } public final zzks zzq() { zza((zzg) this.zzq); return this.zzq; } public final zzlb zzr() { zza((zzg) this.zzw); return this.zzw; } public final zzml zzs() { zza((zzg) this.zzm); return this.zzm; } public final zznt zzt() { zza((zzij) this.zzn); return this.zzn; } public static /* synthetic */ void zza(zzhj zzhjVar, zzix zzixVar) { zzhjVar.zzl().zzt(); zzaz zzazVar = new zzaz(zzhjVar); zzazVar.zzad(); zzhjVar.zzx = zzazVar; zzfq zzfqVar = new zzfq(zzhjVar, zzixVar.zzf); zzfqVar.zzv(); zzhjVar.zzy = zzfqVar; zzft zzftVar = new zzft(zzhjVar); zzftVar.zzv(); zzhjVar.zzv = zzftVar; zzlb zzlbVar = new zzlb(zzhjVar); zzlbVar.zzv(); zzhjVar.zzw = zzlbVar; zzhjVar.zzn.zzae(); zzhjVar.zzj.zzae(); zzhjVar.zzy.zzw(); zzhjVar.zzj().zzn().zza("App measurement initialized, version", 95001L); zzhjVar.zzj().zzn().zza("To enable debug logging run: adb shell setprop log.tag.FA VERBOSE"); String zzad = zzfqVar.zzad(); if (TextUtils.isEmpty(zzhjVar.zzd)) { if (zzhjVar.zzt().zzd(zzad, zzhjVar.zzi.zzp())) { zzhjVar.zzj().zzn().zza("Faster debug mode event logging enabled. To disable, run:\n adb shell setprop debug.firebase.analytics.app .none."); } else { zzhjVar.zzj().zzn().zza("To enable faster debug mode event logging run:\n adb shell setprop debug.firebase.analytics.app " + zzad); } } zzhjVar.zzj().zzc().zza("Debug-level message logging enabled"); if (zzhjVar.zzag != zzhjVar.zzai.get()) { zzhjVar.zzj().zzg().zza("Not all components initialized", Integer.valueOf(zzhjVar.zzag), Integer.valueOf(zzhjVar.zzai.get())); } zzhjVar.zzz = true; } private zzhj(zzix zzixVar) { long currentTimeMillis; Bundle bundle; boolean z = false; Preconditions.checkNotNull(zzixVar); zzad zzadVar = new zzad(zzixVar.zza); this.zzh = zzadVar; zzfk.zza = zzadVar; Context context = zzixVar.zza; this.zzc = context; this.zzd = zzixVar.zzb; this.zze = zzixVar.zzc; this.zzf = zzixVar.zzd; this.zzg = zzixVar.zzh; this.zzac = zzixVar.zze; this.zzu = zzixVar.zzj; this.zzaf = true; com.google.android.gms.internal.measurement.zzdl zzdlVar = zzixVar.zzg; if (zzdlVar != null && (bundle = zzdlVar.zzg) != null) { Object obj = bundle.get("measurementEnabled"); if (obj instanceof Boolean) { this.zzad = (Boolean) obj; } Object obj2 = zzdlVar.zzg.get("measurementDeactivated"); if (obj2 instanceof Boolean) { this.zzae = (Boolean) obj2; } } com.google.android.gms.internal.measurement.zzgw.zzb(context); Clock defaultClock = DefaultClock.getInstance(); this.zzp = defaultClock; Long l = zzixVar.zzi; if (l != null) { currentTimeMillis = l.longValue(); } else { currentTimeMillis = defaultClock.currentTimeMillis(); } this.zza = currentTimeMillis; this.zzi = new zzae(this); zzgl zzglVar = new zzgl(this); zzglVar.zzad(); this.zzj = zzglVar; zzfw zzfwVar = new zzfw(this); zzfwVar.zzad(); this.zzk = zzfwVar; zznt zzntVar = new zznt(this); zzntVar.zzad(); this.zzn = zzntVar; this.zzo = new zzfv(new zziw(zzixVar, this)); this.zzs = new zza(this); zzks zzksVar = new zzks(this); zzksVar.zzv(); this.zzq = zzksVar; zziz zzizVar = new zziz(this); zzizVar.zzv(); this.zzr = zzizVar; zzml zzmlVar = new zzml(this); zzmlVar.zzv(); this.zzm = zzmlVar; zzkn zzknVar = new zzkn(this); zzknVar.zzad(); this.zzt = zzknVar; zzhg zzhgVar = new zzhg(this); zzhgVar.zzad(); this.zzl = zzhgVar; com.google.android.gms.internal.measurement.zzdl zzdlVar2 = zzixVar.zzg; if (zzdlVar2 != null && zzdlVar2.zzb != 0) { z = true; } boolean z2 = !z; if (context.getApplicationContext() instanceof Application) { zzp().zzb(z2); } else { zzj().zzu().zza("Application context is not an Application"); } zzhgVar.zzb(new zzho(this, zzixVar)); } private static void zza(zzij zzijVar) { if (zzijVar == null) { throw new IllegalStateException("Component not created"); } } private static void zza(zzg zzgVar) { if (zzgVar == null) { throw new IllegalStateException("Component not created"); } if (zzgVar.zzy()) { return; } throw new IllegalStateException("Component not initialized: " + String.valueOf(zzgVar.getClass())); } private static void zza(zzim zzimVar) { if (zzimVar == null) { throw new IllegalStateException("Component not created"); } if (zzimVar.zzaf()) { return; } throw new IllegalStateException("Component not initialized: " + String.valueOf(zzimVar.getClass())); } public final void zzy() { throw new IllegalStateException("Unexpected call on client side"); } public final void zzz() { this.zzai.incrementAndGet(); } public final /* synthetic */ void zza(String str, int i, Throwable th, byte[] bArr, Map map) { if ((i != 200 && i != 204 && i != 304) || th != null) { zzj().zzu().zza("Network Request for Deferred Deep Link failed. response, exception", Integer.valueOf(i), th); return; } zzn().zzo.zza(true); if (bArr == null || bArr.length == 0) { zzj().zzc().zza("Deferred Deep Link response empty."); return; } try { JSONObject jSONObject = new JSONObject(new String(bArr)); String optString = jSONObject.optString(SDKConstants.PARAM_TOURNAMENTS_DEEPLINK, ""); if (TextUtils.isEmpty(optString)) { zzj().zzc().zza("Deferred Deep Link is empty."); return; } String optString2 = jSONObject.optString("gclid", ""); String optString3 = jSONObject.optString("gbraid", ""); String optString4 = jSONObject.optString("gad_source", ""); double optDouble = jSONObject.optDouble("timestamp", 0.0d); Bundle bundle = new Bundle(); if (zzok.zza() && this.zzi.zza(zzbh.zzco)) { if (!zzt().zzi(optString)) { zzj().zzu().zza("Deferred Deep Link validation failed. gclid, gbraid, deep link", optString2, optString3, optString); return; } if (!TextUtils.isEmpty(optString3)) { bundle.putString("gbraid", optString3); } if (!TextUtils.isEmpty(optString4)) { bundle.putString("gad_source", optString4); } long longValue = Double.valueOf(optDouble).longValue(); if (longValue > 0) { bundle.putLong("click_timestamp", longValue); } } else if (!zzt().zzi(optString)) { zzj().zzu().zza("Deferred Deep Link validation failed. gclid, deep link", optString2, optString); return; } if (zzok.zza()) { this.zzi.zza(zzbh.zzco); } bundle.putString("gclid", optString2); bundle.putString("_cis", "ddp"); this.zzr.zzc("auto", "_cmp", bundle); zznt zzt = zzt(); if (TextUtils.isEmpty(optString) || !zzt.zza(optString, optDouble)) { return; } zzt.zza().sendBroadcast(new Intent("android.google.analytics.action.DEEPLINK_ACTION")); } catch (JSONException e) { zzj().zzg().zza("Failed to parse the Deferred Deep Link response. exception", e); } } @WorkerThread public final void zza(boolean z) { this.zzac = Boolean.valueOf(z); } @WorkerThread public final void zzb(boolean z) { zzl().zzt(); this.zzaf = z; } /* JADX WARN: Code restructure failed: missing block: B:145:0x00ec, code lost: if (r1.zzk() != false) goto L64; */ /* JADX WARN: Code restructure failed: missing block: B:169:0x0161, code lost: if (r1.zzk() != false) goto L64; */ /* JADX WARN: Removed duplicated region for block: B:121:0x0234 */ @androidx.annotation.WorkerThread /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final void zza(com.google.android.gms.internal.measurement.zzdl r13) { /* Method dump skipped, instructions count: 1297 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.measurement.internal.zzhj.zza(com.google.android.gms.internal.measurement.zzdl):void"); } @WorkerThread public final boolean zzab() { return this.zzac != null && this.zzac.booleanValue(); } @WorkerThread public final boolean zzac() { return zzc() == 0; } @WorkerThread public final boolean zzad() { zzl().zzt(); return this.zzaf; } public final boolean zzae() { return TextUtils.isEmpty(this.zzd); } @WorkerThread public final boolean zzaf() { if (!this.zzz) { throw new IllegalStateException("AppMeasurement is not initialized"); } zzl().zzt(); Boolean bool = this.zzaa; if (bool == null || this.zzab == 0 || (bool != null && !bool.booleanValue() && Math.abs(this.zzp.elapsedRealtime() - this.zzab) > 1000)) { this.zzab = this.zzp.elapsedRealtime(); boolean z = true; Boolean valueOf = Boolean.valueOf(zzt().zze("android.permission.INTERNET") && zzt().zze("android.permission.ACCESS_NETWORK_STATE") && (Wrappers.packageManager(this.zzc).isCallerInstantApp() || this.zzi.zzx() || (zznt.zza(this.zzc) && zznt.zza(this.zzc, false)))); this.zzaa = valueOf; if (valueOf.booleanValue()) { if (!zzt().zza(zzh().zzae(), zzh().zzac()) && TextUtils.isEmpty(zzh().zzac())) { z = false; } this.zzaa = Boolean.valueOf(z); } } return this.zzaa.booleanValue(); } @WorkerThread public final boolean zzah() { zzl().zzt(); zza((zzim) zzai()); String zzad = zzh().zzad(); Pair zza = zzn().zza(zzad); if (!this.zzi.zzu() || ((Boolean) zza.second).booleanValue() || TextUtils.isEmpty((CharSequence) zza.first)) { zzj().zzc().zza("ADID unavailable to retrieve Deferred Deep Link. Skipping"); return false; } if (!zzai().zzc()) { zzj().zzu().zza("Network is not available for Deferred Deep Link request. Skipping"); return false; } StringBuilder sb = new StringBuilder(); zzlb zzr = zzr(); zzr.zzt(); zzr.zzu(); if (!zzr.zzao() || zzr.zzq().zzg() >= 234200) { zzal zzab = zzp().zzab(); Bundle bundle = zzab != null ? zzab.zza : null; if (bundle == null) { int i = this.zzah; this.zzah = i + 1; boolean z = i < 10; zzj().zzc().zza("Failed to retrieve DMA consent from the service, " + (z ? "Retrying." : "Skipping.") + " retryCount", Integer.valueOf(this.zzah)); return z; } zzin zza2 = zzin.zza(bundle, 100); sb.append("&gcs="); sb.append(zza2.zzg()); zzax zza3 = zzax.zza(bundle, 100); sb.append("&dma="); sb.append(zza3.zzd() == Boolean.FALSE ? 0 : 1); if (!TextUtils.isEmpty(zza3.zze())) { sb.append("&dma_cps="); sb.append(zza3.zze()); } int i2 = zzax.zza(bundle) == Boolean.TRUE ? 0 : 1; sb.append("&npa="); sb.append(i2); zzj().zzp().zza("Consent query parameters to Bow", sb); } zznt zzt = zzt(); zzh(); URL zza4 = zzt.zza(95001L, zzad, (String) zza.first, zzn().zzp.zza() - 1, sb.toString()); if (zza4 != null) { zzkn zzai = zzai(); zzkm zzkmVar = new zzkm() { // from class: com.google.android.gms.measurement.internal.zzhl @Override // com.google.android.gms.measurement.internal.zzkm public final void zza(String str, int i3, Throwable th, byte[] bArr, Map map) { zzhj.this.zza(str, i3, th, bArr, map); } }; zzai.zzt(); zzai.zzac(); Preconditions.checkNotNull(zza4); Preconditions.checkNotNull(zzkmVar); zzai.zzl().zza(new zzkp(zzai, zzad, zza4, null, null, zzkmVar)); } return false; } }