mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-22 09:47:34 +01:00
refactor: rename ApkOptions -> Options/BuildOptions
This commit is contained in:
parent
bc51024ea8
commit
3b179f8750
@ -20,6 +20,7 @@ import brut.androlib.*;
|
|||||||
import brut.androlib.err.CantFindFrameworkResException;
|
import brut.androlib.err.CantFindFrameworkResException;
|
||||||
import brut.androlib.err.InFileNotFoundException;
|
import brut.androlib.err.InFileNotFoundException;
|
||||||
import brut.androlib.err.OutDirExistsException;
|
import brut.androlib.err.OutDirExistsException;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.directory.DirectoryException;
|
import brut.directory.DirectoryException;
|
||||||
import brut.util.AaptManager;
|
import brut.util.AaptManager;
|
||||||
@ -207,39 +208,39 @@ public class Main {
|
|||||||
String[] args = cli.getArgs();
|
String[] args = cli.getArgs();
|
||||||
String appDirName = args.length < 2 ? "." : args[1];
|
String appDirName = args.length < 2 ? "." : args[1];
|
||||||
File outFile;
|
File outFile;
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
brut.androlib.options.BuildOptions buildOptions = new BuildOptions();
|
||||||
|
|
||||||
// check for build options
|
// check for build options
|
||||||
if (cli.hasOption("f") || cli.hasOption("force-all")) {
|
if (cli.hasOption("f") || cli.hasOption("force-all")) {
|
||||||
apkOptions.forceBuildAll = true;
|
buildOptions.forceBuildAll = true;
|
||||||
}
|
}
|
||||||
if (cli.hasOption("d") || cli.hasOption("debug")) {
|
if (cli.hasOption("d") || cli.hasOption("debug")) {
|
||||||
apkOptions.debugMode = true;
|
buildOptions.debugMode = true;
|
||||||
}
|
}
|
||||||
if (cli.hasOption("v") || cli.hasOption("verbose")) {
|
if (cli.hasOption("v") || cli.hasOption("verbose")) {
|
||||||
apkOptions.verbose = true;
|
buildOptions.verbose = true;
|
||||||
}
|
}
|
||||||
if (cli.hasOption("a") || cli.hasOption("aapt")) {
|
if (cli.hasOption("a") || cli.hasOption("aapt")) {
|
||||||
apkOptions.aaptPath = cli.getOptionValue("a");
|
buildOptions.aaptPath = cli.getOptionValue("a");
|
||||||
}
|
}
|
||||||
if (cli.hasOption("c") || cli.hasOption("copy-original")) {
|
if (cli.hasOption("c") || cli.hasOption("copy-original")) {
|
||||||
System.err.println("-c/--copy-original has been deprecated. Removal planned for v3.0.0 (#2129)");
|
System.err.println("-c/--copy-original has been deprecated. Removal planned for v3.0.0 (#2129)");
|
||||||
apkOptions.copyOriginalFiles = true;
|
buildOptions.copyOriginalFiles = true;
|
||||||
}
|
}
|
||||||
if (cli.hasOption("p") || cli.hasOption("frame-path")) {
|
if (cli.hasOption("p") || cli.hasOption("frame-path")) {
|
||||||
apkOptions.frameworkFolderLocation = cli.getOptionValue("p");
|
buildOptions.frameworkFolderLocation = cli.getOptionValue("p");
|
||||||
}
|
}
|
||||||
if (cli.hasOption("nc") || cli.hasOption("no-crunch")) {
|
if (cli.hasOption("nc") || cli.hasOption("no-crunch")) {
|
||||||
apkOptions.noCrunch = true;
|
buildOptions.noCrunch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary flag to enable the use of aapt2. This will tranform in time to a use-aapt1 flag, which will be
|
// Temporary flag to enable the use of aapt2. This will tranform in time to a use-aapt1 flag, which will be
|
||||||
// legacy and eventually removed.
|
// legacy and eventually removed.
|
||||||
if (cli.hasOption("use-aapt2")) {
|
if (cli.hasOption("use-aapt2")) {
|
||||||
apkOptions.useAapt2 = true;
|
buildOptions.useAapt2 = true;
|
||||||
}
|
}
|
||||||
if (cli.hasOption("api") || cli.hasOption("api-level")) {
|
if (cli.hasOption("api") || cli.hasOption("api-level")) {
|
||||||
apkOptions.forceApi = Integer.parseInt(cli.getOptionValue("api"));
|
buildOptions.forceApi = Integer.parseInt(cli.getOptionValue("api"));
|
||||||
}
|
}
|
||||||
if (cli.hasOption("o") || cli.hasOption("output")) {
|
if (cli.hasOption("o") || cli.hasOption("output")) {
|
||||||
outFile = new File(cli.getOptionValue("o"));
|
outFile = new File(cli.getOptionValue("o"));
|
||||||
@ -250,9 +251,9 @@ public class Main {
|
|||||||
// try and build apk
|
// try and build apk
|
||||||
try {
|
try {
|
||||||
if (cli.hasOption("a") || cli.hasOption("aapt")) {
|
if (cli.hasOption("a") || cli.hasOption("aapt")) {
|
||||||
apkOptions.aaptVersion = AaptManager.getAaptVersion(cli.getOptionValue("a"));
|
buildOptions.aaptVersion = AaptManager.getAaptVersion(cli.getOptionValue("a"));
|
||||||
}
|
}
|
||||||
new Androlib(apkOptions).build(new File(appDirName), outFile);
|
new Androlib(buildOptions).build(new File(appDirName), outFile);
|
||||||
} catch (BrutException ex) {
|
} catch (BrutException ex) {
|
||||||
System.err.println(ex.getMessage());
|
System.err.println(ex.getMessage());
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
@ -263,23 +264,23 @@ public class Main {
|
|||||||
int paraCount = cli.getArgList().size();
|
int paraCount = cli.getArgList().size();
|
||||||
String apkName = cli.getArgList().get(paraCount - 1);
|
String apkName = cli.getArgList().get(paraCount - 1);
|
||||||
|
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
brut.androlib.options.BuildOptions buildOptions = new BuildOptions();
|
||||||
if (cli.hasOption("p") || cli.hasOption("frame-path")) {
|
if (cli.hasOption("p") || cli.hasOption("frame-path")) {
|
||||||
apkOptions.frameworkFolderLocation = cli.getOptionValue("p");
|
buildOptions.frameworkFolderLocation = cli.getOptionValue("p");
|
||||||
}
|
}
|
||||||
if (cli.hasOption("t") || cli.hasOption("tag")) {
|
if (cli.hasOption("t") || cli.hasOption("tag")) {
|
||||||
apkOptions.frameworkTag = cli.getOptionValue("t");
|
buildOptions.frameworkTag = cli.getOptionValue("t");
|
||||||
}
|
}
|
||||||
new Androlib(apkOptions).installFramework(new File(apkName));
|
new Androlib(buildOptions).installFramework(new File(apkName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void cmdListFrameworks(CommandLine cli) throws AndrolibException {
|
private static void cmdListFrameworks(CommandLine cli) throws AndrolibException {
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
brut.androlib.options.BuildOptions buildOptions = new BuildOptions();
|
||||||
if (cli.hasOption("p") || cli.hasOption("frame-path")) {
|
if (cli.hasOption("p") || cli.hasOption("frame-path")) {
|
||||||
apkOptions.frameworkFolderLocation = cli.getOptionValue("p");
|
buildOptions.frameworkFolderLocation = cli.getOptionValue("p");
|
||||||
}
|
}
|
||||||
|
|
||||||
new Androlib(apkOptions).listFrameworks();
|
new Androlib(buildOptions).listFrameworks();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void cmdPublicizeResources(CommandLine cli) throws AndrolibException {
|
private static void cmdPublicizeResources(CommandLine cli) throws AndrolibException {
|
||||||
@ -290,16 +291,16 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void cmdEmptyFrameworkDirectory(CommandLine cli) throws AndrolibException {
|
private static void cmdEmptyFrameworkDirectory(CommandLine cli) throws AndrolibException {
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
brut.androlib.options.BuildOptions buildOptions = new BuildOptions();
|
||||||
|
|
||||||
if (cli.hasOption("f") || cli.hasOption("force")) {
|
if (cli.hasOption("f") || cli.hasOption("force")) {
|
||||||
apkOptions.forceDeleteFramework = true;
|
buildOptions.forceDeleteFramework = true;
|
||||||
}
|
}
|
||||||
if (cli.hasOption("p") || cli.hasOption("frame-path")) {
|
if (cli.hasOption("p") || cli.hasOption("frame-path")) {
|
||||||
apkOptions.frameworkFolderLocation = cli.getOptionValue("p");
|
buildOptions.frameworkFolderLocation = cli.getOptionValue("p");
|
||||||
}
|
}
|
||||||
|
|
||||||
new Androlib(apkOptions).emptyFrameworkDirectory();
|
new Androlib(buildOptions).emptyFrameworkDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void _version() {
|
private static void _version() {
|
||||||
|
@ -18,6 +18,7 @@ package brut.androlib;
|
|||||||
|
|
||||||
import brut.androlib.meta.MetaInfo;
|
import brut.androlib.meta.MetaInfo;
|
||||||
import brut.androlib.meta.UsesFramework;
|
import brut.androlib.meta.UsesFramework;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.androlib.res.AndrolibResources;
|
import brut.androlib.res.AndrolibResources;
|
||||||
import brut.androlib.res.data.ResPackage;
|
import brut.androlib.res.data.ResPackage;
|
||||||
import brut.androlib.res.data.ResTable;
|
import brut.androlib.res.data.ResTable;
|
||||||
@ -47,16 +48,16 @@ import java.util.zip.ZipOutputStream;
|
|||||||
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();
|
||||||
public final ApkOptions apkOptions;
|
public final BuildOptions buildOptions;
|
||||||
private int mMinSdkVersion = 0;
|
private int mMinSdkVersion = 0;
|
||||||
|
|
||||||
public Androlib() {
|
public Androlib() {
|
||||||
this(new ApkOptions());
|
this(new BuildOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Androlib(ApkOptions apkOptions) {
|
public Androlib(BuildOptions buildOptions) {
|
||||||
this.apkOptions = apkOptions;
|
this.buildOptions = buildOptions;
|
||||||
mAndRes.apkOptions = apkOptions;
|
mAndRes.buildOptions = buildOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResTable getResTable(ExtFile apkFile)
|
public ResTable getResTable(ExtFile apkFile)
|
||||||
@ -281,9 +282,9 @@ public class Androlib {
|
|||||||
LOGGER.info("Using Apktool " + Androlib.getVersion());
|
LOGGER.info("Using Apktool " + Androlib.getVersion());
|
||||||
|
|
||||||
MetaInfo meta = readMetaFile(appDir);
|
MetaInfo meta = readMetaFile(appDir);
|
||||||
apkOptions.isFramework = meta.isFrameworkApk;
|
buildOptions.isFramework = meta.isFrameworkApk;
|
||||||
apkOptions.resourcesAreCompressed = meta.compressionType;
|
buildOptions.resourcesAreCompressed = meta.compressionType;
|
||||||
apkOptions.doNotCompress = meta.doNotCompress;
|
buildOptions.doNotCompress = meta.doNotCompress;
|
||||||
|
|
||||||
mAndRes.setSdkInfo(meta.sdkInfo);
|
mAndRes.setSdkInfo(meta.sdkInfo);
|
||||||
mAndRes.setPackageId(meta.packageInfo);
|
mAndRes.setPackageId(meta.packageInfo);
|
||||||
@ -398,7 +399,7 @@ public class Androlib {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
File stored = new File(appDir, APK_DIRNAME + "/" + filename);
|
File stored = new File(appDir, APK_DIRNAME + "/" + filename);
|
||||||
if (apkOptions.forceBuildAll || isModified(working, stored)) {
|
if (buildOptions.forceBuildAll || isModified(working, stored)) {
|
||||||
LOGGER.info("Copying " + appDir.toString() + " " + filename + " file...");
|
LOGGER.info("Copying " + appDir.toString() + " " + filename + " file...");
|
||||||
try {
|
try {
|
||||||
BrutIO.copyAndClose(new FileInputStream(working), new FileOutputStream(stored));
|
BrutIO.copyAndClose(new FileInputStream(working), new FileOutputStream(stored));
|
||||||
@ -417,13 +418,13 @@ public class Androlib {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
File dex = new File(appDir, APK_DIRNAME + "/" + filename);
|
File dex = new File(appDir, APK_DIRNAME + "/" + filename);
|
||||||
if (! apkOptions.forceBuildAll) {
|
if (! buildOptions.forceBuildAll) {
|
||||||
LOGGER.info("Checking whether sources has changed...");
|
LOGGER.info("Checking whether sources has changed...");
|
||||||
}
|
}
|
||||||
if (apkOptions.forceBuildAll || isModified(smaliDir, dex)) {
|
if (buildOptions.forceBuildAll || isModified(smaliDir, dex)) {
|
||||||
LOGGER.info("Smaling " + folder + " folder into " + filename + "...");
|
LOGGER.info("Smaling " + folder + " folder into " + filename + "...");
|
||||||
dex.delete();
|
dex.delete();
|
||||||
SmaliBuilder.build(smaliDir, dex, apkOptions.forceApi > 0 ? apkOptions.forceApi : mMinSdkVersion);
|
SmaliBuilder.build(smaliDir, dex, buildOptions.forceApi > 0 ? buildOptions.forceApi : mMinSdkVersion);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -443,10 +444,10 @@ public class Androlib {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
File apkDir = new File(appDir, APK_DIRNAME);
|
File apkDir = new File(appDir, APK_DIRNAME);
|
||||||
if (! apkOptions.forceBuildAll) {
|
if (! buildOptions.forceBuildAll) {
|
||||||
LOGGER.info("Checking whether resources has changed...");
|
LOGGER.info("Checking whether resources has changed...");
|
||||||
}
|
}
|
||||||
if (apkOptions.forceBuildAll || isModified(newFiles(APK_RESOURCES_FILENAMES, appDir),
|
if (buildOptions.forceBuildAll || isModified(newFiles(APK_RESOURCES_FILENAMES, appDir),
|
||||||
newFiles(APK_RESOURCES_FILENAMES, apkDir))) {
|
newFiles(APK_RESOURCES_FILENAMES, apkDir))) {
|
||||||
LOGGER.info("Copying raw resources...");
|
LOGGER.info("Copying raw resources...");
|
||||||
appDir.getDirectory().copyToDir(apkDir, APK_RESOURCES_FILENAMES);
|
appDir.getDirectory().copyToDir(apkDir, APK_RESOURCES_FILENAMES);
|
||||||
@ -463,18 +464,18 @@ public class Androlib {
|
|||||||
if (!new File(appDir, "res").exists()) {
|
if (!new File(appDir, "res").exists()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (! apkOptions.forceBuildAll) {
|
if (! buildOptions.forceBuildAll) {
|
||||||
LOGGER.info("Checking whether resources has changed...");
|
LOGGER.info("Checking whether resources has changed...");
|
||||||
}
|
}
|
||||||
File apkDir = new File(appDir, APK_DIRNAME);
|
File apkDir = new File(appDir, APK_DIRNAME);
|
||||||
File resourceFile = new File(apkDir.getParent(), "resources.zip");
|
File resourceFile = new File(apkDir.getParent(), "resources.zip");
|
||||||
|
|
||||||
if (apkOptions.forceBuildAll || isModified(newFiles(APP_RESOURCES_FILENAMES, appDir),
|
if (buildOptions.forceBuildAll || isModified(newFiles(APP_RESOURCES_FILENAMES, appDir),
|
||||||
newFiles(APK_RESOURCES_FILENAMES, apkDir)) || (apkOptions.isAapt2() && !isFile(resourceFile))) {
|
newFiles(APK_RESOURCES_FILENAMES, apkDir)) || (buildOptions.isAapt2() && !isFile(resourceFile))) {
|
||||||
LOGGER.info("Building resources...");
|
LOGGER.info("Building resources...");
|
||||||
|
|
||||||
if (apkOptions.debugMode) {
|
if (buildOptions.debugMode) {
|
||||||
if (apkOptions.isAapt2()) {
|
if (buildOptions.isAapt2()) {
|
||||||
LOGGER.info("Using aapt2 - setting 'debuggable' attribute to 'true' in AndroidManifest.xml");
|
LOGGER.info("Using aapt2 - setting 'debuggable' attribute to 'true' in AndroidManifest.xml");
|
||||||
ResXmlPatcher.setApplicationDebugTagTrue(new File(appDir, "AndroidManifest.xml"));
|
ResXmlPatcher.setApplicationDebugTagTrue(new File(appDir, "AndroidManifest.xml"));
|
||||||
} else {
|
} else {
|
||||||
@ -534,13 +535,13 @@ public class Androlib {
|
|||||||
if (!new File(appDir, "AndroidManifest.xml").exists()) {
|
if (!new File(appDir, "AndroidManifest.xml").exists()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (! apkOptions.forceBuildAll) {
|
if (! buildOptions.forceBuildAll) {
|
||||||
LOGGER.info("Checking whether resources has changed...");
|
LOGGER.info("Checking whether resources has changed...");
|
||||||
}
|
}
|
||||||
|
|
||||||
File apkDir = new File(appDir, APK_DIRNAME);
|
File apkDir = new File(appDir, APK_DIRNAME);
|
||||||
|
|
||||||
if (apkOptions.forceBuildAll || isModified(newFiles(APK_MANIFEST_FILENAMES, appDir),
|
if (buildOptions.forceBuildAll || isModified(newFiles(APK_MANIFEST_FILENAMES, appDir),
|
||||||
newFiles(APK_MANIFEST_FILENAMES, apkDir))) {
|
newFiles(APK_MANIFEST_FILENAMES, apkDir))) {
|
||||||
LOGGER.info("Building AndroidManifest.xml...");
|
LOGGER.info("Building AndroidManifest.xml...");
|
||||||
|
|
||||||
@ -583,7 +584,7 @@ public class Androlib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
File stored = new File(appDir, APK_DIRNAME + "/" + folder);
|
File stored = new File(appDir, APK_DIRNAME + "/" + folder);
|
||||||
if (apkOptions.forceBuildAll || isModified(working, stored)) {
|
if (buildOptions.forceBuildAll || isModified(working, stored)) {
|
||||||
LOGGER.info("Copying libs... (/" + folder + ")");
|
LOGGER.info("Copying libs... (/" + folder + ")");
|
||||||
try {
|
try {
|
||||||
OS.rmdir(stored);
|
OS.rmdir(stored);
|
||||||
@ -596,7 +597,7 @@ public class Androlib {
|
|||||||
|
|
||||||
public void buildCopyOriginalFiles(File appDir)
|
public void buildCopyOriginalFiles(File appDir)
|
||||||
throws AndrolibException {
|
throws AndrolibException {
|
||||||
if (apkOptions.copyOriginalFiles) {
|
if (buildOptions.copyOriginalFiles) {
|
||||||
File originalDir = new File(appDir, "original");
|
File originalDir = new File(appDir, "original");
|
||||||
if (originalDir.exists()) {
|
if (originalDir.exists()) {
|
||||||
try {
|
try {
|
||||||
|
@ -225,7 +225,7 @@ public class ApkDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFrameworkTag(String tag) {
|
public void setFrameworkTag(String tag) {
|
||||||
mAndrolib.apkOptions.frameworkTag = tag;
|
mAndrolib.buildOptions.frameworkTag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeepBrokenResources(boolean keepBrokenResources) {
|
public void setKeepBrokenResources(boolean keepBrokenResources) {
|
||||||
@ -233,7 +233,7 @@ public class ApkDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFrameworkDir(String dir) {
|
public void setFrameworkDir(String dir) {
|
||||||
mAndrolib.apkOptions.frameworkFolderLocation = dir;
|
mAndrolib.buildOptions.frameworkFolderLocation = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResTable getResTable() throws AndrolibException {
|
public ResTable getResTable() throws AndrolibException {
|
||||||
@ -355,8 +355,8 @@ public class ApkDecoder {
|
|||||||
meta.usesFramework = new UsesFramework();
|
meta.usesFramework = new UsesFramework();
|
||||||
meta.usesFramework.ids = Arrays.asList(ids);
|
meta.usesFramework.ids = Arrays.asList(ids);
|
||||||
|
|
||||||
if (mAndrolib.apkOptions.frameworkTag != null) {
|
if (mAndrolib.buildOptions.frameworkTag != null) {
|
||||||
meta.usesFramework.tag = mAndrolib.apkOptions.frameworkTag;
|
meta.usesFramework.tag = mAndrolib.buildOptions.frameworkTag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package brut.androlib;
|
package brut.androlib.options;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class ApkOptions {
|
public class BuildOptions {
|
||||||
public boolean forceBuildAll = false;
|
public boolean forceBuildAll = false;
|
||||||
public boolean forceDeleteFramework = false;
|
public boolean forceDeleteFramework = false;
|
||||||
public boolean debugMode = false;
|
public boolean debugMode = false;
|
@ -17,7 +17,7 @@
|
|||||||
package brut.androlib.res;
|
package brut.androlib.res;
|
||||||
|
|
||||||
import brut.androlib.AndrolibException;
|
import brut.androlib.AndrolibException;
|
||||||
import brut.androlib.ApkOptions;
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.androlib.err.CantFindFrameworkResException;
|
import brut.androlib.err.CantFindFrameworkResException;
|
||||||
import brut.androlib.meta.MetaInfo;
|
import brut.androlib.meta.MetaInfo;
|
||||||
import brut.androlib.meta.PackageInfo;
|
import brut.androlib.meta.PackageInfo;
|
||||||
@ -306,8 +306,8 @@ final public class AndrolibResources {
|
|||||||
return Integer.toString(target);
|
return Integer.toString(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
private File createDoNotCompressExtensionsFile(ApkOptions apkOptions) throws AndrolibException {
|
private File createDoNotCompressExtensionsFile(BuildOptions buildOptions) throws AndrolibException {
|
||||||
if (apkOptions.doNotCompress == null || apkOptions.doNotCompress.isEmpty()) {
|
if (buildOptions.doNotCompress == null || buildOptions.doNotCompress.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ final public class AndrolibResources {
|
|||||||
doNotCompressFile.deleteOnExit();
|
doNotCompressFile.deleteOnExit();
|
||||||
|
|
||||||
BufferedWriter fileWriter = new BufferedWriter(new FileWriter(doNotCompressFile));
|
BufferedWriter fileWriter = new BufferedWriter(new FileWriter(doNotCompressFile));
|
||||||
for (String extension : apkOptions.doNotCompress) {
|
for (String extension : buildOptions.doNotCompress) {
|
||||||
fileWriter.write(extension);
|
fileWriter.write(extension);
|
||||||
fileWriter.newLine();
|
fileWriter.newLine();
|
||||||
}
|
}
|
||||||
@ -358,11 +358,11 @@ final public class AndrolibResources {
|
|||||||
cmd.add("-o");
|
cmd.add("-o");
|
||||||
cmd.add(resourcesZip.getAbsolutePath());
|
cmd.add(resourcesZip.getAbsolutePath());
|
||||||
|
|
||||||
if (apkOptions.verbose) {
|
if (buildOptions.verbose) {
|
||||||
cmd.add("-v");
|
cmd.add("-v");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apkOptions.noCrunch) {
|
if (buildOptions.noCrunch) {
|
||||||
cmd.add("--no-crunch");
|
cmd.add("--no-crunch");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,24 +433,24 @@ final public class AndrolibResources {
|
|||||||
cmd.add("--enable-sparse-encoding");
|
cmd.add("--enable-sparse-encoding");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apkOptions.isFramework) {
|
if (buildOptions.isFramework) {
|
||||||
cmd.add("-x");
|
cmd.add("-x");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apkOptions.doNotCompress != null && !customAapt) {
|
if (buildOptions.doNotCompress != null && !customAapt) {
|
||||||
// Use custom -e option to avoid limits on commandline length.
|
// Use custom -e option to avoid limits on commandline length.
|
||||||
// Can only be used when custom aapt binary is not used.
|
// Can only be used when custom aapt binary is not used.
|
||||||
String extensionsFilePath = createDoNotCompressExtensionsFile(apkOptions).getAbsolutePath();
|
String extensionsFilePath = createDoNotCompressExtensionsFile(buildOptions).getAbsolutePath();
|
||||||
cmd.add("-e");
|
cmd.add("-e");
|
||||||
cmd.add(extensionsFilePath);
|
cmd.add(extensionsFilePath);
|
||||||
} else if (apkOptions.doNotCompress != null) {
|
} else if (buildOptions.doNotCompress != null) {
|
||||||
for (String file : apkOptions.doNotCompress) {
|
for (String file : buildOptions.doNotCompress) {
|
||||||
cmd.add("-0");
|
cmd.add("-0");
|
||||||
cmd.add(file);
|
cmd.add(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!apkOptions.resourcesAreCompressed) {
|
if (!buildOptions.resourcesAreCompressed) {
|
||||||
cmd.add("-0");
|
cmd.add("-0");
|
||||||
cmd.add("arsc");
|
cmd.add("arsc");
|
||||||
}
|
}
|
||||||
@ -475,7 +475,7 @@ final public class AndrolibResources {
|
|||||||
cmd.add(rawDir.getAbsolutePath());
|
cmd.add(rawDir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apkOptions.verbose) {
|
if (buildOptions.verbose) {
|
||||||
cmd.add("-v");
|
cmd.add("-v");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,16 +498,16 @@ final public class AndrolibResources {
|
|||||||
|
|
||||||
cmd.add("p");
|
cmd.add("p");
|
||||||
|
|
||||||
if (apkOptions.verbose) { // output aapt verbose
|
if (buildOptions.verbose) { // output aapt verbose
|
||||||
cmd.add("-v");
|
cmd.add("-v");
|
||||||
}
|
}
|
||||||
if (apkOptions.updateFiles) {
|
if (buildOptions.updateFiles) {
|
||||||
cmd.add("-u");
|
cmd.add("-u");
|
||||||
}
|
}
|
||||||
if (apkOptions.debugMode) { // inject debuggable="true" into manifest
|
if (buildOptions.debugMode) { // inject debuggable="true" into manifest
|
||||||
cmd.add("--debug-mode");
|
cmd.add("--debug-mode");
|
||||||
}
|
}
|
||||||
if (apkOptions.noCrunch) {
|
if (buildOptions.noCrunch) {
|
||||||
cmd.add("--no-crunch");
|
cmd.add("--no-crunch");
|
||||||
}
|
}
|
||||||
// force package id so that some frameworks build with correct id
|
// force package id so that some frameworks build with correct id
|
||||||
@ -555,24 +555,24 @@ final public class AndrolibResources {
|
|||||||
cmd.add("-F");
|
cmd.add("-F");
|
||||||
cmd.add(apkFile.getAbsolutePath());
|
cmd.add(apkFile.getAbsolutePath());
|
||||||
|
|
||||||
if (apkOptions.isFramework) {
|
if (buildOptions.isFramework) {
|
||||||
cmd.add("-x");
|
cmd.add("-x");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apkOptions.doNotCompress != null && !customAapt) {
|
if (buildOptions.doNotCompress != null && !customAapt) {
|
||||||
// Use custom -e option to avoid limits on commandline length.
|
// Use custom -e option to avoid limits on commandline length.
|
||||||
// Can only be used when custom aapt binary is not used.
|
// Can only be used when custom aapt binary is not used.
|
||||||
String extensionsFilePath = createDoNotCompressExtensionsFile(apkOptions).getAbsolutePath();
|
String extensionsFilePath = createDoNotCompressExtensionsFile(buildOptions).getAbsolutePath();
|
||||||
cmd.add("-e");
|
cmd.add("-e");
|
||||||
cmd.add(extensionsFilePath);
|
cmd.add(extensionsFilePath);
|
||||||
} else if (apkOptions.doNotCompress != null) {
|
} else if (buildOptions.doNotCompress != null) {
|
||||||
for (String file : apkOptions.doNotCompress) {
|
for (String file : buildOptions.doNotCompress) {
|
||||||
cmd.add("-0");
|
cmd.add("-0");
|
||||||
cmd.add(file);
|
cmd.add(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!apkOptions.resourcesAreCompressed) {
|
if (!buildOptions.resourcesAreCompressed) {
|
||||||
cmd.add("-0");
|
cmd.add("-0");
|
||||||
cmd.add("arsc");
|
cmd.add("arsc");
|
||||||
}
|
}
|
||||||
@ -610,7 +610,7 @@ final public class AndrolibResources {
|
|||||||
public void aaptPackage(File apkFile, File manifest, File resDir, File rawDir, File assetDir, File[] include)
|
public void aaptPackage(File apkFile, File manifest, File resDir, File rawDir, File assetDir, File[] include)
|
||||||
throws AndrolibException {
|
throws AndrolibException {
|
||||||
|
|
||||||
String aaptPath = apkOptions.aaptPath;
|
String aaptPath = buildOptions.aaptPath;
|
||||||
boolean customAapt = !aaptPath.isEmpty();
|
boolean customAapt = !aaptPath.isEmpty();
|
||||||
List<String> cmd = new ArrayList<>();
|
List<String> cmd = new ArrayList<>();
|
||||||
|
|
||||||
@ -622,7 +622,7 @@ final public class AndrolibResources {
|
|||||||
cmd.add(AaptManager.getAaptBinaryName(getAaptVersion()));
|
cmd.add(AaptManager.getAaptBinaryName(getAaptVersion()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apkOptions.isAapt2()) {
|
if (buildOptions.isAapt2()) {
|
||||||
aapt2Package(apkFile, manifest, resDir, rawDir, assetDir, include, cmd, customAapt);
|
aapt2Package(apkFile, manifest, resDir, rawDir, assetDir, include, cmd, customAapt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -633,7 +633,7 @@ final public class AndrolibResources {
|
|||||||
throws AndrolibException {
|
throws AndrolibException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ZipUtils.zipFolders(rawDir, apkFile, assetDir, apkOptions.doNotCompress);
|
ZipUtils.zipFolders(rawDir, apkFile, assetDir, buildOptions.doNotCompress);
|
||||||
} catch (IOException | BrutException ex) {
|
} catch (IOException | BrutException ex) {
|
||||||
throw new AndrolibException(ex);
|
throw new AndrolibException(ex);
|
||||||
}
|
}
|
||||||
@ -827,7 +827,7 @@ final public class AndrolibResources {
|
|||||||
LOGGER.warning("Can't empty framework directory, no file found at: " + apk.getAbsolutePath());
|
LOGGER.warning("Can't empty framework directory, no file found at: " + apk.getAbsolutePath());
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (apk.exists() && dir.listFiles().length > 1 && ! apkOptions.forceDeleteFramework) {
|
if (apk.exists() && dir.listFiles().length > 1 && ! buildOptions.forceDeleteFramework) {
|
||||||
LOGGER.warning("More than default framework detected. Please run command with `--force` parameter to wipe framework directory.");
|
LOGGER.warning("More than default framework detected. Please run command with `--force` parameter to wipe framework directory.");
|
||||||
} else {
|
} else {
|
||||||
for (File file : dir.listFiles()) {
|
for (File file : dir.listFiles()) {
|
||||||
@ -858,7 +858,7 @@ final public class AndrolibResources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void installFramework(File frameFile) throws AndrolibException {
|
public void installFramework(File frameFile) throws AndrolibException {
|
||||||
installFramework(frameFile, apkOptions.frameworkTag);
|
installFramework(frameFile, buildOptions.frameworkTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void installFramework(File frameFile, String tag)
|
public void installFramework(File frameFile, String tag)
|
||||||
@ -957,8 +957,8 @@ final public class AndrolibResources {
|
|||||||
String path;
|
String path;
|
||||||
|
|
||||||
// if a framework path was specified on the command line, use it
|
// if a framework path was specified on the command line, use it
|
||||||
if (apkOptions.frameworkFolderLocation != null) {
|
if (buildOptions.frameworkFolderLocation != null) {
|
||||||
path = apkOptions.frameworkFolderLocation;
|
path = buildOptions.frameworkFolderLocation;
|
||||||
} else {
|
} else {
|
||||||
File parentPath = new File(System.getProperty("user.home"));
|
File parentPath = new File(System.getProperty("user.home"));
|
||||||
|
|
||||||
@ -983,7 +983,7 @@ final public class AndrolibResources {
|
|||||||
|
|
||||||
if (! dir.exists()) {
|
if (! dir.exists()) {
|
||||||
if (! dir.mkdirs()) {
|
if (! dir.mkdirs()) {
|
||||||
if (apkOptions.frameworkFolderLocation != null) {
|
if (buildOptions.frameworkFolderLocation != null) {
|
||||||
LOGGER.severe("Can't create Framework directory: " + dir);
|
LOGGER.severe("Can't create Framework directory: " + dir);
|
||||||
}
|
}
|
||||||
throw new AndrolibException(String.format(
|
throw new AndrolibException(String.format(
|
||||||
@ -992,7 +992,7 @@ final public class AndrolibResources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apkOptions.frameworkFolderLocation == null) {
|
if (buildOptions.frameworkFolderLocation == null) {
|
||||||
if (! dir.canWrite()) {
|
if (! dir.canWrite()) {
|
||||||
LOGGER.severe(String.format("WARNING: Could not write to (%1$s), using %2$s instead...",
|
LOGGER.severe(String.format("WARNING: Could not write to (%1$s), using %2$s instead...",
|
||||||
dir.getAbsolutePath(), System.getProperty("java.io.tmpdir")));
|
dir.getAbsolutePath(), System.getProperty("java.io.tmpdir")));
|
||||||
@ -1019,7 +1019,7 @@ final public class AndrolibResources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getAaptVersion() {
|
private int getAaptVersion() {
|
||||||
return apkOptions.isAapt2() ? 2 : 1;
|
return buildOptions.isAapt2() ? 2 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getAndroidFrameworkResourcesAsStream() {
|
public InputStream getAndroidFrameworkResourcesAsStream() {
|
||||||
@ -1032,7 +1032,7 @@ final public class AndrolibResources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApkOptions apkOptions;
|
public BuildOptions buildOptions;
|
||||||
|
|
||||||
// TODO: dirty static hack. I have to refactor decoding mechanisms.
|
// TODO: dirty static hack. I have to refactor decoding mechanisms.
|
||||||
public static boolean sKeepBroken = false;
|
public static boolean sKeepBroken = false;
|
||||||
|
@ -78,7 +78,7 @@ public class ResTable {
|
|||||||
return pkg;
|
return pkg;
|
||||||
}
|
}
|
||||||
if (mAndRes != null) {
|
if (mAndRes != null) {
|
||||||
return mAndRes.loadFrameworkPkg(this, id, mAndRes.apkOptions.frameworkTag);
|
return mAndRes.loadFrameworkPkg(this, id, mAndRes.buildOptions.frameworkTag);
|
||||||
}
|
}
|
||||||
throw new UndefinedResObjectException(String.format("package: id=%d", id));
|
throw new UndefinedResObjectException(String.format("package: id=%d", id));
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package brut.androlib;
|
package brut.androlib;
|
||||||
|
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.androlib.res.AndrolibResources;
|
import brut.androlib.res.AndrolibResources;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.directory.DirUtil;
|
import brut.directory.DirUtil;
|
||||||
@ -137,7 +138,7 @@ public abstract class TestUtils {
|
|||||||
|
|
||||||
static File getFrameworkDir() throws AndrolibException {
|
static File getFrameworkDir() throws AndrolibException {
|
||||||
AndrolibResources androlibResources = new AndrolibResources();
|
AndrolibResources androlibResources = new AndrolibResources();
|
||||||
androlibResources.apkOptions = new ApkOptions();
|
androlibResources.buildOptions = new BuildOptions();
|
||||||
return androlibResources.getFrameworkDir();
|
return androlibResources.getFrameworkDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package brut.androlib.aapt1;
|
package brut.androlib.aapt1;
|
||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
@ -46,8 +47,8 @@ public class AndroidOreoNotSparseTest extends BaseTest {
|
|||||||
apkDecoder.decode();
|
apkDecoder.decode();
|
||||||
|
|
||||||
LOGGER.info("Building not_sparse.apk...");
|
LOGGER.info("Building not_sparse.apk...");
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
new Androlib(apkOptions).build(sTestNewDir, testApk);
|
new Androlib(buildOptions).build(sTestNewDir, testApk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package brut.androlib.aapt1;
|
package brut.androlib.aapt1;
|
||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
@ -46,8 +47,8 @@ public class AndroidOreoSparseTest extends BaseTest {
|
|||||||
apkDecoder.decode();
|
apkDecoder.decode();
|
||||||
|
|
||||||
LOGGER.info("Building sparse.apk...");
|
LOGGER.info("Building sparse.apk...");
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
new Androlib(apkOptions).build(sTestNewDir, testApk);
|
new Androlib(buildOptions).build(sTestNewDir, testApk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package brut.androlib.aapt1;
|
package brut.androlib.aapt1;
|
||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
@ -46,11 +47,11 @@ public class DebugTagRetainedTest extends BaseTest {
|
|||||||
TestUtils.copyResourceDir(DebugTagRetainedTest.class, "aapt1/issue1235/", sTestOrigDir);
|
TestUtils.copyResourceDir(DebugTagRetainedTest.class, "aapt1/issue1235/", sTestOrigDir);
|
||||||
|
|
||||||
LOGGER.info("Building issue1235.apk...");
|
LOGGER.info("Building issue1235.apk...");
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
apkOptions.debugMode = true;
|
buildOptions.debugMode = true;
|
||||||
|
|
||||||
File testApk = new File(sTmpDir, "issue1235.apk");
|
File testApk = new File(sTmpDir, "issue1235.apk");
|
||||||
new Androlib(apkOptions).build(sTestOrigDir, testApk);
|
new Androlib(buildOptions).build(sTestOrigDir, testApk);
|
||||||
|
|
||||||
LOGGER.info("Decoding issue1235.apk...");
|
LOGGER.info("Decoding issue1235.apk...");
|
||||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||||
|
@ -18,7 +18,7 @@ package brut.androlib.aapt1;
|
|||||||
|
|
||||||
import brut.androlib.Androlib;
|
import brut.androlib.Androlib;
|
||||||
import brut.androlib.ApkDecoder;
|
import brut.androlib.ApkDecoder;
|
||||||
import brut.androlib.ApkOptions;
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.androlib.TestUtils;
|
import brut.androlib.TestUtils;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
@ -50,8 +50,8 @@ public class EmptyResourcesArscTest {
|
|||||||
apkDecoder.decode();
|
apkDecoder.decode();
|
||||||
|
|
||||||
LOGGER.info("Building issue1730.apk...");
|
LOGGER.info("Building issue1730.apk...");
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
new Androlib(apkOptions).build(sTestNewDir, testApk);
|
new Androlib(buildOptions).build(sTestNewDir, testApk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package brut.androlib.aapt1;
|
package brut.androlib.aapt1;
|
||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
@ -49,11 +50,11 @@ public class SharedLibraryTest extends BaseTest {
|
|||||||
public void isFrameworkTaggingWorking() throws AndrolibException {
|
public void isFrameworkTaggingWorking() throws AndrolibException {
|
||||||
String apkName = "library.apk";
|
String apkName = "library.apk";
|
||||||
|
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
apkOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
|
buildOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
|
||||||
apkOptions.frameworkTag = "building";
|
buildOptions.frameworkTag = "building";
|
||||||
|
|
||||||
new Androlib(apkOptions).installFramework(new File(sTmpDir + File.separator + apkName));
|
new Androlib(buildOptions).installFramework(new File(sTmpDir + File.separator + apkName));
|
||||||
|
|
||||||
assertTrue(fileExists("2-building.apk"));
|
assertTrue(fileExists("2-building.apk"));
|
||||||
}
|
}
|
||||||
@ -62,10 +63,10 @@ public class SharedLibraryTest extends BaseTest {
|
|||||||
public void isFrameworkInstallingWorking() throws AndrolibException {
|
public void isFrameworkInstallingWorking() throws AndrolibException {
|
||||||
String apkName = "library.apk";
|
String apkName = "library.apk";
|
||||||
|
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
apkOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
|
buildOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
|
||||||
|
|
||||||
new Androlib(apkOptions).installFramework(new File(sTmpDir + File.separator + apkName));
|
new Androlib(buildOptions).installFramework(new File(sTmpDir + File.separator + apkName));
|
||||||
|
|
||||||
assertTrue(fileExists("2.apk"));
|
assertTrue(fileExists("2.apk"));
|
||||||
}
|
}
|
||||||
@ -76,36 +77,36 @@ public class SharedLibraryTest extends BaseTest {
|
|||||||
String client = "client.apk";
|
String client = "client.apk";
|
||||||
|
|
||||||
// setup apkOptions
|
// setup apkOptions
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
apkOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
|
buildOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
|
||||||
apkOptions.frameworkTag = "shared";
|
buildOptions.frameworkTag = "shared";
|
||||||
|
|
||||||
// install library/framework
|
// install library/framework
|
||||||
new Androlib(apkOptions).installFramework(new File(sTmpDir + File.separator + library));
|
new Androlib(buildOptions).installFramework(new File(sTmpDir + File.separator + library));
|
||||||
assertTrue(fileExists("2-shared.apk"));
|
assertTrue(fileExists("2-shared.apk"));
|
||||||
|
|
||||||
// decode client.apk
|
// decode client.apk
|
||||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + client));
|
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + client));
|
||||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + client + ".out"));
|
apkDecoder.setOutDir(new File(sTmpDir + File.separator + client + ".out"));
|
||||||
apkDecoder.setFrameworkDir(apkOptions.frameworkFolderLocation);
|
apkDecoder.setFrameworkDir(buildOptions.frameworkFolderLocation);
|
||||||
apkDecoder.setFrameworkTag(apkOptions.frameworkTag);
|
apkDecoder.setFrameworkTag(buildOptions.frameworkTag);
|
||||||
apkDecoder.decode();
|
apkDecoder.decode();
|
||||||
|
|
||||||
// decode library.apk
|
// decode library.apk
|
||||||
ApkDecoder libraryDecoder = new ApkDecoder(new File(sTmpDir + File.separator + library));
|
ApkDecoder libraryDecoder = new ApkDecoder(new File(sTmpDir + File.separator + library));
|
||||||
libraryDecoder.setOutDir(new File(sTmpDir + File.separator + library + ".out"));
|
libraryDecoder.setOutDir(new File(sTmpDir + File.separator + library + ".out"));
|
||||||
libraryDecoder.setFrameworkDir(apkOptions.frameworkFolderLocation);
|
libraryDecoder.setFrameworkDir(buildOptions.frameworkFolderLocation);
|
||||||
libraryDecoder.setFrameworkTag(apkOptions.frameworkTag);
|
libraryDecoder.setFrameworkTag(buildOptions.frameworkTag);
|
||||||
libraryDecoder.decode();
|
libraryDecoder.decode();
|
||||||
|
|
||||||
// build client.apk
|
// build client.apk
|
||||||
ExtFile clientApk = new ExtFile(sTmpDir, client + ".out");
|
ExtFile clientApk = new ExtFile(sTmpDir, client + ".out");
|
||||||
new Androlib(apkOptions).build(clientApk, null);
|
new Androlib(buildOptions).build(clientApk, null);
|
||||||
assertTrue(fileExists(client + ".out" + File.separator + "dist" + File.separator + client));
|
assertTrue(fileExists(client + ".out" + File.separator + "dist" + File.separator + client));
|
||||||
|
|
||||||
// build library.apk (shared library)
|
// build library.apk (shared library)
|
||||||
ExtFile libraryApk = new ExtFile(sTmpDir, library + ".out");
|
ExtFile libraryApk = new ExtFile(sTmpDir, library + ".out");
|
||||||
new Androlib(apkOptions).build(libraryApk, null);
|
new Androlib(buildOptions).build(libraryApk, null);
|
||||||
assertTrue(fileExists(library + ".out" + File.separator + "dist" + File.separator + library));
|
assertTrue(fileExists(library + ".out" + File.separator + "dist" + File.separator + library));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package brut.androlib.aapt1;
|
package brut.androlib.aapt1;
|
||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
@ -39,8 +40,8 @@ public class UnknownCompressionTest extends BaseTest {
|
|||||||
TestUtils.copyResourceDir(UnknownCompressionTest.class, "aapt1/unknown_compression/", sTmpDir);
|
TestUtils.copyResourceDir(UnknownCompressionTest.class, "aapt1/unknown_compression/", sTmpDir);
|
||||||
|
|
||||||
String apk = "deflated_unknowns.apk";
|
String apk = "deflated_unknowns.apk";
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
apkOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
|
buildOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
|
||||||
|
|
||||||
sTestOrigDir = new ExtFile(sTmpDir, apk);
|
sTestOrigDir = new ExtFile(sTmpDir, apk);
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ public class UnknownCompressionTest extends BaseTest {
|
|||||||
|
|
||||||
// build deflated_unknowns
|
// build deflated_unknowns
|
||||||
ExtFile clientApkFolder = new ExtFile(sTestOrigDir.getAbsolutePath() + ".out");
|
ExtFile clientApkFolder = new ExtFile(sTestOrigDir.getAbsolutePath() + ".out");
|
||||||
new Androlib(apkOptions).build(clientApkFolder, null);
|
new Androlib(buildOptions).build(clientApkFolder, null);
|
||||||
sTestNewDir = new ExtFile(clientApkFolder, "dist" + File.separator + apk);
|
sTestNewDir = new ExtFile(clientApkFolder, "dist" + File.separator + apk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package brut.androlib.aapt2;
|
|||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
import brut.androlib.meta.MetaInfo;
|
import brut.androlib.meta.MetaInfo;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
@ -42,13 +43,13 @@ public class BuildAndDecodeTest extends BaseTest {
|
|||||||
LOGGER.info("Unpacking testapp...");
|
LOGGER.info("Unpacking testapp...");
|
||||||
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "aapt2/testapp/", sTestOrigDir);
|
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "aapt2/testapp/", sTestOrigDir);
|
||||||
|
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
apkOptions.useAapt2 = true;
|
buildOptions.useAapt2 = true;
|
||||||
apkOptions.verbose = true;
|
buildOptions.verbose = true;
|
||||||
|
|
||||||
LOGGER.info("Building testapp.apk...");
|
LOGGER.info("Building testapp.apk...");
|
||||||
File testApk = new File(sTmpDir, "testapp.apk");
|
File testApk = new File(sTmpDir, "testapp.apk");
|
||||||
new Androlib(apkOptions).build(sTestOrigDir, testApk);
|
new Androlib(buildOptions).build(sTestOrigDir, testApk);
|
||||||
|
|
||||||
LOGGER.info("Decoding testapp.apk...");
|
LOGGER.info("Decoding testapp.apk...");
|
||||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package brut.androlib.aapt2;
|
package brut.androlib.aapt2;
|
||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
@ -46,13 +47,13 @@ public class DebuggableFalseChangeToTrueTest extends BaseTest {
|
|||||||
TestUtils.copyResourceDir(DebuggableFalseChangeToTrueTest.class, "aapt2/issue2328/debuggable-false", sTestOrigDir);
|
TestUtils.copyResourceDir(DebuggableFalseChangeToTrueTest.class, "aapt2/issue2328/debuggable-false", sTestOrigDir);
|
||||||
|
|
||||||
LOGGER.info("Building issue2328-debuggable-flase.apk...");
|
LOGGER.info("Building issue2328-debuggable-flase.apk...");
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
apkOptions.debugMode = true;
|
buildOptions.debugMode = true;
|
||||||
apkOptions.useAapt2 = true;
|
buildOptions.useAapt2 = true;
|
||||||
apkOptions.verbose = true;
|
buildOptions.verbose = true;
|
||||||
|
|
||||||
File testApk = new File(sTmpDir, "issue2328-debuggable-flase.apk");
|
File testApk = new File(sTmpDir, "issue2328-debuggable-flase.apk");
|
||||||
new Androlib(apkOptions).build(sTestOrigDir, testApk);
|
new Androlib(buildOptions).build(sTestOrigDir, testApk);
|
||||||
|
|
||||||
LOGGER.info("Decoding issue2328-debuggable-flase.apk...");
|
LOGGER.info("Decoding issue2328-debuggable-flase.apk...");
|
||||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package brut.androlib.aapt2;
|
package brut.androlib.aapt2;
|
||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
@ -46,13 +47,13 @@ public class DebuggableTrueAddedTest extends BaseTest {
|
|||||||
TestUtils.copyResourceDir(DebuggableTrueAddedTest.class, "aapt2/issue2328/debuggable-missing", sTestOrigDir);
|
TestUtils.copyResourceDir(DebuggableTrueAddedTest.class, "aapt2/issue2328/debuggable-missing", sTestOrigDir);
|
||||||
|
|
||||||
LOGGER.info("Building issue2328-debuggable-missing.apk...");
|
LOGGER.info("Building issue2328-debuggable-missing.apk...");
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
apkOptions.debugMode = true;
|
buildOptions.debugMode = true;
|
||||||
apkOptions.useAapt2 = true;
|
buildOptions.useAapt2 = true;
|
||||||
apkOptions.verbose = true;
|
buildOptions.verbose = true;
|
||||||
|
|
||||||
File testApk = new File(sTmpDir, "issue2328-debuggable-missing.apk");
|
File testApk = new File(sTmpDir, "issue2328-debuggable-missing.apk");
|
||||||
new Androlib(apkOptions).build(sTestOrigDir, testApk);
|
new Androlib(buildOptions).build(sTestOrigDir, testApk);
|
||||||
|
|
||||||
LOGGER.info("Decoding issue2328-debuggable-missing.apk...");
|
LOGGER.info("Decoding issue2328-debuggable-missing.apk...");
|
||||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package brut.androlib.aapt2;
|
package brut.androlib.aapt2;
|
||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
@ -46,13 +47,13 @@ public class DebuggableTrueRetainedTest extends BaseTest {
|
|||||||
TestUtils.copyResourceDir(DebuggableTrueRetainedTest.class, "aapt2/issue2328/debuggable-true", sTestOrigDir);
|
TestUtils.copyResourceDir(DebuggableTrueRetainedTest.class, "aapt2/issue2328/debuggable-true", sTestOrigDir);
|
||||||
|
|
||||||
LOGGER.info("Building issue2328-debuggable-true.apk...");
|
LOGGER.info("Building issue2328-debuggable-true.apk...");
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
apkOptions.debugMode = true;
|
buildOptions.debugMode = true;
|
||||||
apkOptions.useAapt2 = true;
|
buildOptions.useAapt2 = true;
|
||||||
apkOptions.verbose = true;
|
buildOptions.verbose = true;
|
||||||
|
|
||||||
File testApk = new File(sTmpDir, "issue2328-debuggable-true.apk");
|
File testApk = new File(sTmpDir, "issue2328-debuggable-true.apk");
|
||||||
new Androlib(apkOptions).build(sTestOrigDir, testApk);
|
new Androlib(buildOptions).build(sTestOrigDir, testApk);
|
||||||
|
|
||||||
LOGGER.info("Decoding issue2328-debuggable-true.apk...");
|
LOGGER.info("Decoding issue2328-debuggable-true.apk...");
|
||||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package brut.androlib.aapt2;
|
package brut.androlib.aapt2;
|
||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.androlib.res.data.ResTable;
|
import brut.androlib.res.data.ResTable;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
@ -43,13 +44,13 @@ public class NonStandardPkgIdTest extends BaseTest {
|
|||||||
LOGGER.info("Unpacking pkgid8...");
|
LOGGER.info("Unpacking pkgid8...");
|
||||||
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "aapt2/pkgid8/", sTestOrigDir);
|
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "aapt2/pkgid8/", sTestOrigDir);
|
||||||
|
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
apkOptions.useAapt2 = true;
|
buildOptions.useAapt2 = true;
|
||||||
apkOptions.verbose = true;
|
buildOptions.verbose = true;
|
||||||
|
|
||||||
LOGGER.info("Building pkgid8.apk...");
|
LOGGER.info("Building pkgid8.apk...");
|
||||||
File testApk = new File(sTmpDir, "pkgid8.apk");
|
File testApk = new File(sTmpDir, "pkgid8.apk");
|
||||||
new Androlib(apkOptions).build(sTestOrigDir, testApk);
|
new Androlib(buildOptions).build(sTestOrigDir, testApk);
|
||||||
|
|
||||||
LOGGER.info("Decoding pkgid8.apk...");
|
LOGGER.info("Decoding pkgid8.apk...");
|
||||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package brut.androlib.decode;
|
package brut.androlib.decode;
|
||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
@ -53,8 +54,8 @@ public class DuplicateDexTest extends BaseTest {
|
|||||||
apkDecoder.decode();
|
apkDecoder.decode();
|
||||||
|
|
||||||
LOGGER.info("Building duplicatedex.apk...");
|
LOGGER.info("Building duplicatedex.apk...");
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
new Androlib(apkOptions).build(sTestNewDir, testApk);
|
new Androlib(buildOptions).build(sTestNewDir, testApk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -68,8 +69,8 @@ public class DuplicateDexTest extends BaseTest {
|
|||||||
apkDecoder.decode();
|
apkDecoder.decode();
|
||||||
|
|
||||||
LOGGER.info("Building duplicatedex.apk...");
|
LOGGER.info("Building duplicatedex.apk...");
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
new Androlib(apkOptions).build(sTestNewDir, testApk);
|
new Androlib(buildOptions).build(sTestNewDir, testApk);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ package brut.androlib.res.src;
|
|||||||
|
|
||||||
import brut.androlib.*;
|
import brut.androlib.*;
|
||||||
import brut.androlib.aapt2.BuildAndDecodeTest;
|
import brut.androlib.aapt2.BuildAndDecodeTest;
|
||||||
|
import brut.androlib.options.BuildOptions;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
@ -44,11 +45,11 @@ public class DexStaticFieldValueTest extends BaseTest {
|
|||||||
LOGGER.info("Unpacking issue2543...");
|
LOGGER.info("Unpacking issue2543...");
|
||||||
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "decode/issue2543/", sTestOrigDir);
|
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "decode/issue2543/", sTestOrigDir);
|
||||||
|
|
||||||
ApkOptions apkOptions = new ApkOptions();
|
BuildOptions buildOptions = new BuildOptions();
|
||||||
|
|
||||||
LOGGER.info("Building issue2543.apk...");
|
LOGGER.info("Building issue2543.apk...");
|
||||||
File testApk = new File(sTmpDir, "issue2543.apk");
|
File testApk = new File(sTmpDir, "issue2543.apk");
|
||||||
new Androlib(apkOptions).build(sTestOrigDir, testApk);
|
new Androlib(buildOptions).build(sTestOrigDir, testApk);
|
||||||
|
|
||||||
LOGGER.info("Decoding issue2543.apk...");
|
LOGGER.info("Decoding issue2543.apk...");
|
||||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user