194 lines
6.5 KiB
Java
194 lines
6.5 KiB
Java
|
package com.google.android.gms.internal.clearcut;
|
||
|
|
||
|
import android.content.ContentResolver;
|
||
|
import android.database.Cursor;
|
||
|
import android.net.Uri;
|
||
|
import android.util.Log;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Map;
|
||
|
import java.util.TreeMap;
|
||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||
|
import java.util.regex.Pattern;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public class zzy {
|
||
|
private static HashMap<String, String> zzcu;
|
||
|
private static Object zzcz;
|
||
|
private static boolean zzda;
|
||
|
private static final Uri CONTENT_URI = Uri.parse("content://com.google.android.gsf.gservices");
|
||
|
private static final Uri zzcq = Uri.parse("content://com.google.android.gsf.gservices/prefix");
|
||
|
public static final Pattern zzcr = Pattern.compile("^(1|true|t|on|yes|y)$", 2);
|
||
|
public static final Pattern zzcs = Pattern.compile("^(0|false|f|off|no|n)$", 2);
|
||
|
private static final AtomicBoolean zzct = new AtomicBoolean();
|
||
|
private static final HashMap<String, Boolean> zzcv = new HashMap<>();
|
||
|
private static final HashMap<String, Integer> zzcw = new HashMap<>();
|
||
|
private static final HashMap<String, Long> zzcx = new HashMap<>();
|
||
|
private static final HashMap<String, Float> zzcy = new HashMap<>();
|
||
|
private static String[] zzdb = new String[0];
|
||
|
|
||
|
private static Object zzb(ContentResolver contentResolver) {
|
||
|
Object obj;
|
||
|
synchronized (zzy.class) {
|
||
|
zza(contentResolver);
|
||
|
obj = zzcz;
|
||
|
}
|
||
|
return obj;
|
||
|
}
|
||
|
|
||
|
public static boolean zza(ContentResolver contentResolver, String str, boolean z) {
|
||
|
boolean z2;
|
||
|
Object zzb = zzb(contentResolver);
|
||
|
HashMap<String, Boolean> hashMap = zzcv;
|
||
|
Boolean bool = (Boolean) zza(hashMap, str, Boolean.valueOf(z));
|
||
|
if (bool != null) {
|
||
|
return bool.booleanValue();
|
||
|
}
|
||
|
String zza = zza(contentResolver, str, (String) null);
|
||
|
if (zza != null && !zza.equals("")) {
|
||
|
if (zzcr.matcher(zza).matches()) {
|
||
|
z2 = true;
|
||
|
} else if (zzcs.matcher(zza).matches()) {
|
||
|
z2 = false;
|
||
|
} else {
|
||
|
Log.w("Gservices", "attempt to read gservices key " + str + " (value \"" + zza + "\") as boolean");
|
||
|
}
|
||
|
z = z2;
|
||
|
bool = Boolean.valueOf(z);
|
||
|
}
|
||
|
zza(zzb, hashMap, str, bool);
|
||
|
return z;
|
||
|
}
|
||
|
|
||
|
private static <T> void zza(Object obj, HashMap<String, T> hashMap, String str, T t) {
|
||
|
synchronized (zzy.class) {
|
||
|
if (obj == zzcz) {
|
||
|
hashMap.put(str, t);
|
||
|
zzcu.remove(str);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static void zza(Object obj, String str, String str2) {
|
||
|
synchronized (zzy.class) {
|
||
|
if (obj == zzcz) {
|
||
|
zzcu.put(str, str2);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static void zza(ContentResolver contentResolver) {
|
||
|
if (zzcu == null) {
|
||
|
zzct.set(false);
|
||
|
zzcu = new HashMap<>();
|
||
|
zzcz = new Object();
|
||
|
zzda = false;
|
||
|
contentResolver.registerContentObserver(CONTENT_URI, true, new zzz(null));
|
||
|
return;
|
||
|
}
|
||
|
if (zzct.getAndSet(false)) {
|
||
|
zzcu.clear();
|
||
|
zzcv.clear();
|
||
|
zzcw.clear();
|
||
|
zzcx.clear();
|
||
|
zzcy.clear();
|
||
|
zzcz = new Object();
|
||
|
zzda = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static Map<String, String> zza(ContentResolver contentResolver, String... strArr) {
|
||
|
Cursor query = contentResolver.query(zzcq, null, null, strArr, null);
|
||
|
TreeMap treeMap = new TreeMap();
|
||
|
if (query == null) {
|
||
|
return treeMap;
|
||
|
}
|
||
|
while (query.moveToNext()) {
|
||
|
try {
|
||
|
treeMap.put(query.getString(0), query.getString(1));
|
||
|
} finally {
|
||
|
query.close();
|
||
|
}
|
||
|
}
|
||
|
return treeMap;
|
||
|
}
|
||
|
|
||
|
public static String zza(ContentResolver contentResolver, String str, String str2) {
|
||
|
synchronized (zzy.class) {
|
||
|
zza(contentResolver);
|
||
|
Object obj = zzcz;
|
||
|
if (zzcu.containsKey(str)) {
|
||
|
String str3 = zzcu.get(str);
|
||
|
return str3 != null ? str3 : null;
|
||
|
}
|
||
|
for (String str4 : zzdb) {
|
||
|
if (str.startsWith(str4)) {
|
||
|
if (!zzda || zzcu.isEmpty()) {
|
||
|
zzcu.putAll(zza(contentResolver, zzdb));
|
||
|
zzda = true;
|
||
|
if (zzcu.containsKey(str)) {
|
||
|
String str5 = zzcu.get(str);
|
||
|
return str5 != null ? str5 : null;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
Cursor query = contentResolver.query(CONTENT_URI, null, null, new String[]{str}, null);
|
||
|
if (query != null) {
|
||
|
try {
|
||
|
if (query.moveToFirst()) {
|
||
|
String string = query.getString(1);
|
||
|
if (string != null && string.equals(null)) {
|
||
|
string = null;
|
||
|
}
|
||
|
zza(obj, str, string);
|
||
|
return string != null ? string : null;
|
||
|
}
|
||
|
} finally {
|
||
|
if (query != null) {
|
||
|
query.close();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
zza(obj, str, (String) null);
|
||
|
if (query != null) {
|
||
|
query.close();
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static <T> T zza(HashMap<String, T> hashMap, String str, T t) {
|
||
|
synchronized (zzy.class) {
|
||
|
if (!hashMap.containsKey(str)) {
|
||
|
return null;
|
||
|
}
|
||
|
T t2 = hashMap.get(str);
|
||
|
if (t2 != null) {
|
||
|
t = t2;
|
||
|
}
|
||
|
return t;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static long getLong(ContentResolver contentResolver, String str, long j) {
|
||
|
Object zzb = zzb(contentResolver);
|
||
|
long j2 = 0;
|
||
|
Long l = (Long) zza((HashMap<String, long>) zzcx, str, 0L);
|
||
|
if (l != null) {
|
||
|
return l.longValue();
|
||
|
}
|
||
|
String zza = zza(contentResolver, str, (String) null);
|
||
|
if (zza != null) {
|
||
|
try {
|
||
|
long parseLong = Long.parseLong(zza);
|
||
|
l = Long.valueOf(parseLong);
|
||
|
j2 = parseLong;
|
||
|
} catch (NumberFormatException unused) {
|
||
|
}
|
||
|
}
|
||
|
zza(zzb, zzcx, str, l);
|
||
|
return j2;
|
||
|
}
|
||
|
}
|