package com.google.android.gms.internal.measurement; import android.content.ContentResolver; import android.database.ContentObserver; import android.database.Cursor; import android.database.sqlite.SQLiteException; import android.net.Uri; import android.os.StrictMode; import android.util.Log; import com.google.android.gms.measurement.api.AppMeasurementSdk; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /* loaded from: classes.dex */ public final class zzhf implements zzhk { private final ContentResolver zzc; private final Uri zzd; private final Runnable zze; private final ContentObserver zzf; private final Object zzg; private volatile Map zzh; private final List zzi; private static final Map zzb = new androidx.collection.a(); public static final String[] zza = {"key", AppMeasurementSdk.ConditionalUserProperty.VALUE}; private zzhf(ContentResolver contentResolver, Uri uri, Runnable runnable) { zzhe zzheVar = new zzhe(this, null); this.zzf = zzheVar; this.zzg = new Object(); this.zzi = new ArrayList(); contentResolver.getClass(); uri.getClass(); this.zzc = contentResolver; this.zzd = uri; this.zze = runnable; contentResolver.registerContentObserver(uri, false, zzheVar); } public static zzhf zza(ContentResolver contentResolver, Uri uri, Runnable runnable) { zzhf zzhfVar; synchronized (zzhf.class) { Map map = zzb; zzhfVar = (zzhf) map.get(uri); if (zzhfVar == null) { try { zzhf zzhfVar2 = new zzhf(contentResolver, uri, runnable); try { map.put(uri, zzhfVar2); } catch (SecurityException unused) { } zzhfVar = zzhfVar2; } catch (SecurityException unused2) { } } } return zzhfVar; } static synchronized void zze() { synchronized (zzhf.class) { for (zzhf zzhfVar : zzb.values()) { zzhfVar.zzc.unregisterContentObserver(zzhfVar.zzf); } zzb.clear(); } } @Override // com.google.android.gms.internal.measurement.zzhk public final /* bridge */ /* synthetic */ Object zzb(String str) { return (String) zzc().get(str); } public final Map zzc() { Map map; Map map2 = this.zzh; if (map2 == null) { synchronized (this.zzg) { map2 = this.zzh; if (map2 == null) { StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads(); try { try { map = (Map) zzhi.zza(new zzhj() { // from class: com.google.android.gms.internal.measurement.zzhd @Override // com.google.android.gms.internal.measurement.zzhj public final Object zza() { return zzhf.this.zzd(); } }); } finally { StrictMode.setThreadPolicy(allowThreadDiskReads); } } catch (SQLiteException | IllegalStateException | SecurityException unused) { Log.e("ConfigurationContentLdr", "PhenotypeFlag unable to load ContentProvider, using default values"); StrictMode.setThreadPolicy(allowThreadDiskReads); map = null; } this.zzh = map; map2 = map; } } } return map2 != null ? map2 : Collections.emptyMap(); } final /* synthetic */ Map zzd() { Cursor query = this.zzc.query(this.zzd, zza, null, null, null); if (query == null) { return Collections.emptyMap(); } try { int count = query.getCount(); if (count == 0) { return Collections.emptyMap(); } Map aVar = count <= 256 ? new androidx.collection.a(count) : new HashMap(count, 1.0f); while (query.moveToNext()) { aVar.put(query.getString(0), query.getString(1)); } return aVar; } finally { query.close(); } } public final void zzf() { synchronized (this.zzg) { this.zzh = null; this.zze.run(); } synchronized (this) { Iterator it = this.zzi.iterator(); while (it.hasNext()) { ((zzhg) it.next()).zza(); } } } }