refactor: use MultiDexContainer instead of DexBackedDexFile

This commit is contained in:
Connor Tumbleson 2019-08-17 07:00:15 -04:00
parent 945ce9b3d4
commit fefc5e226a
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75

View File

@ -24,6 +24,7 @@ import org.jf.dexlib2.Opcodes;
import org.jf.dexlib2.dexbacked.DexBackedDexFile; import org.jf.dexlib2.dexbacked.DexBackedDexFile;
import org.jf.dexlib2.dexbacked.DexBackedOdexFile; import org.jf.dexlib2.dexbacked.DexBackedOdexFile;
import org.jf.dexlib2.analysis.InlineMethodResolver; import org.jf.dexlib2.analysis.InlineMethodResolver;
import org.jf.dexlib2.iface.MultiDexContainer;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -68,10 +69,27 @@ public class SmaliDecoder {
jobs = 6; jobs = 6;
} }
// create the dex // create the container
DexBackedDexFile dexFile = DexFileFactory.loadDexEntry(mApkFile, mDexFile, true, Opcodes.forApi(mApi)); MultiDexContainer<? extends DexBackedDexFile> container = DexFileFactory.loadDexContainer(mApkFile, Opcodes.forApi(mApi));
MultiDexContainer.DexEntry<? extends DexBackedDexFile> dexEntry;
DexBackedDexFile dexFile;
if (dexFile.isOdexFile()) { // If we have 1 item, ignore the passed file. Pull the DexFile we need.
if (container.getDexEntryNames().size() == 1) {
dexEntry = container.getEntry(container.getDexEntryNames().get(0));
} else {
dexEntry = container.getEntry(mDexFile);
}
// Double check the passed param exists
if (dexEntry == null) {
dexEntry = container.getEntry(container.getDexEntryNames().get(0));
}
assert dexEntry != null;
dexFile = dexEntry.getDexFile();
if (dexFile.supportsOptimizedOpcodes()) {
throw new AndrolibException("Warning: You are disassembling an odex file without deodexing it."); throw new AndrolibException("Warning: You are disassembling an odex file without deodexing it.");
} }