BTGO游戏盒 v3.4.80版本的 MD5 值为:000032bab1addaabfdc671ee6a7087ab
以下内容为反编译后的 k.java 源代码,内容仅作参考
package com.qiyukf.nimlib.q;
import android.os.AsyncTask;
import android.text.TextUtils;
import com.efs.sdk.base.core.util.NetworkUtil;
import com.qiyukf.module.zip4j.util.InternalZipConstants;
import com.qiyukf.nimlib.sdk.ServerAddresses;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONArray;
import org.json.JSONObject;
public final class k {
private static AtomicBoolean f15870a = new AtomicBoolean(false);
private a f15871b = null;
public static class a extends AsyncTask<Void, Void, Void> {
private a() {
}
private static Void a() {
Object obj;
List<String> d10 = k.d();
if (d10.size() == 0) {
return null;
}
com.qiyukf.nimlib.j.b.b.a.c("NetPing", "***** Net ping start, host list size=" + d10.size() + " *****");
JSONObject jSONObject = new JSONObject();
JSONArray jSONArray = new JSONArray();
for (String str : d10) {
com.qiyukf.nimlib.j.b.b.a.c("NetPing", "ping host ".concat(String.valueOf(str)));
JSONObject f10 = k.f(k.d(str));
if (f10 != null) {
try {
f10.put("ip", str);
jSONArray.put(f10);
} catch (Exception e10) {
e10.printStackTrace();
}
}
com.qiyukf.nimlib.j.b.b.a.c("NetPing", "ping host result=".concat(String.valueOf(f10)));
}
try {
jSONObject.put("net_type", k.e());
Object obj2 = "true";
if (l.b(com.qiyukf.nimlib.c.d())) {
obj = "true";
} else {
obj = "false";
}
jSONObject.put("net_available", obj);
if (!l.c(com.qiyukf.nimlib.c.d())) {
obj2 = "false";
}
jSONObject.put("net_connected", obj2);
jSONObject.put(com.alipay.sdk.util.l.f2088c, jSONArray);
com.qiyukf.nimlib.j.b.b.a.c("NetPing", "***** Net ping end, total result=" + jSONObject.toString() + " ***** ");
} catch (Exception e11) {
e11.printStackTrace();
com.qiyukf.nimlib.j.b.b.a.d("NetPing", "NetPing get network status error", e11);
}
k.f15870a.set(false);
return null;
}
@Override
public final Void doInBackground(Void[] voidArr) {
return a();
}
@Override
public final void onPostExecute(Void r12) {
super.onPostExecute(r12);
}
@Override
public final void onPreExecute() {
super.onPreExecute();
}
public a(byte b10) {
this();
}
}
private k() {
}
public static void c() {
try {
StringBuilder sb = new StringBuilder("network info: ");
sb.append("net_type=" + g() + ", net_available=" + l.b(com.qiyukf.nimlib.c.d()) + ", net_connected=" + l.c(com.qiyukf.nimlib.c.d()));
com.qiyukf.nimlib.j.b.b.a.c("NetPing", sb.toString());
} catch (Exception e10) {
e10.printStackTrace();
}
}
public static String d(String str) {
StringBuilder sb = new StringBuilder();
try {
Process exec = Runtime.getRuntime().exec("ping -c 3 -w 15 ".concat(String.valueOf(str)));
if (exec.waitFor() == 0) {
sb.append("ping " + str + " success\n");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(exec.getInputStream()));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
sb.append(readLine + "\n");
}
} else {
com.qiyukf.nimlib.j.b.b.a.c("NetPing", "unable to ping host, try socket connect...");
boolean e10 = e(str);
StringBuilder sb2 = new StringBuilder("connect ");
sb2.append(e10 ? "success" : com.alipay.sdk.util.e.f2061a);
sb2.append("\n");
sb.append(sb2.toString());
}
} catch (IOException e11) {
e11.printStackTrace();
} catch (InterruptedException e12) {
e12.printStackTrace();
}
return sb.toString();
}
public static String e() {
return g();
}
private static String g() {
int j10 = l.j(com.qiyukf.nimlib.c.d());
return j10 == 1 ? NetworkUtil.NETWORK_CLASS_2G : j10 == 2 ? NetworkUtil.NETWORK_CLASS_3G : j10 == 3 ? NetworkUtil.NETWORK_CLASS_4G : j10 == 10 ? NetworkUtil.NETWORK_TYPE_WIFI : "unknown";
}
public static k a() {
return new k();
}
private static boolean e(String str) {
boolean z10;
Socket socket = new Socket();
try {
try {
socket.connect(new InetSocketAddress(str, 80), 15000);
z10 = socket.isConnected();
try {
socket.close();
} catch (IOException e10) {
e10.printStackTrace();
}
} catch (IOException e11) {
e11.printStackTrace();
try {
socket.close();
} catch (IOException e12) {
e12.printStackTrace();
}
z10 = false;
}
StringBuilder sb = new StringBuilder("socket connect ");
sb.append(str);
sb.append(z10 ? " success" : " failed!!!");
com.qiyukf.nimlib.j.b.b.a.c("NetPing", sb.toString());
return z10;
} catch (Throwable th) {
try {
socket.close();
} catch (IOException e13) {
e13.printStackTrace();
}
throw th;
}
}
public static JSONObject f(String str) {
int indexOf;
int indexOf2;
JSONObject jSONObject = new JSONObject();
try {
if (str.contains("0% packet loss")) {
int indexOf3 = str.indexOf("/mdev = ");
if (indexOf3 == -1 || (indexOf2 = str.indexOf(" ms\n", indexOf3)) == -1) {
return null;
}
String[] split = str.substring(indexOf3 + 8, indexOf2).split(InternalZipConstants.ZIP_FILE_SEPARATOR);
if (split.length != 4) {
return null;
}
jSONObject.put("min", Double.valueOf(split[0]));
jSONObject.put("avg", Double.valueOf(split[1]));
jSONObject.put("max", Double.valueOf(split[2]));
jSONObject.put("mdev", Double.valueOf(split[3]));
jSONObject.put("loss", 0);
} else if (str.contains("100% packet loss")) {
jSONObject.put("loss", 100);
} else {
if (str.contains("% packet loss")) {
int indexOf4 = str.indexOf("/mdev = ");
if (indexOf4 == -1 || (indexOf = str.indexOf(" ms\n", indexOf4)) == -1) {
return null;
}
String substring = str.substring(indexOf4 + 8, indexOf);
String[] split2 = substring.split(InternalZipConstants.ZIP_FILE_SEPARATOR);
if (split2.length != 4) {
return null;
}
int indexOf5 = substring.indexOf("% packet loss");
int indexOf6 = substring.indexOf("received");
if (indexOf5 != -1 && indexOf6 != -1) {
String trim = substring.substring(indexOf6 + 10, indexOf5).trim();
jSONObject.put("min", Double.valueOf(split2[0]));
jSONObject.put("avg", Double.valueOf(split2[1]));
jSONObject.put("max", Double.valueOf(split2[2]));
jSONObject.put("mdev", Double.valueOf(split2[3]));
jSONObject.put("loss", Integer.valueOf(trim));
}
return null;
}
if (str.contains("connect") && str.contains("success")) {
jSONObject.put(com.alipay.sdk.util.l.f2088c, "connect success");
} else if (str.contains(com.alipay.sdk.util.e.f2061a)) {
jSONObject.put(com.alipay.sdk.util.l.f2088c, com.alipay.sdk.util.e.f2061a);
}
}
} catch (Exception e10) {
e10.printStackTrace();
com.qiyukf.nimlib.j.b.b.a.d("NetPing", "getPingStatus error", e10);
}
return jSONObject;
}
public final void b() {
if (!l.b(com.qiyukf.nimlib.c.d())) {
com.qiyukf.nimlib.j.b.b.a.c("NetPing", "unable to start ping, as network is unavailable");
return;
}
if (f15870a.get()) {
com.qiyukf.nimlib.j.b.b.a.c("NetPing", "cancel start ping, as net ping is running...");
} else {
if (this.f15871b != null) {
return;
}
a aVar = new a((byte) 0);
this.f15871b = aVar;
aVar.execute(new Void[0]);
f15870a.set(true);
}
}
private static String c(String str) {
int lastIndexOf = str.lastIndexOf(58);
return lastIndexOf > 0 ? str.substring(0, lastIndexOf) : str;
}
public static List d() {
ArrayList arrayList = new ArrayList();
com.qiyukf.nimlib.net.a.b.a.a.a();
for (String str : com.qiyukf.nimlib.net.a.b.a.a.b()) {
String c10 = c(str);
if (!arrayList.contains(c10)) {
arrayList.add(c10);
}
}
ServerAddresses i10 = com.qiyukf.nimlib.c.i();
if (i10 == null) {
arrayList.add(c(com.qiyukf.nimlib.e.g.f()));
arrayList.add(c(com.qiyukf.nimlib.e.g.h()));
arrayList.add(c("www.163.com"));
} else {
if (!TextUtils.isEmpty(i10.nosUpload)) {
arrayList.add(c(i10.nosUpload));
}
if (!TextUtils.isEmpty(i10.nosDownload)) {
arrayList.add(c(i10.nosDownload));
}
}
return arrayList;
}
}