333 lines
14 KiB
Java
333 lines
14 KiB
Java
|
package o;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.net.ConnectivityManager;
|
||
|
import android.net.NetworkInfo;
|
||
|
import android.os.Build;
|
||
|
import com.google.common.net.HttpHeaders;
|
||
|
import com.google.firebase.crashlytics.internal.common.AbstractSpiCall;
|
||
|
import com.google.firebase.encoders.DataEncoder;
|
||
|
import com.google.firebase.encoders.EncodingException;
|
||
|
import com.google.firebase.encoders.json.JsonDataEncoderBuilder;
|
||
|
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
|
||
|
import com.prolificinteractive.materialcalendarview.TitleChanger;
|
||
|
import io.grpc.internal.GrpcUtil;
|
||
|
import java.io.BufferedReader;
|
||
|
import java.io.BufferedWriter;
|
||
|
import java.io.IOException;
|
||
|
import java.io.InputStream;
|
||
|
import java.io.InputStreamReader;
|
||
|
import java.io.OutputStream;
|
||
|
import java.io.OutputStreamWriter;
|
||
|
import java.net.ConnectException;
|
||
|
import java.net.HttpURLConnection;
|
||
|
import java.net.MalformedURLException;
|
||
|
import java.net.URL;
|
||
|
import java.net.UnknownHostException;
|
||
|
import java.nio.charset.Charset;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Calendar;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import java.util.TimeZone;
|
||
|
import java.util.regex.Pattern;
|
||
|
import java.util.zip.GZIPInputStream;
|
||
|
import java.util.zip.GZIPOutputStream;
|
||
|
import o.AbstractC14641fwz;
|
||
|
import o.AbstractC5394bsH;
|
||
|
import o.C0492Hvb;
|
||
|
import o.C13903fjB;
|
||
|
import o.Owr;
|
||
|
import o.RBB;
|
||
|
import o.RZj;
|
||
|
import o.XCz;
|
||
|
import o.ZSU;
|
||
|
import o.hhG;
|
||
|
import o.qap;
|
||
|
import o.vlY;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class qap implements Qno {
|
||
|
private final ConnectivityManager a;
|
||
|
private final InterfaceC6203cLt b;
|
||
|
private final InterfaceC6203cLt c;
|
||
|
private final DataEncoder d = new JsonDataEncoderBuilder().configureWith(YHw.c).ignoreNullValues(true).build();
|
||
|
private URL e = b(C0379FgY.c);
|
||
|
private final int g = 40000;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
static final class LWm {
|
||
|
final long a;
|
||
|
final URL c;
|
||
|
final int d;
|
||
|
|
||
|
LWm(int i, URL url, long j) {
|
||
|
this.d = i;
|
||
|
this.c = url;
|
||
|
this.a = j;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
static final class Sts {
|
||
|
final URL a;
|
||
|
final GBQ b;
|
||
|
final String c;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public Sts(URL url, GBQ gbq, String str) {
|
||
|
this.a = url;
|
||
|
this.b = gbq;
|
||
|
this.c = str;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public qap(Context context, InterfaceC6203cLt interfaceC6203cLt, InterfaceC6203cLt interfaceC6203cLt2) {
|
||
|
this.a = (ConnectivityManager) context.getSystemService("connectivity");
|
||
|
this.b = interfaceC6203cLt2;
|
||
|
this.c = interfaceC6203cLt;
|
||
|
}
|
||
|
|
||
|
private static URL b(String str) {
|
||
|
try {
|
||
|
return new URL(str);
|
||
|
} catch (MalformedURLException e) {
|
||
|
throw new IllegalArgumentException("Invalid url: ".concat(String.valueOf(str)), e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // o.Qno
|
||
|
public final AbstractC5394bsH d(AbstractC5394bsH abstractC5394bsH) {
|
||
|
int type;
|
||
|
int subtype;
|
||
|
NetworkInfo activeNetworkInfo = this.a.getActiveNetworkInfo();
|
||
|
AbstractC5394bsH.RVV a = abstractC5394bsH.i().b("sdk-version", Build.VERSION.SDK_INT).a("model", Build.MODEL).a("hardware", Build.HARDWARE).a("device", Build.DEVICE).a("product", Build.PRODUCT).a("os-uild", Build.ID).a("manufacturer", Build.MANUFACTURER).a(HiAnalyticsConstant.HaKey.BI_KEY_FINGERPRINT, Build.FINGERPRINT);
|
||
|
Calendar.getInstance();
|
||
|
AbstractC5394bsH.RVV c = a.c("tz-offset", TimeZone.getDefault().getOffset(Calendar.getInstance().getTimeInMillis()) / 1000);
|
||
|
if (activeNetworkInfo != null) {
|
||
|
type = activeNetworkInfo.getType();
|
||
|
} else {
|
||
|
type = vlY.LWm.zzs.zzu;
|
||
|
}
|
||
|
AbstractC5394bsH.RVV b = c.b("net-type", type);
|
||
|
if (activeNetworkInfo != null) {
|
||
|
subtype = activeNetworkInfo.getSubtype();
|
||
|
if (subtype == -1) {
|
||
|
subtype = vlY.Sts.zzu.zzw;
|
||
|
} else if (vlY.Sts.zzv.get(subtype) == null) {
|
||
|
subtype = 0;
|
||
|
}
|
||
|
} else {
|
||
|
subtype = vlY.Sts.zza.zzw;
|
||
|
}
|
||
|
return b.b("mobile-subtype", subtype).b();
|
||
|
}
|
||
|
|
||
|
@Override // o.Qno
|
||
|
public final AbstractC14641fwz d(xqg xqgVar) {
|
||
|
Object b;
|
||
|
RBB.LWm d;
|
||
|
HashMap hashMap = new HashMap();
|
||
|
for (AbstractC5394bsH abstractC5394bsH : xqgVar.b()) {
|
||
|
String b2 = abstractC5394bsH.b();
|
||
|
if (!hashMap.containsKey(b2)) {
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
arrayList.add(abstractC5394bsH);
|
||
|
hashMap.put(b2, arrayList);
|
||
|
} else {
|
||
|
((List) hashMap.get(b2)).add(abstractC5394bsH);
|
||
|
}
|
||
|
}
|
||
|
ArrayList arrayList2 = new ArrayList();
|
||
|
for (Map.Entry entry : hashMap.entrySet()) {
|
||
|
AbstractC5394bsH abstractC5394bsH2 = (AbstractC5394bsH) ((List) entry.getValue()).get(0);
|
||
|
ZSU.HBt e = new Owr.HBt().b(HGs.zza).d(this.c.a()).e(this.b.a()).e(new hhG.HBt().c(RZj.LWm.zzb).a(new XCz.IeS().c(Integer.valueOf(abstractC5394bsH2.b("sdk-version"))).a(abstractC5394bsH2.a("model")).b(abstractC5394bsH2.a("hardware")).c(abstractC5394bsH2.a("device")).g(abstractC5394bsH2.a("product")).j(abstractC5394bsH2.a("os-uild")).e(abstractC5394bsH2.a("manufacturer")).d(abstractC5394bsH2.a(HiAnalyticsConstant.HaKey.BI_KEY_FINGERPRINT)).e()).d());
|
||
|
try {
|
||
|
e.c(Integer.valueOf(Integer.parseInt((String) entry.getKey())));
|
||
|
} catch (NumberFormatException unused) {
|
||
|
e.b((String) entry.getKey());
|
||
|
}
|
||
|
ArrayList arrayList3 = new ArrayList();
|
||
|
for (AbstractC5394bsH abstractC5394bsH3 : (List) entry.getValue()) {
|
||
|
sNO c = abstractC5394bsH3.c();
|
||
|
C1332aAy c1332aAy = c.c;
|
||
|
if (!c1332aAy.equals(new C1332aAy("proto"))) {
|
||
|
if (c1332aAy.equals(new C1332aAy("json"))) {
|
||
|
d = new C0492Hvb.LWm().b(new String(c.a, Charset.forName("UTF-8")));
|
||
|
} else {
|
||
|
new Object[]{c1332aAy};
|
||
|
}
|
||
|
} else {
|
||
|
d = new C0492Hvb.LWm().d(c.a);
|
||
|
}
|
||
|
d.a(abstractC5394bsH3.d()).c(abstractC5394bsH3.j()).b(abstractC5394bsH3.e("tz-offset")).e(new C13903fjB.Sts().d(vlY.LWm.zzt.get(abstractC5394bsH3.b("net-type"))).a(vlY.Sts.zzv.get(abstractC5394bsH3.b("mobile-subtype"))).c());
|
||
|
if (abstractC5394bsH3.e() != null) {
|
||
|
d.a(abstractC5394bsH3.e());
|
||
|
}
|
||
|
arrayList3.add(d.b());
|
||
|
}
|
||
|
e.c(arrayList3);
|
||
|
arrayList2.add(e.e());
|
||
|
}
|
||
|
AkF akF = new AkF(arrayList2);
|
||
|
URL url = this.e;
|
||
|
if (xqgVar.c() != null) {
|
||
|
try {
|
||
|
String str = new String(xqgVar.c(), Charset.forName("UTF-8"));
|
||
|
if (str.startsWith("1$")) {
|
||
|
String[] split = str.substring(2).split(Pattern.quote("\\"), 2);
|
||
|
if (split.length == 2) {
|
||
|
String str2 = split[0];
|
||
|
if (!str2.isEmpty()) {
|
||
|
String str3 = split[1];
|
||
|
if (str3.isEmpty()) {
|
||
|
str3 = null;
|
||
|
}
|
||
|
C0379FgY c0379FgY = new C0379FgY(str2, str3);
|
||
|
r6 = c0379FgY.d != null ? c0379FgY.d : null;
|
||
|
if (c0379FgY.e != null) {
|
||
|
url = b(c0379FgY.e);
|
||
|
}
|
||
|
} else {
|
||
|
throw new IllegalArgumentException("Missing endpoint in CCTDestination extras");
|
||
|
}
|
||
|
} else {
|
||
|
throw new IllegalArgumentException("Extra is not a valid encoded LegacyFlgDestination");
|
||
|
}
|
||
|
} else {
|
||
|
throw new IllegalArgumentException("Version marker missing from extras");
|
||
|
}
|
||
|
} catch (IllegalArgumentException unused2) {
|
||
|
return new C1254ZUn(AbstractC14641fwz.Sts.FATAL_ERROR, -1L);
|
||
|
}
|
||
|
}
|
||
|
try {
|
||
|
Object sts = new Sts(url, akF, r6);
|
||
|
XVC xvc = new XVC(this) { // from class: o.TsM
|
||
|
private final qap d;
|
||
|
|
||
|
@Override // o.XVC
|
||
|
public final Object b(Object obj) {
|
||
|
return this.d.c((qap.Sts) obj);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
{
|
||
|
this.d = this;
|
||
|
}
|
||
|
};
|
||
|
C16317nRS c16317nRS = C16317nRS.e;
|
||
|
int i = 5;
|
||
|
do {
|
||
|
b = xvc.b(sts);
|
||
|
sts = c16317nRS.c(sts, b);
|
||
|
if (sts == null) {
|
||
|
break;
|
||
|
}
|
||
|
i--;
|
||
|
} while (i > 0);
|
||
|
LWm lWm = (LWm) b;
|
||
|
if (lWm.d != 200) {
|
||
|
int i2 = lWm.d;
|
||
|
if (i2 < 500 && i2 != 404) {
|
||
|
return new C1254ZUn(AbstractC14641fwz.Sts.FATAL_ERROR, -1L);
|
||
|
}
|
||
|
return new C1254ZUn(AbstractC14641fwz.Sts.TRANSIENT_ERROR, -1L);
|
||
|
}
|
||
|
return new C1254ZUn(AbstractC14641fwz.Sts.OK, lWm.a);
|
||
|
} catch (IOException unused3) {
|
||
|
return new C1254ZUn(AbstractC14641fwz.Sts.TRANSIENT_ERROR, -1L);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final LWm c(Sts sts) throws IOException {
|
||
|
new Object[]{sts.a};
|
||
|
HttpURLConnection httpURLConnection = (HttpURLConnection) sts.a.openConnection();
|
||
|
httpURLConnection.setConnectTimeout(30000);
|
||
|
httpURLConnection.setReadTimeout(this.g);
|
||
|
httpURLConnection.setDoOutput(true);
|
||
|
httpURLConnection.setInstanceFollowRedirects(false);
|
||
|
httpURLConnection.setRequestMethod(GrpcUtil.HTTP_METHOD);
|
||
|
httpURLConnection.setRequestProperty("User-Agent", String.format("datatransport/%s android/", "2.3.0"));
|
||
|
httpURLConnection.setRequestProperty(HttpHeaders.CONTENT_ENCODING, "gzip");
|
||
|
httpURLConnection.setRequestProperty(HttpHeaders.CONTENT_TYPE, AbstractSpiCall.ACCEPT_JSON_VALUE);
|
||
|
httpURLConnection.setRequestProperty(HttpHeaders.ACCEPT_ENCODING, "gzip");
|
||
|
String str = sts.c;
|
||
|
if (str != null) {
|
||
|
httpURLConnection.setRequestProperty("X-Goog-Api-Key", str);
|
||
|
}
|
||
|
try {
|
||
|
OutputStream outputStream = httpURLConnection.getOutputStream();
|
||
|
try {
|
||
|
GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(outputStream);
|
||
|
try {
|
||
|
this.d.encode(sts.b, new BufferedWriter(new OutputStreamWriter(gZIPOutputStream)));
|
||
|
gZIPOutputStream.close();
|
||
|
if (outputStream != null) {
|
||
|
outputStream.close();
|
||
|
}
|
||
|
int responseCode = httpURLConnection.getResponseCode();
|
||
|
httpURLConnection.getHeaderField(HttpHeaders.CONTENT_TYPE);
|
||
|
httpURLConnection.getHeaderField(HttpHeaders.CONTENT_ENCODING);
|
||
|
if (responseCode == 302 || responseCode == 301 || responseCode == 307) {
|
||
|
return new LWm(responseCode, new URL(httpURLConnection.getHeaderField(HttpHeaders.LOCATION)), 0L);
|
||
|
}
|
||
|
if (responseCode != 200) {
|
||
|
return new LWm(responseCode, null, 0L);
|
||
|
}
|
||
|
InputStream inputStream = httpURLConnection.getInputStream();
|
||
|
try {
|
||
|
InputStream gZIPInputStream = "gzip".equals(httpURLConnection.getHeaderField(HttpHeaders.CONTENT_ENCODING)) ? new GZIPInputStream(inputStream) : inputStream;
|
||
|
try {
|
||
|
LWm lWm = new LWm(responseCode, null, KKK.d(new BufferedReader(new InputStreamReader(gZIPInputStream))).a());
|
||
|
if (gZIPInputStream != null) {
|
||
|
gZIPInputStream.close();
|
||
|
}
|
||
|
if (inputStream != null) {
|
||
|
inputStream.close();
|
||
|
}
|
||
|
return lWm;
|
||
|
} catch (Throwable th) {
|
||
|
if (gZIPInputStream != null) {
|
||
|
try {
|
||
|
gZIPInputStream.close();
|
||
|
} catch (Throwable unused) {
|
||
|
}
|
||
|
}
|
||
|
throw th;
|
||
|
}
|
||
|
} catch (Throwable th2) {
|
||
|
if (inputStream != null) {
|
||
|
try {
|
||
|
inputStream.close();
|
||
|
} catch (Throwable unused2) {
|
||
|
}
|
||
|
}
|
||
|
throw th2;
|
||
|
}
|
||
|
} catch (Throwable th3) {
|
||
|
try {
|
||
|
gZIPOutputStream.close();
|
||
|
} catch (Throwable unused3) {
|
||
|
}
|
||
|
throw th3;
|
||
|
}
|
||
|
} catch (Throwable th4) {
|
||
|
if (outputStream != null) {
|
||
|
try {
|
||
|
outputStream.close();
|
||
|
} catch (Throwable unused4) {
|
||
|
}
|
||
|
}
|
||
|
throw th4;
|
||
|
}
|
||
|
} catch (EncodingException | IOException unused5) {
|
||
|
return new LWm(TitleChanger.DEFAULT_ANIMATION_DELAY, null, 0L);
|
||
|
} catch (ConnectException | UnknownHostException unused6) {
|
||
|
return new LWm(500, null, 0L);
|
||
|
}
|
||
|
}
|
||
|
}
|