本文整理汇总了Java中org.jf.util.ClassFileNameHandler类的典型用法代码示例。如果您正苦于以下问题:Java ClassFileNameHandler类的具体用法?Java ClassFileNameHandler怎么用?Java ClassFileNameHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassFileNameHandler类属于org.jf.util包,在下文中一共展示了ClassFileNameHandler类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildCode
import org.jf.util.ClassFileNameHandler; //导入依赖的package包/类
public static Set<String> buildCode(File smaliDir, File dexFile, DexDiffInfo info) throws IOException,
RecognitionException {
Set<String> classes = new HashSet<String>();
Set<DexBackedClassDef> classDefs = new HashSet<DexBackedClassDef>();
classDefs.addAll(info.getModifiedClasses());
classDefs.addAll(info.getAddedClasses());
final ClassFileNameHandler outFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
final ClassFileNameHandler inFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
DexBuilder dexBuilder = DexBuilder.makeDexBuilder();
File smaliFile;
String className;
for (DexBackedClassDef classDef : classDefs) {
ApkPatch.currentClassType = classDef.getType();
className = TypeGenUtil.newType(classDef.getType());
AfBakSmali.disassembleClass(classDef, outFileNameHandler, getBuildOption(classDefs, 19), false, false);
smaliFile = inFileNameHandler.getUniqueFilenameForClass(className);
classes.add(className.substring(1, className.length() - 1).replace('/', '.'));
SmaliMod.assembleSmaliFile(smaliFile, dexBuilder, true, true);
}
dexBuilder.writeTo(new FileDataStore(dexFile));
return classes;
}
示例2: scanClasses
import org.jf.util.ClassFileNameHandler; //导入依赖的package包/类
public static Set<DexBackedClassDef> scanClasses(File smaliDir, List<File> newFiles) throws PatchException {
Set<DexBackedClassDef> classes = Sets.newHashSet();
try {
for (File newFile : newFiles) {
DexBackedDexFile newDexFile = DexFileFactory.loadDexFile(newFile, 19, true);
Set<? extends DexBackedClassDef> dexClasses = newDexFile.getClasses();
classes.addAll(dexClasses);
}
final ClassFileNameHandler outFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
final ClassFileNameHandler inFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
for (DexBackedClassDef classDef : classes) {
String className = classDef.getType();
ApkPatch.currentClassType = null;
AfBakSmali.disassembleClass(classDef, outFileNameHandler, getBuildOption(classes, 19), true, true);
File smaliFile = inFileNameHandler.getUniqueFilenameForClass(className);
}
} catch (Exception e) {
throw new PatchException(e);
}
return classes;
}
示例3: disassemble
import org.jf.util.ClassFileNameHandler; //导入依赖的package包/类
public static File disassemble(File smaliDir, DexBackedClassDef dexBackedClassDef) throws PatchException {
Set<DexBackedClassDef> classes = Sets.newHashSet();
classes.add(dexBackedClassDef);
final ClassFileNameHandler outFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
final ClassFileNameHandler inFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
String className = dexBackedClassDef.getType();
AfBakSmali.disassembleClass(dexBackedClassDef, outFileNameHandler, getBuildOption(classes, 19), true, false);
File smaliFile = inFileNameHandler.getUniqueFilenameForClass(className);
return smaliFile;
}
示例4: buildPrepareClass
import org.jf.util.ClassFileNameHandler; //导入依赖的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;
}