285 lines
11 KiB
Java
285 lines
11 KiB
Java
package c.i.a.b.i;
|
|
|
|
import android.content.Context;
|
|
import android.content.pm.PackageManager;
|
|
import android.net.ConnectivityManager;
|
|
import android.net.NetworkInfo;
|
|
import android.os.Build;
|
|
import android.telephony.TelephonyManager;
|
|
import android.util.Log;
|
|
import androidx.annotation.Nullable;
|
|
import c.i.a.b.i.e.c;
|
|
import c.i.a.b.i.e.f;
|
|
import c.i.a.b.i.e.i;
|
|
import c.i.a.b.i.e.j;
|
|
import c.i.a.b.i.e.k;
|
|
import c.i.a.b.i.e.o;
|
|
import c.i.a.b.i.e.p;
|
|
import c.i.a.b.j.f;
|
|
import c.i.a.b.j.q.f;
|
|
import c.i.a.b.j.q.g;
|
|
import c.i.a.b.j.q.m;
|
|
import c.i.c.p.h.e;
|
|
import com.adjust.sdk.Constants;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import java.io.IOException;
|
|
import java.net.MalformedURLException;
|
|
import java.net.URL;
|
|
import java.nio.charset.Charset;
|
|
import java.util.ArrayList;
|
|
import java.util.Calendar;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.TimeZone;
|
|
/* compiled from: CctTransportBackend */
|
|
public final class d implements m {
|
|
public final c.i.c.p.a a;
|
|
public final ConnectivityManager b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final Context f602c;
|
|
public final URL d = c(a.a);
|
|
public final c.i.a.b.j.v.a e;
|
|
public final c.i.a.b.j.v.a f;
|
|
public final int g;
|
|
|
|
/* compiled from: CctTransportBackend */
|
|
public static final class a {
|
|
public final URL a;
|
|
public final j b;
|
|
@Nullable
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final String f603c;
|
|
|
|
public a(URL url, j jVar, @Nullable String str) {
|
|
this.a = url;
|
|
this.b = jVar;
|
|
this.f603c = str;
|
|
}
|
|
}
|
|
|
|
/* compiled from: CctTransportBackend */
|
|
public static final class b {
|
|
public final int a;
|
|
@Nullable
|
|
public final URL b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final long f604c;
|
|
|
|
public b(int i, @Nullable URL url, long j) {
|
|
this.a = i;
|
|
this.b = url;
|
|
this.f604c = j;
|
|
}
|
|
}
|
|
|
|
public d(Context context, c.i.a.b.j.v.a aVar, c.i.a.b.j.v.a aVar2) {
|
|
e eVar = new e();
|
|
((c.i.a.b.i.e.b) c.i.a.b.i.e.b.a).a(eVar);
|
|
eVar.e = true;
|
|
this.a = new c.i.c.p.h.d(eVar);
|
|
this.f602c = context;
|
|
this.b = (ConnectivityManager) context.getSystemService("connectivity");
|
|
this.e = aVar2;
|
|
this.f = aVar;
|
|
this.g = 40000;
|
|
}
|
|
|
|
public static URL c(String str) {
|
|
try {
|
|
return new URL(str);
|
|
} catch (MalformedURLException e) {
|
|
throw new IllegalArgumentException(c.d.b.a.a.u("Invalid url: ", str), e);
|
|
}
|
|
}
|
|
|
|
@Override // c.i.a.b.j.q.m
|
|
public g a(f fVar) {
|
|
g.a aVar;
|
|
IOException e;
|
|
String str;
|
|
Integer num;
|
|
g.a aVar2;
|
|
f.b bVar;
|
|
g.a aVar3 = g.a.TRANSIENT_ERROR;
|
|
HashMap hashMap = new HashMap();
|
|
c.i.a.b.j.q.a aVar4 = (c.i.a.b.j.q.a) fVar;
|
|
for (c.i.a.b.j.f fVar2 : aVar4.a) {
|
|
String g = fVar2.g();
|
|
if (!hashMap.containsKey(g)) {
|
|
ArrayList arrayList = new ArrayList();
|
|
arrayList.add(fVar2);
|
|
hashMap.put(g, arrayList);
|
|
} else {
|
|
((List) hashMap.get(g)).add(fVar2);
|
|
}
|
|
}
|
|
ArrayList arrayList2 = new ArrayList();
|
|
Iterator it = hashMap.entrySet().iterator();
|
|
while (true) {
|
|
String str2 = null;
|
|
if (it.hasNext()) {
|
|
Map.Entry entry = (Map.Entry) it.next();
|
|
c.i.a.b.j.f fVar3 = (c.i.a.b.j.f) ((List) entry.getValue()).get(0);
|
|
p pVar = p.DEFAULT;
|
|
Long valueOf = Long.valueOf(this.f.a());
|
|
Long valueOf2 = Long.valueOf(this.e.a());
|
|
c.i.a.b.i.e.e eVar = new c.i.a.b.i.e.e(k.a.ANDROID_FIREBASE, new c(Integer.valueOf(fVar3.f("sdk-version")), fVar3.a("model"), fVar3.a("hardware"), fVar3.a("device"), fVar3.a("product"), fVar3.a("os-uild"), fVar3.a("manufacturer"), fVar3.a("fingerprint"), fVar3.a("locale"), fVar3.a("country"), fVar3.a("mcc_mnc"), fVar3.a("application_build"), null), null);
|
|
try {
|
|
str = null;
|
|
num = Integer.valueOf(Integer.parseInt((String) entry.getKey()));
|
|
} catch (NumberFormatException unused) {
|
|
num = null;
|
|
str = (String) entry.getKey();
|
|
}
|
|
ArrayList arrayList3 = new ArrayList();
|
|
Iterator it2 = ((List) entry.getValue()).iterator();
|
|
while (it2.hasNext()) {
|
|
c.i.a.b.j.f fVar4 = (c.i.a.b.j.f) it2.next();
|
|
c.i.a.b.j.e d = fVar4.d();
|
|
c.i.a.b.b bVar2 = d.a;
|
|
if (bVar2.equals(new c.i.a.b.b("proto"))) {
|
|
byte[] bArr = d.b;
|
|
bVar = new f.b();
|
|
bVar.d = bArr;
|
|
} else if (bVar2.equals(new c.i.a.b.b("json"))) {
|
|
String str3 = new String(d.b, Charset.forName(Constants.ENCODING));
|
|
bVar = new f.b();
|
|
bVar.e = str3;
|
|
} else {
|
|
aVar2 = aVar3;
|
|
Log.w(AnimatableValueParser.N0("CctTransportBackend"), String.format("Received event of unsupported encoding %s. Skipping...", bVar2));
|
|
it2 = it2;
|
|
it = it;
|
|
aVar3 = aVar2;
|
|
}
|
|
bVar.a = Long.valueOf(fVar4.e());
|
|
bVar.f607c = Long.valueOf(fVar4.h());
|
|
String str4 = fVar4.b().get("tz-offset");
|
|
bVar.f = Long.valueOf(str4 == null ? 0 : Long.valueOf(str4).longValue());
|
|
aVar2 = aVar3;
|
|
bVar.g = new i(o.b.B.get(fVar4.f("net-type")), o.a.D.get(fVar4.f("mobile-subtype")), null);
|
|
if (fVar4.c() != null) {
|
|
bVar.b = fVar4.c();
|
|
}
|
|
String str5 = bVar.a == null ? " eventTimeMs" : "";
|
|
if (bVar.f607c == null) {
|
|
str5 = c.d.b.a.a.u(str5, " eventUptimeMs");
|
|
}
|
|
if (bVar.f == null) {
|
|
str5 = c.d.b.a.a.u(str5, " timezoneOffsetSeconds");
|
|
}
|
|
if (str5.isEmpty()) {
|
|
arrayList3.add(new c.i.a.b.i.e.f(bVar.a.longValue(), bVar.b, bVar.f607c.longValue(), bVar.d, bVar.e, bVar.f.longValue(), bVar.g, null));
|
|
it2 = it2;
|
|
it = it;
|
|
aVar3 = aVar2;
|
|
} else {
|
|
throw new IllegalStateException(c.d.b.a.a.u("Missing required properties:", str5));
|
|
}
|
|
}
|
|
String str6 = valueOf == null ? " requestTimeMs" : "";
|
|
if (valueOf2 == null) {
|
|
str6 = c.d.b.a.a.u(str6, " requestUptimeMs");
|
|
}
|
|
if (str6.isEmpty()) {
|
|
arrayList2.add(new c.i.a.b.i.e.g(valueOf.longValue(), valueOf2.longValue(), eVar, num, str, arrayList3, pVar, null));
|
|
it = it;
|
|
aVar3 = aVar3;
|
|
} else {
|
|
throw new IllegalStateException(c.d.b.a.a.u("Missing required properties:", str6));
|
|
}
|
|
} else {
|
|
c.i.a.b.i.e.d dVar = new c.i.a.b.i.e.d(arrayList2);
|
|
URL url = this.d;
|
|
if (aVar4.b != null) {
|
|
try {
|
|
a a2 = a.a(((c.i.a.b.j.q.a) fVar).b);
|
|
String str7 = a2.g;
|
|
if (str7 != null) {
|
|
str2 = str7;
|
|
}
|
|
String str8 = a2.f;
|
|
if (str8 != null) {
|
|
url = c(str8);
|
|
}
|
|
} catch (IllegalArgumentException unused2) {
|
|
return g.a();
|
|
}
|
|
}
|
|
try {
|
|
b bVar3 = (b) AnimatableValueParser.v2(5, new a(url, dVar, str2), new b(this), c.a);
|
|
int i = bVar3.a;
|
|
if (i == 200) {
|
|
return new c.i.a.b.j.q.b(g.a.OK, bVar3.f604c);
|
|
}
|
|
if (i < 500) {
|
|
if (i != 404) {
|
|
return g.a();
|
|
}
|
|
}
|
|
aVar = aVar3;
|
|
try {
|
|
return new c.i.a.b.j.q.b(aVar, -1);
|
|
} catch (IOException e2) {
|
|
e = e2;
|
|
AnimatableValueParser.e0("CctTransportBackend", "Could not make request to the backend", e);
|
|
return new c.i.a.b.j.q.b(aVar, -1);
|
|
}
|
|
} catch (IOException e3) {
|
|
e = e3;
|
|
aVar = aVar3;
|
|
AnimatableValueParser.e0("CctTransportBackend", "Could not make request to the backend", e);
|
|
return new c.i.a.b.j.q.b(aVar, -1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // c.i.a.b.j.q.m
|
|
public c.i.a.b.j.f b(c.i.a.b.j.f fVar) {
|
|
int i;
|
|
NetworkInfo activeNetworkInfo = this.b.getActiveNetworkInfo();
|
|
f.a i2 = fVar.i();
|
|
i2.c().put("sdk-version", String.valueOf(Build.VERSION.SDK_INT));
|
|
i2.c().put("model", Build.MODEL);
|
|
i2.c().put("hardware", Build.HARDWARE);
|
|
i2.c().put("device", Build.DEVICE);
|
|
i2.c().put("product", Build.PRODUCT);
|
|
i2.c().put("os-uild", Build.ID);
|
|
i2.c().put("manufacturer", Build.MANUFACTURER);
|
|
i2.c().put("fingerprint", Build.FINGERPRINT);
|
|
Calendar.getInstance();
|
|
i2.c().put("tz-offset", String.valueOf((long) (TimeZone.getDefault().getOffset(Calendar.getInstance().getTimeInMillis()) / 1000)));
|
|
i2.c().put("net-type", String.valueOf(activeNetworkInfo == null ? o.b.NONE.f() : activeNetworkInfo.getType()));
|
|
int i3 = -1;
|
|
if (activeNetworkInfo == null) {
|
|
i = o.a.UNKNOWN_MOBILE_SUBTYPE.f();
|
|
} else {
|
|
i = activeNetworkInfo.getSubtype();
|
|
if (i == -1) {
|
|
i = o.a.COMBINED.f();
|
|
} else if (o.a.D.get(i) == null) {
|
|
i = 0;
|
|
}
|
|
}
|
|
i2.c().put("mobile-subtype", String.valueOf(i));
|
|
i2.c().put("country", Locale.getDefault().getCountry());
|
|
i2.c().put("locale", Locale.getDefault().getLanguage());
|
|
i2.c().put("mcc_mnc", ((TelephonyManager) this.f602c.getSystemService("phone")).getSimOperator());
|
|
Context context = this.f602c;
|
|
try {
|
|
i3 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
|
|
} catch (PackageManager.NameNotFoundException e) {
|
|
AnimatableValueParser.e0("CctTransportBackend", "Unable to find version code for package", e);
|
|
}
|
|
i2.c().put("application_build", Integer.toString(i3));
|
|
return i2.b();
|
|
}
|
|
}
|