Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move build functions from Androlib to the ApkBuilder #3103

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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