Tinker源碼分析三

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里面。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容