Skip to content

Commit

Permalink
Move build functions from Androlib to the ApkBuilder (#3103)
Browse files Browse the repository at this point in the history
  • Loading branch information
sv99 authored Jun 27, 2023
1 parent 10495cb commit 9c495ca
Show file tree
Hide file tree
Showing 45 changed files with 458 additions and 542 deletions.
21 changes: 12 additions & 9 deletions brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import brut.androlib.exceptions.CantFindFrameworkResException;
import brut.androlib.exceptions.InFileNotFoundException;
import brut.androlib.exceptions.OutDirExistsException;
import brut.androlib.res.AndrolibResources;
import brut.common.BrutException;
import brut.directory.DirectoryException;
import brut.directory.ExtFile;
Expand All @@ -32,6 +33,9 @@
import java.io.IOException;
import java.util.logging.*;

/**
* Main entry point of the apktool.
*/
public class Main {
public static void main(String[] args) throws BrutException {

Expand Down Expand Up @@ -174,10 +178,9 @@ private static void cmdDecode(CommandLine cli, Config config) throws AndrolibExc
}

ApkDecoder decoder = new ApkDecoder(config, new ExtFile(apkName));
decoder.setOutDir(outDir);

try {
decoder.decode();
decoder.decode(outDir);
} catch (OutDirExistsException ex) {
System.err
.println("Destination directory ("
Expand Down Expand Up @@ -259,7 +262,7 @@ private static void cmdBuild(CommandLine cli, Config config) {
if (cli.hasOption("a") || cli.hasOption("aapt")) {
config.aaptVersion = AaptManager.getAaptVersion(cli.getOptionValue("a"));
}
new Androlib(config).build(new File(appDirName), outFile);
new ApkBuilder(config, new ExtFile(appDirName)).build(outFile);
} catch (BrutException ex) {
System.err.println(ex.getMessage());
System.exit(1);
Expand All @@ -268,23 +271,23 @@ private static void cmdBuild(CommandLine cli, Config config) {

private static void cmdInstallFramework(CommandLine cli, Config config) throws AndrolibException {
String apkName = getLastArg(cli);
new Androlib(config).installFramework(new File(apkName));
new AndrolibResources(config).installFramework(new File(apkName));
}

private static void cmdListFrameworks(CommandLine cli, Config config) throws AndrolibException {
new Androlib(config).listFrameworks();
new AndrolibResources(config).listFrameworkDirectory();
}

private static void cmdPublicizeResources(CommandLine cli, Config config) throws AndrolibException {
String apkName = getLastArg(cli);
new Androlib(config).publicizeResources(new File(apkName));
new AndrolibResources(config).publicizeResources(new File(apkName));
}

private static void cmdEmptyFrameworkDirectory(CommandLine cli, Config config) throws AndrolibException {
if (cli.hasOption("f") || cli.hasOption("force")) {
config.forceDeleteFramework = true;
}
new Androlib(config).emptyFrameworkDirectory();
new AndrolibResources(config).emptyFrameworkDirectory();
}

private static String getLastArg(CommandLine cli) {
Expand All @@ -293,7 +296,7 @@ private static String getLastArg(CommandLine cli) {
}

private static void _version() {
System.out.println(Androlib.getVersion());
System.out.println(ApktoolProperties.getVersion());
}

private static void _Options() {
Expand Down Expand Up @@ -549,7 +552,7 @@ private static void usage() {

// print out license info prior to formatter.
System.out.println(
"Apktool v" + Androlib.getVersion() + " - a tool for reengineering Android apk files\n" +
"Apktool v" + ApktoolProperties.getVersion() + " - a tool for reengineering Android apk files\n" +
"with smali v" + ApktoolProperties.get("smaliVersion") +
" and baksmali v" + ApktoolProperties.get("baksmaliVersion") + "\n" +
"Copyright 2010 Ryszard Wiśniewski <[email protected]>\n" +
Expand Down
Loading

0 comments on commit 9c495ca

Please sign in to comment.