QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 hz.java 源代码,内容仅作参考
package kcsdkint;
import android.net.ConnectivityManager;
import android.net.LinkProperties;
import android.net.Network;
import android.net.NetworkRequest;
import android.os.Build;
import com.huawei.hms.framework.common.ContainerUtils;
import com.tencent.mtt.video.browser.export.wc.m3u8.M3U8Constants;
import com.tencent.qqlive.tvkplayer.api.TVKPlayerMsg;
import com.xiaomi.mipush.sdk.Constants;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import kcsdkint.kc;
import kcsdkint.ko;
import tmsdk.common.gourd.GourdEnv;
public final class hz {
public static class a {
String f84268a;
long f84269b;
}
public static kc.a a() {
String str;
gt.f();
Map<String, kc.a> a2 = kc.a();
if (a2.size() > 0) {
String b2 = kf.b();
String a3 = ki.a(jo.c());
hv.a();
String a4 = hv.b().a(ko.e.i);
Set<String> keySet = a2.keySet();
HashMap hashMap = new HashMap();
for (String str2 : keySet) {
if (a4 == null) {
if (("Xiaomi".equals(b2) && str2 != null && str2.contains("usbnet")) || ((str2 != null && str2.contains("tun0")) || (str2 != null && str2.startsWith("wlan")))) {
str = "** filter by default: ".concat(String.valueOf(str2));
jy.a("NetPhoneIpHelper", str);
}
hashMap.put(str2, a2.get(str2));
} else {
if (a4 != null && !a(a4, str2, b2, a3)) {
str = "** filter by cloud:" + str2 + ", " + b2 + ", " + a3;
jy.a("NetPhoneIpHelper", str);
}
hashMap.put(str2, a2.get(str2));
}
}
if (hashMap.size() == 0) {
return null;
}
Set entrySet = hashMap.entrySet();
int size = entrySet.size();
Iterator it = entrySet.iterator();
if (size == 1) {
kc.a aVar = (kc.a) ((Map.Entry) it.next()).getValue();
jy.b("NetPhoneIpHelper", "pick single interface:".concat(String.valueOf(aVar)));
return aVar;
}
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
String str3 = (String) entry.getKey();
if (a(str3) || c(str3)) {
jy.b("NetPhoneIpHelper", "valid interface:" + ((String) entry.getKey()));
return (kc.a) entry.getValue();
}
}
}
return null;
}
private static boolean a(String str) {
LinkProperties linkProperties;
try {
if (Build.VERSION.SDK_INT >= 23) {
ConnectivityManager connectivityManager = (ConnectivityManager) GourdEnv.getInstance().getHostContext().getSystemService("connectivity");
if ((GourdEnv.getInstance().getHostContext().getPackageManager().checkPermission("android.permission.ACCESS_NETWORK_STATE", GourdEnv.getInstance().getHostContext().getPackageName()) == 0) && connectivityManager.getActiveNetworkInfo() != null && (linkProperties = connectivityManager.getLinkProperties(connectivityManager.getActiveNetwork())) != null && str != null) {
if (str.equals(linkProperties.getInterfaceName())) {
return true;
}
}
}
} catch (Throwable th) {
th.printStackTrace();
}
return false;
}
private static boolean a(String str, String str2, String str3, String str4) {
HashMap hashMap = new HashMap();
if (str != null) {
for (String str5 : str.split(ContainerUtils.FIELD_DELIMITER)) {
String[] split = str5.split(Constants.ACCEPT_TIME_SEPARATOR_SP);
if (split != null && split.length == 2) {
String str6 = split[0];
String str7 = split[1];
List list = (List) hashMap.get(str6);
if (list == null) {
list = new ArrayList();
}
String[] split2 = str7.split(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
if (split2 != null) {
for (String str8 : split2) {
list.add(str8);
}
}
hashMap.put(str6, list);
}
}
}
List list2 = (List) hashMap.get(str3 + M3U8Constants.COMMENT_PREFIX + str4);
if (list2 == null) {
list2 = (List) hashMap.get(str3 + "#all");
}
if (list2 == null) {
list2 = (List) hashMap.get("all#all");
}
if (list2 != null) {
Iterator it = list2.iterator();
while (it.hasNext()) {
if (str2.contains((String) it.next())) {
return false;
}
}
}
return true;
}
private static a b(String str) {
try {
String[] strArr = {TVKPlayerMsg.PLAYER_CHOICE_SELF, "thread-self"};
int i = 0;
while (true) {
if (i >= 2) {
return null;
}
String a2 = jn.a("cat /proc/" + strArr[i] + "/net/dev");
if (a2 != null) {
String[] split = a2.split("\n");
if (split.length > 2) {
for (int i2 = 2; i2 < split.length; i2++) {
String[] split2 = split[i2].split("\\s+");
String str2 = split2[0];
String str3 = split2[9];
if (str != null && str2 != null && str2.startsWith(str)) {
a aVar = new a();
aVar.f84268a = str2;
aVar.f84269b = Long.parseLong(str3);
return aVar;
}
}
} else {
continue;
}
}
i++;
}
} catch (Throwable th) {
th.printStackTrace();
return null;
}
}
public static boolean b() {
if (Build.VERSION.SDK_INT < 21) {
return false;
}
try {
((dc) Cdo.a(dc.class)).a(399354);
final ConnectivityManager connectivityManager = (ConnectivityManager) gt.f().getSystemService("connectivity");
NetworkRequest.Builder builder = new NetworkRequest.Builder();
builder.addCapability(12);
builder.addTransportType(0);
NetworkRequest build = builder.build();
final CountDownLatch countDownLatch = new CountDownLatch(1);
connectivityManager.requestNetwork(build, new ConnectivityManager.NetworkCallback() {
@Override
public final void onAvailable(Network network) {
super.onAvailable(network);
try {
js.a("https://www.qq.com", 5000);
connectivityManager.unregisterNetworkCallback(this);
((dc) Cdo.a(dc.class)).a(399355);
} catch (Throwable th) {
th.printStackTrace();
}
try {
countDownLatch.countDown();
} catch (Throwable th2) {
th2.printStackTrace();
}
}
@Override
public final void onUnavailable() {
super.onUnavailable();
try {
countDownLatch.countDown();
} catch (Throwable th) {
th.printStackTrace();
}
}
});
countDownLatch.await(5L, TimeUnit.SECONDS);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
private static boolean c(String str) {
a b2 = b(str);
if (b2 == null) {
return false;
}
try {
js.a("https://mmgr.gtimg.com/gjsmall/net/index.html", 10000);
} catch (UnknownHostException | Exception unused) {
}
a b3 = b(str);
return b3 != null && b3.f84269b > b2.f84269b;
}
}