Kufar v3.2.0版本的 MD5 值为:6a4d203db1c561c7e3bcd50d23fed59f
以下内容为反编译后的 NetworkTester.java 源代码,内容仅作参考
package com.startapp.networkTest.startapp;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Looper;
import androidx.annotation.Nullable;
import androidx.work.PeriodicWorkRequest;
import com.startapp.a3;
import com.startapp.a5;
import com.startapp.d2;
import com.startapp.h9;
import com.startapp.networkTest.results.ConnectivityTestResult;
import com.startapp.networkTest.results.LatencyResult;
import com.startapp.networkTest.startapp.CoverageMapperManager;
import com.startapp.r5;
import com.startapp.x2;
import com.startapp.x7;
public final class NetworkTester {
private static final String CTLT_CHECK_INTERVAL_KEY = "StartappCtLtCheckIntervalKey";
private static final String CTLT_GUARD_DIFF_KEY = "StartappGuardDiffKey";
private static final String CTLT_PREV_TIME_CHECK_KEY = "StartappCtLtPrevTimeCheckKey";
public static final String LOG_TAG = "NetworkTester";
private static final String P3WRAPPER_PREFS = "StartappP3WrapperPrefs";
@Nullable
@SuppressLint({"StaticFieldLeak"})
public static NetworkTester sInstance;
public Thread mActiveThread;
public ConnectivityTestListener mConnectivityTestListener;
private Context mContext;
@Nullable
public CoverageMapperManager mCoverageMapper;
public a3 mForegroundTestManager;
public static final class Config {
public String PROJECT_ID = "20050";
public String CONNECTIVITY_TEST_HOSTNAME = "d2to8y50b3n6dq.cloudfront.net";
public String CONNECTIVITY_TEST_FILENAME = "/favicon.ico";
public boolean CONNECTIVITY_TEST_ENABLED = true;
public boolean NIR_COLLECT_CELLINFO = true;
public boolean CT_COLLECT_CELLINFO = true;
public int NIR_COLLECT_CELLINFO_THRESHOLD = 2;
public String CONNECTIVITY_TEST_CDNCONFIG_URL = "https://d2to8y50b3n6dq.cloudfront.net/truststores/[PROJECTID]/cdnconfig.zip";
public String GEOIP_URL = "https://geoip.api.c0nnectthed0ts.com/geoip/";
public long FOREGROUND_TEST_CT_SCHEDULE_INTERVAL = PeriodicWorkRequest.MIN_PERIODIC_FLEX_MILLIS;
public long FOREGROUND_TEST_CT_MIN_INTERVAL = 180000;
public boolean FOREGROUND_TEST_CT_ENABLED = true;
public boolean FOREGROUND_TEST_NIR_ENABLED = true;
}
public class a implements Runnable {
public final Context f53916a;
public final b f53917b;
public class C0759a implements x7 {
public final boolean[] f53918a;
public final Looper f53919b;
public final d2 f53920c;
public class RunnableC0760a implements Runnable {
public RunnableC0760a() {
}
@Override
public void run() {
a.this.f53917b.a(false);
}
}
public C0759a(boolean[] zArr, Looper looper, d2 d2Var) {
this.f53918a = zArr;
this.f53919b = looper;
this.f53920c = d2Var;
}
@Override
public void a() {
this.f53920c.b();
Looper looper = this.f53919b;
if (looper != null) {
NetworkTester.sInstance.mActiveThread = null;
looper.quit();
}
ConnectivityTestListener connectivityTestListener = NetworkTester.sInstance.mConnectivityTestListener;
if (connectivityTestListener != null) {
connectivityTestListener.onConnectivityTestFinished(new h9(new RunnableC0760a()));
} else {
a.this.f53917b.a(false);
}
}
@Override
public void onConnectivityTestResult(ConnectivityTestResult connectivityTestResult) {
boolean[] zArr = this.f53918a;
if (zArr[0]) {
Looper looper = this.f53919b;
if (looper != null) {
NetworkTester.sInstance.mActiveThread = null;
looper.quit();
a.this.f53917b.a(false);
return;
}
return;
}
zArr[0] = true;
ConnectivityTestListener connectivityTestListener = NetworkTester.sInstance.mConnectivityTestListener;
if (connectivityTestListener != null) {
connectivityTestListener.onConnectivityTestResult(connectivityTestResult);
}
}
@Override
public void onLatencyTestResult(LatencyResult latencyResult) {
boolean[] zArr = this.f53918a;
if (zArr[1]) {
Looper looper = this.f53919b;
if (looper != null) {
NetworkTester.sInstance.mActiveThread = null;
looper.quit();
a.this.f53917b.a(false);
return;
}
return;
}
zArr[1] = true;
ConnectivityTestListener connectivityTestListener = NetworkTester.sInstance.mConnectivityTestListener;
if (connectivityTestListener != null) {
connectivityTestListener.onLatencyTestResult(latencyResult);
}
}
}
public a(Context context, b bVar) {
this.f53916a = context;
this.f53917b = bVar;
}
@Override
public void run() {
Looper.prepare();
Looper myLooper = Looper.myLooper();
d2 d2Var = new d2(this.f53916a.getApplicationContext());
d2Var.a();
d2Var.a(new C0759a(new boolean[2], myLooper, d2Var));
Looper.loop();
}
}
public interface b {
void a(boolean z11);
}
private NetworkTester() {
}
public static void init(Context context, Config config) {
if (context != null) {
if (config != null) {
String a11 = r5.a(config);
if (a11 != null) {
if (sInstance != null) {
return;
}
NetworkTester networkTester = new NetworkTester();
sInstance = networkTester;
networkTester.mContext = context;
a5.a(context, a11.getBytes());
sInstance.mCoverageMapper = new CoverageMapperManager(context);
sInstance.mForegroundTestManager = new a3(context, sInstance.mCoverageMapper);
return;
}
throw new IllegalArgumentException("Wrong format of config");
}
throw new IllegalArgumentException("config is null");
}
throw new IllegalArgumentException("context is null");
}
public static int isAppInForeground() {
a3 a3Var;
NetworkTester networkTester = sInstance;
if (networkTester != null && (a3Var = networkTester.mForegroundTestManager) != null) {
return a3Var.d();
}
return -1;
}
public static boolean isPermissionGranted(Context context, String str) {
int checkSelfPermission;
try {
if (Build.VERSION.SDK_INT >= 23) {
checkSelfPermission = context.checkSelfPermission(str);
if (checkSelfPermission != 0) {
return false;
}
return true;
}
if (context.checkCallingOrSelfPermission(str) != 0) {
return false;
}
return true;
} catch (Throwable th2) {
x2.a(th2);
return false;
}
}
public static void runTests(Context context, b bVar) {
CoverageMapperManager coverageMapperManager;
CoverageMapperManager coverageMapperManager2;
if (sInstance == null) {
bVar.a(false);
return;
}
if (!isPermissionGranted(context, "android.permission.ACCESS_FINE_LOCATION") && !isPermissionGranted(context, "android.permission.ACCESS_COARSE_LOCATION")) {
NetworkTester networkTester = sInstance;
if (networkTester != null && (coverageMapperManager2 = networkTester.mCoverageMapper) != null) {
coverageMapperManager2.e();
}
bVar.a(false);
return;
}
SharedPreferences sharedPreferences = context.getSharedPreferences(P3WRAPPER_PREFS, 0);
long j11 = sharedPreferences.getLong(CTLT_GUARD_DIFF_KEY, 120000L);
if (System.currentTimeMillis() - sharedPreferences.getLong(CTLT_PREV_TIME_CHECK_KEY, 0L) < sharedPreferences.getLong(CTLT_CHECK_INTERVAL_KEY, j11) - j11) {
bVar.a(false);
return;
}
if (!a5.h()) {
bVar.a(false);
return;
}
if (sInstance.mActiveThread != null) {
bVar.a(false);
return;
}
sharedPreferences.edit().putLong(CTLT_PREV_TIME_CHECK_KEY, System.currentTimeMillis()).commit();
NetworkTester networkTester2 = sInstance;
if (networkTester2 != null && (coverageMapperManager = networkTester2.mCoverageMapper) != null) {
coverageMapperManager.b();
}
if (networkTester2 != null) {
networkTester2.mActiveThread = new Thread(new h9(new a(context, bVar)));
}
sInstance.mActiveThread.start();
}
public static void setOnConnectivityLatencyListener(ConnectivityTestListener connectivityTestListener) {
NetworkTester networkTester = sInstance;
if (networkTester != null) {
networkTester.mConnectivityTestListener = connectivityTestListener;
}
}
public static void setOnNetworkInfoListener(CoverageMapperManager.OnNetworkInfoResultListener onNetworkInfoResultListener) {
CoverageMapperManager coverageMapperManager;
NetworkTester networkTester = sInstance;
if (networkTester != null && (coverageMapperManager = networkTester.mCoverageMapper) != null) {
coverageMapperManager.a(onNetworkInfoResultListener);
}
}
public static void startListening(long j11, long j12) {
NetworkTester networkTester = sInstance;
if (networkTester == null) {
return;
}
SharedPreferences sharedPreferences = networkTester.mContext.getSharedPreferences(P3WRAPPER_PREFS, 0);
sharedPreferences.edit().putLong(CTLT_CHECK_INTERVAL_KEY, j11).commit();
sharedPreferences.edit().putLong(CTLT_GUARD_DIFF_KEY, j12).commit();
CoverageMapperManager coverageMapperManager = networkTester.mCoverageMapper;
if (coverageMapperManager != null) {
coverageMapperManager.b();
}
a3 a3Var = networkTester.mForegroundTestManager;
if (a3Var != null) {
a3Var.e();
}
}
public static void stopListening() {
a3 a3Var;
CoverageMapperManager coverageMapperManager;
NetworkTester networkTester = sInstance;
if (networkTester != null && (coverageMapperManager = networkTester.mCoverageMapper) != null) {
coverageMapperManager.e();
}
if (networkTester != null && (a3Var = networkTester.mForegroundTestManager) != null) {
a3Var.h();
}
}
}