mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-07 10:35:52 +01:00
DexFileBuilder: added possibility to smali InputStream.
This commit is contained in:
parent
5afc491ebc
commit
853d807f59
@ -32,16 +32,22 @@ import org.jf.smali.*;
|
|||||||
public class DexFileBuilder {
|
public class DexFileBuilder {
|
||||||
public void addSmaliFile(File smaliFile) throws AndrolibException {
|
public void addSmaliFile(File smaliFile) throws AndrolibException {
|
||||||
try {
|
try {
|
||||||
if (!assembleSmaliFile(smaliFile)) {
|
addSmaliFile(new FileInputStream(smaliFile));
|
||||||
|
} catch (FileNotFoundException ex) {
|
||||||
|
throw new AndrolibException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSmaliFile(InputStream smaliStream) throws AndrolibException {
|
||||||
|
try {
|
||||||
|
if (!assembleSmaliFile(smaliStream)) {
|
||||||
throw new AndrolibException(
|
throw new AndrolibException(
|
||||||
"Could not smali file: " + smaliFile);
|
"Could not smali file: " + smaliStream);
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new AndrolibException(
|
throw new AndrolibException(ex);
|
||||||
"Could not smali file: " + smaliFile, ex);
|
|
||||||
} catch (RecognitionException ex) {
|
} catch (RecognitionException ex) {
|
||||||
throw new AndrolibException(
|
throw new AndrolibException(ex);
|
||||||
"Could not smali file: " + smaliFile, ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,10 +80,9 @@ public class DexFileBuilder {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean assembleSmaliFile(File smaliFile)
|
private boolean assembleSmaliFile(InputStream smaliStream)
|
||||||
throws IOException, RecognitionException {
|
throws IOException, RecognitionException {
|
||||||
ANTLRInputStream input = new ANTLRInputStream(new FileInputStream(smaliFile), "UTF8");
|
ANTLRInputStream input = new ANTLRInputStream(smaliStream, "UTF8");
|
||||||
input.name = smaliFile.getAbsolutePath();
|
|
||||||
|
|
||||||
smaliLexer lexer = new smaliLexer(input);
|
smaliLexer lexer = new smaliLexer(input);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user