use of org.jf.dexlib2.iface.ClassDef in project atlas by alibaba.
the class PatchUtils method getBundleClassDef.
private static Map<String, ClassDef> getBundleClassDef(File file) throws IOException {
HashMap<String, ClassDef> classDefMap = new HashMap<String, ClassDef>();
File[] dexFiles = getDexFiles(file);
HashSet<ClassDef> classDefs = new HashSet<ClassDef>();
for (File dexFile : dexFiles) {
classDefs.addAll(DexFileFactory.loadDexFile(dexFile, 19, true).getClasses());
}
for (ClassDef classDef : classDefs) {
classDefMap.put(classDef.getType(), classDef);
}
return classDefMap;
}
use of org.jf.dexlib2.iface.ClassDef in project atlas by alibaba.
the class PatchUtils method getTpatchClassDef.
public static void getTpatchClassDef(File tpatchFile, Map<String, Map<String, ClassDef>> bundleMap) throws IOException {
if (tpatchFile == null || !tpatchFile.exists()) {
return;
}
File unZipFolder = new File(tpatchFile.getParentFile(), tpatchFile.getName().split("\\.")[0]);
unZipFolder.mkdirs();
ZipUtils.unzip(tpatchFile, unZipFolder.getAbsolutePath());
File[] bundleFolder = unZipFolder.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory() && pathname.getName().startsWith("lib");
}
});
for (File file : bundleFolder) {
Map<String, ClassDef> dexClasses = getBundleClassDef(file);
bundleMap.put(file.getName(), dexClasses);
}
FileUtils.deleteDirectory(tpatchFile.getParentFile());
}
use of org.jf.dexlib2.iface.ClassDef in project atlas by alibaba.
the class SmaliCodeUtils method createBaksmaliOptions.
/**
* 生成解析成smali代码的选项
*
* @return
*/
private static baksmaliOptions createBaksmaliOptions(ClassDef classDef) {
baksmaliOptions options = new baksmaliOptions();
options.deodex = false;
options.noParameterRegisters = false;
options.useLocalsDirective = true;
options.useSequentialLabels = true;
options.outputDebugInfo = true;
options.addCodeOffsets = false;
options.jobs = -1;
options.noAccessorComments = false;
// 128
options.registerInfo = 0;
options.ignoreErrors = false;
options.inlineResolver = null;
options.checkPackagePrivateAccess = false;
options.apiLevel = DEFAULT_API_LEVEL;
List<ClassDef> classDefs = Lists.newArrayList();
classDefs.add(classDef);
options.syntheticAccessorResolver = new SyntheticAccessorResolver(classDefs);
return options;
}
use of org.jf.dexlib2.iface.ClassDef in project android-classyshark by google.
the class StressTest method runAllClassesInDex.
public static void runAllClassesInDex(String jarCanonicalPath) throws Exception {
DexFile dexFile = DexlibLoader.loadDexFile(new File(jarCanonicalPath));
Set<? extends ClassDef> allClassesInDex = dexFile.getClasses();
for (ClassDef currentClass : allClassesInDex) {
String normType = DexlibAdapter.getClassStringFromDex(currentClass.getType());
Translator sourceGenerator = TranslatorFactory.createTranslator(normType, new File(jarCanonicalPath));
sourceGenerator.apply();
System.out.println(sourceGenerator.toString());
}
}
use of org.jf.dexlib2.iface.ClassDef in project android-classyshark by google.
the class DexlibAdapter method getClassDefByName.
public static ClassDef getClassDefByName(String className, DexFile dexFile) throws Exception {
ClassDef result = null;
String dexName;
for (ClassDef currentClassDef : dexFile.getClasses()) {
dexName = currentClassDef.getType();
if (isMatchFromDex(className, dexName)) {
result = currentClassDef;
break;
}
}
return result;
}
Aggregations