mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 05:47:46 +01:00
Updating Framework Support
This commit is contained in:
parent
466319ad51
commit
daa1e1d753
@ -48,7 +48,7 @@ public class Main {
|
|||||||
|
|
||||||
// cli parser
|
// cli parser
|
||||||
CommandLineParser parser = new PosixParser();
|
CommandLineParser parser = new PosixParser();
|
||||||
CommandLine commandLine = null;
|
CommandLine commandLine;
|
||||||
|
|
||||||
// load options
|
// load options
|
||||||
_Options();
|
_Options();
|
||||||
@ -57,7 +57,7 @@ public class Main {
|
|||||||
commandLine = parser.parse(allOptions, args, false);
|
commandLine = parser.parse(allOptions, args, false);
|
||||||
} catch (ParseException ex) {
|
} catch (ParseException ex) {
|
||||||
System.err.println(ex.getMessage());
|
System.err.println(ex.getMessage());
|
||||||
usage(commandLine);
|
usage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +86,9 @@ public class Main {
|
|||||||
} else if (opt.equalsIgnoreCase("if") || opt.equalsIgnoreCase("install-framework")) {
|
} else if (opt.equalsIgnoreCase("if") || opt.equalsIgnoreCase("install-framework")) {
|
||||||
cmdInstallFramework(commandLine);
|
cmdInstallFramework(commandLine);
|
||||||
cmdFound = true;
|
cmdFound = true;
|
||||||
|
} else if (opt.equalsIgnoreCase("u") || opt.equalsIgnoreCase("update-framework")) {
|
||||||
|
cmdUpdateFramework(commandLine);
|
||||||
|
cmdFound = true;
|
||||||
} else if (opt.equalsIgnoreCase("publicize-resources")) {
|
} else if (opt.equalsIgnoreCase("publicize-resources")) {
|
||||||
cmdPublicizeResources(commandLine);
|
cmdPublicizeResources(commandLine);
|
||||||
cmdFound = true;
|
cmdFound = true;
|
||||||
@ -97,7 +100,7 @@ public class Main {
|
|||||||
if (commandLine.hasOption("version")) {
|
if (commandLine.hasOption("version")) {
|
||||||
_version();
|
_version();
|
||||||
} else {
|
} else {
|
||||||
usage(commandLine);
|
usage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,7 +110,7 @@ public class Main {
|
|||||||
|
|
||||||
int paraCount = cli.getArgList().size();
|
int paraCount = cli.getArgList().size();
|
||||||
String apkName = (String) cli.getArgList().get(paraCount - 1);
|
String apkName = (String) cli.getArgList().get(paraCount - 1);
|
||||||
File outDir = null;
|
File outDir;
|
||||||
|
|
||||||
// check for options
|
// check for options
|
||||||
if (cli.hasOption("s") || cli.hasOption("no-src")) {
|
if (cli.hasOption("s") || cli.hasOption("no-src")) {
|
||||||
@ -224,8 +227,7 @@ public class Main {
|
|||||||
new Androlib(apkOptions).build(new File(appDirName), outFile);
|
new Androlib(apkOptions).build(new File(appDirName), outFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void cmdInstallFramework(CommandLine cli)
|
private static void cmdInstallFramework(CommandLine cli) throws AndrolibException {
|
||||||
throws AndrolibException {
|
|
||||||
int paraCount = cli.getArgList().size();
|
int paraCount = cli.getArgList().size();
|
||||||
String apkName = (String) cli.getArgList().get(paraCount - 1);
|
String apkName = (String) cli.getArgList().get(paraCount - 1);
|
||||||
|
|
||||||
@ -239,14 +241,26 @@ public class Main {
|
|||||||
new Androlib(apkOptions).installFramework(new File(apkName));
|
new Androlib(apkOptions).installFramework(new File(apkName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void cmdPublicizeResources(CommandLine cli)
|
private static void cmdPublicizeResources(CommandLine cli) throws AndrolibException {
|
||||||
throws AndrolibException {
|
|
||||||
int paraCount = cli.getArgList().size();
|
int paraCount = cli.getArgList().size();
|
||||||
String apkName = (String) cli.getArgList().get(paraCount - 1);
|
String apkName = (String) cli.getArgList().get(paraCount - 1);
|
||||||
|
|
||||||
new Androlib().publicizeResources(new File(apkName));
|
new Androlib().publicizeResources(new File(apkName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void cmdUpdateFramework(CommandLine cli) throws AndrolibException {
|
||||||
|
ApkOptions apkOptions = new ApkOptions();
|
||||||
|
|
||||||
|
if (cli.hasOption("f") || cli.hasOption("force")) {
|
||||||
|
apkOptions.forceDeleteFramework = true;
|
||||||
|
}
|
||||||
|
if (cli.hasOption("p") || cli.hasOption("frame-path")) {
|
||||||
|
apkOptions.frameworkFolderLocation = cli.getOptionValue("p");
|
||||||
|
}
|
||||||
|
|
||||||
|
new Androlib(apkOptions).updateFramework();
|
||||||
|
}
|
||||||
|
|
||||||
private static void _version() {
|
private static void _version() {
|
||||||
System.out.println(Androlib.getVersion());
|
System.out.println(Androlib.getVersion());
|
||||||
}
|
}
|
||||||
@ -426,7 +440,7 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void usage(CommandLine commandLine) {
|
private static void usage() {
|
||||||
|
|
||||||
// load basicOptions
|
// load basicOptions
|
||||||
_Options();
|
_Options();
|
||||||
|
@ -684,6 +684,10 @@ public class Androlib {
|
|||||||
mAndRes.installFramework(frameFile);
|
mAndRes.installFramework(frameFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateFramework() throws AndrolibException {
|
||||||
|
mAndRes.updateFramework();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isFrameworkApk(ResTable resTable) {
|
public boolean isFrameworkApk(ResTable resTable) {
|
||||||
for (ResPackage pkg : resTable.listMainPackages()) {
|
for (ResPackage pkg : resTable.listMainPackages()) {
|
||||||
if (pkg.getId() < 64) {
|
if (pkg.getId() < 64) {
|
||||||
|
@ -19,6 +19,7 @@ import java.util.Collection;
|
|||||||
|
|
||||||
public class ApkOptions {
|
public class ApkOptions {
|
||||||
public boolean forceBuildAll = false;
|
public boolean forceBuildAll = false;
|
||||||
|
public boolean forceDeleteFramework = false;
|
||||||
public boolean debugMode = false;
|
public boolean debugMode = false;
|
||||||
public boolean verbose = false;
|
public boolean verbose = false;
|
||||||
public boolean copyOriginalFiles = false;
|
public boolean copyOriginalFiles = false;
|
||||||
|
@ -591,6 +591,19 @@ final public class AndrolibResources {
|
|||||||
throw new CantFindFrameworkResException(id);
|
throw new CantFindFrameworkResException(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateFramework() throws AndrolibException {
|
||||||
|
File dir = getFrameworkDir();
|
||||||
|
File apk;
|
||||||
|
|
||||||
|
apk = new File(dir, "1.apk");
|
||||||
|
|
||||||
|
if (! apk.exists()) {
|
||||||
|
LOGGER.warning("Can't update framework, no file found at: " + apk.getAbsolutePath());
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void installFramework(File frameFile) throws AndrolibException {
|
public void installFramework(File frameFile) throws AndrolibException {
|
||||||
installFramework(frameFile, apkOptions.frameworkTag);
|
installFramework(frameFile, apkOptions.frameworkTag);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user