use of com.taobao.android.tpatch.builder.PatchFileBuilder in project atlas by alibaba.
the class TPatchTool method createIncrementPatchFiles.
/**
* 生成增量的patch文件
*/
private BuildPatchInfos createIncrementPatchFiles(String productionName, File curTPatchFile, File targetDirectory, File newApkUnzipFolder, PatchInfo curPatchInfo, String patchHistoryUrl) throws IOException, PatchException {
BuildPatchInfos historyBuildPatchInfos = null;
if (!StringUtils.isEmpty(patchHistoryUrl)) {
String patchHisUrl = patchHistoryUrl + "?baseVersion=" + baseApkVersion + "&productIdentifier=" + productionName;
String response = HttpClientUtils.getUrl(patchHisUrl);
historyBuildPatchInfos = JSON.parseObject(response, BuildPatchInfos.class);
}
Map<String, File> awbBundleMap = new HashMap<String, File>();
for (ArtifactBundleInfo artifactBundleInfo : artifactBundleInfos) {
String bundleFileSoName = "lib" + artifactBundleInfo.getPkgName().replace('.', '_') + ".so";
File bundleFile = new File(newApkUnzipFolder, "lib" + File.separator + "armeabi" + File.separator + bundleFileSoName);
if (bundleFile.exists()) {
awbBundleMap.put(artifactBundleInfo.getArtifactId(), bundleFile);
}
}
PatchFileBuilder patchFileBuilder = new PatchFileBuilder(historyBuildPatchInfos, curTPatchFile, curPatchInfo, awbBundleMap, targetDirectory, baseApkVersion);
patchFileBuilder.setNoPatchBundles(noPatchBundles);
return patchFileBuilder.createHistoryTPatches(diffBundleDex, logger);
}
use of com.taobao.android.tpatch.builder.PatchFileBuilder 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