本文整理汇总了Java中org.jf.dexlib2.dexbacked.DexBackedMethod类的典型用法代码示例。如果您正苦于以下问题:Java DexBackedMethod类的具体用法?Java DexBackedMethod怎么用?Java DexBackedMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DexBackedMethod类属于org.jf.dexlib2.dexbacked包,在下文中一共展示了DexBackedMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compare
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
private static boolean compare(DexBackedMethod dexBackedMethod, DexBackedMethod sDexBackedMethod) {
if (dexBackedMethod == null || sDexBackedMethod == null || dexBackedMethod.getName() == null || sDexBackedMethod.getName() == null) {
return false;
}
if (dexBackedMethod.getName().equals(sDexBackedMethod.getName())) {
List<String> parameters = dexBackedMethod.getParameterTypes();
List<String> sParameters = sDexBackedMethod.getParameterTypes();
if (parameters.size() != sParameters.size()) {
return false;
}
for (String param : parameters) {
if (!sParameters.contains(param)) {
return false;
}
}
return true;
}
return false;
}
示例2: filterMethod
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
@Override
public boolean filterMethod(MethodDiffInfo methodDiffInfo) throws PatchException {
DexBackedMethod dexBackedMethod = methodDiffInfo.getBackedMethod();
if (dexBackedMethod.getName().equals("<clinit>") || dexBackedMethod.getName().contains("ajc$preClinit")||dexBackedMethod.getName().equals("<init>")||dexBackedMethod.getName().contains("access$")) {
return true;
}
if (methodDiffInfo.getType().equals(DiffType.REMOVE)) {
return true;
} else if (methodDiffInfo.getType().equals(DiffType.ADD)){
throw new PatchException("can't add method:" + dexBackedMethod.getName() + " in class:" + dexBackedMethod.getDefiningClass());
}
if (dexBackedMethod.getParameters().size() > 8) {
throw new PatchException("can't patch method:" + dexBackedMethod.getName() + "has Parameters above 8 in class:"+dexBackedMethod.getDefiningClass());
}
if (dexBackedMethod.getParameterTypes().contains("J") || dexBackedMethod.getParameterTypes().contains("D") || dexBackedMethod.getParameterTypes().contains("F")) {
throw new PatchException("can't patch method:" + dexBackedMethod.getName() + "has ParameterType long,double or float in class:"+dexBackedMethod.getDefiningClass());
}
return false;
}
示例3: DexMethod
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public DexMethod(DexBackedMethod method, boolean fullMethodSignatures) {
this.fullMethodSignatures = fullMethodSignatures;
this.method = method;
opCounts = new TObjectIntHashMap<>();
apiCounts = new TObjectIntHashMap<>();
stringReferenceCounts = new TObjectIntHashMap<>();
fieldReferenceCounts = new TObjectIntHashMap<>();
annotationCount = method.getAnnotations().size();
if (method.getImplementation() != null) {
analyze(method.getImplementation());
}
methodAccessors = buildAccessors(method.getAccessFlags());
}
示例4: analyze
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
private void analyze() {
fieldCount = Utils.makeCollection(classDef.getFields()).size();
for (DexBackedMethod dbm : classDef.getMethods()) {
DexMethod dexMethod;
try {
dexMethod = new DexMethod(dbm, fullMethodSignatures);
failedMethods += 1;
} catch (Exception e) {
Logger.warn("Failed to analyze method: " + ReferenceUtil.getMethodDescriptor(dbm) + "; skipping", e);
continue;
}
String methodDescriptor = ReferenceUtil.getMethodDescriptor(dbm);
String methodSignature = methodDescriptor.split("->", 2)[1];
methodSignatureToMethod.put(methodSignature, dexMethod);
Utils.rollUp(opCounts, dexMethod.getOpCounts());
Utils.rollUp(apiCounts, dexMethod.getApiCounts());
Utils.rollUp(stringReferenceCounts, dexMethod.getStringReferenceCounts());
Utils.rollUp(fieldReferenceCounts, dexMethod.getFieldReferenceCounts());
Utils.rollUp(methodAccessorCounts, dexMethod.getMethodAccessors());
annotationCount += dexMethod.getAnnotationCount();
registerCount += dexMethod.getRegisterCount();
instructionCount += dexMethod.getInstructionCount();
tryCatchCount += dexMethod.getTryCatchCount();
debugItemCount += dexMethod.getDebugItemCount();
cyclomaticComplexity += dexMethod.getCyclomaticComplexity();
}
if (!methodSignatureToMethod.isEmpty()) {
cyclomaticComplexity /= methodSignatureToMethod.size();
}
}
示例5: getMethodAnnotaionPrepareClasses
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public static void getMethodAnnotaionPrepareClasses(DexDiffInfo dexDiffInfo, Set<String> prepareclasses){
for (DexBackedMethod method:dexDiffInfo.getModifiedMethods()){
Set<? extends Annotation>annotations = method.getAnnotations();
if (annotations == null){
continue;
}
for (Annotation annotation:annotations){
String type = annotation.getType();
if (type!= null&&type.startsWith("L")&&type.endsWith(";")){
prepareclasses.add(type.substring(1, type.length() - 1).replace('/', '.'));
System.out.println("prepare class: " + type);
}
Set<? extends AnnotationElement> elements = annotation.getElements();
for (AnnotationElement dexBackedAnnotationElement:elements){
if (dexBackedAnnotationElement.getValue() instanceof DexBackedArrayEncodedValue){
List<? extends EncodedValue> values = ((DexBackedArrayEncodedValue) dexBackedAnnotationElement.getValue()).getValue();
for (EncodedValue encodedValue:values) {
if (encodedValue instanceof TypeEncodedValue) {
prepareclasses.add(((TypeEncodedValue) encodedValue).getValue().substring(1, ((TypeEncodedValue) encodedValue).getValue().length() - 1).replace('/', '.'));
System.out.println("prepare class: " + ((TypeEncodedValue) encodedValue).getValue());
}
}
}else if (dexBackedAnnotationElement.getValue() instanceof DexBackedTypeEncodedValue){
String value = ((DexBackedTypeEncodedValue) dexBackedAnnotationElement.getValue()).getValue();
prepareclasses.add(value.substring(1, value.length() - 1).replace('/', '.'));
System.out.println("prepare class: " + value);
}
}
}
}
}
示例6: addModifiedMethods
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public void addModifiedMethods(DexBackedMethod method) throws PatchException {
System.out.println("add modified Method:" + method.getReturnType()
+ " " + method.getName() + "("
+ Formater.formatStringList(method.getParameterTypes())
+ ") in Class:" + method.getDefiningClass());
this.modifiedMethods.add(method);
if (!modifiedClasses.contains(method.classDef)) {
modifiedClasses.add(method.classDef);
String className = method.classDef.getType();
addManifestModifiedClass(className);
}
}
示例7: getMethod
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
private static DexBackedMethod getMethod(
DexBackedClassDef classDef,
String methodName) {
for (DexBackedMethod method : classDef.getVirtualMethods()) {
String matchName = method.getName();
if (matchName.equals(methodName)) {
return method;
}
}
return null;
}
示例8: getMethod
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public DexBackedMethod getMethod() {
return method;
}
示例9: buildPrepareClass
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
private static Set<String> buildPrepareClass(File smaliDir, List<File> newFiles,
DexDiffInfo info) throws PatchException {
Set<DexBackedClassDef> classes = Sets.newHashSet();
classes = SmaliDiffUtils.scanClasses(smaliDir, newFiles);
ArrayList<String> methods = new ArrayList<String>();
{
Set<DexBackedMethod> tempSet = info.getModifiedMethods();
for (DexBackedMethod methodRef : tempSet) {
String template = methodRef.getDefiningClass() + "->" + methodRef.getName();
methods.add(template);
System.out.println("template: " + template);
if (superClasses.containsKey(methodRef.getDefiningClass())) {
ArrayList<String> derivedClasses = superClasses.get(methodRef.getDefiningClass());
for (int i = 0; i < derivedClasses.size(); i++) {
template = derivedClasses.get(i) + "->" + methodRef.getName();
System.out.println("template: " + template);
methods.add(template);
}
}
}
}
Set<String> prepareClasses = new HashSet<String>();
try {
final ClassFileNameHandler inFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
for (DexBackedClassDef classDef : classes) {
currentClassType = null;
String className = TypeGenUtil.newType(classDef.getType());
// baksmali.disassembleClass(classDef, outFileNameHandler, options);
File smaliFile = inFileNameHandler.getUniqueFilenameForClass(className);
if (!smaliFile.exists()){
continue;
}
//增加class注解到prepare
getClassAnnotaionPrepareClasses(classDef,prepareClasses,info);
BufferedReader br = new BufferedReader(new FileReader(smaliFile));
String data = br.readLine();// 一次读入一行,直到读入null为文件结束
while (data != null) {
boolean find = false;
for (String m : methods) {
if (data.contains(m)) {
find = true;
break;
}
}
if (find) {
prepareClasses.add(className.substring(1, className.length() - 1).replace('/', '.'));
System.out.println("prepare class: " + className);
break;
}
data = br.readLine(); // 接着读下一行
}
br.close();
}
} catch (Exception e) {
throw new PatchException(e);
}
for (DexBackedMethod method:info.getModifiedMethods()) {
prepareClasses.add(method.getDefiningClass().substring(1, method.getDefiningClass().length() - 1).replace("/", "."));
}
//增加modify的anatation到prepare
// getMethodAnnotaionPrepareClasses(info,prepareClasses);
return prepareClasses;
}
示例10: getBackedMethod
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public DexBackedMethod getBackedMethod() {
return backedMethod;
}
示例11: setBackedMethod
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public void setBackedMethod(DexBackedMethod backedMethod) {
this.backedMethod = backedMethod;
}
示例12: getModifiedMethods
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public Set<DexBackedMethod> getModifiedMethods() {
return modifiedMethods;
}
示例13: getAddedMethods
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public Set<DexBackedMethod> getAddedMethods() {
return addedMethods;
}
示例14: addMethod
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
public void addMethod(int transactionId, String methodName, DexBackedMethod method) {
String dottedReturnType = Utils.descriptorToDot(method.getReturnType());
/* Update imports for return type */
this.addImport(dottedReturnType);
String shortReturnType = Utils.getShort(dottedReturnType);
/* Args */
String paramString = makeParamString(method);
String methodString = " " + shortReturnType + " " + methodName + "(" + paramString + ");";
/* Add to the array list */
this.methods.put(transactionId, methodString);
}
示例15: processDex
import org.jf.dexlib2.dexbacked.DexBackedMethod; //导入依赖的package包/类
private static int processDex(String outputDirectory) {
int rtn = 0;
int i = 0;
Set<? extends DexBackedClassDef> classDefs = gDexFile.getClasses();
/* Find all IInterfaces first */
for (DexBackedClassDef classDef: classDefs) {
String className = Utils.descriptorToDot(classDef.getType());
/* No support AIDL */
if (className.startsWith("android.support")) {
continue;
}
SortedSet<String> interfaces = new TreeSet(classDef.getInterfaces());
if (interfaces.size() != 1) {
continue;
}
/* Getting here is a valid AIDL (or so we think) */
if (Utils.descriptorToDot(interfaces.first()).equals(IINTERFACE_CLASS)) {
/* First find the Stub and get a list of transactions */
String stubName = className + ".Stub";
String stubProxyName = className + ".Stub.Proxy";
DexBackedClassDef stubDef = getClassDef(classDefs, stubName);
DexBackedClassDef stubProxyDef = getClassDef(classDefs, stubProxyName);
if (stubDef == null) {
System.err.println("[ERROR] Unable to find Stub for class: "
+ stubName + ", Skiping!");
continue;
}
if (stubProxyDef == null) {
System.err.println("[ERROR] Unable to find Stub.Proxy for class: "
+ stubProxyName + ", Skiping!");
continue;
}
AidlFile aidl = new AidlFile(className, outputDirectory);
/* Next, we need all the transactions for this. */
for (DexBackedField field : stubDef.getStaticFields()) {
if (field.getName().startsWith("TRANSACTION_")) {
String methodName = field.getName().replace("TRANSACTION_", "");
/* Transaction ID for sorting */
EncodedValue iiev = field.getInitialValue();
int transactionId = ((IntEncodedValue) iiev).getValue();
/* Get the Stub.Proxy method (which has return + args) */
DexBackedMethod method = getMethod(stubProxyDef, methodName);
aidl.addMethod(transactionId, methodName, method);
}
}
/* Write it out. */
aidl.writeFile();
}
}
return rtn;
}