Java Code Examples for com.android.dex.Dex#getNextSectionStart()

The following examples show how to use com.android.dex.Dex#getNextSectionStart() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DexMerger.java    From Box with Apache License 2.0 4 votes vote down vote up
private DexMerger(Dex[] dexes, CollisionPolicy collisionPolicy, DxContext context,
        WriterSizes writerSizes) throws IOException {
    this.dexes = dexes;
    this.collisionPolicy = collisionPolicy;
    this.context = context;
    this.writerSizes = writerSizes;

    dexOut = new Dex(writerSizes.size());

    indexMaps = new IndexMap[dexes.length];
    for (int i = 0; i < dexes.length; i++) {
        indexMaps[i] = new IndexMap(dexOut, dexes[i].getTableOfContents());
    }
    instructionTransformer = new InstructionTransformer();

    headerOut = dexOut.appendSection(writerSizes.header, "header");
    idsDefsOut = dexOut.appendSection(writerSizes.idsDefs, "ids defs");

    contentsOut = dexOut.getTableOfContents();
    contentsOut.dataOff = dexOut.getNextSectionStart();

    contentsOut.mapList.off = dexOut.getNextSectionStart();
    contentsOut.mapList.size = 1;
    mapListOut = dexOut.appendSection(writerSizes.mapList, "map list");

    contentsOut.typeLists.off = dexOut.getNextSectionStart();
    typeListOut = dexOut.appendSection(writerSizes.typeList, "type list");

    contentsOut.annotationSetRefLists.off = dexOut.getNextSectionStart();
    annotationSetRefListOut = dexOut.appendSection(
            writerSizes.annotationsSetRefList, "annotation set ref list");

    contentsOut.annotationSets.off = dexOut.getNextSectionStart();
    annotationSetOut = dexOut.appendSection(writerSizes.annotationsSet, "annotation sets");

    contentsOut.classDatas.off = dexOut.getNextSectionStart();
    classDataOut = dexOut.appendSection(writerSizes.classData, "class data");

    contentsOut.codes.off = dexOut.getNextSectionStart();
    codeOut = dexOut.appendSection(writerSizes.code, "code");

    contentsOut.stringDatas.off = dexOut.getNextSectionStart();
    stringDataOut = dexOut.appendSection(writerSizes.stringData, "string data");

    contentsOut.debugInfos.off = dexOut.getNextSectionStart();
    debugInfoOut = dexOut.appendSection(writerSizes.debugInfo, "debug info");

    contentsOut.annotations.off = dexOut.getNextSectionStart();
    annotationOut = dexOut.appendSection(writerSizes.annotation, "annotation");

    contentsOut.encodedArrays.off = dexOut.getNextSectionStart();
    encodedArrayOut = dexOut.appendSection(writerSizes.encodedArray, "encoded array");

    contentsOut.annotationsDirectories.off = dexOut.getNextSectionStart();
    annotationsDirectoryOut = dexOut.appendSection(
            writerSizes.annotationsDirectory, "annotations directory");

    contentsOut.dataSize = dexOut.getNextSectionStart() - contentsOut.dataOff;
}
 
