Search in sources :

Example 1 with EntryExplanation

use of com.google.archivepatcher.explainer.EntryExplanation in project android-bundle-support by lizhangqu.

the class ApkFileByFileDiffParser method createTreeNode.

@NonNull
public static DefaultMutableTreeNode createTreeNode(@NonNull ArchiveContext oldFile, @NonNull ArchiveContext newFile) throws IOException, InterruptedException {
    ArchiveNode oldRoot = ArchiveTreeStructure.create(oldFile);
    ArchiveNode newRoot = ArchiveTreeStructure.create(newFile);
    PatchExplainer explainer = new PatchExplainer(new DeflateCompressor(), new BsDiffDeltaGenerator());
    Map<String, Long> pathsToDiffSize = new HashMap<>();
    List<EntryExplanation> explanationList = explainer.explainPatch(oldFile.getArchive().getPath().toFile(), newFile.getArchive().getPath().toFile());
    for (EntryExplanation explanation : explanationList) {
        String path = new String(explanation.getPath().getData(), "UTF8");
        pathsToDiffSize.put(path, explanation.getCompressedSizeInPatch());
    }
    return createTreeNode(oldRoot, newRoot, pathsToDiffSize);
}
Also used : EntryExplanation(com.google.archivepatcher.explainer.EntryExplanation) ArchiveNode(io.github.lizhangqu.intellij.android.bundle.analyzer.ArchiveNode) DeflateCompressor(com.google.archivepatcher.shared.DeflateCompressor) HashMap(java.util.HashMap) BsDiffDeltaGenerator(com.google.archivepatcher.generator.bsdiff.BsDiffDeltaGenerator) PatchExplainer(com.google.archivepatcher.explainer.PatchExplainer) NonNull(com.android.annotations.NonNull)

Aggregations

NonNull (com.android.annotations.NonNull)1 EntryExplanation (com.google.archivepatcher.explainer.EntryExplanation)1 PatchExplainer (com.google.archivepatcher.explainer.PatchExplainer)1 BsDiffDeltaGenerator (com.google.archivepatcher.generator.bsdiff.BsDiffDeltaGenerator)1 DeflateCompressor (com.google.archivepatcher.shared.DeflateCompressor)1 ArchiveNode (io.github.lizhangqu.intellij.android.bundle.analyzer.ArchiveNode)1 HashMap (java.util.HashMap)1