4399游戏盒 v7.2.1.31版本的 MD5 值为:951717f45e3fda95c8a358caf4ca93e1
以下内容为反编译后的 h.java 源代码,内容仅作参考
package diz;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.os.Build;
import com.framework.EnvironmentMode;
import com.framework.net.HttpHeaderKey;
import com.framework.utils.FilenameUtils;
import com.m4399.gamecenter.plugin.main.fastplay.helper.FastPlayAuthHelper;
import com.m4399.gamecenter.plugin.main.manager.http.RequestHeaderManager;
import com.meizu.cloud.pushsdk.notification.model.AdvanceSetting;
import com.pm.api.AppManagerHelper;
import com.umeng.analytics.pro.am;
import dalvik.system.DexClassLoader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.concurrent.ThreadsKt;
import kotlin.io.ByteStreamsKt;
import kotlin.io.CloseableKt;
import kotlin.io.FilesKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Lambda;
import kotlin.text.Charsets;
import kotlin.text.StringsKt;
import org.json.JSONObject;
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000X\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0006\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0002\b\u0012\n\u0002\u0018\u0002\n\u0002\b\u0007\bÆ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\bC\u0010DJ\u000f\u0010\u0003\u001a\u00020\u0002H\u0002¢\u0006\u0004\b\u0003\u0010\u0004J\u0017\u0010\b\u001a\u00020\u00072\u0006\u0010\u0006\u001a\u00020\u0005H\u0002¢\u0006\u0004\b\b\u0010\tJ\u0017\u0010\n\u001a\u00020\u00022\u0006\u0010\u0006\u001a\u00020\u0005H\u0002¢\u0006\u0004\b\n\u0010\u000bJ\u0017\u0010\u000e\u001a\u00020\r2\u0006\u0010\f\u001a\u00020\u0007H\u0002¢\u0006\u0004\b\u000e\u0010\u000fJ\u0017\u0010\n\u001a\u00020\r2\u0006\u0010\u0011\u001a\u00020\u0010H\u0002¢\u0006\u0004\b\n\u0010\u0012J\u001f\u0010\u0014\u001a\u00020\u00102\u0006\u0010\u0006\u001a\u00020\u00052\u0006\u0010\u0013\u001a\u00020\u0007H\u0002¢\u0006\u0004\b\u0014\u0010\u0015JB\u0010\u0014\u001a\u00020\r2\u0006\u0010\u0016\u001a\u00020\u00102\u0006\u0010\u0018\u001a\u00020\u00172!\u0010\u001c\u001a\u001d\u0012\u0013\u0012\u00110\u0017¢\u0006\f\b\u001a\u0012\b\b\u0016\u0012\u0004\b\b(\u001b\u0012\u0004\u0012\u00020\r0\u0019H\u0002¢\u0006\u0004\b\u0014\u0010\u001dJ\u001f\u0010\u0014\u001a\u00020\u001f2\u0006\u0010\u0006\u001a\u00020\u00052\u0006\u0010\u001e\u001a\u00020\u0010H\u0002¢\u0006\u0004\b\u0014\u0010 J\u0017\u0010!\u001a\u00020\r2\u0006\u0010\u0006\u001a\u00020\u0005H\u0002¢\u0006\u0004\b!\u0010\"J\u0017\u0010\u000e\u001a\u00020\r2\u0006\u0010#\u001a\u00020\u001fH\u0002¢\u0006\u0004\b\u000e\u0010$J\u0017\u0010\u0003\u001a\u00020\u00072\u0006\u0010\u0006\u001a\u00020\u0005H\u0002¢\u0006\u0004\b\u0003\u0010\tJ'\u0010\u0014\u001a\u00020\u00172\u0006\u0010%\u001a\u00020\u001f2\u0006\u0010&\u001a\u00020\u001f2\u0006\u0010'\u001a\u00020\u0017H\u0002¢\u0006\u0004\b\u0014\u0010(J\u0017\u0010\u0014\u001a\u00020\u00022\u0006\u0010\f\u001a\u00020\u0007H\u0002¢\u0006\u0004\b\u0014\u0010)J\u0017\u0010\u0014\u001a\u00020\u00172\u0006\u0010%\u001a\u00020\u001fH\u0002¢\u0006\u0004\b\u0014\u0010*J\u0017\u0010\u0014\u001a\u00020\u00172\u0006\u0010,\u001a\u00020+H\u0002¢\u0006\u0004\b\u0014\u0010-J\u0015\u0010\u000e\u001a\u00020\u001f2\u0006\u0010\u0006\u001a\u00020\u0005¢\u0006\u0004\b\u000e\u0010.J\u0015\u0010/\u001a\u00020\r2\u0006\u0010\u0006\u001a\u00020\u0005¢\u0006\u0004\b/\u0010\"J\u0015\u0010\u0014\u001a\u00020\u00022\u0006\u0010\u0006\u001a\u00020\u0005¢\u0006\u0004\b\u0014\u0010\u000bR\"\u0010\f\u001a\u00020\u00078\u0006@\u0006X\u0086.¢\u0006\u0012\n\u0004\b\n\u00100\u001a\u0004\b\u000e\u00101\"\u0004\b\n\u0010\u000fR\"\u00105\u001a\u00020\u00108\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b2\u00103\u001a\u0004\b\u0014\u00104\"\u0004\b\u0014\u0010\u0012R$\u00107\u001a\u0004\u0018\u00010\u00108\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b6\u00103\u001a\u0004\b\b\u00104\"\u0004\b\u000e\u0010\u0012R\u0016\u00109\u001a\u00020\u00028\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b!\u00108R\u0016\u0010:\u001a\u00020\u00028\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\b\u00108R\u0016\u0010;\u001a\u00020\u00028\u0006@\u0006X\u0086T¢\u0006\u0006\n\u0004\b\u0003\u00108R\u001c\u0010<\u001a\u00020\u00108\u0006@\u0006X\u0086D¢\u0006\f\n\u0004\b\u0014\u00103\u001a\u0004\b!\u00104R\"\u0010=\u001a\u00020\u00078\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b/\u00100\u001a\u0004\b\n\u00101\"\u0004\b/\u0010\u000fR\"\u0010B\u001a\u00020>8\u0006@\u0006X\u0086.¢\u0006\u0012\n\u0004\b\u000e\u0010?\u001a\u0004\b/\u0010@\"\u0004\b\u0014\u0010A¨\u0006E"}, d2 = {"Ldiz/h;", "", "", "g", "()Z", "Landroid/content/Context;", com.umeng.analytics.pro.d.R, "Ldiz/g;", "f", "(Landroid/content/Context;)Ldiz/g;", "c", "(Landroid/content/Context;)Z", "config", "", RequestHeaderManager.MBOX_HEAD_KEY_UDID_CUSTOM_HEADER, "(Ldiz/g;)V", "", "apkPath", "(Ljava/lang/String;)V", "serverConfig", am.av, "(Landroid/content/Context;Ldiz/g;)Ljava/lang/String;", "name", "", "totalTimes", "Lkotlin/Function1;", "Lkotlin/ParameterName;", "times", "block", "(Ljava/lang/String;ILkotlin/jvm/functions/Function1;)V", "version", "Ljava/io/File;", "(Landroid/content/Context;Ljava/lang/String;)Ljava/io/File;", com.huawei.hms.push.e.f1002a, "(Landroid/content/Context;)V", "outputFile", "(Ljava/io/File;)V", "apkFile", "libDir", "expectSoSize", "(Ljava/io/File;Ljava/io/File;I)I", "(Ldiz/g;)Z", "(Ljava/io/File;)I", "Ljava/util/zip/ZipFile;", "apkZipFile", "(Ljava/util/zip/ZipFile;)I", "(Landroid/content/Context;)Ljava/io/File;", "d", "Ldiz/g;", "()Ldiz/g;", am.aG, "Ljava/lang/String;", "()Ljava/lang/String;", "channel", "i", FastPlayAuthHelper.KEY_UDID, "Z", "checkedEnv", "checkedUpgraded", "envOnline", "TAG", "newConfig", "Landroid/content/SharedPreferences;", "Landroid/content/SharedPreferences;", "()Landroid/content/SharedPreferences;", "(Landroid/content/SharedPreferences;)V", "sp", "<init>", "()V", "module-hotfix_release"}, k = 1, mv = {1, 4, 0})
public final class h {
public static SharedPreferences sp = null;
public static QuHeConfig config = null;
private static boolean checkedEnv = false;
private static boolean checkedUpgraded = false;
public static final boolean envOnline = true;
private static String udid;
public static final h j = new h();
private static final String TAG = TAG;
private static final String TAG = TAG;
private static QuHeConfig newConfig = new QuHeConfig();
private static String channel = "unknow";
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u000e\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"", AdvanceSetting.NETWORK_TYPE, "", am.av, "(I)V"}, k = 3, mv = {1, 4, 0})
public static final class a extends Lambda implements Function1<Integer, Unit> {
public final Context f2895a;
public a(Context context) {
super(1);
this.f2895a = context;
}
public final void a(int i) {
h.j.e(this.f2895a);
}
@Override
public Unit invoke(Integer num) {
a(num.intValue());
return Unit.INSTANCE;
}
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u000e\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"", AdvanceSetting.NETWORK_TYPE, "", am.av, "(I)V"}, k = 3, mv = {1, 4, 0})
public static final class b extends Lambda implements Function1<Integer, Unit> {
public final File f2896a;
public final QuHeConfig b;
public b(File file, QuHeConfig quHeConfig) {
super(1);
this.f2896a = file;
this.b = quHeConfig;
}
public final void a(int i) {
n nVar = n.h;
h hVar = h.j;
nVar.a(hVar.e(), "unzip so file from " + this.f2896a + ", times " + i);
File file = this.f2896a;
hVar.a(file, new File(file.getParentFile(), "lib"), this.b.getLibSoSize());
}
@Override
public Unit invoke(Integer num) {
a(num.intValue());
return Unit.INSTANCE;
}
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\b\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0001\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0001\u0010\u0002"}, d2 = {"", am.av, "()V"}, k = 3, mv = {1, 4, 0})
public static final class c extends Lambda implements Function0<Unit> {
public final Context f2897a;
public c(Context context) {
super(0);
this.f2897a = context;
}
public final void a() {
n nVar = n.h;
h hVar = h.j;
nVar.a(hVar.e(), "check upgrade in main process, checkedEnv:" + h.a(hVar));
try {
try {
if (!h.a(hVar)) {
hVar.b(this.f2897a);
}
} catch (Exception e) {
nVar = n.h;
nVar.b(h.j.e(), "invoke getAllGame error ", e);
}
if (hVar.g()) {
hVar.c(this.f2897a);
nVar.a();
return;
}
long j = hVar.d().getLong("checkTime", 0L);
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - j >= 3600000) {
hVar.c(this.f2897a);
hVar.d().edit().putLong("checkTime", currentTimeMillis).commit();
nVar.a();
return;
}
n.b(nVar, hVar.e(), "Ignore check upgrade, currentTimeMillis:" + currentTimeMillis + ", lastCheckTime:" + j, null, 4, null);
nVar.a();
} catch (Throwable th) {
n.h.a();
throw th;
}
}
@Override
public Unit invoke() {
a();
return Unit.INSTANCE;
}
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u000e\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"", AdvanceSetting.NETWORK_TYPE, "", am.av, "(I)V"}, k = 3, mv = {1, 4, 0})
public static final class d extends Lambda implements Function1<Integer, Unit> {
public final QuHeConfig f2898a;
public final File b;
public d(QuHeConfig quHeConfig, File file) {
super(1);
this.f2898a = quHeConfig;
this.b = file;
}
public final void a(int i) {
n.h.a(h.j.e(), "has new version, start download, times " + i);
l.b.a(this.f2898a.getUrl(), this.b, this.f2898a.getMd5());
}
@Override
public Unit invoke(Integer num) {
a(num.intValue());
return Unit.INSTANCE;
}
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u000e\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"", AdvanceSetting.NETWORK_TYPE, "", am.av, "(I)V"}, k = 3, mv = {1, 4, 0})
public static final class e extends Lambda implements Function1<Integer, Unit> {
public final File f2899a;
public final QuHeConfig b;
public final int c;
public e(File file, QuHeConfig quHeConfig, int i) {
super(1);
this.f2899a = file;
this.b = quHeConfig;
this.c = i;
}
public final void a(int i) {
n nVar = n.h;
h hVar = h.j;
nVar.a(hVar.e(), "unzip so file from " + this.f2899a + ", times " + i);
QuHeConfig quHeConfig = this.b;
File file = this.f2899a;
quHeConfig.a(hVar.a(file, new File(file.getParentFile(), "lib"), this.c));
}
@Override
public Unit invoke(Integer num) {
a(num.intValue());
return Unit.INSTANCE;
}
}
private h() {
}
public final boolean g() {
try {
Class<?> cls = Class.forName("SystemProperties");
Intrinsics.checkExpressionValueIsNotNull(cls, "Class.forName(\"SystemProperties\")");
return Intrinsics.areEqual((String) q.a(cls, "get", "log.tag.quheconfig", ""), "quhetest");
} catch (Exception unused) {
return false;
}
}
public final void c(QuHeConfig quHeConfig) {
Intrinsics.checkParameterIsNotNull(quHeConfig, "<set-?>");
config = quHeConfig;
}
public final SharedPreferences d() {
SharedPreferences sharedPreferences = sp;
if (sharedPreferences == null) {
Intrinsics.throwUninitializedPropertyAccessException("sp");
}
return sharedPreferences;
}
public final String e() {
return TAG;
}
public final String f() {
return udid;
}
public static final boolean a(h hVar) {
return checkedEnv;
}
public final void e(Context context) {
n nVar = n.h;
String str = TAG;
nVar.a(str, "start extractFromAsset ");
File a2 = a(context, "1.5.200");
a2.delete();
File file = new File(a2.getAbsolutePath() + FilenameUtils.SEPARATOR_EXTENSION + System.nanoTime() + ".tmp");
FileOutputStream fileOutputStream = new FileOutputStream(file);
try {
InputStream input = context.getAssets().open("com.m4399.quhe.200.apk");
try {
Intrinsics.checkExpressionValueIsNotNull(input, "input");
ByteStreamsKt.copyTo$default(input, fileOutputStream, 0, 2, null);
CloseableKt.closeFinally(input, null);
CloseableKt.closeFinally(fileOutputStream, null);
file.renameTo(a2);
if (StringsKt.equals(j.a(a2), diz.a.h, true)) {
nVar.a(str, "extract finish and md5 is valid : 01682cdba47b691e71ce4a7165121ad0");
nVar.a(str, "start testDex " + a2.getAbsolutePath());
String absolutePath = a2.getAbsolutePath();
Intrinsics.checkExpressionValueIsNotNull(absolutePath, "outputFile.absolutePath");
c(absolutePath);
nVar.a(str, "testDex finish");
a(a2, new File(a2.getParentFile(), "lib"), a(a2));
b(a2);
StringBuilder sb = new StringBuilder();
sb.append("extractFromAsset finish ");
QuHeConfig quHeConfig = config;
if (quHeConfig == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
sb.append(quHeConfig);
nVar.b(str, sb.toString());
return;
}
throw new IllegalStateException("extract from assets fail: md5 error, except:01682cdba47b691e71ce4a7165121ad0 , actual: " + j.a(a2));
} finally {
}
} finally {
}
}
private final QuHeConfig f(Context context) {
if (config == null) {
SharedPreferences sharedPreferences = context.getSharedPreferences("QuHe", 4);
Intrinsics.checkExpressionValueIsNotNull(sharedPreferences, "context.getSharedPrefere…ntext.MODE_MULTI_PROCESS)");
sp = sharedPreferences;
if (sharedPreferences == null) {
Intrinsics.throwUninitializedPropertyAccessException("sp");
}
config = new QuHeConfig(sharedPreferences);
n nVar = n.h;
String str = TAG;
StringBuilder sb = new StringBuilder();
sb.append("QuHeConfig from sp: ");
QuHeConfig quHeConfig = config;
if (quHeConfig == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
sb.append(quHeConfig);
nVar.a(str, sb.toString());
}
QuHeConfig quHeConfig2 = config;
if (quHeConfig2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
return quHeConfig2;
}
public final QuHeConfig c() {
return newConfig;
}
public final void d(QuHeConfig quHeConfig) {
Intrinsics.checkParameterIsNotNull(quHeConfig, "<set-?>");
newConfig = quHeConfig;
}
public final synchronized boolean c(Context context) {
n nVar;
String str;
QuHeConfig g;
int versionCode;
QuHeConfig quHeConfig;
if (checkedUpgraded) {
return false;
}
checkedUpgraded = true;
try {
nVar = n.h;
str = TAG;
StringBuilder sb = new StringBuilder();
sb.append("current config : ");
QuHeConfig quHeConfig2 = config;
if (quHeConfig2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
sb.append(quHeConfig2);
nVar.a(str, sb.toString());
g = g(context);
nVar.a(str, "server version : " + g);
versionCode = g.getVersionCode();
quHeConfig = config;
if (quHeConfig == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
} catch (Throwable th) {
n.h.a(TAG, "checkUpgrade error " + th.getMessage(), th);
}
if (versionCode <= quHeConfig.getVersionCode()) {
return false;
}
g.c(a(context, g));
long currentTimeMillis = System.currentTimeMillis();
nVar.a(str, "valid dex and trigger dex2oat");
c(g.getPath());
nVar.a(str, "dex2oat consume time:" + (System.currentTimeMillis() - currentTimeMillis) + "ms");
boolean killAllProcessInBg = AppManagerHelper.INSTANCE.getINSTANCE().killAllProcessInBg();
nVar.a(str, "kill all process if they were in background : " + killAllProcessInBg);
b(g);
if (killAllProcessInBg) {
SharedPreferences sharedPreferences = sp;
if (sharedPreferences == null) {
Intrinsics.throwUninitializedPropertyAccessException("sp");
}
g.b(sharedPreferences);
nVar.a(str, "save new config " + g);
newConfig = g;
return true;
}
return false;
}
private final QuHeConfig g(Context context) {
String str;
int i;
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(com.m4399.gamecenter.plugin.main.b.a.APP_PACKAGE_NAME, 0);
l lVar = l.b;
lVar.a().put("User-Agent", "4399GameCenter/" + packageInfo.versionName + "(android;Pixel 5a;12;1080x2222;WIFI;" + packageInfo.versionCode + ".200;unknow)");
String str2 = udid;
if (str2 == null || str2.length() == 0) {
SharedPreferences sharedPreferences = sp;
if (sharedPreferences == null) {
Intrinsics.throwUninitializedPropertyAccessException("sp");
}
String string = sharedPreferences.getString(FastPlayAuthHelper.KEY_UDID, "");
udid = string;
if (string == null || string.length() == 0) {
udid = UUID.randomUUID().toString();
SharedPreferences sharedPreferences2 = sp;
if (sharedPreferences2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("sp");
}
sharedPreferences2.edit().putString(FastPlayAuthHelper.KEY_UDID, udid).apply();
}
}
Map<String, String> a2 = lVar.a();
String str3 = udid;
if (str3 == null) {
Intrinsics.throwNpe();
}
a2.put(HttpHeaderKey.MUDID, str3);
SharedPreferences sharedPreferences3 = context.getSharedPreferences("com.m4399.framework", 0);
if (Intrinsics.areEqual(EnvironmentMode.TESTER, sharedPreferences3.getString("pref.key.http.environment", EnvironmentMode.ONLINE))) {
lVar.a().put(HttpHeaderKey.HTTPS_ENV, "com.m4399.gamecenter/test");
str = "https://dlstest.img4399.com/service/android/v1.1/app-plugin.html";
} else {
lVar.a().put(HttpHeaderKey.HTTPS_ENV, "com.m4399.gamecenter/online");
str = "https://mapi.yxhapi.com/service/android/v1.1/app-plugin.html";
}
if (sharedPreferences3.getBoolean("pref.key.http.preview_model", false)) {
lVar.a().put(HttpHeaderKey.DEMOD, "editor");
}
StringBuilder sb = new StringBuilder(str);
sb.append("?");
StringsKt.append(sb, "osVersionCode=", Integer.valueOf(Build.VERSION.SDK_INT));
sb.append("&pluginVersion=");
QuHeConfig quHeConfig = config;
if (quHeConfig == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
if (quHeConfig.getVersionCode() > 0) {
QuHeConfig quHeConfig2 = config;
if (quHeConfig2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
i = quHeConfig2.getVersionCode();
} else {
i = 200;
}
sb.append(i);
sb.append("&pluginPackage=com.m4399.quhe");
sb.append("&versionCode=" + packageInfo.versionCode);
sb.append("&package=com.m4399.gamecenter");
StringsKt.append(sb, "&qudao=", channel);
String sb2 = sb.toString();
Intrinsics.checkExpressionValueIsNotNull(sb2, "StringBuilder(serverHost…nel)\n }.toString()");
return new QuHeConfig(lVar.a(sb2));
}
public final QuHeConfig b() {
QuHeConfig quHeConfig = config;
if (quHeConfig == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
return quHeConfig;
}
public final void d(Context context) {
Intrinsics.checkParameterIsNotNull(context, "context");
if (!a(context)) {
n.h.b(TAG, "current process:" + p.f.a() + ", packageName:" + context.getPackageName() + " ignore upgrade");
return;
}
ThreadsKt.thread((r12 & 1) != 0, (r12 & 2) != 0 ? false : false, (r12 & 4) != 0 ? null : null, (r12 & 8) != 0 ? null : null, (r12 & 16) != 0 ? -1 : 0, new c(context));
}
public final void b(String str) {
udid = str;
}
public final void a(SharedPreferences sharedPreferences) {
Intrinsics.checkParameterIsNotNull(sharedPreferences, "<set-?>");
sp = sharedPreferences;
}
public final synchronized File b(Context context) {
Intrinsics.checkParameterIsNotNull(context, "context");
if (checkedEnv) {
QuHeConfig quHeConfig = config;
if (quHeConfig == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
return new File(quHeConfig.getPath());
}
String packageName = context.getPackageName();
Intrinsics.checkExpressionValueIsNotNull(packageName, "context.packageName");
channel = packageName;
o oVar = new o(new File(context.getFilesDir(), "quhe/1.5.200/.lock"));
try {
oVar.a();
long currentTimeMillis = System.currentTimeMillis();
f(context);
QuHeConfig quHeConfig2 = config;
if (quHeConfig2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
boolean a2 = a(quHeConfig2);
n.h.a(TAG, "config check :" + a2 + ", time:" + (System.currentTimeMillis() - currentTimeMillis) + "ms");
if (!a2) {
QuHeConfig quHeConfig3 = config;
if (quHeConfig3 == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
SharedPreferences sharedPreferences = sp;
if (sharedPreferences == null) {
Intrinsics.throwUninitializedPropertyAccessException("sp");
}
quHeConfig3.b(sharedPreferences);
}
QuHeConfig quHeConfig4 = config;
if (quHeConfig4 == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
if (quHeConfig4.getVersionCode() < 200) {
a("extractFromAsset", 3, new a(context));
}
checkedEnv = true;
QuHeConfig quHeConfig5 = config;
if (quHeConfig5 == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
return new File(quHeConfig5.getPath());
} finally {
oVar.b();
}
}
public final String a() {
return channel;
}
public final void a(String str) {
Intrinsics.checkParameterIsNotNull(str, "<set-?>");
channel = str;
}
public final boolean a(Context context) {
Intrinsics.checkParameterIsNotNull(context, "context");
String packageName = context.getPackageName();
if (Intrinsics.areEqual(p.f.a(), packageName)) {
return StringsKt.contains$default((CharSequence) packageName, (CharSequence) com.m4399.gamecenter.plugin.main.b.a.APP_PACKAGE_NAME, false, 2, (Object) null) || StringsKt.contains$default((CharSequence) packageName, (CharSequence) "plugingame", false, 2, (Object) null);
}
return false;
}
private final String a(Context context, QuHeConfig serverConfig) {
File a2 = a(context, serverConfig.getVersion());
a("download", 3, new d(serverConfig, a2));
a("unZipLib", 3, new e(a2, serverConfig, a(a2)));
String absolutePath = a2.getAbsolutePath();
Intrinsics.checkExpressionValueIsNotNull(absolutePath, "outputFile.absolutePath");
return absolutePath;
}
private final void a(String name, int totalTimes, Function1<? super Integer, Unit> block) {
Throwable e2 = new IllegalStateException("can not catch exception in retry ");
int i = 0;
while (true) {
int i2 = i + 1;
if (i >= totalTimes) {
throw e2;
}
try {
block.invoke(Integer.valueOf(i2));
return;
} catch (Exception e3) {
e2 = e3;
n.h.b(TAG, "execute " + name + " error", e2);
i = i2;
}
}
}
private final File a(Context context, String version) {
File file = new File(context.getFilesDir(), "quhe/" + version + "/quhe.apk");
File parentFile = file.getParentFile();
if (parentFile != null) {
parentFile.mkdirs();
}
return file;
}
public final int a(File apkFile, File libDir, int expectSoSize) {
FilesKt.deleteRecursively(libDir);
libDir.mkdirs();
n.h.a(TAG, "start unZipLib from '" + apkFile + "' to '" + libDir + "', expectSoSize;" + expectSoSize);
String str = p.f.e() ? "lib/arm64-v8a" : "lib/armeabi-v7a";
ZipFile zipFile = new ZipFile(apkFile);
try {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
boolean z = false;
int i = 0;
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
Intrinsics.checkExpressionValueIsNotNull(entry, "entry");
String name = entry.getName();
Intrinsics.checkExpressionValueIsNotNull(name, "name");
if (!StringsKt.contains$default(name, "../", z, 2, (Object) null) && StringsKt.startsWith$default(name, str, z, 2, (Object) null) && !entry.isDirectory() && StringsKt.endsWith$default(name, ".so", z, 2, (Object) null)) {
String substring = name.substring(StringsKt.lastIndexOf$default((CharSequence) name, "/", 0, false, 6, (Object) null) + 1);
Intrinsics.checkExpressionValueIsNotNull(substring, "(this as java.lang.String).substring(startIndex)");
File file = new File(libDir, substring + ".tmp");
InputStream input = zipFile.getInputStream(entry);
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
try {
Intrinsics.checkExpressionValueIsNotNull(input, "input");
ByteStreamsKt.copyTo$default(input, fileOutputStream, 0, 2, null);
CloseableKt.closeFinally(fileOutputStream, null);
CloseableKt.closeFinally(input, null);
File file2 = new File(libDir, substring);
boolean renameTo = file.renameTo(file2);
n.h.a(TAG, "unzip file " + name + ", rename from " + file + " to " + file2 + ", " + renameTo);
if (!renameTo) {
FilesKt.deleteRecursively(libDir);
throw new IllegalStateException("rename from " + file + " to " + file2 + " error");
}
i++;
} finally {
}
} finally {
}
}
z = false;
}
Unit unit = Unit.INSTANCE;
CloseableKt.closeFinally(zipFile, null);
n.h.a(TAG, "unZipLib finish");
if (expectSoSize == i || expectSoSize == -1) {
return i;
}
FilesKt.deleteRecursively(libDir);
throw new IllegalStateException("so file size expect " + expectSoSize + " but " + i);
} finally {
}
}
private final void c(String apkPath) {
try {
String parent = new File(apkPath).getParent();
new DexClassLoader(apkPath, parent, parent, h.class.getClassLoader()).loadClass("com.pm.api.DefaultAppManager");
} catch (Exception e2) {
File parentFile = new File(apkPath).getParentFile();
Boolean valueOf = parentFile != null ? Boolean.valueOf(FilesKt.deleteRecursively(parentFile)) : null;
n.a(n.h, TAG, "testDex error, delete all file " + valueOf, null, 4, null);
throw e2;
}
}
private final void b(QuHeConfig config2) {
AppManagerHelper.INSTANCE.getINSTANCE().notifyUpgrade(config2.getPkg(), config2.getVersionCode(), config2.getVersion(), config2.getMd5());
}
private final void b(File outputFile) {
QuHeConfig quHeConfig = new QuHeConfig();
config = quHeConfig;
quHeConfig.b(200);
QuHeConfig quHeConfig2 = config;
if (quHeConfig2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
quHeConfig2.f("1.5.200");
QuHeConfig quHeConfig3 = config;
if (quHeConfig3 == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
String absolutePath = outputFile.getAbsolutePath();
Intrinsics.checkExpressionValueIsNotNull(absolutePath, "outputFile.absolutePath");
quHeConfig3.c(absolutePath);
QuHeConfig quHeConfig4 = config;
if (quHeConfig4 == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
quHeConfig4.b(diz.a.h);
QuHeConfig quHeConfig5 = config;
if (quHeConfig5 == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
File[] listFiles = new File(outputFile.getParentFile(), "lib").listFiles();
quHeConfig5.a(listFiles != null ? listFiles.length : 0);
QuHeConfig quHeConfig6 = config;
if (quHeConfig6 == null) {
Intrinsics.throwUninitializedPropertyAccessException("config");
}
SharedPreferences sharedPreferences = sp;
if (sharedPreferences == null) {
Intrinsics.throwUninitializedPropertyAccessException("sp");
}
quHeConfig6.b(sharedPreferences);
}
private final boolean a(QuHeConfig config2) {
if (config2.getVersionCode() == 0) {
n.h.a(TAG, "The first load does not require check");
return true;
}
File file = new File(config2.getPath());
if (!file.exists()) {
config2.b(0);
config2.c("file not exits");
n.b(n.h, TAG, "apk file " + file + " not exits, rollback to version 0", null, 4, null);
return false;
}
n nVar = n.h;
String str = TAG;
nVar.a(str, "apk file exists: " + file);
String a2 = j.a(file);
if (!StringsKt.equals(a2, config2.getMd5(), true)) {
config2.b(0);
file.delete();
config2.c("file md5 error");
n.b(nVar, str, file + " md5 error, file md5:" + a2 + ", config md5:" + config2.getMd5() + ", rollback to version 0", null, 4, null);
return false;
}
nVar.a(str, "md5 check finish");
File file2 = new File(file.getParentFile(), "lib");
File[] listFiles = file2.listFiles();
int length = listFiles != null ? listFiles.length : 0;
nVar.a(str, "There " + length + " so file in " + file2 + ", libSoSize in sp :" + config2.getLibSoSize());
if (config2.getLibSoSize() == 0) {
config2.a(a(file));
n.b(nVar, str, "fix libSoSize in sp to " + config2.getLibSoSize(), null, 4, null);
}
if (length != config2.getLibSoSize()) {
n.b(nVar, str, "Unzip when so file missing", null, 4, null);
a("unZipLib", 3, new b(file, config2));
return false;
}
nVar.b(str, "file " + file + " check success");
return true;
}
private final int a(File apkFile) {
ZipFile zipFile = new ZipFile(apkFile);
try {
ZipEntry entry = zipFile.getEntry("assets/config.json");
if (entry != null) {
InputStream inputStream = zipFile.getInputStream(entry);
Intrinsics.checkExpressionValueIsNotNull(inputStream, "it.getInputStream(configEntry)");
String str = new String(ByteStreamsKt.readBytes(inputStream), Charsets.UTF_8);
n.h.a(TAG, "read config json from apk file: " + str);
int i = new JSONObject(str).getInt("soSize");
CloseableKt.closeFinally(zipFile, null);
return i;
}
int a2 = j.a(zipFile);
CloseableKt.closeFinally(zipFile, null);
return a2;
} catch (Throwable th) {
try {
throw th;
} catch (Throwable th2) {
CloseableKt.closeFinally(zipFile, th);
throw th2;
}
}
}
private final int a(ZipFile apkZipFile) {
Enumeration<? extends ZipEntry> entries = apkZipFile.entries();
Intrinsics.checkExpressionValueIsNotNull(entries, "apkZipFile.entries()");
Iterator it = CollectionsKt.iterator(entries);
int i = 0;
while (it.hasNext()) {
ZipEntry entry = (ZipEntry) it.next();
Intrinsics.checkExpressionValueIsNotNull(entry, "entry");
String name = entry.getName();
Intrinsics.checkExpressionValueIsNotNull(name, "entry.name");
if (StringsKt.contains$default((CharSequence) name, (CharSequence) "lib/arm64-v8a", false, 2, (Object) null)) {
String name2 = entry.getName();
Intrinsics.checkExpressionValueIsNotNull(name2, "entry.name");
if (StringsKt.endsWith$default(name2, ".so", false, 2, (Object) null)) {
i++;
}
}
}
n.h.a(TAG, "read so size from apk file: " + i);
return i;
}
}