com.android.dex.MethodId Java Examples

The following examples show how to use com.android.dex.MethodId. 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: Grep.java    From Box with Apache License 2.0 5 votes vote down vote up
private 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;
    }
}
 
Example #2
Source File: DexIndexPrinter.java    From buck with Apache License 2.0 5 votes vote down vote up
private void printMethodIds() throws IOException {
    int index = 0;
    for (MethodId methodId : dex.methodIds()) {
        System.out.println("methodId " + index + ": " + methodId);
        index++;
    }
}
 
Example #3
Source File: FindUsages.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the methods with {@code memberNameIndex} declared by {@code
 * declaringType} and its subtypes.
 */
private Set<Integer> getMethodIds(Dex dex, Set<Integer> memberNameIndexes, int declaringType) {
    Set<Integer> subtypes = findAssignableTypes(dex, declaringType);

    Set<Integer> methods = new HashSet<Integer>();
    int methodIndex = 0;
    for (MethodId method : dex.methodIds()) {
        if (memberNameIndexes.contains(method.getNameIndex())
                && subtypes.contains(method.getDeclaringClassIndex())) {
            methods.add(methodIndex);
        }
        methodIndex++;
    }
    return methods;
}
 
Example #4
Source File: FindUsages.java    From buck with Apache License 2.0 5 votes vote down vote up
private 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;
    }
}
 
Example #5
Source File: Grep.java    From buck with Apache License 2.0 5 votes vote down vote up
private 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;
    }
}
 
Example #6
Source File: DexLimitTracker.java    From bazel with Apache License 2.0 5 votes vote down vote up
static MethodDescriptor fromDex(Dex dex, int methodIndex) {
  MethodId method = dex.methodIds().get(methodIndex);
  ProtoId proto = dex.protoIds().get(method.getProtoIndex());
  String name = dex.strings().get(method.getNameIndex());
  String declaringClass = typeName(dex, method.getDeclaringClassIndex());
  String returnType = typeName(dex, proto.getReturnTypeIndex());
  TypeList parameterTypeIndices = dex.readTypeList(proto.getParametersOffset());
  ImmutableList.Builder<String> parameterTypes = ImmutableList.builder();
  for (short parameterTypeIndex : parameterTypeIndices.getTypes()) {
    parameterTypes.add(typeName(dex, parameterTypeIndex & 0xFFFF));
  }
  return new AutoValue_DexLimitTracker_MethodDescriptor(
      declaringClass, name, parameterTypes.build(), returnType);
}
 
Example #7
Source File: DexIndexPrinter.java    From Box with Apache License 2.0 5 votes vote down vote up
private void printMethodIds() throws IOException {
    int index = 0;
    for (MethodId methodId : dex.methodIds()) {
        System.out.println("methodId " + index + ": " + methodId);
        index++;
    }
}
 
Example #8
Source File: FindUsages.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the methods with {@code memberNameIndex} declared by {@code
 * declaringType} and its subtypes.
 */
private Set<Integer> getMethodIds(Dex dex, Set<Integer> memberNameIndexes, int declaringType) {
    Set<Integer> subtypes = findAssignableTypes(dex, declaringType);

    Set<Integer> methods = new HashSet<Integer>();
    int methodIndex = 0;
    for (MethodId method : dex.methodIds()) {
        if (memberNameIndexes.contains(method.getNameIndex())
                && subtypes.contains(method.getDeclaringClassIndex())) {
            methods.add(methodIndex);
        }
        methodIndex++;
    }
    return methods;
}
 
Example #9
Source File: FindUsages.java    From Box with Apache License 2.0 5 votes vote down vote up
private 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;
    }
}
 
