Java Code Examples for org.jf.dexlib2.dexbacked.DexBackedMethod#getName()
The following examples show how to use
org.jf.dexlib2.dexbacked.DexBackedMethod#getName() .
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: SmaliDiffUtils.java From atlas with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: AndFixFilterImpl.java From atlas with Apache License 2.0 | 6 votes |
@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; }
Example 3
Source File: ApkPatch.java From atlas with Apache License 2.0 | 4 votes |
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; }