fix: pass opcodes=null for baksmali to auto-determine by dex version

When DexBackedDexFile gets opcodes==null, it calls getDefaultOpcodes(dexVersion) which returns the appropriate opcodes for the given dex version. No hints are required for baksmali, but only needed for smali.
https://github.com/JesusFreke/smali/blob/master/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/DexBackedDexFile.java#L83
This commit is contained in:
IgorEisberg 2021-07-03 23:05:04 +03:00
parent 204b742cf0
commit 1472b50541
3 changed files with 9 additions and 12 deletions

View File

@ -71,10 +71,6 @@ public class ApkDecoder {
mOutDir = outDir; mOutDir = outDir;
} }
public void setApiLevel(int apiLevel) {
mApiLevel = apiLevel;
}
public void decode() throws AndrolibException, IOException, DirectoryException { public void decode() throws AndrolibException, IOException, DirectoryException {
try { try {
File outDir = getOutDir(); File outDir = getOutDir();
@ -221,6 +217,10 @@ public class ApkDecoder {
} }
} }
public void setApiLevel(int apiLevel) {
mApiLevel = apiLevel;
}
public void setBaksmaliDebugMode(boolean bakDeb) { public void setBaksmaliDebugMode(boolean bakDeb) {
mBakDeb = bakDeb; mBakDeb = bakDeb;
} }
@ -420,11 +420,11 @@ public class ApkDecoder {
meta.versionInfo = info; meta.versionInfo = info;
} }
private void putSharedLibraryInfo(MetaInfo meta) { private void putSharedLibraryInfo(MetaInfo meta) throws AndrolibException {
meta.sharedLibrary = mResTable.getSharedLibrary(); meta.sharedLibrary = mResTable.getSharedLibrary();
} }
private void putSparseResourcesInfo(MetaInfo meta) { private void putSparseResourcesInfo(MetaInfo meta) throws AndrolibException {
meta.sparseResources = mResTable.getSparseResources(); meta.sparseResources = mResTable.getSparseResources();
} }
@ -454,5 +454,5 @@ public class ApkDecoder {
private boolean mBakDeb = true; private boolean mBakDeb = true;
private Collection<String> mUncompressedFiles; private Collection<String> mUncompressedFiles;
private boolean mAnalysisMode = false; private boolean mAnalysisMode = false;
private int mApiLevel = 15; private int mApiLevel = 0;
} }

View File

@ -32,14 +32,11 @@ import java.io.InputStream;
import java.util.logging.Logger; import java.util.logging.Logger;
public class SmaliBuilder { public class SmaliBuilder {
public static void build(ExtFile smaliDir, File dexFile, int apiLevel) throws AndrolibException { public static void build(ExtFile smaliDir, File dexFile, int apiLevel) throws AndrolibException {
new SmaliBuilder(smaliDir, dexFile, apiLevel).build(); new SmaliBuilder(smaliDir, dexFile, apiLevel).build();
} }
public static void build(ExtFile smaliDir, File dexFile) throws AndrolibException {
new SmaliBuilder(smaliDir, dexFile, 0).build();
}
private SmaliBuilder(ExtFile smaliDir, File dexFile, int apiLevel) { private SmaliBuilder(ExtFile smaliDir, File dexFile, int apiLevel) {
mSmaliDir = smaliDir; mSmaliDir = smaliDir;
mDexFile = dexFile; mDexFile = dexFile;

View File

@ -67,7 +67,7 @@ public class SmaliDecoder {
} }
// create the container // create the container
MultiDexContainer<? extends DexBackedDexFile> container = DexFileFactory.loadDexContainer(mApkFile, Opcodes.forApi(mApiLevel)); MultiDexContainer<? extends DexBackedDexFile> container = DexFileFactory.loadDexContainer(mApkFile, mApiLevel > 0 ? Opcodes.forApi(mApiLevel) : null);
MultiDexContainer.DexEntry<? extends DexBackedDexFile> dexEntry; MultiDexContainer.DexEntry<? extends DexBackedDexFile> dexEntry;
DexBackedDexFile dexFile; DexBackedDexFile dexFile;