QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 WalledGardenDetectTask.java 源代码,内容仅作参考
package com.tencent.mtt.base.task;
import android.net.Network;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.text.TextUtils;
import com.tencent.basesupport.FLogger;
import com.tencent.mtt.compliance.MethodDelegate;
import com.tencent.tar.deprecated.CameraUtils;
import com.tencent.tbs.common.internal.service.StatServerHolder;
import com.xiaomi.mipush.sdk.Constants;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import tmsdk.common.gourd.vine.IActionReportService;
public class WalledGardenDetectTask extends BaseWalledGardenTask implements Handler.Callback {
private static String g = "9a6f75849b";
private static String m;
public String f33227c;
WalledGardenMessage f33228d;
String e;
int f;
private Handler j;
private Network k;
private String n;
private int o;
private String h = "https://dnet.mb.qq.com/rsp204";
private int i = 0;
private boolean l = false;
private String a(InputStream inputStream) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder sb = new StringBuilder();
while (true) {
try {
try {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
sb.append(readLine);
} catch (IOException unused) {
return null;
}
} catch (IOException unused2) {
bufferedReader.close();
return null;
} catch (Throwable th) {
try {
bufferedReader.close();
} catch (IOException unused3) {
}
throw th;
}
}
String sb2 = sb.toString();
try {
bufferedReader.close();
} catch (IOException unused4) {
}
return sb2;
}
private String a(HttpURLConnection httpURLConnection, String str) {
String[] split;
String str2 = null;
try {
if (TextUtils.isEmpty(null) && !TextUtils.isEmpty(httpURLConnection.getHeaderField("Location"))) {
str2 = httpURLConnection.getHeaderField("Location");
}
String host = new URL(this.h).getHost();
String host2 = httpURLConnection.getURL().getHost();
FLogger.d("WalledGardenDetectTask", "seq=1;host=" + host + ";mWalledGardenUrl=" + this.h + ";newHost=" + host2);
if (!TextUtils.equals(host, host2)) {
str2 = httpURLConnection.getURL().toExternalForm();
}
if (TextUtils.isEmpty(str2) && !TextUtils.isEmpty(httpURLConnection.getHeaderField("Refresh")) && (split = httpURLConnection.getHeaderField("Refresh").split(IActionReportService.COMMON_SEPARATOR)) != null && split.length == 2) {
str2 = split[1].trim();
}
} catch (Throwable unused) {
}
FLogger.d("WalledGardenDetectTask", "seq=2;url=" + str2);
return str2;
}
private void a(int i, String str) {
HashMap hashMap = new HashMap();
hashMap.put("type", "wifi_30x");
hashMap.put("key1", i + "");
hashMap.put("key2", str);
StatServerHolder.statWithBeacon("MTT_DEV_DEBUG_ACTION", hashMap);
}
private void a(int i, String str, String str2) {
HashMap hashMap = new HashMap();
hashMap.put("type", "wifi_link_error");
hashMap.put("key1", i + "");
hashMap.put("key2", str);
hashMap.put("key3", str2);
StatServerHolder.statWithBeacon("MTT_DEV_DEBUG_ACTION", hashMap);
}
private void a(HttpURLConnection httpURLConnection, int i, String str, String str2) {
if (i == 200 || (i >= 301 && i <= 307)) {
this.n = a(httpURLConnection, str2);
if (i < 301 || i > 307 || TextUtils.isEmpty(str)) {
return;
}
a(i, str);
}
}
private int g() {
HttpURLConnection httpURLConnection;
Throwable th;
String str;
FLogger.d("WalledGardenDetectTask", "seq=1;action=tryWalledGardenConnection() -- >;mWalledGardenUrl=" + this.h);
String str2 = null;
this.n = null;
this.e = null;
this.f = 0;
try {
URL url = new URL(this.h);
httpURLConnection = (HttpURLConnection) ((this.k == null || Build.VERSION.SDK_INT < 21) ? url.openConnection() : this.k.openConnection(url));
try {
httpURLConnection.setInstanceFollowRedirects(false);
httpURLConnection.setConnectTimeout(150000);
httpURLConnection.setReadTimeout(150000);
httpURLConnection.setUseCaches(false);
if (!TextUtils.isEmpty(m)) {
httpURLConnection.setRequestProperty("User-Agent", m);
}
InputStream inputStream = httpURLConnection.getInputStream();
int responseCode = httpURLConnection.getResponseCode();
this.f = responseCode;
FLogger.d("WalledGardenDetectTask", "seq=3;code=" + responseCode);
if (responseCode == 200) {
str = a(inputStream);
FLogger.d("WalledGardenDetectTask", "seq=4;rsp=" + str);
} else {
str = null;
}
if (this.i == 1 && responseCode == 200) {
str2 = a(inputStream);
if (TextUtils.equals(str2, g)) {
return 0;
}
} else if (responseCode == 204) {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return 0;
}
a(httpURLConnection, responseCode, str, str2);
FLogger.d("WalledGardenDetectTask", "seq=5;detect SSID=" + this.f33227c + ";mRedirectUrl=" + this.n);
if (!TextUtils.isEmpty(this.n)) {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return 2;
}
if (responseCode == 200) {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return 2;
}
FLogger.d("WalledGardenDetectTask", "seq=6;result=wifi disc;code=" + responseCode);
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return 1;
} catch (Throwable th2) {
th = th2;
try {
FLogger.d("WalledGardenDetectTask", "seq=7;exception=" + th.getMessage());
this.e = th.getMessage();
a(0, "", th.getMessage());
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return 3;
} finally {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
}
}
} catch (Throwable th3) {
httpURLConnection = null;
th = th3;
}
}
@Override
public void a() {
this.l = true;
}
public void a(Network network) {
this.k = network;
}
public void a(String str) {
this.h = str;
}
public void b(String str) {
this.f33227c = str;
}
public int c() {
return this.o;
}
public String d() {
return this.n;
}
public WalledGardenMessage e() {
return this.f33228d;
}
public void f() {
String str;
String replaceAll;
if (m == null) {
Locale locale = Locale.getDefault();
StringBuffer stringBuffer = new StringBuffer();
String str2 = Build.VERSION.RELEASE;
try {
str2 = new String(str2.getBytes("UTF-8"), "ISO8859-1");
} catch (Exception unused) {
}
if (str2.length() <= 0) {
str2 = "1.0";
}
stringBuffer.append(str2);
stringBuffer.append("; ");
String language = locale.getLanguage();
if (language != null) {
stringBuffer.append(language.toLowerCase());
String country = locale.getCountry();
if (country != null) {
stringBuffer.append(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
str = country.toLowerCase();
}
if ("REL".equals(Build.VERSION.CODENAME)) {
String model = MethodDelegate.getModel();
try {
model = new String(model.getBytes("UTF-8"), "ISO8859-1");
} catch (Exception unused2) {
}
if (model.length() > 0) {
stringBuffer.append("; ");
stringBuffer.append(model);
}
}
replaceAll = Build.ID.replaceAll("[一-龥]", "");
if (replaceAll.length() > 0) {
stringBuffer.append(" Build/");
stringBuffer.append(replaceAll);
}
m = String.format("Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/537.36 (KHTML, like Gecko)Version/4.0 %s%s Mobile Safari/537.36", stringBuffer, "Chrome/37.0.0.0", " MQQBrowser/6.9");
}
str = CameraUtils.DEFAULT_L_LOCALE;
stringBuffer.append(str);
if ("REL".equals(Build.VERSION.CODENAME)) {
}
replaceAll = Build.ID.replaceAll("[一-龥]", "");
if (replaceAll.length() > 0) {
}
m = String.format("Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/537.36 (KHTML, like Gecko)Version/4.0 %s%s Mobile Safari/537.36", stringBuffer, "Chrome/37.0.0.0", " MQQBrowser/6.9");
}
}
@Override
public boolean handleMessage(Message message) {
if (message.what != 100) {
return false;
}
this.l = true;
this.o = 3;
if (this.f33228d == null) {
this.f33228d = new WalledGardenMessage();
this.f33228d.f33234b = this.f33207a;
this.f33228d.f33233a = this.f33227c;
}
WalledGardenMessage walledGardenMessage = this.f33228d;
walledGardenMessage.e = -1;
walledGardenMessage.f33236d = "超时,主动返回";
walledGardenMessage.f33235c = this.o;
walledGardenMessage.f = 150000;
b();
FLogger.d("WalledGardenDetectTask", "seq=1;mSsid=" + this.f33227c + ";mResult=" + this.o);
return false;
}
@Override
public void run() {
long elapsedRealtime = SystemClock.elapsedRealtime();
this.l = false;
this.f33228d = new WalledGardenMessage();
this.f33228d.f33234b = this.f33207a;
this.f33228d.f33233a = this.f33227c;
if (this.j == null) {
this.j = new Handler(Looper.getMainLooper(), this);
}
this.j.removeMessages(100);
this.j.sendEmptyMessageDelayed(100, 150000L);
f();
this.o = g();
this.j.removeMessages(100);
if (this.l) {
return;
}
WalledGardenMessage walledGardenMessage = this.f33228d;
walledGardenMessage.e = this.f;
walledGardenMessage.f33236d = this.e;
walledGardenMessage.f33235c = this.o;
walledGardenMessage.f = (int) (SystemClock.elapsedRealtime() - elapsedRealtime);
b();
}
}