use of com.taobao.android.tpatch.model.BundleBO in project atlas by alibaba.
the class TPatchTask method createInput.
private BaseInput createInput(ApkBO apkBO, ApkBO newApkBO, boolean retainMainBundleRes) throws IOException {
TpatchInput tpatchInput = null;
if (getProject().hasProperty("hotfix")) {
tpatchInput = new HotPatchInput();
} else {
tpatchInput = new DexPatchInput();
}
tpatchInput.baseApkBo = apkBO;
tpatchInput.newApkBo = newApkBO;
tpatchInput.baseApkFileList = patchContext.getBaseApkFiles();
tpatchInput.newApkFileList = patchContext.getNewApkFiles(appVariantContext);
tpatchInput.outPatchDir = outPatchFolder;
tpatchInput.productName = patchContext.appSignName;
tpatchInput.outPutJson = new File(getOutPatchFolder(), "patchs.json");
tpatchInput.artifactBundleInfos = patchContext.artifactBundleInfos;
tpatchInput.diffBundleDex = true;
tpatchInput.newPatch = patchContext.newPatch;
tpatchInput.mainBundleName = patchContext.mainBundleName;
tpatchInput.retainMainBundleRes = retainMainBundleRes;
if (StringUtils.isNotBlank(patchContext.excludeFiles)) {
tpatchInput.notIncludeFiles = (patchContext.excludeFiles.split(","));
}
if (apkBO.getVersionName().equals(newApkBO.getVersionName())) {
if (tpatchInput instanceof HotPatchInput) {
((HotPatchInput) tpatchInput).hotClassListFile = patchContext.hotClassListFile;
((HotPatchInput) tpatchInput).patchType = PatchType.HOTFIX;
((HotPatchInput) tpatchInput).excludeClasses = patchContext.excludeClasses;
} else {
tpatchInput.patchType = PatchType.DEXPATCH;
((DexPatchInput) tpatchInput).patchClasses = patchContext.patchClasses;
((DexPatchInput) tpatchInput).excludeClasses = patchContext.excludeClasses;
}
tpatchInput.mainBundleName = "com.taobao.maindex";
} else {
tpatchInput.patchType = PatchType.TPATCH;
tpatchInput.createHisPatch = true;
tpatchInput.diffNativeSo = patchContext.diffNativeSo;
tpatchInput.diffBundleSo = patchContext.diffBundleSo;
tpatchInput.bundleWhiteList = appVariantContext.bundleListCfg;
tpatchInput.createAll = StringUtils.isEmpty(patchContext.tpatchHistoryUrl);
tpatchInput.LAST_PATCH_URL = patchContext.LAST_PATCH_URL;
tpatchInput.hisPatchUrl = patchContext.tpatchHistoryUrl;
if (null != patchContext.patchVersions) {
tpatchInput.versionList = patchContext.patchVersions;
}
}
List<Pair<BundleBO, BundleBO>> remoteBundles = new ArrayList<>();
// Get the remote bundle
for (AwbBundle awbBundle : AtlasBuildContext.awbBundleMap.values()) {
if (awbBundle.isRemote) {
File bundleFile = awbBundle.outputBundleFile;
getProject().getLogger().error("add bundle compare " + bundleFile.getAbsolutePath());
BundleBO newBundleBO = new BundleBO(awbBundle.getResolvedCoordinates().getArtifactId(), bundleFile, "");
File baseBundleFile = new File(patchContext.apExplodeFolder, "remotebundles/" + bundleFile.getName());
getProject().getLogger().error("add bundle compare base : " + baseBundleFile.getAbsolutePath());
BundleBO baseBundleBO = null;
if (baseBundleFile.exists()) {
getProject().getLogger().error("add bundle compare " + baseBundleFile.getAbsolutePath() + "->" + bundleFile.getAbsolutePath());
baseBundleBO = new BundleBO(awbBundle.getResolvedCoordinates().getArtifactId(), baseBundleFile, "");
}
remoteBundles.add(Pair.of(baseBundleBO, newBundleBO));
}
}
if (remoteBundles.size() > 0) {
tpatchInput.splitDiffBundle = remoteBundles;
}
return tpatchInput;
}
use of com.taobao.android.tpatch.model.BundleBO in project atlas by alibaba.
the class TPatchTool method doPatch.
@Override
public PatchFile doPatch() throws Exception {
TpatchInput tpatchInput = (TpatchInput) input;
TpatchFile tpatchFile = new TpatchFile();
File hisPatchJsonFile = new File(tpatchInput.outPutJson.getParentFile(), "patchs-" + input.newApkBo.getVersionName() + ".json");
hisTpatchFolder = new File(tpatchInput.outPatchDir.getParentFile().getParentFile().getParentFile().getParentFile(), "hisTpatch");
tpatchFile.diffJson = new File(((TpatchInput) input).outPatchDir, "diff.json");
tpatchFile.patchInfo = new File(((TpatchInput) input).outPatchDir, "patchInfo.json");
final File patchTmpDir = new File(((TpatchInput) input).outPatchDir, "tpatch-tmp");
final File mainDiffFolder = new File(patchTmpDir, ((TpatchInput) input).mainBundleName);
patchTmpDir.mkdirs();
FileUtils.cleanDirectory(patchTmpDir);
mainDiffFolder.mkdirs();
File lastPatchFile = null;
readWhiteList(((TpatchInput) input).bundleWhiteList);
lastPatchFile = getLastPatchFile(input.baseApkBo.getVersionName(), ((TpatchInput) input).productName, ((TpatchInput) input).outPatchDir);
PatchUtils.getTpatchClassDef(lastPatchFile, bundleClassMap);
Profiler.release();
Profiler.enter("unzip apks");
// unzip apk
File unzipFolder = unzipApk(((TpatchInput) input).outPatchDir);
final File newApkUnzipFolder = new File(unzipFolder, NEW_APK_UNZIP_NAME);
final File baseApkUnzipFolder = new File(unzipFolder, BASE_APK_UNZIP_NAME);
Profiler.release();
ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper();
String taskName = "diffBundleTask";
//
Collection<File> soFiles = FileUtils.listFiles(newApkUnzipFolder, new String[] { "so" }, true);
// process remote bumdle
if ((((TpatchInput) input).splitDiffBundle != null)) {
for (final Pair<BundleBO, BundleBO> bundle : ((TpatchInput) input).splitDiffBundle) {
if (bundle.getFirst() == null || bundle.getSecond() == null) {
logger.warning("remote bundle is not set to splitDiffBundles");
continue;
}
executorServicesHelper.submitTask(taskName, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
TPatchTool.this.processBundleFiles(bundle.getSecond().getBundleFile(), bundle.getFirst().getBundleFile(), patchTmpDir);
return true;
}
});
}
}
Profiler.enter("awbspatch");
Collection<File> retainFiles = FileUtils.listFiles(newApkUnzipFolder, new IOFileFilter() {
@Override
public boolean accept(File file) {
String relativePath = PathUtils.toRelative(newApkUnzipFolder, file.getAbsolutePath());
if (pathMatcher.match(DEFAULT_NOT_INCLUDE_RESOURCES, relativePath)) {
return false;
}
if (null != ((TpatchInput) (input)).notIncludeFiles && pathMatcher.match(((TpatchInput) (input)).notIncludeFiles, relativePath)) {
return false;
}
return true;
}
@Override
public boolean accept(File file, String s) {
return accept(new File(file, s));
}
}, TrueFileFilter.INSTANCE);
executorServicesHelper.submitTask(taskName, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
// 得到主bundle的dex diff文件
// File mianDiffDestDex = new File(mainDiffFolder, DEX_NAME);
// File tmpDexFolder = new File(patchTmpDir, ((TpatchInput)input).mainBundleName + "-dex");
createBundleDexPatch(newApkUnzipFolder, baseApkUnzipFolder, mainDiffFolder, // tmpDexFolder,
true);
// 是否保留主bundle的资源文件
if (isRetainMainBundleRes()) {
copyMainBundleResources(newApkUnzipFolder, baseApkUnzipFolder, new File(patchTmpDir, ((TpatchInput) input).mainBundleName), retainFiles);
}
return true;
}
});
for (final File soFile : soFiles) {
System.out.println("do patch:" + soFile.getAbsolutePath());
final String relativePath = PathUtils.toRelative(newApkUnzipFolder, soFile.getAbsolutePath());
if (null != ((TpatchInput) input).notIncludeFiles && pathMatcher.match(((TpatchInput) input).notIncludeFiles, relativePath)) {
continue;
}
executorServicesHelper.submitTask(taskName, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
File destFile = new File(patchTmpDir, ((TpatchInput) input).mainBundleName + "/" + relativePath);
File baseSoFile = new File(baseApkUnzipFolder, relativePath);
if (isBundleFile(soFile)) {
processBundleFiles(soFile, baseSoFile, patchTmpDir);
} else if (isFileModify(soFile, baseSoFile)) {
if (destFile.exists()) {
FileUtils.deleteQuietly(destFile);
}
if (!baseSoFile.exists() || !((TpatchInput) input).diffNativeSo) {
// 新增
FileUtils.copyFile(soFile, destFile);
} else {
destFile = new File(destFile.getParentFile(), destFile.getName() + ".patch");
SoDiffUtils.diffSo(patchTmpDir, baseSoFile, soFile, destFile);
soFileDefs.add(new SoFileDef(baseSoFile, soFile, destFile, relativePath));
}
}
return true;
}
});
}
executorServicesHelper.waitTaskCompleted(taskName);
executorServicesHelper.stop();
Profiler.release();
Profiler.enter("ziptpatchfile");
// zip file
File patchFile = createTPatchFile(((TpatchInput) input).outPatchDir, patchTmpDir);
tpatchFile.patchFile = patchFile;
PatchInfo curPatchInfo = createBasePatchInfo(patchFile);
Profiler.release();
Profiler.enter("createhistpatch");
BuildPatchInfos buildPatchInfos = createIncrementPatchFiles(((TpatchInput) input).productName, patchFile, ((TpatchInput) input).outPatchDir, newApkUnzipFolder, curPatchInfo, ((TpatchInput) input).hisPatchUrl);
Profiler.release();
Profiler.enter("writejson");
buildPatchInfos.getPatches().add(curPatchInfo);
buildPatchInfos.setBaseVersion(input.baseApkBo.getVersionName());
buildPatchInfos.setDiffBundleDex(input.diffBundleDex);
FileUtils.writeStringToFile(((TpatchInput) input).outPutJson, JSON.toJSONString(buildPatchInfos));
BuildPatchInfos testForBuildPatchInfos = new BuildPatchInfos();
testForBuildPatchInfos.setBaseVersion(buildPatchInfos.getBaseVersion());
List<PatchInfo> patchInfos = new ArrayList<>();
testForBuildPatchInfos.setPatches(patchInfos);
testForBuildPatchInfos.setDiffBundleDex(buildPatchInfos.isDiffBundleDex());
for (PatchInfo patchInfo : buildPatchInfos.getPatches()) {
if (patchInfo.getTargetVersion().equals(buildPatchInfos.getBaseVersion())) {
patchInfos.add(patchInfo);
}
}
FileUtils.writeStringToFile(hisPatchJsonFile, JSON.toJSONString(testForBuildPatchInfos));
tpatchFile.updateJsons = new ArrayList<File>();
Map<String, List<String>> map = new HashMap<>();
for (PatchInfo patchInfo : buildPatchInfos.getPatches()) {
UpdateInfo updateInfo = new UpdateInfo(patchInfo, buildPatchInfos.getBaseVersion());
// System.out.println("start to check:"+patchInfo.getTargetVersion()+"......");
// List<PatchChecker.ReasonMsg> msgs = new PatchChecker(updateInfo,bundleInfos.get(patchInfo.getTargetVersion()),new File(((TpatchInput) input).outPatchDir,patchInfo.getFileName())).check();
// map.put(patchInfo.getFileName(),msgToString(msgs));
File updateJson = new File(((TpatchInput) input).outPatchDir, "update-" + patchInfo.getTargetVersion() + ".json");
FileUtils.writeStringToFile(updateJson, JSON.toJSONString(updateInfo, true));
tpatchFile.updateJsons.add(updateJson);
}
// tpatchFile.patchChecker = new File(((TpatchInput) input).outPatchDir,"patch-check.json");
// FileUtils.writeStringToFile(tpatchFile.patchChecker, JSON.toJSONString(map, true));
// 删除临时的目录
FileUtils.deleteDirectory(patchTmpDir);
apkDiff.setBaseApkVersion(input.baseApkBo.getVersionName());
apkDiff.setNewApkVersion(input.newApkBo.getVersionName());
apkDiff.setBundleDiffResults(bundleDiffResults);
boolean newApkFileExist = input.newApkBo.getApkFile().exists() && input.newApkBo.getApkFile().isFile();
if (newApkFileExist) {
apkDiff.setNewApkMd5(MD5Util.getFileMD5String(input.newApkBo.getApkFile()));
}
apkDiff.setFileName(input.newApkBo.getApkName());
apkPatchInfos.setBaseApkVersion(input.baseApkBo.getVersionName());
apkPatchInfos.setNewApkVersion(input.newApkBo.getVersionName());
apkPatchInfos.setBundleDiffResults(diffPatchInfos);
apkPatchInfos.setFileName(patchFile.getName());
apkPatchInfos.setNewApkMd5(MD5Util.getFileMD5String(patchFile));
FileUtils.writeStringToFile(tpatchFile.diffJson, JSON.toJSONString(apkDiff));
FileUtils.writeStringToFile(tpatchFile.patchInfo, JSON.toJSONString(apkPatchInfos));
FileUtils.copyFileToDirectory(tpatchFile.diffJson, ((TpatchInput) input).outPatchDir.getParentFile(), true);
if (newApkFileExist) {
FileUtils.copyFileToDirectory(input.newApkBo.getApkFile(), ((TpatchInput) input).outPatchDir.getParentFile(), true);
}
Profiler.release();
logger.warning(Profiler.dump());
return tpatchFile;
}
use of com.taobao.android.tpatch.model.BundleBO in project atlas by alibaba.
the class APatchTool method doPatch.
@Override
public PatchFile doPatch() throws Exception {
APatchFile patchFile = new APatchFile();
ApatchInput apatchInput = (ApatchInput) input;
mappingMap = apatchInput.mappingMap;
if (apatchInput.mappingMap.get(apatchInput.replaceAnnotation) != null) {
MethodReplaceAnnotation.ANNOTATION = apatchInput.mappingMap.get(apatchInput.replaceAnnotation);
}
File patchTmpDir = new File(input.outPutFile.getParentFile(), "apatch-tmp");
patchTmpDir.mkdirs();
patchFile.aDiffText = new File(input.outPutFile.getParentFile(), "apatch-diff.txt");
patchFile.diffJson = new File(input.outPutFile.getParentFile(), "apatch-diff.json");
FileUtils.deleteQuietly(patchFile.aDiffText);
patchFile.aDiffText.createNewFile();
// unzip apk
File unzipFolder = unzipApk(patchTmpDir);
final File newApkUnzipFolder = new File(unzipFolder, NEW_APK_UNZIP_NAME);
final File baseApkUnzipFolder = new File(unzipFolder, BASE_APK_UNZIP_NAME);
// first generate main bundle patch file
List<File> aPatches = createBundleAPatch(newApkUnzipFolder, baseApkUnzipFolder, patchTmpDir, apatchInput.andfixMainBundleName, patchFile.aDiffText, patchFile.diffJson);
// second generate common bundle patch file
//
Collection<File> soFiles = FileUtils.listFiles(newApkUnzipFolder, new String[] { "so" }, true);
if (input.splitDiffBundle != null) {
for (Pair<BundleBO, BundleBO> bundle : input.splitDiffBundle) {
if (bundle.getFirst() == null || bundle.getSecond() == null) {
continue;
}
List<File> aPatchFiles = processBundleFiles(bundle.getSecond().getBundleFile(), bundle.getFirst().getBundleFile(), patchTmpDir, patchFile.aDiffText, patchFile.diffJson);
if (null != aPatchFiles) {
for (File aPatchFile : aPatchFiles) {
if (null != aPatchFile && aPatchFile.exists()) {
aPatches.add(aPatchFile);
}
}
}
}
}
for (File soFile : soFiles) {
String relativePath = PathUtils.toRelative(newApkUnzipFolder, soFile.getAbsolutePath());
if (null != apatchInput.notIncludeFiles && pathMatcher.match(apatchInput.notIncludeFiles, relativePath)) {
continue;
}
File baseSoFile = new File(baseApkUnzipFolder, relativePath);
if (PatchUtils.isBundleFile(soFile)) {
// if bundle file
List<File> aPatchFiles = processBundleFiles(soFile, baseSoFile, patchTmpDir, patchFile.aDiffText, patchFile.diffJson);
if (null != aPatchFiles) {
for (File aPatchFile : aPatchFiles) {
if (null != aPatchFile && aPatchFile.exists()) {
aPatches.add(aPatchFile);
}
}
}
}
}
if (aPatches.size() <= 0) {
throw new Exception("No apatch files! No classes modify!");
}
// merge apatch file
File[] aPatchFiles = new File[aPatches.size()];
aPatchFiles = aPatches.toArray(aPatchFiles);
File mergePatchFile = null;
if (null != aPatchFiles && aPatchFiles.length > 1) {
MergePatch mergePatch = new MergePatch(aPatchFiles, apatchInput.projectArtifactId, patchTmpDir);
mergePatchFile = mergePatch.doMerge();
} else if (null != aPatchFiles && aPatchFiles.length == 1) {
mergePatchFile = aPatchFiles[0];
}
if (null != mergePatchFile && mergePatchFile.exists()) {
FileUtils.moveFile(mergePatchFile, input.outPutFile);
}
FileUtils.deleteDirectory(unzipFolder);
FileUtils.deleteDirectory(patchTmpDir);
patchFile.patchFile = input.outPutFile;
return patchFile;
}
use of com.taobao.android.tpatch.model.BundleBO in project atlas by alibaba.
the class DexPatchTool method doPatch.
@Override
public PatchFile doPatch() throws Exception {
TpatchInput tpatchInput = (TpatchInput) input;
DexPatchFile tpatchFile = new DexPatchFile();
tpatchFile.diffJson = new File(tpatchInput.outPatchDir, "diff.json");
tpatchFile.patchInfo = new File(tpatchInput.outPatchDir, "patchInfo.json");
final File patchTmpDir = new File(tpatchInput.outPatchDir, "dexpatch-tmp");
final File mainDiffFolder = new File(patchTmpDir, tpatchInput.mainBundleName);
patchTmpDir.mkdirs();
FileUtils.cleanDirectory(patchTmpDir);
mainDiffFolder.mkdirs();
Profiler.release();
Profiler.enter("unzip apks");
// unzip apk
File unzipFolder = unzipApk(((TpatchInput) input).outPatchDir);
final File newApkUnzipFolder = new File(unzipFolder, NEW_APK_UNZIP_NAME);
final File baseApkUnzipFolder = new File(unzipFolder, BASE_APK_UNZIP_NAME);
Profiler.release();
ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper();
String taskName = "diffBundleTask";
//
Collection<File> soFiles = FileUtils.listFiles(newApkUnzipFolder, new String[] { "so" }, true);
// process remote bumdle
if (tpatchInput.splitDiffBundle != null) {
for (final Pair<BundleBO, BundleBO> bundle : ((TpatchInput) input).splitDiffBundle) {
executorServicesHelper.submitTask(taskName, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
processBundleFiles(bundle.getSecond().getBundleFile(), bundle.getFirst().getBundleFile(), patchTmpDir);
return true;
}
});
}
}
Profiler.enter("awbspatch");
executorServicesHelper.submitTask(taskName, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
// 得到主bundle的dex diff文件
createBundleDexPatch(newApkUnzipFolder, baseApkUnzipFolder, mainDiffFolder, true);
return true;
}
});
for (final File soFile : soFiles) {
System.out.println("do dexpatch:" + soFile.getAbsolutePath());
final String relativePath = PathUtils.toRelative(newApkUnzipFolder, soFile.getAbsolutePath());
if (null != tpatchInput.notIncludeFiles && pathMatcher.match(tpatchInput.notIncludeFiles, relativePath)) {
continue;
}
executorServicesHelper.submitTask(taskName, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
File destFile = new File(patchTmpDir, tpatchInput.mainBundleName + "/" + relativePath);
File baseSoFile = new File(baseApkUnzipFolder, relativePath);
if (isBundleFile(soFile)) {
processBundleFiles(soFile, baseSoFile, patchTmpDir);
}
return true;
}
});
}
executorServicesHelper.waitTaskCompleted(taskName);
executorServicesHelper.stop();
Profiler.release();
Profiler.enter("ziptpatchfile");
// zip file
File patchFile = createDexPatchFile(tpatchInput.outPatchDir, patchTmpDir);
tpatchFile.patchFile = patchFile;
if (!patchFile.exists()) {
return null;
}
PatchInfo curPatchInfo = createBasePatchInfo(patchFile);
Profiler.release();
Profiler.enter("writejson");
BuildPatchInfos buildPatchInfos = new BuildPatchInfos();
buildPatchInfos.getPatches().add(curPatchInfo);
buildPatchInfos.setBaseVersion(input.baseApkBo.getVersionName());
buildPatchInfos.setDiffBundleDex(true);
FileUtils.writeStringToFile(tpatchInput.outPutJson, JSON.toJSONString(buildPatchInfos));
// 删除临时的目录
FileUtils.deleteDirectory(patchTmpDir);
apkDiff.setBaseApkVersion(input.baseApkBo.getVersionName());
apkDiff.setNewApkVersion(input.newApkBo.getVersionName());
apkDiff.setBundleDiffResults(bundleDiffResults);
boolean newApkFileExist = input.newApkBo.getApkFile().exists() && input.newApkBo.getApkFile().isFile();
if (newApkFileExist) {
apkDiff.setNewApkMd5(MD5Util.getFileMD5String(input.newApkBo.getApkFile()));
}
apkDiff.setFileName(input.newApkBo.getApkName());
apkPatchInfos.setBaseApkVersion(input.baseApkBo.getVersionName());
apkPatchInfos.setNewApkVersion(input.newApkBo.getVersionName());
apkPatchInfos.setBundleDiffResults(diffPatchInfos);
apkPatchInfos.setFileName(patchFile.getName());
apkPatchInfos.setNewApkMd5(MD5Util.getFileMD5String(patchFile));
FileUtils.writeStringToFile(tpatchFile.diffJson, JSON.toJSONString(apkDiff));
FileUtils.writeStringToFile(tpatchFile.patchInfo, JSON.toJSONString(apkPatchInfos));
FileUtils.copyFileToDirectory(tpatchFile.diffJson, tpatchInput.outPatchDir.getParentFile(), true);
if (newApkFileExist) {
FileUtils.copyFileToDirectory(input.newApkBo.getApkFile(), tpatchInput.outPatchDir.getParentFile(), true);
}
Profiler.release();
logger.warning(Profiler.dump());
return tpatchFile;
}
use of com.taobao.android.tpatch.model.BundleBO in project atlas by alibaba.
the class TPatchTool method createIncrementPatchFiles.
/**
* create increment patch
* file
*/
private BuildPatchInfos createIncrementPatchFiles(String productionName, File curTPatchFile, File targetDirectory, File newApkUnzipFolder, PatchInfo curPatchInfo, String patchHistoryUrl) throws IOException, PatchException {
BuildPatchInfos historyBuildPatchInfos = null;
String response = null;
if (!StringUtils.isEmpty(patchHistoryUrl)) {
String patchHisUrl = patchHistoryUrl + "?baseVersion=" + input.baseApkBo.getVersionName() + "&productIdentifier=" + productionName;
try {
response = HttpClientUtils.getUrl(patchHisUrl);
historyBuildPatchInfos = JSON.parseObject(response, BuildPatchInfos.class);
} catch (Throwable e) {
historyBuildPatchInfos = null;
}
} else {
File[] files = hisTpatchFolder.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String filename) {
return filename.startsWith("patchs-") && filename.endsWith(".json");
}
});
if (files != null && files.length > 0) {
historyBuildPatchInfos = mergeHisPatchInfo(files);
}
}
if (historyBuildPatchInfos == null) {
return new BuildPatchInfos();
}
Iterator<PatchInfo> patchInfos = historyBuildPatchInfos.getPatches().iterator();
while (patchInfos.hasNext()) {
PatchInfo patchInfo = patchInfos.next();
if (!patchInfo.getTargetVersion().equals(input.baseApkBo.getVersionName())) {
patchInfos.remove();
}
}
Map<String, File> awbBundleMap = new HashMap<String, File>();
for (ArtifactBundleInfo artifactBundleInfo : input.artifactBundleInfos) {
String bundleFileSoName = "lib" + artifactBundleInfo.getPkgName().replace('.', '_') + ".so";
File bundleFile = new File(newApkUnzipFolder, "lib" + "/" + "armeabi" + "/" + bundleFileSoName);
File assetsBundleFile = new File(newApkUnzipFolder, "assets" + "/" + bundleFileSoName);
if (bundleFile.exists()) {
awbBundleMap.put(artifactBundleInfo.getArtifactId(), bundleFile);
} else if (assetsBundleFile.exists()) {
awbBundleMap.put(artifactBundleInfo.getArtifactId(), assetsBundleFile);
}
}
if (((TpatchInput) input).splitDiffBundle != null) {
for (Pair<BundleBO, BundleBO> bundle : ((TpatchInput) input).splitDiffBundle) {
awbBundleMap.put(bundle.getSecond().getBundleName(), bundle.getSecond().getBundleFile());
}
}
PatchFileBuilder patchFileBuilder = new PatchFileBuilder(historyBuildPatchInfos, curTPatchFile, curPatchInfo, awbBundleMap, targetDirectory, input.baseApkBo.getVersionName());
patchFileBuilder.setNoPatchBundles(((TpatchInput) input).noPatchBundles);
patchFileBuilder.setHistroyVersionList(((TpatchInput) input).versionList);
return patchFileBuilder.createHistoryTPatches(input.diffBundleDex, logger);
}
Aggregations