Dex文件的合成与分解
一、DexPatchFile类
Dex文件分为这几个区域:
StringData| Integer| ProtoId| FieldId|MethodId|ClassDef|TypeList|AnnotationSetRefList|AnnotationSet|ClassData|Code|DebugInfoItem|Annotation|EncodedValue|AnnotationsDirectory
-----|-----|------|-----|----|-----|-----|-----|-----|-------|-----|-----|-----|------
StringData| Integer| ProtoId| FieldId|MethodId|ClassDef|TypeList|AnnotationSetRefList|AnnotationSet|ClassData|Code|DebugInfoItem|Annotation|EncodedValue|AnnotationsDirectory
public DexPatchApplier(
InputStream oldDexIn,
int initDexSize,
InputStream patchFileIn,
SmallPatchedDexItemFile extraInfoFile) throws IOException {
this(
new Dex(oldDexIn, initDexSize),
(patchFileIn != null ? new DexPatchFile(patchFileIn) : null),
extraInfoFile
);}
构造成生一个老的Dex文件,一个DexPatchFile文件,一个SmallPatchedDexItemFile文件。
executeAndSaveTo(OutputStream out)分块合成算法,合成后,存储在outputStream里面。