use of com.taobao.android.object.ClassDiffInfo in project atlas by alibaba.
the class TPatchDexTool method createTPatchDex.
/**
* 生成淘宝的动态部署的patch的Dex文件
*
* @param outDexFile
*/
public DexDiffInfo createTPatchDex(File outDexFile) throws IOException, RecognitionException, PatchException {
outDexFile.getParentFile().mkdirs();
DexDiffInfo dexDiffInfo = dexDiffer.doDiff();
// 将有变动的类写入到diff.dex
final Set<ClassDef> modifyClasses = new HashSet<ClassDef>();
for (ClassDiffInfo classDiffInfo : dexDiffInfo.getClassDiffInfoMap().values()) {
if (DiffType.MODIFY.equals(classDiffInfo.getType()) || DiffType.ADD.equals(classDiffInfo.getType()) || DiffType.OVERRIDE.equals(classDiffInfo.getType())) {
modifyClasses.add(classDiffInfo.getClassDef());
}
}
if (modifyClasses.size() > 0) {
DexFileFactory.writeDexFile(outDexFile.getAbsolutePath(), new DexFile() {
@Nonnull
@Override
public Set<? extends ClassDef> getClasses() {
return new AbstractSet<ClassDef>() {
@Nonnull
@Override
public Iterator<ClassDef> iterator() {
return modifyClasses.iterator();
}
@Override
public int size() {
return modifyClasses.size();
}
};
}
});
}
return dexDiffInfo;
}
Aggregations