Search in sources :

Example 1 with EncodedValueReader

use of com.android.dex.EncodedValueReader in project buck by facebook.

the class Grep method grep.

/**
     * Prints usages to out. Returns the number of matches found.
     */
public int grep() {
    for (ClassDef classDef : dex.classDefs()) {
        currentClass = classDef;
        currentMethod = null;
        if (classDef.getClassDataOffset() == 0) {
            continue;
        }
        ClassData classData = dex.readClassData(classDef);
        // find the strings in encoded constants
        int staticValuesOffset = classDef.getStaticValuesOffset();
        if (staticValuesOffset != 0) {
            readArray(new EncodedValueReader(dex.open(staticValuesOffset)));
        }
        // find the strings in method bodies
        for (ClassData.Method method : classData.allMethods()) {
            currentMethod = method;
            if (method.getCodeOffset() != 0) {
                codeReader.visitAll(dex.readCode(method).getInstructions());
            }
        }
    }
    currentClass = null;
    currentMethod = null;
    return count;
}
Also used : ClassDef(com.android.dex.ClassDef) EncodedValueReader(com.android.dex.EncodedValueReader) ClassData(com.android.dex.ClassData)

Example 2 with EncodedValueReader

use of com.android.dex.EncodedValueReader in project buck by facebook.

the class IndexMap method adjustEncodedValue.

public EncodedValue adjustEncodedValue(EncodedValue encodedValue) {
    ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput(32);
    new EncodedValueTransformer(out).transform(new EncodedValueReader(encodedValue));
    return new EncodedValue(out.toByteArray());
}
Also used : EncodedValue(com.android.dex.EncodedValue) EncodedValueReader(com.android.dex.EncodedValueReader) ByteArrayAnnotatedOutput(com.android.dx.util.ByteArrayAnnotatedOutput)

Example 3 with EncodedValueReader

use of com.android.dex.EncodedValueReader in project buck by facebook.

the class IndexMap method adjustEncodedArray.

public EncodedValue adjustEncodedArray(EncodedValue encodedArray) {
    ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput(32);
    new EncodedValueTransformer(out).transformArray(new EncodedValueReader(encodedArray, ENCODED_ARRAY));
    return new EncodedValue(out.toByteArray());
}
Also used : EncodedValue(com.android.dex.EncodedValue) EncodedValueReader(com.android.dex.EncodedValueReader) ByteArrayAnnotatedOutput(com.android.dx.util.ByteArrayAnnotatedOutput)

Aggregations

EncodedValueReader (com.android.dex.EncodedValueReader)3 EncodedValue (com.android.dex.EncodedValue)2 ByteArrayAnnotatedOutput (com.android.dx.util.ByteArrayAnnotatedOutput)2 ClassData (com.android.dex.ClassData)1 ClassDef (com.android.dex.ClassDef)1