QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 ConnectivityDetector.java 源代码,内容仅作参考
package com.tencent.common.connectivitydetect;
import com.tencent.basesupport.FLogger;
import com.tencent.common.http.Apn;
import com.tencent.mtt.miniprogram.util.log.UploadUtil;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.URL;
public class ConnectivityDetector {
private static final byte[] f9199a = "9a6f75849b".getBytes();
public static boolean a() {
if (Apn.isNetworkConnected()) {
return Apn.isWifiMode() ? b() : c();
}
return false;
}
private static boolean a(byte[] bArr, byte[] bArr2) {
if (bArr == null && bArr2 == null) {
return true;
}
if (bArr == null && bArr2 != null) {
return false;
}
if ((bArr != null && bArr2 == null) || bArr.length != bArr2.length) {
return false;
}
for (int i = 0; i < bArr.length; i++) {
if (bArr[i] != bArr2[i]) {
return false;
}
}
return true;
}
public static boolean b() {
HttpURLConnection httpURLConnection;
InputStream inputStream = null;
try {
httpURLConnection = (HttpURLConnection) new URL("https://res.imtt.qq.com/qbprobe/netprobe.txt?t=" + System.currentTimeMillis()).openConnection();
try {
httpURLConnection.setInstanceFollowRedirects(false);
httpURLConnection.setConnectTimeout(5000);
httpURLConnection.setReadTimeout(5000);
httpURLConnection.setUseCaches(false);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setRequestProperty("Connection", UploadUtil.CLOSE);
httpURLConnection.setRequestProperty("Cache-Control", "no-cache");
httpURLConnection.connect();
InputStream inputStream2 = httpURLConnection.getInputStream();
int responseCode = httpURLConnection.getResponseCode();
FLogger.d("ConnectivityDetector", "checkNetworkConnectivity: HttpRsp code = " + responseCode);
if (responseCode != 200) {
FLogger.d("ConnectivityDetector", "checkNetworkConnectivity: HttpRsp code not 200!!");
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (Exception unused) {
}
}
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Exception unused2) {
}
}
return false;
}
byte[] bArr = new byte[f9199a.length];
if (inputStream2.read(bArr) == bArr.length && a(bArr, f9199a)) {
FLogger.d("ConnectivityDetector", "checkNetworkConnectivity SUCC: buffer = " + new String(bArr));
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (Exception unused3) {
}
}
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Exception unused4) {
}
}
return true;
}
FLogger.d("ConnectivityDetector", "checkNetworkConnectivity FAIL: buffer = " + new String(bArr));
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (Exception unused5) {
}
}
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Exception unused6) {
}
}
return false;
} catch (Throwable unused7) {
if (0 != 0) {
try {
inputStream.close();
} catch (Exception unused8) {
}
}
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Exception unused9) {
}
}
return false;
}
} catch (Throwable unused10) {
httpURLConnection = null;
}
}
public static boolean c() {
try {
Socket socket = new Socket();
socket.connect(new InetSocketAddress("www.qq.com", 80), 5000);
socket.close();
return true;
} catch (Throwable unused) {
return false;
}
}
}