public int findClassDefIndexFromTypeIndex(int typeIndex) { checkBounds(typeIndex, tableOfContents.typeIds.size); if (!tableOfContents.classDefs.exists()) { return -1; } for (int i = 0; i < tableOfContents.classDefs.size; i++) { if (typeIndexFromClassDefIndex(i) == typeIndex) { return i; } } return -1; }
@Override public ProtoId get(int index) { checkBounds(index, tableOfContents.protoIds.size); return openSection(tableOfContents.protoIds.off + (SizeOf.PROTO_ID_ITEM * index)) .readProtoId(); } @Override public int size() {
public int readEnum() { checkType(ENCODED_ENUM); type = MUST_READ; return EncodedValueCodec.readUnsignedInt(in, arg, false); }
/** * Generates the signature and checksum of the dex file {@code out} and * writes them to the file. */ public void writeHashes() throws IOException { openSection(SIGNATURE_OFFSET).write(computeSignature(true)); openSection(CHECKSUM_OFFSET).writeInt(computeChecksum()); }
public int getTypeIndex() { EncodedValueReader reader = getReader(); reader.readAnnotation(); return reader.getAnnotationType(); }
public void readFrom(Dex dex) throws IOException { readHeader(dex.openSection(header)); // special case, since mapList.byteCount is available only after // computeSizesFromOffsets() was invoked, so here we can't use // dex.openSection(mapList) to get dex section. Or // an {@code java.nio.BufferUnderflowException} will be thrown. readMap(dex.openSection(mapList.off)); computeSizesFromOffsets(); }
@Override public String get(int index) { checkBounds(index, tableOfContents.stringIds.size); int stringOff = openSection(tableOfContents.stringIds.off + (index * SizeOf.STRING_ID_ITEM)).readInt(); return openSection(stringOff).readStringData().value; } @Override public int size() {
@Override public FieldId get(int index) { checkBounds(index, tableOfContents.fieldIds.size); return openSection(tableOfContents.fieldIds.off + (SizeOf.MEMBER_ID_ITEM * index)) .readFieldId(); } @Override public int size() {
@Override public MethodId get(int index) { checkBounds(index, tableOfContents.methodIds.size); return openSection(tableOfContents.methodIds.off + (SizeOf.MEMBER_ID_ITEM * index)) .readMethodId(); } @Override public int size() {
@Override public ClassDef get(int index) { checkBounds(index, tableOfContents.classDefs.size); return openSection(tableOfContents.classDefs.off + (SizeOf.CLASS_DEF_ITEM * index)) .readClassDef(); }
@Override public int byteCountInDex() { int res = Leb128.unsignedLeb128Size(staticFields.length); res += Leb128.unsignedLeb128Size(instanceFields.length); res += Leb128.unsignedLeb128Size(directMethods.length); res += Leb128.unsignedLeb128Size(virtualMethods.length); res += calcFieldsSize(staticFields); res += calcFieldsSize(instanceFields); res += calcMethodsSize(directMethods); res += calcMethodsSize(virtualMethods); return res; }
public int readInt() { checkType(ENCODED_INT); type = MUST_READ; return EncodedValueCodec.readSignedInt(in, arg); }
public long readLong() { checkType(ENCODED_LONG); type = MUST_READ; return EncodedValueCodec.readSignedLong(in, arg); }
public int readMethod() { checkType(ENCODED_METHOD); type = MUST_READ; return EncodedValueCodec.readUnsignedInt(in, arg, false); }
public byte readByte() { checkType(ENCODED_BYTE); type = MUST_READ; return (byte) EncodedValueCodec.readSignedInt(in, arg); }
public int readField() { checkType(ENCODED_FIELD); type = MUST_READ; return EncodedValueCodec.readUnsignedInt(in, arg, false); }
public short readShort() { checkType(ENCODED_SHORT); type = MUST_READ; return (short) EncodedValueCodec.readSignedInt(in, arg); }
public int readString() { checkType(ENCODED_STRING); type = MUST_READ; return EncodedValueCodec.readUnsignedInt(in, arg, false); }
public int readType() { checkType(ENCODED_TYPE); type = MUST_READ; return EncodedValueCodec.readUnsignedInt(in, arg, false); }
public char readChar() { checkType(ENCODED_CHAR); type = MUST_READ; return (char) EncodedValueCodec.readUnsignedInt(in, arg, false); }