VidMate v4.2613版本的 MD5 值为:993482c79f779838c3f6749049d55510
以下内容为反编译后的 b.java 源代码,内容仅作参考
package com.startapp.networkTest.d.a;
import android.content.Context;
import android.net.SSLCertificateSocketFactory;
import android.os.AsyncTask;
import android.os.Build;
import android.os.SystemClock;
import android.telephony.TelephonyManager;
import com.startapp.networkTest.c.a;
import com.startapp.networkTest.controller.LocationController;
import com.startapp.networkTest.data.BatteryInfo;
import com.startapp.networkTest.data.LocationInfo;
import com.startapp.networkTest.data.WifiInfo;
import com.startapp.networkTest.enums.ConnectionTypes;
import com.startapp.networkTest.enums.CtCriteriaTypes;
import com.startapp.networkTest.enums.voice.CallStates;
import com.startapp.networkTest.results.ConnectivityTestResult;
import com.startapp.networkTest.results.LatencyResult;
import com.startapp.networkTest.speedtest.SpeedtestEngineStatus;
import com.startapp.networkTest.utils.h;
import com.startapp.networkTest.utils.l;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.TimeoutException;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.TrustManager;
import org.apache.commons.io.IOUtils;
public class b {
private static final String e = "b";
public com.startapp.networkTest.controller.d a;
public com.startapp.networkTest.controller.e b;
public LocationController c;
public f d;
private Context f;
private com.startapp.networkTest.d g;
private String h;
private String i;
private String j;
private String k;
private Random l;
private float m;
private boolean n;
public class a extends AsyncTask<Void, String, ConnectivityTestResult> implements com.startapp.networkTest.speedtest.a {
private ConnectivityTestResult b;
private com.startapp.networkTest.c.a c;
public class C0130a {
final int a;
final String b;
final boolean c;
public C0130a(int i, String str, boolean z) {
this.a = i;
this.b = str;
this.c = z;
}
}
private a() {
}
public a(b bVar, byte b) {
this();
}
private C0130a a(InputStream inputStream) {
boolean z;
byte[] bArr = new byte[1024];
int i = 0;
int i2 = 0;
while (true) {
int read = inputStream.read();
z = true;
i++;
if (read == 10) {
z = false;
break;
}
if (read < 0) {
break;
}
int i3 = i2 + 1;
bArr[i2] = (byte) read;
if (i3 == bArr.length) {
bArr = Arrays.copyOf(bArr, i3 + 1024);
}
i2 = i3;
}
if (i2 > 0 && bArr[i2 - 1] == 13) {
i2--;
}
return new C0130a(i, new String(bArr, 0, i2, "UTF-8"), z);
}
private ConnectivityTestResult a() {
String str;
boolean z;
CallStates callStates;
List<c> a;
LinkedList linkedList;
int i;
int i2;
LinkedList linkedList2;
Throwable th;
List<c> list;
Exception exc;
boolean z2;
Throwable th2;
int i3;
c cVar;
SSLSocket sSLSocket;
String str2;
c cVar2;
boolean z3;
String str3;
SSLCertificateSocketFactory sSLCertificateSocketFactory;
SSLSocket sSLSocket2;
long elapsedRealtime;
c cVar3;
SSLSocket sSLSocket3;
int i4;
boolean z4;
List<c> list2;
int i5;
LinkedList linkedList3;
int i6;
int i7;
Exception exc2;
int i8;
boolean z5;
boolean z6;
int i9;
int i10;
byte[] bArr;
InputStream inputStream;
boolean z7;
int i11;
long j;
Throwable th3;
long j2;
C0130a a2;
String upperCase;
long j3;
int read;
long j4;
Class<?> cls;
ConnectivityTestResult connectivityTestResult;
com.startapp.networkTest.b.a a3;
WifiInfo wifiInfo;
long j5;
long b;
long j6;
long b2;
boolean a4;
BatteryInfo a5 = new com.startapp.networkTest.controller.a(b.this.f).a();
if (b.this.m != -1.0f && a5.BatteryLevel < b.this.m) {
return null;
}
com.startapp.networkTest.data.a.d f = com.startapp.networkTest.controller.c.f(b.this.f);
if (!b.this.n && b.this.a.f() == ConnectionTypes.Mobile && b.this.a.c(f.SubscriptionId)) {
return null;
}
long j7 = 0;
try {
j6 = com.startapp.networkTest.c.a.d.a.getLong("P3INS_PFK_CONNECTIVITY_TEST_TRUSTSTORE_LAST_CHECK", 0L);
b2 = com.startapp.networkTest.f.b.b();
} catch (Exception e) {
str = "checkAndLoadTruststore: " + e.toString();
z = false;
}
if (com.startapp.networkTest.c.a.b.CONNECTIVITY_TEST_TRUSTSTORE_UPDATE_INTERVAL + j6 >= b2 && j6 <= b2) {
a4 = false;
z = a4;
str = null;
j5 = com.startapp.networkTest.c.a.d.a.getLong("P3INS_PFK_CONNECTIVITY_TEST_CDNCONFIG_LAST_CHECK", 0L);
b = com.startapp.networkTest.f.b.b();
if (com.startapp.networkTest.c.a.b.CONNECTIVITY_TEST_CDNCONFIG_UPDATE_INTERVAL + j5 >= b || j5 > b) {
com.startapp.networkTest.utils.a.a();
}
if (com.startapp.networkTest.c.a() || b.this.b == null) {
return null;
}
this.b = new ConnectivityTestResult(b.this.h, b.this.g.a());
this.b.LocationInfo = b.this.c.b();
Set<String> stringSet = com.startapp.networkTest.c.a.d.a.getStringSet("P3INS_PFK_CDN_CT_SERVER_LIST", null);
String[] strArr = (stringSet == null || stringSet.isEmpty()) ? com.startapp.networkTest.c.a.b.CONNECTIVITY_TEST_HOSTNAME_ARRAY : (String[]) stringSet.toArray(new String[stringSet.size()]);
CtCriteriaTypes valueOf = CtCriteriaTypes.valueOf(com.startapp.networkTest.c.a.d.a.getString("P3INS_PFK_CDN_CT_CRITERIA", com.startapp.networkTest.c.a.b.CONNECTIVITY_TEST_CRITERIA.name()));
if (str != null) {
StringBuilder sb = new StringBuilder();
ConnectivityTestResult connectivityTestResult2 = this.b;
sb.append(connectivityTestResult2.ErrorReason);
sb.append(str);
connectivityTestResult2.ErrorReason = sb.toString();
}
this.b.Version = "20190816130349";
this.b.ServerFilename = b.this.j + "?id=" + b.this.l.nextLong();
this.b.BatteryInfo = a5;
this.b.DeviceInfo = com.startapp.networkTest.controller.c.a(b.this.f);
this.b.MemoryInfo = com.startapp.networkTest.controller.c.b(b.this.f);
this.b.RadioInfo = b.this.a.c();
if (com.startapp.networkTest.c.a.b.CT_COLLECT_CELLINFO) {
this.b.CellInfo = new ArrayList<>(Arrays.asList(b.this.a.d()));
}
this.b.ApnInfo = new ArrayList<>(Arrays.asList(b.this.a.e()));
this.b.NetworkRegistrationInfo = new ArrayList<>(Arrays.asList(b.this.a.a(b.this.a.a.DefaultDataSimId)));
this.b.VoiceNetworkType = b.this.a.g();
ConnectivityTestResult connectivityTestResult3 = this.b;
TelephonyManager telephonyManager = (TelephonyManager) b.this.f.getSystemService("phone");
if (telephonyManager != null) {
switch (telephonyManager.getCallState()) {
case 0:
callStates = CallStates.Idle;
break;
case 1:
callStates = CallStates.Ringing;
break;
case 2:
callStates = CallStates.Offhook;
break;
}
connectivityTestResult3.CallState = callStates;
this.b.StorageInfo = com.startapp.networkTest.controller.c.c(b.this.f);
this.b.WifiInfo = b.this.b.c();
this.b.TrafficInfo = com.startapp.networkTest.controller.c.a(b.this.b);
this.b.ScreenState = com.startapp.networkTest.controller.c.d(b.this.f);
this.b.IdleStateOnStart = com.startapp.networkTest.controller.c.e(b.this.f);
this.b.SimInfo = f;
this.b.TimeInfo = com.startapp.networkTest.f.b.a();
this.b.TestTimestamp = this.b.TimeInfo.TimestampTableau;
this.b.TruststoreTimestamp = com.startapp.networkTest.c.a.d.c();
this.b.CtId = com.startapp.networkTest.utils.d.a(this.b.TimeInfo, this.b.GUID);
if (b.this.g.a.getBoolean("P3INS_PFK_CONNECTIVITY_KEEPALIVE_ENABLED", com.startapp.networkTest.c.a.b.CONNECTIVITY_KEEPALIVE_ENABLED) && !b.this.g.b()) {
this.b.IsKeepAlive = true;
}
long elapsedRealtime2 = SystemClock.elapsedRealtime();
long uptimeMillis = SystemClock.uptimeMillis();
HostnameVerifier defaultHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
com.startapp.networkTest.a.a aVar = new com.startapp.networkTest.a.a(b.this.f, z);
a = a(strArr, valueOf);
linkedList = new LinkedList();
String str4 = b.this.i;
long j8 = elapsedRealtime2;
long j9 = uptimeMillis;
i = 0;
int i12 = 0;
SSLSocket sSLSocket4 = null;
SSLCertificateSocketFactory sSLCertificateSocketFactory2 = null;
c cVar4 = null;
String str5 = b.this.k;
String str6 = str4;
i2 = 0;
while (true) {
if (i2 >= a.size() || (a.isEmpty() && str6.length() > 0)) {
com.startapp.networkTest.data.d dVar = new com.startapp.networkTest.data.d();
try {
try {
long elapsedRealtime3 = SystemClock.elapsedRealtime();
try {
long uptimeMillis2 = SystemClock.uptimeMillis();
try {
c cVar5 = new c();
i++;
try {
this.b.LocalhostPingSuccess = b();
long elapsedRealtime4 = SystemClock.elapsedRealtime();
if (a.isEmpty()) {
try {
try {
c cVar6 = a.get(i2);
i3 = i;
try {
sSLSocket = sSLSocket4;
try {
this.b.ServerHostname = cVar6.address;
cVar6.totalTests++;
dVar.Try = i2 + 1;
dVar.HostFile = this.b.ServerHostname + this.b.ServerFilename;
cVar = cVar6;
try {
this.b.ServerIp = new com.startapp.networkTest.net.a().a(this.b.ServerHostname);
this.b.DurationDNS = SystemClock.elapsedRealtime() - elapsedRealtime4;
str2 = str6;
cVar2 = cVar;
z3 = true;
} catch (Exception e2) {
e = e2;
exc = e;
list = a;
linkedList2 = linkedList;
j9 = uptimeMillis2;
j8 = elapsedRealtime3;
i = i3;
sSLSocket4 = sSLSocket;
cVar4 = cVar;
z2 = true;
try {
String a6 = b.a(exc.toString());
StringBuilder sb2 = new StringBuilder();
ConnectivityTestResult connectivityTestResult4 = this.b;
sb2.append(connectivityTestResult4.ErrorReason);
sb2.append(a6);
sb2.append("; ");
connectivityTestResult4.ErrorReason = sb2.toString();
if (!z2) {
}
i2++;
linkedList = linkedList2;
a = list;
j7 = 0;
} catch (Throwable th4) {
th2 = th4;
th = th2;
if (z2) {
}
}
}
} catch (Exception e3) {
e = e3;
cVar = cVar6;
}
} catch (Exception e4) {
cVar = cVar6;
exc = e4;
list = a;
linkedList2 = linkedList;
j9 = uptimeMillis2;
j8 = elapsedRealtime3;
i = i3;
}
} catch (Exception e5) {
exc = e5;
list = a;
linkedList2 = linkedList;
cVar4 = cVar5;
z2 = true;
j9 = uptimeMillis2;
j8 = elapsedRealtime3;
String a62 = b.a(exc.toString());
StringBuilder sb22 = new StringBuilder();
ConnectivityTestResult connectivityTestResult42 = this.b;
sb22.append(connectivityTestResult42.ErrorReason);
sb22.append(a62);
sb22.append("; ");
connectivityTestResult42.ErrorReason = sb22.toString();
if (!z2) {
}
i2++;
linkedList = linkedList2;
a = list;
j7 = 0;
}
} catch (Throwable th5) {
th = th5;
linkedList2 = linkedList;
z2 = true;
if (z2) {
}
}
} else {
i3 = i;
sSLSocket = sSLSocket4;
try {
try {
if (str5.length() > 0) {
try {
try {
if (str6.length() > 0) {
this.b.ServerIp = str5;
this.b.ServerHostname = str6;
try {
this.b.DurationDNS = 0L;
str2 = "";
i2--;
str5 = "";
cVar2 = cVar5;
z3 = false;
} catch (Exception e6) {
exc = e6;
list = a;
linkedList2 = linkedList;
cVar4 = cVar5;
i = i3;
sSLSocket4 = sSLSocket;
z2 = false;
j9 = uptimeMillis2;
j8 = elapsedRealtime3;
String a622 = b.a(exc.toString());
StringBuilder sb222 = new StringBuilder();
ConnectivityTestResult connectivityTestResult422 = this.b;
sb222.append(connectivityTestResult422.ErrorReason);
sb222.append(a622);
sb222.append("; ");
connectivityTestResult422.ErrorReason = sb222.toString();
if (!z2) {
linkedList2.add(dVar);
}
i2++;
linkedList = linkedList2;
a = list;
j7 = 0;
}
}
} catch (Throwable th6) {
th = th6;
linkedList2 = linkedList;
z2 = false;
if (z2) {
throw th;
}
linkedList2.add(dVar);
throw th;
}
} catch (Exception e7) {
exc = e7;
list = a;
linkedList2 = linkedList;
cVar4 = cVar5;
i = i3;
sSLSocket4 = sSLSocket;
}
}
this.b.ServerIp = new com.startapp.networkTest.net.a().a(this.b.ServerHostname);
this.b.DurationDNS = SystemClock.elapsedRealtime() - elapsedRealtime4;
str2 = "";
cVar2 = cVar5;
z3 = false;
} catch (Exception e8) {
list = a;
linkedList2 = linkedList;
str6 = "";
cVar4 = cVar5;
i = i3;
sSLSocket4 = sSLSocket;
z2 = false;
exc = e8;
j9 = uptimeMillis2;
j8 = elapsedRealtime3;
String a6222 = b.a(exc.toString());
StringBuilder sb2222 = new StringBuilder();
ConnectivityTestResult connectivityTestResult4222 = this.b;
sb2222.append(connectivityTestResult4222.ErrorReason);
sb2222.append(a6222);
sb2222.append("; ");
connectivityTestResult4222.ErrorReason = sb2222.toString();
if (!z2) {
}
i2++;
linkedList = linkedList2;
a = list;
j7 = 0;
}
this.b.ServerHostname = str6;
i2--;
} catch (Exception e9) {
list = a;
linkedList2 = linkedList;
exc = e9;
cVar4 = cVar5;
i = i3;
sSLSocket4 = sSLSocket;
}
}
try {
try {
if (this.b.DurationDNS > 30000) {
dVar.ServerIp = this.b.ServerIp;
dVar.DurationDNS = this.b.DurationDNS;
cVar2.DNSSuccess++;
i12++;
sSLCertificateSocketFactory = (SSLCertificateSocketFactory) SSLCertificateSocketFactory.getDefault(30000);
try {
sSLCertificateSocketFactory.setTrustManagers(new TrustManager[]{aVar});
str3 = str2;
} catch (Exception e10) {
e = e10;
list = a;
str3 = str2;
}
try {
InetSocketAddress inetSocketAddress = new InetSocketAddress(this.b.ServerIp, 443);
SSLSocket sSLSocket5 = (SSLSocket) sSLCertificateSocketFactory.createSocket();
try {
elapsedRealtime = SystemClock.elapsedRealtime();
sSLSocket5.connect(inetSocketAddress, 30000);
sSLSocket2 = sSLSocket5;
z2 = z3;
} catch (Exception e11) {
e = e11;
list = a;
sSLSocket2 = sSLSocket5;
z2 = z3;
}
} catch (Exception e12) {
e = e12;
list = a;
z2 = z3;
linkedList2 = linkedList;
cVar4 = cVar2;
sSLCertificateSocketFactory2 = sSLCertificateSocketFactory;
j9 = uptimeMillis2;
j8 = elapsedRealtime3;
i = i3;
sSLSocket4 = sSLSocket;
str6 = str3;
exc = e;
String a62222 = b.a(exc.toString());
StringBuilder sb22222 = new StringBuilder();
ConnectivityTestResult connectivityTestResult42222 = this.b;
sb22222.append(connectivityTestResult42222.ErrorReason);
sb22222.append(a62222);
sb22222.append("; ");
connectivityTestResult42222.ErrorReason = sb22222.toString();
if (!z2) {
}
i2++;
linkedList = linkedList2;
a = list;
j7 = 0;
}
try {
this.b.DurationTcpConnect = SystemClock.elapsedRealtime() - elapsedRealtime;
cVar2.TCPSuccess++;
cVar3 = cVar2;
j9 = uptimeMillis2;
j8 = elapsedRealtime3;
i = i3;
sSLSocket3 = sSLSocket2;
i4 = 1;
z4 = true;
} catch (Exception e13) {
e = e13;
list = a;
linkedList2 = linkedList;
cVar4 = cVar2;
sSLCertificateSocketFactory2 = sSLCertificateSocketFactory;
j9 = uptimeMillis2;
j8 = elapsedRealtime3;
i = i3;
str6 = str3;
sSLSocket4 = sSLSocket2;
exc = e;
String a622222 = b.a(exc.toString());
StringBuilder sb222222 = new StringBuilder();
ConnectivityTestResult connectivityTestResult422222 = this.b;
sb222222.append(connectivityTestResult422222.ErrorReason);
sb222222.append(a622222);
sb222222.append("; ");
connectivityTestResult422222.ErrorReason = sb222222.toString();
if (!z2) {
}
i2++;
linkedList = linkedList2;
a = list;
j7 = 0;
} catch (Throwable th7) {
th2 = th7;
linkedList2 = linkedList;
th = th2;
if (z2) {
}
}
} else {
list = a;
str3 = str2;
z2 = z3;
linkedList2 = linkedList;
try {
this.b.DurationDNS = -1L;
throw new TimeoutException("DNS Timeout");
} catch (Exception e14) {
e = e14;
cVar4 = cVar2;
j9 = uptimeMillis2;
j8 = elapsedRealtime3;
i = i3;
sSLSocket4 = sSLSocket;
str6 = str3;
exc = e;
String a6222222 = b.a(exc.toString());
StringBuilder sb2222222 = new StringBuilder();
ConnectivityTestResult connectivityTestResult4222222 = this.b;
sb2222222.append(connectivityTestResult4222222.ErrorReason);
sb2222222.append(a6222222);
sb2222222.append("; ");
connectivityTestResult4222222.ErrorReason = sb2222222.toString();
if (!z2) {
}
i2++;
linkedList = linkedList2;
a = list;
j7 = 0;
}
}
} catch (Exception e15) {
e = e15;
list = a;
str3 = str2;
z2 = z3;
linkedList2 = linkedList;
}
} catch (Throwable th8) {
th2 = th8;
z2 = z3;
}
} catch (Exception e16) {
list = a;
linkedList2 = linkedList;
exc = e16;
cVar4 = cVar5;
}
} catch (Exception e17) {
list = a;
linkedList2 = linkedList;
exc = e17;
j9 = uptimeMillis2;
j8 = elapsedRealtime3;
z2 = false;
String a62222222 = b.a(exc.toString());
StringBuilder sb22222222 = new StringBuilder();
ConnectivityTestResult connectivityTestResult42222222 = this.b;
sb22222222.append(connectivityTestResult42222222.ErrorReason);
sb22222222.append(a62222222);
sb22222222.append("; ");
connectivityTestResult42222222.ErrorReason = sb22222222.toString();
if (!z2) {
}
i2++;
linkedList = linkedList2;
a = list;
j7 = 0;
}
} catch (Exception e18) {
list = a;
linkedList2 = linkedList;
exc = e18;
}
} catch (Exception e19) {
list = a;
linkedList2 = linkedList;
exc = e19;
}
} catch (Throwable th9) {
linkedList2 = linkedList;
th = th9;
}
}
i2++;
linkedList = linkedList2;
a = list;
j7 = 0;
}
if (z4) {
list2 = a;
i5 = i4;
linkedList3 = linkedList;
i6 = i;
i7 = i12;
i8 = 0;
z5 = false;
} else {
try {
try {
long elapsedRealtime5 = SystemClock.elapsedRealtime();
boolean z8 = z4;
if (Build.VERSION.SDK_INT >= 17) {
try {
sSLCertificateSocketFactory.setHostname(sSLSocket3, this.b.ServerHostname);
list2 = a;
i5 = i4;
} catch (Exception e20) {
exc2 = e20;
list2 = a;
i5 = i4;
linkedList3 = linkedList;
i6 = i;
i7 = i12;
i8 = 0;
z5 = false;
String a7 = b.a(exc2.toString());
StringBuilder sb3 = new StringBuilder();
ConnectivityTestResult connectivityTestResult5 = this.b;
sb3.append(connectivityTestResult5.ErrorReason);
sb3.append(a7);
sb3.append("; ");
connectivityTestResult5.ErrorReason = sb3.toString();
if (sSLSocket3 != null) {
}
if (z5) {
}
this.b.RadioInfoOnEnd = b.this.a.c();
this.b.DurationOverallNoSleep = SystemClock.uptimeMillis() - j9;
this.b.DurationOverall = SystemClock.elapsedRealtime() - j8;
this.b.IdleStateOnEnd = com.startapp.networkTest.controller.c.e(b.this.f);
this.b.MultiCdnInfo = new ArrayList<>(linkedList3);
this.b.ServerMultiSuccess = i6 + (i7 * Math.round(Math.pow(10.0d, 2.0d))) + (i5 * Math.round(Math.pow(10.0d, 4.0d))) + (i8 * Math.round(Math.pow(10.0d, 6.0d)));
if (this.b.AirportCode.isEmpty()) {
}
if (list2.size() > 0) {
}
if (com.startapp.networkTest.c.a.b.CLEAR_CT_LOCATION_INFO) {
}
return this.b;
}
} else {
try {
cls = sSLCertificateSocketFactory.getClass();
list2 = a;
i5 = i4;
} catch (Exception e21) {
e = e21;
list2 = a;
i5 = i4;
}
try {
Class<?>[] clsArr = new Class[1];
try {
clsArr[0] = String.class;
cls.getMethod("setHostname", clsArr).invoke(sSLCertificateSocketFactory, this.b.ServerHostname);
} catch (Exception e22) {
e = e22;
Exception exc3 = e;
try {
StringBuilder sb4 = new StringBuilder();
ConnectivityTestResult connectivityTestResult6 = this.b;
sb4.append(connectivityTestResult6.SslException);
sb4.append("SNI not available:");
sb4.append(exc3.getMessage());
sb4.append("; ");
connectivityTestResult6.SslException = sb4.toString();
if (defaultHostnameVerifier.verify(this.b.ServerHostname, sSLSocket3.getSession())) {
}
} catch (Exception e23) {
e = e23;
linkedList3 = linkedList;
i6 = i;
i7 = i12;
exc2 = e;
i8 = 0;
z5 = false;
String a72 = b.a(exc2.toString());
StringBuilder sb32 = new StringBuilder();
ConnectivityTestResult connectivityTestResult52 = this.b;
sb32.append(connectivityTestResult52.ErrorReason);
sb32.append(a72);
sb32.append("; ");
connectivityTestResult52.ErrorReason = sb32.toString();
if (sSLSocket3 != null) {
}
if (z5) {
}
this.b.RadioInfoOnEnd = b.this.a.c();
this.b.DurationOverallNoSleep = SystemClock.uptimeMillis() - j9;
this.b.DurationOverall = SystemClock.elapsedRealtime() - j8;
this.b.IdleStateOnEnd = com.startapp.networkTest.controller.c.e(b.this.f);
this.b.MultiCdnInfo = new ArrayList<>(linkedList3);
this.b.ServerMultiSuccess = i6 + (i7 * Math.round(Math.pow(10.0d, 2.0d))) + (i5 * Math.round(Math.pow(10.0d, 4.0d))) + (i8 * Math.round(Math.pow(10.0d, 6.0d)));
if (this.b.AirportCode.isEmpty()) {
}
if (list2.size() > 0) {
}
if (com.startapp.networkTest.c.a.b.CLEAR_CT_LOCATION_INFO) {
}
return this.b;
}
}
} catch (Exception e24) {
e = e24;
Exception exc32 = e;
StringBuilder sb42 = new StringBuilder();
ConnectivityTestResult connectivityTestResult62 = this.b;
sb42.append(connectivityTestResult62.SslException);
sb42.append("SNI not available:");
sb42.append(exc32.getMessage());
sb42.append("; ");
connectivityTestResult62.SslException = sb42.toString();
if (defaultHostnameVerifier.verify(this.b.ServerHostname, sSLSocket3.getSession())) {
}
}
}
try {
} catch (Exception e25) {
StringBuilder sb5 = new StringBuilder();
ConnectivityTestResult connectivityTestResult7 = this.b;
sb5.append(connectivityTestResult7.SslException);
sb5.append("Cannot validate hostname: ");
sb5.append(e25.getMessage());
sb5.append("; ");
connectivityTestResult7.SslException = sb5.toString();
}
if (defaultHostnameVerifier.verify(this.b.ServerHostname, sSLSocket3.getSession())) {
z6 = z8;
this.b.DurationSSL = SystemClock.elapsedRealtime() - elapsedRealtime5;
if (!z6) {
}
this.b.TestType = aVar.a;
bArr = new byte[2048];
PrintWriter printWriter = new PrintWriter(sSLSocket3.getOutputStream());
long elapsedRealtime6 = SystemClock.elapsedRealtime();
printWriter.print("GET ");
printWriter.print(this.b.ServerFilename);
printWriter.print(" HTTP/1.1");
printWriter.print(IOUtils.LINE_SEPARATOR_WINDOWS);
printWriter.print("HOST: ");
printWriter.print(this.b.ServerHostname);
printWriter.print(IOUtils.LINE_SEPARATOR_WINDOWS);
printWriter.print("Connection: close");
printWriter.print(IOUtils.LINE_SEPARATOR_WINDOWS);
printWriter.print(IOUtils.LINE_SEPARATOR_WINDOWS);
printWriter.print(IOUtils.LINE_SEPARATOR_WINDOWS);
printWriter.flush();
this.b.DurationHttpGetCommand = SystemClock.elapsedRealtime() - elapsedRealtime6;
long elapsedRealtime7 = SystemClock.elapsedRealtime();
inputStream = sSLSocket3.getInputStream();
z7 = z6;
i11 = -1;
j = 0;
while (true) {
a2 = a(inputStream);
linkedList3 = linkedList;
j2 = j + a2.a;
i10 = i9;
upperCase = a2.b.toUpperCase();
i7 = i12;
if (upperCase.startsWith("HTTP")) {
}
}
this.b.HeaderBytesRead = j2;
if (i11 == -1) {
}
while (true) {
read = inputStream.read(bArr);
if (read == -1) {
}
}
j4 = j;
if (z7) {
}
if (j4 > 0) {
}
if (sSLSocket3 != null) {
}
i8 = i10;
z5 = true;
} else {
StringBuilder sb6 = new StringBuilder();
ConnectivityTestResult connectivityTestResult8 = this.b;
sb6.append(connectivityTestResult8.SslException);
sb6.append("Expected ");
sb6.append(this.b.ServerHostname);
sb6.append(" found ");
sb6.append(sSLSocket3.getSession().getPeerPrincipal());
sb6.append("; ");
connectivityTestResult8.SslException = sb6.toString();
z6 = false;
this.b.DurationSSL = SystemClock.elapsedRealtime() - elapsedRealtime5;
i9 = !z6 ? 1 : 0;
try {
this.b.TestType = aVar.a;
try {
bArr = new byte[2048];
PrintWriter printWriter2 = new PrintWriter(sSLSocket3.getOutputStream());
long elapsedRealtime62 = SystemClock.elapsedRealtime();
printWriter2.print("GET ");
printWriter2.print(this.b.ServerFilename);
printWriter2.print(" HTTP/1.1");
printWriter2.print(IOUtils.LINE_SEPARATOR_WINDOWS);
printWriter2.print("HOST: ");
printWriter2.print(this.b.ServerHostname);
printWriter2.print(IOUtils.LINE_SEPARATOR_WINDOWS);
printWriter2.print("Connection: close");
printWriter2.print(IOUtils.LINE_SEPARATOR_WINDOWS);
printWriter2.print(IOUtils.LINE_SEPARATOR_WINDOWS);
printWriter2.print(IOUtils.LINE_SEPARATOR_WINDOWS);
printWriter2.flush();
this.b.DurationHttpGetCommand = SystemClock.elapsedRealtime() - elapsedRealtime62;
long elapsedRealtime72 = SystemClock.elapsedRealtime();
inputStream = sSLSocket3.getInputStream();
z7 = z6;
i11 = -1;
j = 0;
while (true) {
try {
try {
a2 = a(inputStream);
linkedList3 = linkedList;
j2 = j + a2.a;
i10 = i9;
try {
upperCase = a2.b.toUpperCase();
i7 = i12;
try {
} catch (Throwable th10) {
th = th10;
}
} catch (Throwable th11) {
th = th11;
}
} catch (Exception e26) {
e = e26;
exc2 = e;
i8 = i10;
z5 = true;
String a722 = b.a(exc2.toString());
StringBuilder sb322 = new StringBuilder();
ConnectivityTestResult connectivityTestResult522 = this.b;
sb322.append(connectivityTestResult522.ErrorReason);
sb322.append(a722);
sb322.append("; ");
connectivityTestResult522.ErrorReason = sb322.toString();
if (sSLSocket3 != null) {
try {
sSLSocket3.close();
} catch (Exception unused) {
}
}
if (z5) {
}
this.b.RadioInfoOnEnd = b.this.a.c();
this.b.DurationOverallNoSleep = SystemClock.uptimeMillis() - j9;
this.b.DurationOverall = SystemClock.elapsedRealtime() - j8;
this.b.IdleStateOnEnd = com.startapp.networkTest.controller.c.e(b.this.f);
this.b.MultiCdnInfo = new ArrayList<>(linkedList3);
this.b.ServerMultiSuccess = i6 + (i7 * Math.round(Math.pow(10.0d, 2.0d))) + (i5 * Math.round(Math.pow(10.0d, 4.0d))) + (i8 * Math.round(Math.pow(10.0d, 6.0d)));
if (this.b.AirportCode.isEmpty()) {
}
if (list2.size() > 0) {
}
if (com.startapp.networkTest.c.a.b.CLEAR_CT_LOCATION_INFO) {
}
return this.b;
}
} catch (Throwable th12) {
th = th12;
}
if (upperCase.startsWith("HTTP")) {
i6 = i;
if (upperCase.startsWith("CONTENT-LENGTH:")) {
try {
try {
i11 = Integer.parseInt(upperCase.substring(15).trim());
} catch (NumberFormatException unused2) {
}
j = j2;
linkedList = linkedList3;
i9 = i10;
i12 = i7;
i = i6;
} catch (Throwable th13) {
th = th13;
}
} else {
if (upperCase.startsWith("X-AMZ-CF-ID:")) {
this.b.AmazonId = a2.b.substring(15).trim();
} else if (!a2.c && !upperCase.equals("")) {
if (upperCase.startsWith("X-AMZ-CF-POP:")) {
this.b.AirportCode = h.b(a2.b.toLowerCase().substring(13).trim());
}
}
j = j2;
linkedList = linkedList3;
i9 = i10;
i12 = i7;
i = i6;
}
th = th13;
th3 = th;
if (j2 > 0) {
throw th3;
}
this.b.DurationHttpReceive = SystemClock.elapsedRealtime() - elapsedRealtime72;
this.b.BytesRead = j2;
throw th3;
}
try {
this.b.HTTPStatus = Integer.parseInt(upperCase.split(" ")[1]);
if (this.b.HTTPStatus != 200) {
StringBuilder sb7 = new StringBuilder();
ConnectivityTestResult connectivityTestResult9 = this.b;
sb7.append(connectivityTestResult9.ErrorReason);
sb7.append("Request failed! Unexcepted HTTP code: ");
sb7.append(this.b.HTTPStatus);
sb7.append("; ");
connectivityTestResult9.ErrorReason = sb7.toString();
z7 = false;
}
j = j2;
linkedList = linkedList3;
i9 = i10;
i12 = i7;
} catch (Throwable th14) {
th3 = th14;
}
}
this.b.HeaderBytesRead = j2;
if (i11 == -1) {
j = j2;
j3 = ((int) j2) + i11;
} else {
j = j2;
j3 = Long.MAX_VALUE;
}
while (true) {
try {
read = inputStream.read(bArr);
if (read == -1) {
j += read;
if (j < j3 && read > 0) {
}
} else if (j < j3) {
throw new IOException("Could not read all bytes");
}
} catch (Throwable th15) {
th = th15;
th3 = th;
j2 = j;
if (j2 > 0) {
}
}
}
j4 = j;
if (z7) {
try {
this.b.Success = true;
cVar3.successfulTests++;
} catch (Throwable th16) {
th3 = th16;
j2 = j4;
}
}
if (j4 > 0) {
this.b.DurationHttpReceive = SystemClock.elapsedRealtime() - elapsedRealtime72;
this.b.BytesRead = j4;
}
if (sSLSocket3 != null) {
try {
sSLSocket3.close();
} catch (Exception unused3) {
}
}
i8 = i10;
z5 = true;
} catch (Exception e27) {
e = e27;
i10 = i9;
linkedList3 = linkedList;
i6 = i;
i7 = i12;
}
} catch (Exception e28) {
int i13 = i9;
linkedList3 = linkedList;
i6 = i;
i7 = i12;
exc2 = e28;
i8 = i13;
z5 = false;
String a7222 = b.a(exc2.toString());
StringBuilder sb3222 = new StringBuilder();
ConnectivityTestResult connectivityTestResult5222 = this.b;
sb3222.append(connectivityTestResult5222.ErrorReason);
sb3222.append(a7222);
sb3222.append("; ");
connectivityTestResult5222.ErrorReason = sb3222.toString();
if (sSLSocket3 != null) {
}
if (z5) {
}
this.b.RadioInfoOnEnd = b.this.a.c();
this.b.DurationOverallNoSleep = SystemClock.uptimeMillis() - j9;
this.b.DurationOverall = SystemClock.elapsedRealtime() - j8;
this.b.IdleStateOnEnd = com.startapp.networkTest.controller.c.e(b.this.f);
this.b.MultiCdnInfo = new ArrayList<>(linkedList3);
this.b.ServerMultiSuccess = i6 + (i7 * Math.round(Math.pow(10.0d, 2.0d))) + (i5 * Math.round(Math.pow(10.0d, 4.0d))) + (i8 * Math.round(Math.pow(10.0d, 6.0d)));
if (this.b.AirportCode.isEmpty()) {
}
if (list2.size() > 0) {
}
if (com.startapp.networkTest.c.a.b.CLEAR_CT_LOCATION_INFO) {
}
return this.b;
}
}
} catch (Exception e29) {
e = e29;
list2 = a;
i5 = i4;
linkedList3 = linkedList;
i6 = i;
i7 = i12;
}
} finally {
}
}
if (z5) {
if (this.b.RadioInfo.ConnectionType == ConnectionTypes.WiFi) {
connectivityTestResult = this.b;
a3 = com.startapp.networkTest.b.a.a();
wifiInfo = this.b.WifiInfo;
} else if (com.startapp.networkTest.c.a.b.GEOIP_MOBILE_ENABLED && this.b.RadioInfo.ConnectionType == ConnectionTypes.Mobile) {
connectivityTestResult = this.b;
a3 = com.startapp.networkTest.b.a.a();
wifiInfo = null;
}
connectivityTestResult.IspInfo = a3.a(wifiInfo);
}
this.b.RadioInfoOnEnd = b.this.a.c();
this.b.DurationOverallNoSleep = SystemClock.uptimeMillis() - j9;
this.b.DurationOverall = SystemClock.elapsedRealtime() - j8;
this.b.IdleStateOnEnd = com.startapp.networkTest.controller.c.e(b.this.f);
this.b.MultiCdnInfo = new ArrayList<>(linkedList3);
this.b.ServerMultiSuccess = i6 + (i7 * Math.round(Math.pow(10.0d, 2.0d))) + (i5 * Math.round(Math.pow(10.0d, 4.0d))) + (i8 * Math.round(Math.pow(10.0d, 6.0d)));
if (this.b.AirportCode.isEmpty()) {
this.b.AirportCode = h.a(this.b.ServerIp);
}
if (list2.size() > 0) {
a(list2);
}
if (com.startapp.networkTest.c.a.b.CLEAR_CT_LOCATION_INFO) {
this.b.LocationInfo = new LocationInfo();
}
return this.b;
}
callStates = CallStates.Unknown;
connectivityTestResult3.CallState = callStates;
this.b.StorageInfo = com.startapp.networkTest.controller.c.c(b.this.f);
this.b.WifiInfo = b.this.b.c();
this.b.TrafficInfo = com.startapp.networkTest.controller.c.a(b.this.b);
this.b.ScreenState = com.startapp.networkTest.controller.c.d(b.this.f);
this.b.IdleStateOnStart = com.startapp.networkTest.controller.c.e(b.this.f);
this.b.SimInfo = f;
this.b.TimeInfo = com.startapp.networkTest.f.b.a();
this.b.TestTimestamp = this.b.TimeInfo.TimestampTableau;
this.b.TruststoreTimestamp = com.startapp.networkTest.c.a.d.c();
this.b.CtId = com.startapp.networkTest.utils.d.a(this.b.TimeInfo, this.b.GUID);
if (b.this.g.a.getBoolean("P3INS_PFK_CONNECTIVITY_KEEPALIVE_ENABLED", com.startapp.networkTest.c.a.b.CONNECTIVITY_KEEPALIVE_ENABLED)) {
this.b.IsKeepAlive = true;
}
long elapsedRealtime22 = SystemClock.elapsedRealtime();
long uptimeMillis3 = SystemClock.uptimeMillis();
HostnameVerifier defaultHostnameVerifier2 = HttpsURLConnection.getDefaultHostnameVerifier();
com.startapp.networkTest.a.a aVar2 = new com.startapp.networkTest.a.a(b.this.f, z);
a = a(strArr, valueOf);
linkedList = new LinkedList();
String str42 = b.this.i;
long j82 = elapsedRealtime22;
long j92 = uptimeMillis3;
i = 0;
int i122 = 0;
SSLSocket sSLSocket42 = null;
SSLCertificateSocketFactory sSLCertificateSocketFactory22 = null;
c cVar42 = null;
String str52 = b.this.k;
String str62 = str42;
i2 = 0;
while (true) {
if (i2 >= a.size()) {
}
com.startapp.networkTest.data.d dVar2 = new com.startapp.networkTest.data.d();
long elapsedRealtime32 = SystemClock.elapsedRealtime();
long uptimeMillis22 = SystemClock.uptimeMillis();
c cVar52 = new c();
i++;
this.b.LocalhostPingSuccess = b();
long elapsedRealtime42 = SystemClock.elapsedRealtime();
if (a.isEmpty()) {
}
if (this.b.DurationDNS > 30000) {
}
i2++;
linkedList = linkedList2;
a = list;
j7 = 0;
}
if (z4) {
}
if (z5) {
}
this.b.RadioInfoOnEnd = b.this.a.c();
this.b.DurationOverallNoSleep = SystemClock.uptimeMillis() - j92;
this.b.DurationOverall = SystemClock.elapsedRealtime() - j82;
this.b.IdleStateOnEnd = com.startapp.networkTest.controller.c.e(b.this.f);
this.b.MultiCdnInfo = new ArrayList<>(linkedList3);
this.b.ServerMultiSuccess = i6 + (i7 * Math.round(Math.pow(10.0d, 2.0d))) + (i5 * Math.round(Math.pow(10.0d, 4.0d))) + (i8 * Math.round(Math.pow(10.0d, 6.0d)));
if (this.b.AirportCode.isEmpty()) {
}
if (list2.size() > 0) {
}
if (com.startapp.networkTest.c.a.b.CLEAR_CT_LOCATION_INFO) {
}
return this.b;
}
a4 = l.a(b.this.f);
z = a4;
str = null;
j5 = com.startapp.networkTest.c.a.d.a.getLong("P3INS_PFK_CONNECTIVITY_TEST_CDNCONFIG_LAST_CHECK", 0L);
b = com.startapp.networkTest.f.b.b();
if (com.startapp.networkTest.c.a.b.CONNECTIVITY_TEST_CDNCONFIG_UPDATE_INTERVAL + j5 >= b) {
}
com.startapp.networkTest.utils.a.a();
if (com.startapp.networkTest.c.a()) {
}
return null;
}
private List<c> a(String[] strArr, CtCriteriaTypes ctCriteriaTypes) {
LinkedList linkedList = new LinkedList();
LinkedList linkedList2 = new LinkedList();
Set<String> stringSet = com.startapp.networkTest.c.a.d.a.getStringSet("P3INS_PFK_CT_CRITERIA_SERVER_LIST", null);
LinkedList<c> linkedList3 = new LinkedList();
if (stringSet != null) {
Iterator<String> it = stringSet.iterator();
while (it.hasNext()) {
c cVar = (c) com.startapp.common.d.b.a(it.next(), c.class);
if (cVar != null) {
linkedList3.add(cVar);
}
}
}
for (String str : strArr) {
c cVar2 = new c();
cVar2.address = str;
linkedList2.add(cVar2);
}
for (c cVar3 : linkedList3) {
for (int i = 0; i < linkedList2.size(); i++) {
if (((c) linkedList2.get(i)).address.equals(cVar3.address)) {
linkedList2.set(i, cVar3);
}
}
}
switch (ctCriteriaTypes) {
case NoChange:
return linkedList2;
case Random:
Collections.shuffle(linkedList2, new Random(System.nanoTime()));
return new LinkedList(linkedList2);
case DNSSuccessful:
Collections.sort(linkedList2, new Comparator<c>() {
@Override
public final int compare(c cVar4, c cVar5) {
return cVar4.DNSSuccess - cVar5.DNSSuccess;
}
});
return new LinkedList(linkedList2);
case TCPSuccessful:
Collections.sort(linkedList2, new Comparator<c>() {
@Override
public final int compare(c cVar4, c cVar5) {
return cVar4.TCPSuccess - cVar5.TCPSuccess;
}
});
return new LinkedList(linkedList2);
case FullSuccessful:
Collections.sort(linkedList2, new Comparator<c>() {
@Override
public final int compare(c cVar4, c cVar5) {
return cVar4.successfulTests - cVar5.successfulTests;
}
});
return new LinkedList(linkedList2);
case TotalTests:
Collections.sort(linkedList2, new Comparator<c>() {
@Override
public final int compare(c cVar4, c cVar5) {
return cVar4.totalTests - cVar5.totalTests;
}
});
return new LinkedList(linkedList2);
default:
return linkedList;
}
}
private static void a(List<c> list) {
HashSet hashSet = new HashSet();
Iterator<c> it = list.iterator();
while (it.hasNext()) {
hashSet.add(it.next().toString());
}
com.startapp.networkTest.c.a.d.a(hashSet);
}
private static boolean b() {
BufferedReader bufferedReader;
BufferedReader bufferedReader2 = null;
try {
try {
try {
bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("ping -W 3 -c 1 -s 56 127.0.0.1").getInputStream()));
} catch (IOException e) {
e = e;
}
} catch (Throwable th) {
th = th;
}
} catch (IOException e2) {
e2.printStackTrace();
}
try {
bufferedReader.readLine();
String readLine = bufferedReader.readLine();
if (readLine != null && readLine.length() > 0) {
if (readLine.split(" ").length == 8) {
try {
bufferedReader.close();
return true;
} catch (IOException e3) {
e3.printStackTrace();
return true;
}
}
}
bufferedReader.close();
} catch (IOException e4) {
e = e4;
bufferedReader2 = bufferedReader;
e.printStackTrace();
if (bufferedReader2 == null) {
return false;
}
bufferedReader2.close();
return false;
} catch (Throwable th2) {
th = th2;
bufferedReader2 = bufferedReader;
if (bufferedReader2 != null) {
try {
bufferedReader2.close();
} catch (IOException e5) {
e5.printStackTrace();
}
}
throw th;
}
return false;
}
@Override
public final void a(SpeedtestEngineStatus speedtestEngineStatus) {
if (speedtestEngineStatus == SpeedtestEngineStatus.END || speedtestEngineStatus == SpeedtestEngineStatus.ABORTED) {
com.startapp.networkTest.c.a aVar = this.c;
if (aVar.d != null) {
aVar.d.a();
}
if (aVar.b != null) {
aVar.b.b();
}
if (aVar.c != null) {
aVar.c.b();
}
if (b.this.d != null) {
b.this.d.a((LatencyResult) this.c.e);
b.this.d.a();
}
}
}
@Override
protected final ConnectivityTestResult doInBackground(Void[] voidArr) {
return a();
}
@Override
protected final void onPostExecute(ConnectivityTestResult connectivityTestResult) {
ConnectivityTestResult connectivityTestResult2 = connectivityTestResult;
com.startapp.networkTest.d dVar = b.this.g;
dVar.a.edit().putLong("P3INS_PFK_CONNECTIVITY_TEST_TIMESTAMP", SystemClock.elapsedRealtime()).commit();
if (b.this.d != null) {
b.this.d.a(connectivityTestResult2);
}
if (connectivityTestResult2 != null) {
boolean z = false;
if (b.this.g.b() && connectivityTestResult2.ServerIp.length() > 0) {
this.c = new com.startapp.networkTest.c.a(this, b.this.f);
this.c.g = connectivityTestResult2.CtId;
this.c.i = connectivityTestResult2.AirportCode;
this.c.h = String.valueOf(connectivityTestResult2.TimeInfo.TimestampMillis + connectivityTestResult2.DurationDNS + connectivityTestResult2.DurationTcpConnect + connectivityTestResult2.DurationHttpReceive);
com.startapp.networkTest.c.a aVar = this.c;
LocationController.ProviderMode providerMode = com.startapp.networkTest.c.a.b.LTR_LOCATIONPROVIDER;
if (aVar.d != null) {
aVar.d.a(providerMode);
}
if (aVar.b != null) {
aVar.b.a();
}
if (aVar.c != null) {
aVar.c.a();
}
com.startapp.networkTest.c.a aVar2 = this.c;
String str = connectivityTestResult2.ServerIp;
aVar2.f = new ArrayList<>();
new a.AsyncTaskC0127a(str).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
z = true;
}
if (z || b.this.d == null) {
return;
}
b.this.d.a();
}
}
}
public b(Context context) {
this.f = context;
this.g = new com.startapp.networkTest.d(context);
com.startapp.networkTest.a aVar = com.startapp.networkTest.c.a.b;
this.h = aVar.PROJECT_ID;
this.i = aVar.CONNECTIVITY_TEST_HOSTNAME;
this.j = aVar.CONNECTIVITY_TEST_FILENAME;
this.k = aVar.CONNECTIVITY_TEST_IP;
this.l = new Random();
this.m = aVar.CONNECTIVITY_TEST_MIN_BATTERY_LEVEL;
this.n = aVar.CONNECTIVITY_TEST_ENABLED_IN_ROAMING;
this.c = new LocationController(context);
this.a = new com.startapp.networkTest.controller.d(context);
this.b = new com.startapp.networkTest.controller.e(context);
}
static String a(String str) {
return (str == null || str.isEmpty()) ? "" : str.replaceAll("(?:[0-9]{1,3}\\.){3}[0-9]{1,3}", "XXX").replaceAll("([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}", "XXX");
}
}