Example #10
Source File: MethodInfo.java    From Box with Apache License 2.0 5 votes vote down vote up
private MethodInfo(DexNode dex, int mthIndex) {
	MethodId mthId = dex.getMethodId(mthIndex);
	name = dex.getString(mthId.getNameIndex());
	alias = name;
	aliasFromPreset = false;
	declClass = ClassInfo.fromDex(dex, mthId.getDeclaringClassIndex());

	ProtoId proto = dex.getProtoId(mthId.getProtoIndex());
	retType = dex.getType(proto.getReturnTypeIndex());
	args = dex.readParamList(proto.getParametersOffset());
	shortId = makeSignature(true);
}
 
Example #11
Source File: MethodInfo.java    From Box with Apache License 2.0 5 votes vote down vote up
private MethodInfo(DexNode dex, int mthIndex) {
	MethodId mthId = dex.getMethodId(mthIndex);
	name = dex.getString(mthId.getNameIndex());
	alias = name;
	aliasFromPreset = false;
	declClass = ClassInfo.fromDex(dex, mthId.getDeclaringClassIndex());

	ProtoId proto = dex.getProtoId(mthId.getProtoIndex());
	retType = dex.getType(proto.getReturnTypeIndex());
	args = dex.readParamList(proto.getParametersOffset());
	shortId = makeSignature(true);
}
 
Example #12
Source File: DexIndexPrinter.java    From Box with Apache License 2.0 5 votes vote down vote up
private void printMethodIds() throws IOException {
    int index = 0;
    for (MethodId methodId : dex.methodIds()) {
        System.out.println("methodId " + index + ": " + methodId);
        index++;
    }
}
 
Example #13
Source File: FindUsages.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the methods with {@code memberNameIndex} declared by {@code
 * declaringType} and its subtypes.
 */
private Set<Integer> getMethodIds(Dex dex, Set<Integer> memberNameIndexes, int declaringType) {
    Set<Integer> subtypes = findAssignableTypes(dex, declaringType);

    Set<Integer> methods = new HashSet<Integer>();
    int methodIndex = 0;
    for (MethodId method : dex.methodIds()) {
        if (memberNameIndexes.contains(method.getNameIndex())
                && subtypes.contains(method.getDeclaringClassIndex())) {
            methods.add(methodIndex);
        }
        methodIndex++;
    }
    return methods;
}
 
Example #14
Source File: FindUsages.java    From Box with Apache License 2.0 5 votes vote down vote up
private 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;
    }
}
 
Example #15
Source File: Grep.java    From Box with Apache License 2.0 5 votes vote down vote up
private 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;
    }
}
 
Example #16
Source File: IndexMap.java    From Box with Apache License 2.0 4 votes vote down vote up
public MethodId adjust(MethodId methodId) {
    return new MethodId(target,
            adjustType(methodId.getDeclaringClassIndex()),
            adjustProto(methodId.getProtoIndex()),
            adjustString(methodId.getNameIndex()));
}
 
Example #17
Source File: DexNode.java    From Box with Apache License 2.0 4 votes vote down vote up
public MethodId getMethodId(int mthIndex) {
	return dexBuf.methodIds().get(mthIndex);
}
 
Example #18
Source File: IndexMap.java    From buck with Apache License 2.0 4 votes vote down vote up
public MethodId adjust(MethodId methodId) {
    return new MethodId(target,
            adjustType(methodId.getDeclaringClassIndex()),
            adjustProto(methodId.getProtoIndex()),
            adjustString(methodId.getNameIndex()));
}
 
Example #19
Source File: IndexMap.java    From Box with Apache License 2.0 4 votes vote down vote up
public MethodId adjust(MethodId methodId) {
    return new MethodId(target,
            adjustType(methodId.getDeclaringClassIndex()),
            adjustProto(methodId.getProtoIndex()),
            adjustString(methodId.getNameIndex()));
}
 
Example #20
Source File: DexNode.java    From Box with Apache License 2.0 4 votes vote down vote up
public MethodId getMethodId(int mthIndex) {
	return dexBuf.methodIds().get(mthIndex);
}