mirror of
https://github.com/revanced/Apktool.git
synced 2025-05-07 17:24:25 +02:00
pass api to DexFileFactory
This commit is contained in:
parent
af32d4da3e
commit
fb7fbf0805
@ -66,13 +66,13 @@ public class Androlib {
|
||||
}
|
||||
|
||||
public void decodeSourcesSmali(File apkFile, File outDir, boolean debug, String debugLinePrefix,
|
||||
boolean bakdeb) throws AndrolibException {
|
||||
boolean bakdeb, int api) throws AndrolibException {
|
||||
try {
|
||||
File smaliDir = new File(outDir, SMALI_DIRNAME);
|
||||
OS.rmdir(smaliDir);
|
||||
smaliDir.mkdirs();
|
||||
LOGGER.info("Baksmaling...");
|
||||
SmaliDecoder.decode(apkFile, smaliDir, debug, debugLinePrefix, bakdeb);
|
||||
SmaliDecoder.decode(apkFile, smaliDir, debug, debugLinePrefix, bakdeb, api);
|
||||
} catch (BrutException ex) {
|
||||
throw new AndrolibException(ex);
|
||||
}
|
||||
|
@ -119,13 +119,16 @@ public class ApkDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> sdkInfo = mAndrolib.getResTable(mApkFile).getSdkInfo();
|
||||
int api = (sdkInfo.get("targetSdkVersion") != null) ? Integer.parseInt(sdkInfo.get("targetSdkVersion")) : mDefaultApi;
|
||||
|
||||
if (hasSources()) {
|
||||
switch (mDecodeSources) {
|
||||
case DECODE_SOURCES_NONE:
|
||||
mAndrolib.decodeSourcesRaw(mApkFile, outDir, mDebug);
|
||||
break;
|
||||
case DECODE_SOURCES_SMALI:
|
||||
mAndrolib.decodeSourcesSmali(mApkFile, outDir, mDebug, mDebugLinePrefix, mBakDeb);
|
||||
mAndrolib.decodeSourcesSmali(mApkFile, outDir, mDebug, mDebugLinePrefix, mBakDeb, api);
|
||||
break;
|
||||
case DECODE_SOURCES_JAVA:
|
||||
mAndrolib.decodeSourcesJava(mApkFile, outDir, mDebug);
|
||||
@ -350,6 +353,7 @@ public class ApkDecoder {
|
||||
private String mFrameTag;
|
||||
private boolean mKeepBrokenResources = false;
|
||||
private String mFrameworkDir = null;
|
||||
private int mDefaultApi = 15;
|
||||
private boolean mBakDeb = true;
|
||||
private boolean mCompressResources = false;
|
||||
private boolean mAnalysisMode = false;
|
||||
|
@ -40,17 +40,18 @@ import java.nio.file.attribute.BasicFileAttributes;
|
||||
public class SmaliDecoder {
|
||||
|
||||
public static void decode(File apkFile, File outDir, boolean debug, String debugLinePrefix,
|
||||
boolean bakdeb) throws AndrolibException {
|
||||
new SmaliDecoder(apkFile, outDir, debug, debugLinePrefix, bakdeb).decode();
|
||||
boolean bakdeb, int api) throws AndrolibException {
|
||||
new SmaliDecoder(apkFile, outDir, debug, debugLinePrefix, bakdeb, api).decode();
|
||||
}
|
||||
|
||||
private SmaliDecoder(File apkFile, File outDir, boolean debug, String debugLinePrefix,
|
||||
boolean bakdeb) {
|
||||
boolean bakdeb, int api) {
|
||||
mApkFile = apkFile;
|
||||
mOutDir = outDir.toPath();
|
||||
mDebug = debug;
|
||||
mDebugLinePrefix = debugLinePrefix;
|
||||
mBakDeb = bakdeb;
|
||||
mApi = api;
|
||||
}
|
||||
|
||||
private void decode() throws AndrolibException {
|
||||
@ -73,7 +74,7 @@ public class SmaliDecoder {
|
||||
options.inlineResolver = null;
|
||||
options.checkPackagePrivateAccess = false;
|
||||
|
||||
baksmali.disassembleDexFile(DexFileFactory.loadDexFile(mApkFile, 0), options);
|
||||
baksmali.disassembleDexFile(DexFileFactory.loadDexFile(mApkFile, mApi), options);
|
||||
|
||||
if (mDebug) {
|
||||
Files.walkFileTree(mOutDir, new SmaliFileVisitor());
|
||||
@ -88,6 +89,7 @@ public class SmaliDecoder {
|
||||
private final boolean mDebug;
|
||||
private final String mDebugLinePrefix;
|
||||
private final boolean mBakDeb;
|
||||
private final int mApi;
|
||||
|
||||
|
||||
private class SmaliFileVisitor extends SimpleFileVisitor<Path> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user