258 lines
9.6 KiB
Java
258 lines
9.6 KiB
Java
package com.google.android.gms.internal.gtm;
|
|
|
|
import android.os.Bundle;
|
|
import com.google.android.gms.common.internal.Preconditions;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class zzoo {
|
|
public static zzoa<?> zzq(Object obj) {
|
|
if (obj == null) {
|
|
return zzog.zzaul;
|
|
}
|
|
if (obj instanceof zzoa) {
|
|
return (zzoa) obj;
|
|
}
|
|
if (obj instanceof Boolean) {
|
|
return new zzod((Boolean) obj);
|
|
}
|
|
if (obj instanceof Short) {
|
|
return new zzoe(Double.valueOf(((Short) obj).doubleValue()));
|
|
}
|
|
if (obj instanceof Integer) {
|
|
return new zzoe(Double.valueOf(((Integer) obj).doubleValue()));
|
|
}
|
|
if (obj instanceof Long) {
|
|
return new zzoe(Double.valueOf(((Long) obj).doubleValue()));
|
|
}
|
|
if (obj instanceof Float) {
|
|
return new zzoe(Double.valueOf(((Float) obj).doubleValue()));
|
|
}
|
|
if (obj instanceof Double) {
|
|
return new zzoe((Double) obj);
|
|
}
|
|
if (obj instanceof Byte) {
|
|
return new zzom(obj.toString());
|
|
}
|
|
if (obj instanceof Character) {
|
|
return new zzom(obj.toString());
|
|
}
|
|
if (obj instanceof String) {
|
|
return new zzom((String) obj);
|
|
}
|
|
if (obj instanceof List) {
|
|
ArrayList arrayList = new ArrayList();
|
|
Iterator it = ((List) obj).iterator();
|
|
while (it.hasNext()) {
|
|
arrayList.add(zzq(it.next()));
|
|
}
|
|
return new zzoh(arrayList);
|
|
}
|
|
if (obj instanceof Map) {
|
|
HashMap hashMap = new HashMap();
|
|
for (Map.Entry entry : ((Map) obj).entrySet()) {
|
|
Preconditions.checkArgument(entry.getKey() instanceof String);
|
|
hashMap.put((String) entry.getKey(), zzq(entry.getValue()));
|
|
}
|
|
return new zzok(hashMap);
|
|
}
|
|
if (obj instanceof Bundle) {
|
|
HashMap hashMap2 = new HashMap();
|
|
Bundle bundle = (Bundle) obj;
|
|
for (String str : bundle.keySet()) {
|
|
hashMap2.put(str, zzq(bundle.get(str)));
|
|
}
|
|
return new zzok(hashMap2);
|
|
}
|
|
String valueOf = String.valueOf(obj.getClass());
|
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 20);
|
|
sb.append("Type not supported: ");
|
|
sb.append(valueOf);
|
|
throw new UnsupportedOperationException(sb.toString());
|
|
}
|
|
|
|
public static Object zzj(zzoa<?> zzoaVar) {
|
|
if (zzoaVar == null || zzoaVar == zzog.zzaul) {
|
|
return null;
|
|
}
|
|
if (zzoaVar instanceof zzod) {
|
|
return ((zzod) zzoaVar).value();
|
|
}
|
|
if (zzoaVar instanceof zzoe) {
|
|
zzoe zzoeVar = (zzoe) zzoaVar;
|
|
double doubleValue = zzoeVar.value().doubleValue();
|
|
if (!Double.isInfinite(doubleValue) && doubleValue - Math.floor(doubleValue) < 1.0E-5d) {
|
|
return Integer.valueOf((int) doubleValue);
|
|
}
|
|
return zzoeVar.value().toString();
|
|
}
|
|
if (zzoaVar instanceof zzom) {
|
|
return ((zzom) zzoaVar).value();
|
|
}
|
|
if (zzoaVar instanceof zzoh) {
|
|
ArrayList arrayList = new ArrayList();
|
|
for (zzoa<?> zzoaVar2 : ((zzoh) zzoaVar).value()) {
|
|
Object zzj = zzj(zzoaVar2);
|
|
if (zzj == null) {
|
|
zzev.zzav(String.format("Failure to convert a list element to object: %s (%s)", zzoaVar2, zzoaVar2.getClass().getCanonicalName()));
|
|
return null;
|
|
}
|
|
arrayList.add(zzj);
|
|
}
|
|
return arrayList;
|
|
}
|
|
if (zzoaVar instanceof zzok) {
|
|
HashMap hashMap = new HashMap();
|
|
for (Map.Entry<String, zzoa<?>> entry : ((zzok) zzoaVar).value().entrySet()) {
|
|
Object zzj2 = zzj(entry.getValue());
|
|
if (zzj2 == null) {
|
|
zzev.zzav(String.format("Failure to convert a map's value to object: %s (%s)", entry.getValue(), entry.getValue().getClass().getCanonicalName()));
|
|
return null;
|
|
}
|
|
hashMap.put(entry.getKey(), zzj2);
|
|
}
|
|
return hashMap;
|
|
}
|
|
String valueOf = String.valueOf(zzoaVar.getClass());
|
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 49);
|
|
sb.append("Converting to Object from unknown abstract type: ");
|
|
sb.append(valueOf);
|
|
zzev.zzav(sb.toString());
|
|
return null;
|
|
}
|
|
|
|
public static Bundle zzk(Map<String, zzoa<?>> map) {
|
|
if (map == null) {
|
|
return null;
|
|
}
|
|
Bundle bundle = new Bundle(map.size());
|
|
for (Map.Entry<String, zzoa<?>> entry : map.entrySet()) {
|
|
if (entry.getValue() instanceof zzom) {
|
|
bundle.putString(entry.getKey(), ((zzom) entry.getValue()).value());
|
|
} else if (entry.getValue() instanceof zzod) {
|
|
bundle.putBoolean(entry.getKey(), ((zzod) entry.getValue()).value().booleanValue());
|
|
} else if (entry.getValue() instanceof zzoe) {
|
|
bundle.putDouble(entry.getKey(), ((zzoe) entry.getValue()).value().doubleValue());
|
|
} else if (entry.getValue() instanceof zzok) {
|
|
bundle.putBundle(entry.getKey(), zzk(((zzok) entry.getValue()).value()));
|
|
} else {
|
|
throw new IllegalArgumentException(String.format("Invalid param type for key '%s'. Only boolean, double and string types and maps of thereof are supported.", entry.getKey()));
|
|
}
|
|
}
|
|
return bundle;
|
|
}
|
|
|
|
public static Map<String, Object> zza(Bundle bundle) {
|
|
HashMap hashMap = new HashMap();
|
|
for (String str : bundle.keySet()) {
|
|
Object obj = bundle.get(str);
|
|
if (obj instanceof Bundle) {
|
|
hashMap.put(str, zza((Bundle) obj));
|
|
} else if (obj instanceof List) {
|
|
hashMap.put(str, zzf((List) obj));
|
|
} else {
|
|
hashMap.put(str, obj);
|
|
}
|
|
}
|
|
return hashMap;
|
|
}
|
|
|
|
private static List<Object> zzf(List<Object> list) {
|
|
ArrayList arrayList = new ArrayList();
|
|
for (Object obj : list) {
|
|
if (obj instanceof Bundle) {
|
|
arrayList.add(zza((Bundle) obj));
|
|
} else if (obj instanceof List) {
|
|
arrayList.add(zzf((List) obj));
|
|
} else {
|
|
arrayList.add(obj);
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
public static zzoa zzk(zzoa<?> zzoaVar) {
|
|
if (!(zzoaVar instanceof zzok)) {
|
|
return zzoaVar;
|
|
}
|
|
HashSet hashSet = new HashSet();
|
|
Map<String, zzoa<?>> value = ((zzok) zzoaVar).value();
|
|
for (Map.Entry<String, zzoa<?>> entry : value.entrySet()) {
|
|
if (entry.getValue() == zzog.zzaum) {
|
|
hashSet.add(entry.getKey());
|
|
}
|
|
}
|
|
Iterator it = hashSet.iterator();
|
|
while (it.hasNext()) {
|
|
value.remove((String) it.next());
|
|
}
|
|
return zzoaVar;
|
|
}
|
|
|
|
public static zzoa zza(zzfl zzflVar, zzoa zzoaVar) {
|
|
Preconditions.checkNotNull(zzoaVar);
|
|
if (!zzl(zzoaVar) && !(zzoaVar instanceof zzof) && !(zzoaVar instanceof zzoh) && !(zzoaVar instanceof zzok)) {
|
|
if (zzoaVar instanceof zzol) {
|
|
zzoaVar = zza(zzflVar, (zzol) zzoaVar);
|
|
} else {
|
|
throw new UnsupportedOperationException("Attempting to evaluate unknown type");
|
|
}
|
|
}
|
|
if (zzoaVar != null) {
|
|
if (zzoaVar instanceof zzol) {
|
|
throw new IllegalArgumentException("AbstractType evaluated to illegal type Statement.");
|
|
}
|
|
return zzoaVar;
|
|
}
|
|
throw new IllegalArgumentException("AbstractType evaluated to Java null");
|
|
}
|
|
|
|
public static zzog zza(zzfl zzflVar, List<zzoa<?>> list) {
|
|
for (zzoa<?> zzoaVar : list) {
|
|
Preconditions.checkArgument(zzoaVar instanceof zzol);
|
|
zzoa zza = zza(zzflVar, zzoaVar);
|
|
if (zzm(zza)) {
|
|
return (zzog) zza;
|
|
}
|
|
}
|
|
return zzog.zzaum;
|
|
}
|
|
|
|
public static boolean zzl(zzoa zzoaVar) {
|
|
return (zzoaVar instanceof zzod) || (zzoaVar instanceof zzoe) || (zzoaVar instanceof zzom) || zzoaVar == zzog.zzaul || zzoaVar == zzog.zzaum;
|
|
}
|
|
|
|
public static boolean zzm(zzoa zzoaVar) {
|
|
if (zzoaVar == zzog.zzauk || zzoaVar == zzog.zzauj) {
|
|
return true;
|
|
}
|
|
return (zzoaVar instanceof zzog) && ((zzog) zzoaVar).zzmh();
|
|
}
|
|
|
|
public static zzoa zza(zzfl zzflVar, zzol zzolVar) {
|
|
String zzmj = zzolVar.zzmj();
|
|
List<zzoa<?>> zzmk = zzolVar.zzmk();
|
|
zzoa<?> zzca = zzflVar.zzca(zzmj);
|
|
if (zzca == null) {
|
|
StringBuilder sb = new StringBuilder(String.valueOf(zzmj).length() + 28);
|
|
sb.append("Function '");
|
|
sb.append(zzmj);
|
|
sb.append("' is not supported");
|
|
throw new UnsupportedOperationException(sb.toString());
|
|
}
|
|
if (!(zzca instanceof zzof)) {
|
|
StringBuilder sb2 = new StringBuilder(String.valueOf(zzmj).length() + 29);
|
|
sb2.append("Function '");
|
|
sb2.append(zzmj);
|
|
sb2.append("' is not a function");
|
|
throw new UnsupportedOperationException(sb2.toString());
|
|
}
|
|
return ((zzof) zzca).value().zzb(zzflVar, (zzoa[]) zzmk.toArray(new zzoa[zzmk.size()]));
|
|
}
|
|
}
|