4399游戏盒 v7.2.1.31版本的 MD5 值为:951717f45e3fda95c8a358caf4ca93e1
以下内容为反编译后的 GrayscaleTest.java 源代码,内容仅作参考
package com.download.test;
import android.content.pm.PackageInfo;
import com.download.DownloadConfigKey;
import com.download.DownloadImplType;
import com.download.DownloadManager;
import com.download.DownloadModel;
import com.download.constance.K;
import com.download.log.NetLogHandler;
import com.download.okhttp.OkHttpHelper;
import com.framework.config.Config;
import com.framework.utils.AH;
import com.framework.utils.AppUtils;
import com.m4399.gamecenter.plugin.main.b.a;
import com.m4399.gamecenter.plugin.main.fastplay.helper.FastPlayAuthHelper;
import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.MapsKt;
import kotlin.coroutines.Continuation;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.Dispatchers;
import kotlinx.coroutines.GlobalScope;
import kotlinx.coroutines.h;
import kotlinx.coroutines.j;
import okhttp3.Request;
import okhttp3.ResponseBody;
import org.json.JSONObject;
import timber.log.Timber;
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000H\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u000e\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0010\b\n\u0002\b\u0007\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\bÆ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u000e\u0010\u0014\u001a\u00020\n2\u0006\u0010\u0015\u001a\u00020\u0005J\u0006\u0010\u0016\u001a\u00020\u0017J\u000e\u0010\u0018\u001a\u00020\n2\u0006\u0010\u0019\u001a\u00020\u001aJ\u000e\u0010\u001b\u001a\u00020\u001c2\u0006\u0010\u001d\u001a\u00020\u001eJ\u0013\u0010\u001f\u001a\u0004\u0018\u00010\u0017H\u0086@ø\u0001\u0000¢\u0006\u0002\u0010 J\u0013\u0010!\u001a\u0004\u0018\u00010\u0017H\u0086@ø\u0001\u0000¢\u0006\u0002\u0010 R\u001d\u0010\u0003\u001a\u000e\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u00060\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0007\u0010\bR\u001a\u0010\t\u001a\u00020\nX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\t\u0010\u000b\"\u0004\b\f\u0010\rR\u001a\u0010\u000e\u001a\u00020\u000fX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0010\u0010\u0011\"\u0004\b\u0012\u0010\u0013\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006\""}, d2 = {"Lcom/download/test/GrayscaleTest;", "", "()V", "grayscaleTestConfig", "Ljava/util/concurrent/ConcurrentHashMap;", "", "Lcom/download/test/GTConfig;", "getGrayscaleTestConfig", "()Ljava/util/concurrent/ConcurrentHashMap;", "isLoadGrayScaleConfig", "", "()Z", "setLoadGrayScaleConfig", "(Z)V", "versionCode", "", "getVersionCode", "()I", "setVersionCode", "(I)V", "isSupportTest", FastPlayAuthHelper.KEY_PKG, "pullGrayscaleConfig", "", "removePlugin", "config", "Lcom/download/test/PluginConfig;", "selectDownloadType", "Lcom/download/DownloadImplType;", "model", "Lcom/download/DownloadModel;", "syncGetDeletePluginConfig", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "syncGetGrayScaleConfig", "m4399-download_release"}, k = 1, mv = {1, 1, 16})
public final class GrayscaleTest {
private static int versionCode;
public static final GrayscaleTest INSTANCE = new GrayscaleTest();
private static boolean yL = true;
private static final ConcurrentHashMap<String, GTConfig> yM = new ConcurrentHashMap<>();
static {
PackageInfo packageInfo = AppUtils.getPackageInfo();
versionCode = packageInfo != null ? packageInfo.versionCode : 0;
}
private GrayscaleTest() {
}
public final boolean isLoadGrayScaleConfig() {
return yL;
}
public final void setLoadGrayScaleConfig(boolean z) {
yL = z;
}
public final ConcurrentHashMap<String, GTConfig> getGrayscaleTestConfig() {
return yM;
}
public final int getVersionCode() {
return versionCode;
}
public final void setVersionCode(int i) {
versionCode = i;
}
public final DownloadImplType selectDownloadType(DownloadModel model) {
Intrinsics.checkParameterIsNotNull(model, "model");
if (!((Boolean) model.getExtra(K.key.DOWNLOAD_TASK_AR_GRAYSCALE_TEST, true)).booleanValue()) {
NetLogHandler.writeLog("已设置过灰度测试类型, 不再设置灰度参数", new Object[0]);
DownloadImplType downloadImplType = model.getDownloadImplType();
Intrinsics.checkExpressionValueIsNotNull(downloadImplType, "model.downloadImplType");
return downloadImplType;
}
GTConfig gTConfig = yM.get(model.getPackageName());
if (gTConfig != null) {
long currentTimeMillis = System.currentTimeMillis();
NetLogHandler.writeLog("当前时间:{}, 灰度开始时间:{},灰度结束时间:{}", Long.valueOf(currentTimeMillis), Long.valueOf(gTConfig.getBegin()), Long.valueOf(gTConfig.getEnd()));
long begin = gTConfig.getBegin() + 1;
long end = gTConfig.getEnd();
if (begin <= currentTimeMillis && end > currentTimeMillis) {
NetLogHandler.writeLog("符合灰度时间配置条件, 开始请求最大并发数", new Object[0]);
GrayscaleTest grayscaleTest = INSTANCE;
String packageName = model.getPackageName();
Intrinsics.checkExpressionValueIsNotNull(packageName, "model.packageName");
if (grayscaleTest.isSupportTest(packageName)) {
model.setDownloadImplType(DownloadImplType.valueOf(Integer.valueOf(gTConfig.getType())));
}
model.putExtra(K.key.DOWNLOAD_TASK_AR_GRAYSCALE_TEST, false);
}
}
DownloadImplType downloadImplType2 = model.getDownloadImplType();
Intrinsics.checkExpressionValueIsNotNull(downloadImplType2, "model.downloadImplType");
return downloadImplType2;
}
public final void pullGrayscaleConfig() {
if (yL && !(!Intrinsics.areEqual(a.APP_PACKAGE_NAME, AppUtils.getCurProcessName(AH.getApplication())))) {
j.launch$default(GlobalScope.INSTANCE, null, null, new GrayscaleTest$pullGrayscaleConfig$1(null), 3, null);
}
}
public final Object syncGetGrayScaleConfig(Continuation<? super Unit> continuation) {
return h.withContext(Dispatchers.getIO(), new GrayscaleTest$syncGetGrayScaleConfig$2(null), continuation);
}
public final Object syncGetDeletePluginConfig(Continuation<? super Unit> continuation) {
return h.withContext(Dispatchers.getIO(), new GrayscaleTest$syncGetDeletePluginConfig$2(null), continuation);
}
public final boolean removePlugin(PluginConfig config) {
Intrinsics.checkParameterIsNotNull(config, "config");
Integer num = (Integer) Config.getValue(DownloadConfigKey.DOWNLOAD_LOAD_PLUGIN_VERSION);
int version = config.getVersion();
if (num == null || version != num.intValue()) {
return false;
}
String str = (String) Config.getValue(DownloadConfigKey.DOWNLOAD_LOAD_PLUGIN_PATH);
if (str != null) {
Timber.d("delete plugin file " + str + ", result: " + new File(str).delete(), new Object[0]);
Config.setValue(DownloadConfigKey.DOWNLOAD_LOAD_PLUGIN_PATH, "");
Timber.d("set DOWNLOAD_LOAD_PLUGIN_PATH to ''", new Object[0]);
}
Config.setValue(DownloadConfigKey.DOWNLOAD_LOAD_PLUGIN_VERSION, 0);
if (!config.getDeleteTask()) {
return true;
}
DownloadManager dm = DownloadManager.getInstance();
Intrinsics.checkExpressionValueIsNotNull(dm, "dm");
Map<String, DownloadModel> downloads = dm.getDownloads();
Intrinsics.checkExpressionValueIsNotNull(downloads, "dm.downloads");
for (DownloadModel value : MapsKt.toMutableMap(downloads).values()) {
Intrinsics.checkExpressionValueIsNotNull(value, "value");
if (value.getDownloadImplType() == DownloadImplType.TRShare) {
dm.cancelDownload(value);
Timber.d("remove task " + value.getPackageName(), new Object[0]);
}
}
return true;
}
public final boolean isSupportTest(String pkg) {
String string;
Intrinsics.checkParameterIsNotNull(pkg, "pkg");
int i = 3;
while (true) {
int i2 = i - 1;
if (i <= 0) {
return false;
}
try {
ResponseBody body = OkHttpHelper.getInstance().newBuilder().retryOnConnectionFailure(false).readTimeout(2000, TimeUnit.MILLISECONDS).build().newCall(new Request.Builder().get().url("https://sjbc.img4399.com/api/v1/gdc/check?packag=" + pkg + "&version=" + versionCode).build()).execute().body();
if (body != null && (string = body.string()) != null) {
JSONObject jSONObject = new JSONObject(string);
if (100 == jSONObject.getInt("code")) {
boolean optBoolean = jSONObject.optBoolean("result", false);
NetLogHandler.writeLog("是否符合最大并发数:{}", Boolean.valueOf(optBoolean));
return optBoolean;
}
continue;
}
} catch (Exception e) {
NetLogHandler.writeLog("请求灰度配置数据失败,{}", e);
}
i = i2;
}
}
}