正在查看: 微商客 v2.1.2 应用的 l.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 微商客 v2.1.2 应用的 l.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.qiyukf.nimlib.r;
import android.os.AsyncTask;
import android.text.TextUtils;
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 l {
private static AtomicBoolean a = new AtomicBoolean(false);
private a b = null;
private l() {
}
public static l a() {
return new l();
}
public final void b() {
if (!m.b(com.qiyukf.nimlib.c.d())) {
com.qiyukf.nimlib.log.b.c("NetPing", "unable to start ping, as network is unavailable");
return;
}
if (a.get()) {
com.qiyukf.nimlib.log.b.c("NetPing", "cancel start ping, as net ping is running...");
} else {
if (this.b != null) {
return;
}
a aVar = new a((byte) 0);
this.b = aVar;
aVar.execute(new Void[0]);
a.set(true);
}
}
public static void c() {
try {
StringBuilder sb = new StringBuilder("net_type=");
sb.append(g()).append(", net_available=").append(m.b(com.qiyukf.nimlib.c.d())).append(", net_connected=").append(m.c(com.qiyukf.nimlib.c.d()));
com.qiyukf.nimlib.log.b.c("NetPing", "network info: " + sb.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
private static class a extends AsyncTask<Void, Void, Void> {
private a() {
}
a(byte b) {
this();
}
@Override
protected final Void doInBackground(Void[] voidArr) {
return a();
}
@Override
protected final void onPostExecute(Void r1) {
super.onPostExecute(r1);
}
private static Void a() {
List<String> d = l.d();
if (d.size() == 0) {
return null;
}
com.qiyukf.nimlib.log.b.c("NetPing", "***** Net ping start, host list size=" + d.size() + " *****");
JSONObject jSONObject = new JSONObject();
JSONArray jSONArray = new JSONArray();
for (String str : d) {
com.qiyukf.nimlib.log.b.c("NetPing", "ping host ".concat(String.valueOf(str)));
JSONObject f = l.f(l.d(str));
if (f != null) {
try {
f.put("ip", str);
jSONArray.put(f);
} catch (Exception e) {
e.printStackTrace();
}
}
com.qiyukf.nimlib.log.b.c("NetPing", "ping host result=".concat(String.valueOf(f)));
}
try {
jSONObject.put("net_type", l.g());
Object obj = "true";
jSONObject.put("net_available", m.b(com.qiyukf.nimlib.c.d()) ? "true" : "false");
if (!m.c(com.qiyukf.nimlib.c.d())) {
obj = "false";
}
jSONObject.put("net_connected", obj);
jSONObject.put("result", jSONArray);
com.qiyukf.nimlib.log.b.c("NetPing", "***** Net ping end, total result=" + jSONObject.toString() + " ***** ");
} catch (Exception e2) {
e2.printStackTrace();
com.qiyukf.nimlib.log.b.d("NetPing", "NetPing get network status error", e2);
}
l.a.set(false);
return null;
}
@Override
protected final void onPreExecute() {
super.onPreExecute();
}
}
private static String c(String str) {
int lastIndexOf = str.lastIndexOf(58);
return lastIndexOf > 0 ? str.substring(0, lastIndexOf) : str;
}
public static String d(String str) {
StringBuilder sb = new StringBuilder();
try {
Process start = new ProcessBuilder("/system/bin/ping", "-c", "3", "-w", "15", str).start();
if (start.waitFor() != 0) {
com.qiyukf.nimlib.log.b.c("NetPing", "unable to ping host, try socket connect...");
sb.append("connect " + (e(str) ? "success" : "failed") + "\n");
} else {
sb.append("ping " + str + " success\n");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(start.getInputStream()));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
sb.append(readLine + "\n");
}
}
} catch (Throwable th) {
com.qiyukf.nimlib.log.b.d("NetPing", "ping host error", th);
}
return sb.toString();
}
private static boolean e(String str) {
boolean z;
Socket socket = new Socket();
try {
try {
socket.connect(new InetSocketAddress(str, 80), 15000);
z = socket.isConnected();
} catch (IOException e) {
e.printStackTrace();
try {
socket.close();
} catch (IOException e2) {
e2.printStackTrace();
}
z = false;
}
com.qiyukf.nimlib.log.b.c("NetPing", "socket connect " + str + (z ? " success" : " failed!!!"));
return z;
} finally {
try {
socket.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
}
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("result", "connect success");
} else if (str.contains("failed")) {
jSONObject.put("result", "failed");
}
}
} catch (Exception e) {
e.printStackTrace();
com.qiyukf.nimlib.log.b.d("NetPing", "getPingStatus error", e);
}
return jSONObject;
}
public static String g() {
int j = m.j(com.qiyukf.nimlib.c.d());
if (j == 1) {
return "2g";
}
if (j == 2) {
return "3g";
}
if (j == 3) {
return "4g";
}
if (j == 10) {
return "wifi";
}
return "unknown";
}
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 c = c(str);
if (!arrayList.contains(c)) {
arrayList.add(c);
}
}
ServerAddresses k = com.qiyukf.nimlib.c.k();
if (k == null) {
arrayList.add(c(com.qiyukf.nimlib.f.g.j()));
arrayList.add(c(com.qiyukf.nimlib.f.g.l()));
arrayList.add(c("www.163.com"));
} else {
if (!TextUtils.isEmpty(k.nosUpload)) {
arrayList.add(c(k.nosUpload));
}
if (!TextUtils.isEmpty(k.nosDownload)) {
arrayList.add(c(k.nosDownload));
}
}
return arrayList;
}
}