package com.google.android.gms.internal.measurement; import android.content.ContentResolver; import androidx.annotation.GuardedBy; import androidx.annotation.Nullable; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; /* loaded from: classes3.dex */ public final class zzga implements zzfx { private final AtomicBoolean zza = new AtomicBoolean(); @Nullable @GuardedBy("this") private HashMap zzb = null; @GuardedBy("this") private final HashMap zzc = new HashMap<>(16, 1.0f); @GuardedBy("this") private final HashMap zzd = new HashMap<>(16, 1.0f); @GuardedBy("this") private final HashMap zze = new HashMap<>(16, 1.0f); @GuardedBy("this") private final HashMap zzf = new HashMap<>(16, 1.0f); @Nullable @GuardedBy("this") private Object zzg = null; @GuardedBy("this") private boolean zzh = false; @GuardedBy("this") private String[] zzi = new String[0]; private final zzgd zzj = new zzgb(); @Override // com.google.android.gms.internal.measurement.zzfx @Nullable public final String zza(@Nullable ContentResolver contentResolver, String str, @Nullable String str2) { if (contentResolver == null) { throw new IllegalStateException("ContentResolver needed with GservicesDelegateSupplier.init()"); } synchronized (this) { try { if (this.zzb == null) { this.zza.set(false); this.zzb = new HashMap<>(16, 1.0f); this.zzg = new Object(); contentResolver.registerContentObserver(zzfv.zza, true, new zzgc(this, null)); } else if (this.zza.getAndSet(false)) { this.zzb.clear(); this.zzc.clear(); this.zzd.clear(); this.zze.clear(); this.zzf.clear(); this.zzg = new Object(); this.zzh = false; } Object obj = this.zzg; if (this.zzb.containsKey(str)) { String str3 = this.zzb.get(str); return str3 != null ? str3 : null; } for (String str4 : this.zzi) { if (str.startsWith(str4)) { if (!this.zzh) { try { HashMap hashMap = (HashMap) this.zzj.zza(contentResolver, this.zzi, new zzge() { // from class: com.google.android.gms.internal.measurement.zzfz @Override // com.google.android.gms.internal.measurement.zzge public final Map zza(int i) { return new HashMap(i, 1.0f); } }); if (!hashMap.isEmpty()) { Set keySet = hashMap.keySet(); keySet.removeAll(this.zzc.keySet()); keySet.removeAll(this.zzd.keySet()); keySet.removeAll(this.zze.keySet()); keySet.removeAll(this.zzf.keySet()); } if (!hashMap.isEmpty()) { if (this.zzb.isEmpty()) { this.zzb = hashMap; } else { this.zzb.putAll(hashMap); } } this.zzh = true; } catch (zzgg unused) { } if (this.zzb.containsKey(str)) { String str5 = this.zzb.get(str); return str5 != null ? str5 : null; } } return null; } } try { String zza = this.zzj.zza(contentResolver, str); if (zza != null && zza.equals(null)) { zza = null; } synchronized (this) { try { if (obj == this.zzg) { this.zzb.put(str, zza); } } finally { } } if (zza != null) { return zza; } return null; } catch (zzgg unused2) { return null; } } finally { } } } }