jimu-decompiled/sources/com/tencent/wxop/stat/ap.java
2025-05-13 19:24:51 +02:00

139 lines
5.0 KiB
Java

package com.tencent.wxop.stat;
import android.content.Context;
import com.tencent.bugly.BuglyStrategy;
import com.tencent.wxop.stat.common.StatLogger;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
/* loaded from: classes.dex */
class ap implements Runnable {
private Context a;
private Map<String, Integer> b;
private StatSpecifyReportedInfo c;
public ap(Context context, Map<String, Integer> map, StatSpecifyReportedInfo statSpecifyReportedInfo) {
this.a = null;
this.b = null;
this.c = null;
this.a = context;
this.c = statSpecifyReportedInfo;
if (map != null) {
this.b = map;
}
}
/* JADX WARN: Multi-variable type inference failed */
private NetworkMonitor a(String str, int i) {
StatLogger statLogger;
StatLogger statLogger2;
int i2;
StatLogger statLogger3;
StatLogger statLogger4;
NetworkMonitor networkMonitor = new NetworkMonitor();
Socket socket = new Socket();
try {
try {
networkMonitor.setDomain(str);
networkMonitor.setPort(i);
long currentTimeMillis = System.currentTimeMillis();
InetSocketAddress inetSocketAddress = new InetSocketAddress(str, i);
socket.connect(inetSocketAddress, BuglyStrategy.a.MAX_USERDATA_VALUE_LENGTH);
networkMonitor.setMillisecondsConsume(System.currentTimeMillis() - currentTimeMillis);
networkMonitor.setRemoteIp(inetSocketAddress.getAddress().getHostAddress());
socket.close();
try {
socket.close();
} catch (Throwable th) {
statLogger4 = StatServiceImpl.q;
statLogger4.e(th);
}
i2 = 0;
socket = socket;
} catch (IOException e) {
statLogger = StatServiceImpl.q;
statLogger.e((Throwable) e);
i2 = -1;
socket = statLogger2;
}
networkMonitor.setStatusCode(i2);
return networkMonitor;
} finally {
try {
socket.close();
} catch (Throwable th2) {
statLogger3 = StatServiceImpl.q;
statLogger3.e(th2);
}
}
}
private Map<String, Integer> a() {
String str;
StatLogger statLogger;
HashMap hashMap = new HashMap();
String a = StatConfig.a("__MTA_TEST_SPEED__", (String) null);
if (a != null && a.trim().length() != 0) {
for (String str2 : a.split(";")) {
String[] split = str2.split(",");
if (split != null && split.length == 2 && (str = split[0]) != null && str.trim().length() != 0) {
try {
hashMap.put(str, Integer.valueOf(Integer.valueOf(split[1]).intValue()));
} catch (NumberFormatException e) {
statLogger = StatServiceImpl.q;
statLogger.e((Throwable) e);
}
}
}
}
return hashMap;
}
@Override // java.lang.Runnable
public void run() {
StatLogger statLogger;
StatLogger statLogger2;
StatLogger statLogger3;
String str;
try {
if (this.b == null) {
this.b = a();
}
if (this.b != null && this.b.size() != 0) {
JSONArray jSONArray = new JSONArray();
for (Map.Entry<String, Integer> entry : this.b.entrySet()) {
String key = entry.getKey();
if (key != null && key.length() != 0) {
if (entry.getValue() == null) {
statLogger3 = StatServiceImpl.q;
str = "port is null for " + key;
statLogger3.w(str);
} else {
jSONArray.put(a(entry.getKey(), entry.getValue().intValue()).toJSONObject());
}
}
statLogger3 = StatServiceImpl.q;
str = "empty domain name.";
statLogger3.w(str);
}
if (jSONArray.length() == 0) {
return;
}
com.tencent.wxop.stat.event.i iVar = new com.tencent.wxop.stat.event.i(this.a, StatServiceImpl.a(this.a, false, this.c), this.c);
iVar.a(jSONArray.toString());
new aq(iVar).a();
return;
}
statLogger2 = StatServiceImpl.q;
statLogger2.i("empty domain list.");
} catch (Throwable th) {
statLogger = StatServiceImpl.q;
statLogger.e(th);
}
}
}