Example 2
Source File: DexMerger.java    From Box with Apache License 2.0 4 votes vote down vote up
private DexMerger(Dex[] dexes, CollisionPolicy collisionPolicy, DxContext context,
        WriterSizes writerSizes) throws IOException {
    this.dexes = dexes;
    this.collisionPolicy = collisionPolicy;
    this.context = context;
    this.writerSizes = writerSizes;

    dexOut = new Dex(writerSizes.size());

    indexMaps = new IndexMap[dexes.length];
    for (int i = 0; i < dexes.length; i++) {
        indexMaps[i] = new IndexMap(dexOut, dexes[i].getTableOfContents());
    }
    instructionTransformer = new InstructionTransformer();

    headerOut = dexOut.appendSection(writerSizes.header, "header");
    idsDefsOut = dexOut.appendSection(writerSizes.idsDefs, "ids defs");

    contentsOut = dexOut.getTableOfContents();
    contentsOut.dataOff = dexOut.getNextSectionStart();

    contentsOut.mapList.off = dexOut.getNextSectionStart();
    contentsOut.mapList.size = 1;
    mapListOut = dexOut.appendSection(writerSizes.mapList, "map list");

    contentsOut.typeLists.off = dexOut.getNextSectionStart();
    typeListOut = dexOut.appendSection(writerSizes.typeList, "type list");

    contentsOut.annotationSetRefLists.off = dexOut.getNextSectionStart();
    annotationSetRefListOut = dexOut.appendSection(
            writerSizes.annotationsSetRefList, "annotation set ref list");

    contentsOut.annotationSets.off = dexOut.getNextSectionStart();
    annotationSetOut = dexOut.appendSection(writerSizes.annotationsSet, "annotation sets");

    contentsOut.classDatas.off = dexOut.getNextSectionStart();
    classDataOut = dexOut.appendSection(writerSizes.classData, "class data");

    contentsOut.codes.off = dexOut.getNextSectionStart();
    codeOut = dexOut.appendSection(writerSizes.code, "code");

    contentsOut.stringDatas.off = dexOut.getNextSectionStart();
    stringDataOut = dexOut.appendSection(writerSizes.stringData, "string data");

    contentsOut.debugInfos.off = dexOut.getNextSectionStart();
    debugInfoOut = dexOut.appendSection(writerSizes.debugInfo, "debug info");

    contentsOut.annotations.off = dexOut.getNextSectionStart();
    annotationOut = dexOut.appendSection(writerSizes.annotation, "annotation");

    contentsOut.encodedArrays.off = dexOut.getNextSectionStart();
    encodedArrayOut = dexOut.appendSection(writerSizes.encodedArray, "encoded array");

    contentsOut.annotationsDirectories.off = dexOut.getNextSectionStart();
    annotationsDirectoryOut = dexOut.appendSection(
            writerSizes.annotationsDirectory, "annotations directory");

    contentsOut.dataSize = dexOut.getNextSectionStart() - contentsOut.dataOff;
}
 
Example 3
Source File: DexMerger.java    From buck with Apache License 2.0 4 votes vote down vote up
private DexMerger(Dex[] dexes, CollisionPolicy collisionPolicy, DxContext context,
        WriterSizes writerSizes) throws IOException {
    this.dexes = dexes;
    this.collisionPolicy = collisionPolicy;
    this.context = context;
    this.writerSizes = writerSizes;

    dexOut = new Dex(writerSizes.size());

    indexMaps = new IndexMap[dexes.length];
    for (int i = 0; i < dexes.length; i++) {
        indexMaps[i] = new IndexMap(dexOut, dexes[i].getTableOfContents());
    }
    instructionTransformer = new InstructionTransformer();

    headerOut = dexOut.appendSection(writerSizes.header, "header");
    idsDefsOut = dexOut.appendSection(writerSizes.idsDefs, "ids defs");

    contentsOut = dexOut.getTableOfContents();
    contentsOut.dataOff = dexOut.getNextSectionStart();

    contentsOut.mapList.off = dexOut.getNextSectionStart();
    contentsOut.mapList.size = 1;
    mapListOut = dexOut.appendSection(writerSizes.mapList, "map list");

    contentsOut.typeLists.off = dexOut.getNextSectionStart();
    typeListOut = dexOut.appendSection(writerSizes.typeList, "type list");

    contentsOut.annotationSetRefLists.off = dexOut.getNextSectionStart();
    annotationSetRefListOut = dexOut.appendSection(
            writerSizes.annotationsSetRefList, "annotation set ref list");

    contentsOut.annotationSets.off = dexOut.getNextSectionStart();
    annotationSetOut = dexOut.appendSection(writerSizes.annotationsSet, "annotation sets");

    contentsOut.classDatas.off = dexOut.getNextSectionStart();
    classDataOut = dexOut.appendSection(writerSizes.classData, "class data");

    contentsOut.codes.off = dexOut.getNextSectionStart();
    codeOut = dexOut.appendSection(writerSizes.code, "code");

    contentsOut.stringDatas.off = dexOut.getNextSectionStart();
    stringDataOut = dexOut.appendSection(writerSizes.stringData, "string data");

    contentsOut.debugInfos.off = dexOut.getNextSectionStart();
    debugInfoOut = dexOut.appendSection(writerSizes.debugInfo, "debug info");

    contentsOut.annotations.off = dexOut.getNextSectionStart();
    annotationOut = dexOut.appendSection(writerSizes.annotation, "annotation");

    contentsOut.encodedArrays.off = dexOut.getNextSectionStart();
    encodedArrayOut = dexOut.appendSection(writerSizes.encodedArray, "encoded array");

    contentsOut.annotationsDirectories.off = dexOut.getNextSectionStart();
    annotationsDirectoryOut = dexOut.appendSection(
            writerSizes.annotationsDirectory, "annotations directory");

    contentsOut.dataSize = dexOut.getNextSectionStart() - contentsOut.dataOff;
}