Search in sources :

Example 6 with PatchInfo

use of com.taobao.android.object.PatchInfo in project atlas by alibaba.

the class PatchFileBuilder method createHisTPatch.

/**
     * 创建指定版本的patch文件
     *
     * @param targetVersion
     */
private PatchInfo createHisTPatch(String targetVersion, ILogger logger) throws IOException, PatchException {
    PatchInfo hisPatchInfo = hisPatchInfos.get(targetVersion);
    String patchName = "patch-" + currentBuildPatchInfo.getPatchVersion() + "@" + hisPatchInfo.getPatchVersion();
    File destTPathTmpFolder = new File(tPatchTmpFolder, patchName);
    destTPathTmpFolder.mkdirs();
    File curTPatchUnzipFolder = unzipCurTPatchFolder(patchName);
    // 处理awb的更新
    List<BundlePatch> bundlePatches = diffPatch(hisPatchInfo, currentBuildPatchInfo);
    PatchInfo newPatchInfo = processBundlePatch(hisPatchInfo, bundlePatches, curTPatchUnzipFolder);
    // 比对主bundle的信息
    PatchBundleInfo curMainBundleInfo = getMainBundleInfo(currentBuildPatchInfo);
    PatchBundleInfo hisMainBundleInfo = getMainBundleInfo(hisPatchInfo);
    PatchBundleInfo mainBundleInfo = new PatchBundleInfo();
    mainBundleInfo.setMainBundle(true);
    mainBundleInfo.setNewBundle(false);
    if (null != curMainBundleInfo) {
        File mainBundleFile = new File(curTPatchUnzipFolder, curMainBundleInfo.getName() + ".so");
        FileUtils.copyFileToDirectory(mainBundleFile, destTPathTmpFolder);
        mainBundleInfo.setVersion(curMainBundleInfo.getVersion());
        mainBundleInfo.setPkgName(curMainBundleInfo.getPkgName());
        mainBundleInfo.setBaseVersion(curMainBundleInfo.getBaseVersion());
        mainBundleInfo.setName(curMainBundleInfo.getName());
        mainBundleInfo.setPkgName(curMainBundleInfo.getPkgName());
        mainBundleInfo.setApplicationName(curMainBundleInfo.getApplicationName());
        newPatchInfo.getBundles().add(mainBundleInfo);
    }
    // 生成tpatch文件
    for (PatchBundleInfo bundleInfo : newPatchInfo.getBundles()) {
        if (bundleInfo.getMainBundle() || bundleInfo.getNewBundle() || noPatchBundles.contains(bundleInfo.getPkgName())) {
            File bundleFolder = new File(destTPathTmpFolder, bundleInfo.getName());
            File soFile = new File(destTPathTmpFolder, bundleInfo.getName() + ".so");
            if (soFile.exists() || bundleInfo.getVersion().equals(ROLLBACK_VERSION)) {
                continue;
            }
            zipBundleSo(bundleFolder, soFile);
            FileUtils.deleteDirectory(bundleFolder);
        }
    }
    File tPatchFile = new File(patchsFolder, newPatchInfo.getFileName());
    if (tPatchFile.exists())
        FileUtils.deleteQuietly(tPatchFile);
    zipBundleSo(destTPathTmpFolder, tPatchFile);
    if (null != logger) {
        logger.info("[TPatchFile]" + tPatchFile.getAbsolutePath());
    }
    return newPatchInfo;
}
Also used : PatchBundleInfo(com.taobao.android.object.PatchBundleInfo) PatchInfo(com.taobao.android.object.PatchInfo)

Aggregations

PatchInfo (com.taobao.android.object.PatchInfo)6 PatchBundleInfo (com.taobao.android.object.PatchBundleInfo)4 PatchException (com.taobao.android.differ.dex.PatchException)3 BuildPatchInfos (com.taobao.android.object.BuildPatchInfos)3 ExecutorServicesHelper (com.taobao.android.task.ExecutorServicesHelper)2 File (java.io.File)2 ArtifactBundleInfo (com.taobao.android.object.ArtifactBundleInfo)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 RecognitionException (org.antlr.runtime.RecognitionException)1 Test (org.junit.Test)1