Methods Summary |
---|
private void | encounterString(int index)
if (stringIds.contains(index)) {
out.println(location() + " " + dex.strings().get(index));
count++;
}
|
private java.util.Set | getStringIds(com.android.dex.Dex dex, java.util.regex.Pattern pattern)
Set<Integer> stringIds = new HashSet<Integer>();
int stringIndex = 0;
for (String s : dex.strings()) {
if (pattern.matcher(s).find()) {
stringIds.add(stringIndex);
}
stringIndex++;
}
return stringIds;
|
public int | grep()Prints usages to out. Returns the number of matches found.
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;
|
private java.lang.String | location()
String className = dex.typeNames().get(currentClass.getTypeIndex());
if (currentMethod != null) {
MethodId methodId = dex.methodIds().get(currentMethod.getMethodIndex());
return className + "." + dex.strings().get(methodId.getNameIndex());
} else {
return className;
}
|
private void | readArray(com.android.dex.EncodedValueReader reader)
for (int i = 0, size = reader.readArray(); i < size; i++) {
switch (reader.peek()) {
case EncodedValueReader.ENCODED_STRING:
encounterString(reader.readString());
break;
case EncodedValueReader.ENCODED_ARRAY:
readArray(reader);
break;
}
}
|