mirror of
https://github.com/revanced/Apktool.git
synced 2025-05-04 07:44:26 +02:00
style: return DexFile interface from SmaliDecoder
This commit is contained in:
parent
6cfa79e456
commit
fad2f99541
@ -32,6 +32,10 @@ import brut.androlib.src.SmaliDecoder;
|
|||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.directory.*;
|
import brut.directory.*;
|
||||||
import brut.util.*;
|
import brut.util.*;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.jf.dexlib2.iface.DexFile;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -41,9 +45,6 @@ import java.util.zip.ZipEntry;
|
|||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
|
|
||||||
public class Androlib {
|
public class Androlib {
|
||||||
private final AndrolibResources mAndRes = new AndrolibResources();
|
private final AndrolibResources mAndRes = new AndrolibResources();
|
||||||
protected final ResUnknownFiles mResUnknownFiles = new ResUnknownFiles();
|
protected final ResUnknownFiles mResUnknownFiles = new ResUnknownFiles();
|
||||||
@ -95,9 +96,10 @@ public class Androlib {
|
|||||||
OS.rmdir(smaliDir);
|
OS.rmdir(smaliDir);
|
||||||
smaliDir.mkdirs();
|
smaliDir.mkdirs();
|
||||||
LOGGER.info("Baksmaling " + filename + "...");
|
LOGGER.info("Baksmaling " + filename + "...");
|
||||||
apiLevel = SmaliDecoder.decode(apkFile, smaliDir, filename, bakDeb, apiLevel);
|
DexFile dexFile = SmaliDecoder.decode(apkFile, smaliDir, filename, bakDeb, apiLevel);
|
||||||
if (mMinSdkVersion == 0 || mMinSdkVersion > apiLevel) {
|
int minSdkVersion = dexFile.getOpcodes().api;
|
||||||
mMinSdkVersion = apiLevel;
|
if (mMinSdkVersion == 0 || mMinSdkVersion > minSdkVersion) {
|
||||||
|
mMinSdkVersion = minSdkVersion;
|
||||||
}
|
}
|
||||||
} catch (BrutException ex) {
|
} catch (BrutException ex) {
|
||||||
throw new AndrolibException(ex);
|
throw new AndrolibException(ex);
|
||||||
|
@ -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.DexFile;
|
||||||
import org.jf.dexlib2.iface.MultiDexContainer;
|
import org.jf.dexlib2.iface.MultiDexContainer;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -31,7 +32,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class SmaliDecoder {
|
public class SmaliDecoder {
|
||||||
|
|
||||||
public static int decode(File apkFile, File outDir, String dexName, boolean bakDeb, int apiLevel)
|
public static DexFile decode(File apkFile, File outDir, String dexName, boolean bakDeb, int apiLevel)
|
||||||
throws AndrolibException {
|
throws AndrolibException {
|
||||||
return new SmaliDecoder(apkFile, outDir, dexName, bakDeb, apiLevel).decode();
|
return new SmaliDecoder(apkFile, outDir, dexName, bakDeb, apiLevel).decode();
|
||||||
}
|
}
|
||||||
@ -44,7 +45,7 @@ public class SmaliDecoder {
|
|||||||
mApiLevel = apiLevel;
|
mApiLevel = apiLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int decode() throws AndrolibException {
|
private DexFile decode() throws AndrolibException {
|
||||||
try {
|
try {
|
||||||
final BaksmaliOptions options = new BaksmaliOptions();
|
final BaksmaliOptions options = new BaksmaliOptions();
|
||||||
|
|
||||||
@ -67,7 +68,8 @@ public class SmaliDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create the container
|
// create the container
|
||||||
MultiDexContainer<? extends DexBackedDexFile> container = DexFileFactory.loadDexContainer(mApkFile, mApiLevel > 0 ? Opcodes.forApi(mApiLevel) : null);
|
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;
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ public class SmaliDecoder {
|
|||||||
|
|
||||||
Baksmali.disassembleDexFile(dexFile, mOutDir, jobs, options);
|
Baksmali.disassembleDexFile(dexFile, mOutDir, jobs, options);
|
||||||
|
|
||||||
return dexFile.getOpcodes().api;
|
return dexFile;
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new AndrolibException(ex);
|
throw new AndrolibException(ex);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user