CarrotChat v2.8.60.240131版本的 MD5 值为:2baf8b9f31830b86b5c5a85ae6b47e05
以下内容为反编译后的 e.java 源代码,内容仅作参考
package com.mobile.auth.gatewayauth.detectnet;
import android.content.Context;
import android.net.Network;
import android.os.Build;
import android.text.TextUtils;
import com.mobile.auth.d.e;
import com.mobile.auth.gatewayauth.ExceptionProcessor;
import com.mobile.auth.gatewayauth.utils.i;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
public class e {
private static volatile e a;
private String g;
private String h;
private AtomicBoolean f13068c = new AtomicBoolean(false);
private int f13070e = 3;
private int f = 2;
private ExecutorService f13067b = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS, new ArrayBlockingQueue(3), new ThreadPoolExecutor.CallerRunsPolicy());
private ConcurrentHashMap<String, String> f13069d = new ConcurrentHashMap<>();
public e() {
this.h = "eco.taobao.com";
try {
this.h = new URL("https://dypnsapi.aliyuncs.com/?").getHost();
} catch (MalformedURLException unused) {
}
}
static DetectResult a(e eVar, String str, DetectResult detectResult) {
try {
return eVar.b(str, detectResult);
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
return null;
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
return null;
}
}
}
private DetectResult a(String str, DetectResult detectResult) {
try {
i.a("pingNet: ping检测top默认");
c a2 = a(str, this.h);
detectResult.setTopConnected(a2.a());
if (a2.a()) {
detectResult.setTopWholeMS(a2.b());
} else {
detectResult.setTopWholeMS(0L);
}
return detectResult;
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
return null;
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
return null;
}
}
}
public static e a() {
try {
if (a == null) {
synchronized (e.class) {
if (a == null) {
a = new e();
}
}
}
return a;
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
return null;
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
return null;
}
}
}
static AtomicBoolean a(e eVar) {
try {
return eVar.f13068c;
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
return null;
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
return null;
}
}
}
private void a(Context context, final String str, final a aVar) {
DetectResult cuCellularConnected;
try {
i.a("pingNet:检测 默认网络和蜂窝网络");
final DetectResult detectResult = new DetectResult();
detectResult.setRequestIds(this.f13069d.keySet()).setSessionIds(this.f13069d.values());
a(str, detectResult);
com.mobile.auth.d.e eVar = new com.mobile.auth.d.e();
if (Build.VERSION.SDK_INT >= 21) {
eVar.a(context, new e.a() {
@Override
public void a() {
try {
i.a("pingNet:切换蜂窝网络超时!");
detectResult.setTopCellularConnected(false).setTopCellularWholeMS(0L).setCuCellularConnected(false).setCuCellularWholeMS(0L);
e.a(e.this).set(false);
a aVar2 = aVar;
if (aVar2 != null) {
aVar2.a(detectResult);
}
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
}
}
}
@Override
public void a(int i, String str2, long j) {
try {
i.a("pingNet:切换蜂窝网络失败!");
detectResult.setTopCellularConnected(false).setTopCellularWholeMS(0L).setCuCellularConnected(false).setCuCellularWholeMS(0L);
e.a(e.this).set(false);
a aVar2 = aVar;
if (aVar2 != null) {
aVar2.a(detectResult);
}
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
}
}
}
@Override
public void a(Network network, long j) {
try {
i.a("pingNet:切换蜂窝网络成功!");
e.a(e.this, str, detectResult);
e.b(e.this, str, detectResult);
e.a(e.this).set(false);
a aVar2 = aVar;
if (aVar2 != null) {
aVar2.a(detectResult);
}
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
}
}
}
});
return;
}
boolean a2 = eVar.a(context, this.h);
i.a("pingNet:系统5.0以下切换蜂窝网络是否成功:" + a2);
if (a2) {
b(str, detectResult);
c(str, detectResult);
} else {
detectResult.setTopCellularConnected(false).setTopCellularWholeMS(0L);
}
if (TextUtils.isEmpty(this.g)) {
cuCellularConnected = detectResult.setCuCellularConnected(false);
} else if (eVar.a(context, this.g)) {
c(str, detectResult);
this.f13068c.set(false);
if (aVar == null) {
aVar.a(detectResult);
return;
}
return;
} else {
cuCellularConnected = detectResult.setCuCellularConnected(false);
}
cuCellularConnected.setCuCellularWholeMS(0L);
this.f13068c.set(false);
if (aVar == null) {
}
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
}
}
}
static void a(e eVar, Context context, String str, a aVar) {
try {
eVar.a(context, str, aVar);
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
}
}
}
static DetectResult b(e eVar, String str, DetectResult detectResult) {
try {
return eVar.c(str, detectResult);
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
return null;
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
return null;
}
}
}
private DetectResult b(String str, DetectResult detectResult) {
try {
i.a("pingNet: ping检测top蜂窝");
c a2 = a(str, this.h);
detectResult.setTopCellularConnected(a2.a());
if (a2.a()) {
detectResult.setTopCellularWholeMS(a2.b());
} else {
detectResult.setTopCellularWholeMS(0L);
}
return detectResult;
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
return null;
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
return null;
}
}
}
static ConcurrentHashMap b(e eVar) {
try {
return eVar.f13069d;
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
return null;
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
return null;
}
}
}
static DetectResult c(e eVar, String str, DetectResult detectResult) {
try {
return eVar.a(str, detectResult);
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
return null;
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
return null;
}
}
}
private DetectResult c(String str, DetectResult detectResult) {
try {
i.a("pingNet: ping检测蜂窝");
if (TextUtils.isEmpty(this.g)) {
detectResult.setCuCellularConnected(false).setCuCellularWholeMS(0L);
} else {
c a2 = a(str, this.g);
detectResult.setCuCellularConnected(a2.a());
if (a2.a()) {
detectResult.setCuCellularWholeMS(a2.b());
} else {
detectResult.setCuCellularWholeMS(0L);
}
}
return detectResult;
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
return null;
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
return null;
}
}
}
public c a(String str, String str2) {
try {
i.a("pingNet:" + str + " ping start");
c cVar = new c();
int i = 0;
while (i < this.f) {
cVar = d.a(str2, this.f13070e);
i.a("pingNet:第" + i + "次 result:" + cVar.toString());
i++;
if (cVar.a()) {
break;
}
}
i.a("pingNet:" + str + " ping stop");
i.a("pingNet:" + str + " 总共 ping了:" + i + "次");
return cVar;
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
return null;
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
return null;
}
}
}
public e a(String str) {
try {
this.g = str;
return this;
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
return null;
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
return null;
}
}
}
public void a(final Context context, final String str, final String str2, final a aVar) {
try {
i.a("pingNet:" + str + " startDetect");
this.f13067b.execute(new Runnable() {
@Override
public void run() {
DetectResult detectResult;
a aVar2;
try {
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
return;
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
return;
}
}
if (e.a(e.this).compareAndSet(false, true)) {
e.b(e.this).clear();
e.b(e.this).put(str, str2);
if (com.mobile.auth.gatewayauth.utils.c.i(context)) {
i.a("pingNet:纯蜂窝网络连接");
DetectResult detectResult2 = new DetectResult();
detectResult2.setRequestIds(e.b(e.this).keySet()).setSessionIds(e.b(e.this).values());
detectResult = e.b(e.this, str, e.a(e.this, str, detectResult2));
detectResult.setTopConnected(false).setTopWholeMS(0L);
e.a(e.this).set(false);
aVar2 = aVar;
} else if (com.mobile.auth.gatewayauth.utils.c.e(context)) {
i.a("pingNet:wifi+蜂窝网络");
e.a(e.this, context, str, aVar);
} else {
i.a("pingNet:纯wifi");
detectResult = new DetectResult();
detectResult.setRequestIds(e.b(e.this).keySet()).setSessionIds(e.b(e.this).values());
e.c(e.this, str, detectResult);
detectResult.setTopCellularConnected(false).setTopCellularWholeMS(0L).setCuCellularConnected(false).setCuCellularWholeMS(0L);
e.a(e.this).set(false);
aVar2 = aVar;
if (aVar2 != null) {
aVar2.a(detectResult);
}
}
ExceptionProcessor.processException(th);
return;
}
i.a("pingNet:" + str + " 已经有检测在实施:" + e.b(e.this).toString());
e.b(e.this).put(str, str2);
}
});
} catch (Throwable th) {
try {
ExceptionProcessor.processException(th);
} catch (Throwable th2) {
ExceptionProcessor.processException(th2);
}
}
}
}