工作空间 v3.7.4.6版本的 MD5 值为:94c1c0052e9f2e949ae1349e6caf437b
以下内容为反编译后的 H5PackageManager.java 源代码,内容仅作参考
package com.uusafe.h5app.library;
import android.app.Application;
import android.content.Context;
import android.text.TextUtils;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.uusafe.base.modulesdk.module.manager.BaseModuleManager;
import com.uusafe.base.modulesdk.module.netapi.BaseApis;
import com.uusafe.commbase.utils.CommPackageUtils;
import com.uusafe.h5app.library.api.ConfigInfo;
import com.uusafe.h5app.library.api.H5ApplicationInfo;
import com.uusafe.h5app.library.browser.DispatchService;
import com.uusafe.h5app.library.browser.utils.ProcessUtils;
import com.uusafe.h5app.library.install.Installer;
import com.uusafe.h5app.library.internal.entity.ZlaInfo;
import com.uusafe.h5app.library.internal.exception.ParseException;
import com.uusafe.h5app.library.internal.res.H5Lan;
import com.uusafe.h5app.library.internal.res.Resource;
import com.uusafe.h5app.library.utils.AppIdDigestUtil;
import com.uusafe.h5app.library.utils.ConfigUtil;
import com.uusafe.h5app.library.utils.CustomURLEncoder;
import com.uusafe.h5app.library.utils.JsonUtil;
import com.uusafe.h5app.library.utils.ProcessRecordUtil;
import com.uusafe.jsbridge.module.ModuleManager;
import com.uusafe.utils.common.FileUtils;
import com.uusafe.utils.common.StringUtils;
import com.uusafe.utils.common.ZZLog;
import com.xiaomi.mipush.sdk.Constants;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class H5PackageManager {
private static final String PROCESS_ZPVD = ".com.zpvd";
public static Application application;
private static H5PackageManager instance = new H5PackageManager();
private String h5Lan = H5Lan.H5_AUTO;
private Map<String, Resource> resMap = new HashMap();
private H5PackageManager() {
}
public static void attachBaseContext(Application application2) {
H5ApplicationInfo applicationInfo;
application = application2;
String curProcessName = ProcessUtils.getCurProcessName(application2);
boolean z = true;
boolean z2 = false;
if (TextUtils.equals(curProcessName, PROCESS_ZPVD)) {
z2 = true;
} else if (ProcessUtils.isBrowserProcess(application2)) {
ZZLog.e("attachBaseContext===" + FileUtils.readFile("/data/user/0/com.uusafe.portal/files/1600482578173359626_zzydemo/tmp/client_usage.json", application2));
} else {
z = false;
}
if (z) {
ModuleManager.getInstance();
String readProcessBind = ProcessRecordUtil.readProcessBind(application2, curProcessName);
Logger.log("isBrowserProcess,attachBaseContext appId=" + readProcessBind);
ProcessRecordUtil.recordProcess(application2, curProcessName, readProcessBind);
String str = "";
if (!z2) {
try {
if (getInstance().getApplicationInfo(application2, readProcessBind) != null) {
str = applicationInfo.id + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + applicationInfo.name + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + applicationInfo.logo;
}
} catch (Throwable th) {
Logger.logE(th);
}
}
BaseModuleManager.getInstance().getSandboxSdkModule().H5ZManagerAttachBaseContext(application2, z2, str, ConfigUtil.getClientId(application2));
}
ZZLog.e("attachBaseContext===1111" + FileUtils.readFile("/data/user/0/com.uusafe.portal/files/1600482578173359626_zzydemo/tmp/client_usage.json", application2));
}
private void checkAndMoveAppPath(Context context, String str) throws IOException, ParseException {
String uniqueString = AppIdDigestUtil.uniqueString(str);
File h5HomeDir = Env.getH5HomeDir(context, uniqueString);
File codePath = Env.getCodePath(context, uniqueString);
if (!new File(h5HomeDir, ".h5prop").exists() || Installer.getProp(codePath) == null) {
File h5HomeDir2 = Env.getH5HomeDir(context, uniqueString + "_old");
File codePath2 = Env.getCodePath(context, uniqueString + "_old");
if (new File(h5HomeDir2, ".h5prop").exists()) {
if (Installer.getProp(Env.getCodePath(context, uniqueString + "_old")) != null) {
com.uusafe.h5app.library.utils.FileUtils.deleteDirectory(codePath);
Installer.moveCodeDir(codePath2, codePath);
return;
}
}
throw new ParseException("app code is not valid or not found!");
}
}
public static void clearCache(Context context) {
Installer.clearCache(context);
}
public static void clearCacheForSandboxH5(Context context) {
try {
File parentFile = context.getFilesDir().getParentFile();
com.uusafe.h5app.library.utils.FileUtils.deleteDirectory(new File(parentFile.getAbsolutePath() + "/zzyh5"));
} catch (Exception e2) {
e2.printStackTrace();
}
}
public static void enableLog(boolean z) {
Logger.enableLog(z);
}
public static long getCacheForSandboxH5(Context context) {
long j = 0;
try {
List<String> appList = Installer.getAppList(context);
int size = appList.size();
for (int i = 0; i < size; i++) {
j += com.uusafe.h5app.library.utils.FileUtils.sizeOf(Env.getSandboxH5CacheDir(context, appList.get(i)));
}
} catch (Exception e2) {
e2.printStackTrace();
}
return j;
}
public static long getCacheSize(Context context) {
try {
File parentFile = context.getFilesDir().getParentFile();
return com.uusafe.h5app.library.utils.FileUtils.sizeOf(new File(parentFile.getAbsolutePath() + "/zzyh5"));
} catch (Exception e2) {
e2.printStackTrace();
return 0L;
}
}
public static H5PackageManager getInstance() {
return instance;
}
public static String getVersion() {
return "3.7.4.6.2061490498";
}
public static int getVersionCode() {
return 2061490498;
}
public static String getVersionName() {
return "3.7.4.6";
}
public static boolean init(Context context) {
Installer.init(context);
return true;
}
public static void onCreate(Application application2) {
String curProcessName = ProcessUtils.getCurProcessName(application2);
if (ProcessUtils.isBrowserProcess(application2) || TextUtils.equals(curProcessName, PROCESS_ZPVD)) {
String readProcess = ProcessRecordUtil.readProcess(application2, curProcessName);
Logger.log("isBrowserProcess,onCreate appId=" + readProcess);
try {
ZZLog.e("H5PackageManager", "onCreate ppId=" + readProcess, new Object[0]);
BaseModuleManager.getInstance().getSandboxSdkModule().H5ZManagerOnCreate(application2);
} catch (Throwable th) {
Logger.logE(th);
}
}
}
public static boolean setClientId4SandBox(Context context, String str) {
return ConfigUtil.saveClientId(context, str);
}
public boolean clearAllAppData(Context context) throws IOException {
return Installer.clearAllAppData(context);
}
public boolean clearAppData(Context context, String str) throws IOException {
return Installer.clearAppData(context, str);
}
public List<String> getAppList(Context context) throws IOException {
return Installer.getAppList(context);
}
public H5ApplicationInfo getApplicationInfo(Context context, String str) {
ZlaInfo zlaInfo;
try {
File file = new File(Env.getCodePath(context, AppIdDigestUtil.uniqueString(str)), "zla.json");
if (!file.exists() || (zlaInfo = JsonUtil.getZlaInfo(file)) == null) {
return null;
}
Resource resource = this.resMap.get(str);
if (resource == null) {
resource = Resource.getRes(context, str);
this.resMap.put(str, resource);
}
resource.setLan(this.h5Lan);
return H5ApplicationInfo.parse(zlaInfo.application, resource);
} catch (Throwable th) {
Logger.logE(th);
return null;
}
}
public String getLan() {
return this.h5Lan;
}
public boolean installApp(Context context, File file) {
return Installer.install(context, file);
}
public void launchApp(Context context, String str, ConfigInfo configInfo, String str2) {
BaseModuleManager.getInstance().getSandboxSdkModule().pushGlobal(BaseApis.H5FLAG, "true");
H5ApplicationInfo applicationInfo = getApplicationInfo(context, str);
if (applicationInfo != null) {
String str3 = applicationInfo.index;
if (StringUtils.areNotEmpty(str2)) {
if (applicationInfo.mode == 2) {
String htmlUrlScheme = CommPackageUtils.getHtmlUrlScheme(str2, context);
try {
if (htmlUrlScheme.contains("?")) {
String encode = CustomURLEncoder.encode(htmlUrlScheme, "UTF-8");
File h5HomeDir = Env.getH5HomeDir(context, AppIdDigestUtil.uniqueString(applicationInfo.id));
String substring = encode.substring(0, encode.indexOf("?"));
htmlUrlScheme = encode.substring(encode.indexOf("?") + 1);
applicationInfo.index = Env.getDefaultLocalAppPath(h5HomeDir).getAbsolutePath() + "/" + substring;
}
applicationInfo.localScheme = CustomURLEncoder.encode(htmlUrlScheme, "UTF-8");
} catch (Exception e2) {
e2.printStackTrace();
}
} else {
URI create = URI.create(str3);
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(create.getScheme());
stringBuffer.append("://");
stringBuffer.append(create.getHost());
if (StringUtils.areNotEmpty(create.getPort() + "") && create.getPort() > 0) {
stringBuffer.append(Constants.COLON_SEPARATOR);
stringBuffer.append(create.getPort());
}
String htmlUrlScheme2 = CommPackageUtils.getHtmlUrlScheme(str2, context);
try {
htmlUrlScheme2 = CustomURLEncoder.encode(htmlUrlScheme2, "UTF-8");
} catch (Exception e3) {
e3.printStackTrace();
}
if (htmlUrlScheme2.contains("?")) {
stringBuffer.append("/");
stringBuffer.append(htmlUrlScheme2);
applicationInfo.index = stringBuffer.toString();
} else if (str3.contains("?")) {
applicationInfo.index = str3 + "&" + htmlUrlScheme2;
} else {
applicationInfo.index = str3 + "?" + htmlUrlScheme2;
}
}
}
DispatchService.startDispatchService(context, applicationInfo, configInfo);
}
}
public void setLan(String str) {
this.h5Lan = str;
}
public boolean unInstallApp(Context context, String str) {
boolean unInstall = Installer.unInstall(context, str);
this.resMap.remove(str);
return unInstall;
}
}