refactor: get rid of all that logging

This commit is contained in:
Lucaskyy 2022-06-11 19:24:41 +02:00
parent cdc3eefd88
commit e115848dbc
No known key found for this signature in database
GPG Key ID: 1530BFF96D1EEB89
23 changed files with 105 additions and 105 deletions

View File

@ -81,7 +81,7 @@ public class Androlib {
public void decodeSourcesRaw(ExtFile apkFile, File outDir, String filename) public void decodeSourcesRaw(ExtFile apkFile, File outDir, String filename)
throws AndrolibException { throws AndrolibException {
try { try {
LOGGER.info("Copying raw " + filename + " file..."); LOGGER.fine("Copying raw " + filename + " file...");
apkFile.getDirectory().copyToDir(outDir, filename); apkFile.getDirectory().copyToDir(outDir, filename);
} catch (DirectoryException ex) { } catch (DirectoryException ex) {
throw new AndrolibException(ex); throw new AndrolibException(ex);
@ -99,7 +99,7 @@ public class Androlib {
} }
OS.rmdir(smaliDir); OS.rmdir(smaliDir);
smaliDir.mkdirs(); smaliDir.mkdirs();
LOGGER.info("Baksmaling " + filename + "..."); LOGGER.fine("Baksmaling " + filename + "...");
DexFile dexFile = SmaliDecoder.decode(apkFile, smaliDir, filename, bakDeb, apiLevel); DexFile dexFile = SmaliDecoder.decode(apkFile, smaliDir, filename, bakDeb, apiLevel);
int minSdkVersion = dexFile.getOpcodes().api; int minSdkVersion = dexFile.getOpcodes().api;
if (mMinSdkVersion == 0 || mMinSdkVersion > minSdkVersion) { if (mMinSdkVersion == 0 || mMinSdkVersion > minSdkVersion) {
@ -113,7 +113,7 @@ public class Androlib {
public void decodeManifestRaw(ExtFile apkFile, File outDir) public void decodeManifestRaw(ExtFile apkFile, File outDir)
throws AndrolibException { throws AndrolibException {
try { try {
LOGGER.info("Copying raw manifest..."); LOGGER.fine("Copying raw manifest...");
apkFile.getDirectory().copyToDir(outDir, APK_MANIFEST_FILENAMES); apkFile.getDirectory().copyToDir(outDir, APK_MANIFEST_FILENAMES);
} catch (DirectoryException ex) { } catch (DirectoryException ex) {
throw new AndrolibException(ex); throw new AndrolibException(ex);
@ -128,7 +128,7 @@ public class Androlib {
public void decodeResourcesRaw(ExtFile apkFile, File outDir) public void decodeResourcesRaw(ExtFile apkFile, File outDir)
throws AndrolibException { throws AndrolibException {
try { try {
LOGGER.info("Copying raw resources..."); LOGGER.fine("Copying raw resources...");
apkFile.getDirectory().copyToDir(outDir, APK_RESOURCES_FILENAMES); apkFile.getDirectory().copyToDir(outDir, APK_RESOURCES_FILENAMES);
} catch (DirectoryException ex) { } catch (DirectoryException ex) {
throw new AndrolibException(ex); throw new AndrolibException(ex);
@ -147,7 +147,7 @@ public class Androlib {
public void decodeRawFiles(ExtFile apkFile, File outDir, short decodeAssetMode) public void decodeRawFiles(ExtFile apkFile, File outDir, short decodeAssetMode)
throws AndrolibException { throws AndrolibException {
LOGGER.info("Copying assets and libs..."); LOGGER.fine("Copying assets and libs...");
try { try {
Directory in = apkFile.getDirectory(); Directory in = apkFile.getDirectory();
@ -206,7 +206,7 @@ public class Androlib {
public void decodeUnknownFiles(ExtFile apkFile, File outDir) public void decodeUnknownFiles(ExtFile apkFile, File outDir)
throws AndrolibException { throws AndrolibException {
LOGGER.info("Copying unknown files..."); LOGGER.fine("Copying unknown files...");
File unknownOut = new File(outDir, UNK_DIRNAME); File unknownOut = new File(outDir, UNK_DIRNAME);
try { try {
Directory unk = apkFile.getDirectory(); Directory unk = apkFile.getDirectory();
@ -230,7 +230,7 @@ public class Androlib {
public void writeOriginalFiles(ExtFile apkFile, File outDir) public void writeOriginalFiles(ExtFile apkFile, File outDir)
throws AndrolibException { throws AndrolibException {
LOGGER.info("Copying original files..."); LOGGER.fine("Copying original files...");
File originalDir = new File(outDir, "original"); File originalDir = new File(outDir, "original");
if (!originalDir.exists()) { if (!originalDir.exists()) {
originalDir.mkdirs(); originalDir.mkdirs();
@ -251,7 +251,7 @@ public class Androlib {
// If the original APK contains the folder META-INF/services folder // If the original APK contains the folder META-INF/services folder
// that is used for service locators (like coroutines on android), // that is used for service locators (like coroutines on android),
// copy it to the destination folder so it does not get dropped. // copy it to the destination folder so it does not get dropped.
LOGGER.info("Copying META-INF/services directory"); LOGGER.fine("Copying META-INF/services directory");
in.copyToDir(outDir, "META-INF/services"); in.copyToDir(outDir, "META-INF/services");
} }
} }
@ -286,7 +286,7 @@ public class Androlib {
public void build(ExtFile appDir, File outFile) public void build(ExtFile appDir, File outFile)
throws BrutException { throws BrutException {
LOGGER.info("Using Apktool " + Androlib.getVersion()); LOGGER.fine("Using Apktool " + Androlib.getVersion());
MetaInfo meta = readMetaFile(appDir); MetaInfo meta = readMetaFile(appDir);
buildOptions.isFramework = meta.isFrameworkApk; buildOptions.isFramework = meta.isFrameworkApk;
@ -337,7 +337,7 @@ public class Androlib {
throw new AndrolibException(ex.getMessage()); throw new AndrolibException(ex.getMessage());
} }
} }
LOGGER.info("Built apk..."); LOGGER.fine("Built apk...");
} }
private void buildManifestFile(File appDir, File manifest, File manifestOriginal) private void buildManifestFile(File appDir, File manifest, File manifestOriginal)
@ -407,7 +407,7 @@ public class Androlib {
} }
File stored = new File(appDir, APK_DIRNAME + "/" + filename); File stored = new File(appDir, APK_DIRNAME + "/" + filename);
if (buildOptions.forceBuildAll || isModified(working, stored)) { if (buildOptions.forceBuildAll || isModified(working, stored)) {
LOGGER.info("Copying " + appDir.toString() + " " + filename + " file..."); LOGGER.fine("Copying " + appDir.toString() + " " + filename + " file...");
try { try {
BrutIO.copyAndClose(new FileInputStream(working), new FileOutputStream(stored)); BrutIO.copyAndClose(new FileInputStream(working), new FileOutputStream(stored));
return true; return true;
@ -426,10 +426,10 @@ public class Androlib {
} }
File dex = new File(appDir, APK_DIRNAME + "/" + filename); File dex = new File(appDir, APK_DIRNAME + "/" + filename);
if (! buildOptions.forceBuildAll) { if (! buildOptions.forceBuildAll) {
LOGGER.info("Checking whether sources has changed..."); LOGGER.fine("Checking whether sources has changed...");
} }
if (buildOptions.forceBuildAll || isModified(smaliDir, dex)) { if (buildOptions.forceBuildAll || isModified(smaliDir, dex)) {
LOGGER.info("Smaling " + folder + " folder into " + filename + "..."); LOGGER.fine("Smaling " + folder + " folder into " + filename + "...");
dex.delete(); dex.delete();
SmaliBuilder.build(smaliDir, dex, buildOptions.forceApi > 0 ? buildOptions.forceApi : mMinSdkVersion); SmaliBuilder.build(smaliDir, dex, buildOptions.forceApi > 0 ? buildOptions.forceApi : mMinSdkVersion);
} }
@ -452,11 +452,11 @@ public class Androlib {
} }
File apkDir = new File(appDir, APK_DIRNAME); File apkDir = new File(appDir, APK_DIRNAME);
if (! buildOptions.forceBuildAll) { if (! buildOptions.forceBuildAll) {
LOGGER.info("Checking whether resources has changed..."); LOGGER.fine("Checking whether resources has changed...");
} }
if (buildOptions.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.fine("Copying raw resources...");
appDir.getDirectory().copyToDir(apkDir, APK_RESOURCES_FILENAMES); appDir.getDirectory().copyToDir(apkDir, APK_RESOURCES_FILENAMES);
} }
return true; return true;
@ -472,18 +472,18 @@ public class Androlib {
return false; return false;
} }
if (! buildOptions.forceBuildAll) { if (! buildOptions.forceBuildAll) {
LOGGER.info("Checking whether resources has changed..."); LOGGER.fine("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 (buildOptions.forceBuildAll || isModified(newFiles(APP_RESOURCES_FILENAMES, appDir), if (buildOptions.forceBuildAll || isModified(newFiles(APP_RESOURCES_FILENAMES, appDir),
newFiles(APK_RESOURCES_FILENAMES, apkDir)) || (buildOptions.isAapt2() && !isFile(resourceFile))) { newFiles(APK_RESOURCES_FILENAMES, apkDir)) || (buildOptions.isAapt2() && !isFile(resourceFile))) {
LOGGER.info("Building resources..."); LOGGER.fine("Building resources...");
if (buildOptions.debugMode) { if (buildOptions.debugMode) {
if (buildOptions.isAapt2()) { if (buildOptions.isAapt2()) {
LOGGER.info("Using aapt2 - setting 'debuggable' attribute to 'true' in AndroidManifest.xml"); LOGGER.fine("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 {
ResXmlPatcher.removeApplicationDebugTag(new File(appDir, "AndroidManifest.xml")); ResXmlPatcher.removeApplicationDebugTag(new File(appDir, "AndroidManifest.xml"));
@ -499,12 +499,12 @@ public class Androlib {
} }
File netSecConfOrig = new File(appDir, "res/xml/network_security_config.xml"); File netSecConfOrig = new File(appDir, "res/xml/network_security_config.xml");
if (netSecConfOrig.exists()) { if (netSecConfOrig.exists()) {
LOGGER.info("Replacing existing network_security_config.xml!"); LOGGER.fine("Replacing existing network_security_config.xml!");
netSecConfOrig.delete(); netSecConfOrig.delete();
} }
ResXmlPatcher.modNetworkSecurityConfig(netSecConfOrig); ResXmlPatcher.modNetworkSecurityConfig(netSecConfOrig);
ResXmlPatcher.setNetworkSecurityConfig(new File(appDir, "AndroidManifest.xml")); ResXmlPatcher.setNetworkSecurityConfig(new File(appDir, "AndroidManifest.xml"));
LOGGER.info("Added permissive network security config in manifest"); LOGGER.fine("Added permissive network security config in manifest");
} }
File apkFile = File.createTempFile("APKTOOL", null); File apkFile = File.createTempFile("APKTOOL", null);
@ -548,7 +548,7 @@ public class Androlib {
throws AndrolibException { throws AndrolibException {
try { try {
File apkDir = new File(appDir, APK_DIRNAME); File apkDir = new File(appDir, APK_DIRNAME);
LOGGER.info("Copying raw AndroidManifest.xml..."); LOGGER.fine("Copying raw AndroidManifest.xml...");
appDir.getDirectory().copyToDir(apkDir, APK_MANIFEST_FILENAMES); appDir.getDirectory().copyToDir(apkDir, APK_MANIFEST_FILENAMES);
return true; return true;
} catch (DirectoryException ex) { } catch (DirectoryException ex) {
@ -563,14 +563,14 @@ public class Androlib {
return false; return false;
} }
if (! buildOptions.forceBuildAll) { if (! buildOptions.forceBuildAll) {
LOGGER.info("Checking whether resources has changed..."); LOGGER.fine("Checking whether resources has changed...");
} }
File apkDir = new File(appDir, APK_DIRNAME); File apkDir = new File(appDir, APK_DIRNAME);
if (buildOptions.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.fine("Building AndroidManifest.xml...");
File apkFile = File.createTempFile("APKTOOL", null); File apkFile = File.createTempFile("APKTOOL", null);
apkFile.delete(); apkFile.delete();
@ -614,7 +614,7 @@ public class Androlib {
File stored = new File(appDir, APK_DIRNAME + "/" + folder); File stored = new File(appDir, APK_DIRNAME + "/" + folder);
if (buildOptions.forceBuildAll || isModified(working, stored)) { if (buildOptions.forceBuildAll || isModified(working, stored)) {
LOGGER.info("Copying libs... (/" + folder + ")"); LOGGER.fine("Copying libs... (/" + folder + ")");
try { try {
OS.rmdir(stored); OS.rmdir(stored);
OS.cpdir(working, stored); OS.cpdir(working, stored);
@ -630,18 +630,18 @@ public class Androlib {
File originalDir = new File(appDir, "original"); File originalDir = new File(appDir, "original");
if (originalDir.exists()) { if (originalDir.exists()) {
try { try {
LOGGER.info("Copy original files..."); LOGGER.fine("Copy original files...");
Directory in = (new ExtFile(originalDir)).getDirectory(); Directory in = (new ExtFile(originalDir)).getDirectory();
if (in.containsFile("AndroidManifest.xml")) { if (in.containsFile("AndroidManifest.xml")) {
LOGGER.info("Copy AndroidManifest.xml..."); LOGGER.fine("Copy AndroidManifest.xml...");
in.copyToDir(new File(appDir, APK_DIRNAME), "AndroidManifest.xml"); in.copyToDir(new File(appDir, APK_DIRNAME), "AndroidManifest.xml");
} }
if (in.containsFile("stamp-cert-sha256")) { if (in.containsFile("stamp-cert-sha256")) {
LOGGER.info("Copy stamp-cert-sha256..."); LOGGER.fine("Copy stamp-cert-sha256...");
in.copyToDir(new File(appDir, APK_DIRNAME), "stamp-cert-sha256"); in.copyToDir(new File(appDir, APK_DIRNAME), "stamp-cert-sha256");
} }
if (in.containsDir("META-INF")) { if (in.containsDir("META-INF")) {
LOGGER.info("Copy META-INF..."); LOGGER.fine("Copy META-INF...");
in.copyToDir(new File(appDir, APK_DIRNAME), "META-INF"); in.copyToDir(new File(appDir, APK_DIRNAME), "META-INF");
} }
} catch (DirectoryException ex) { } catch (DirectoryException ex) {
@ -654,7 +654,7 @@ public class Androlib {
public void buildUnknownFiles(File appDir, File outFile, MetaInfo meta) public void buildUnknownFiles(File appDir, File outFile, MetaInfo meta)
throws AndrolibException { throws AndrolibException {
if (meta.unknownFiles != null) { if (meta.unknownFiles != null) {
LOGGER.info("Copying unknown files/dir..."); LOGGER.fine("Copying unknown files/dir...");
Map<String, String> files = meta.unknownFiles; Map<String, String> files = meta.unknownFiles;
File tempFile = new File(outFile.getParent(), outFile.getName() + ".apktool_temp"); File tempFile = new File(outFile.getParent(), outFile.getName() + ".apktool_temp");
@ -738,7 +738,7 @@ public class Androlib {
} }
public void buildApk(File appDir, File outApk) throws AndrolibException { public void buildApk(File appDir, File outApk) throws AndrolibException {
LOGGER.info("Building apk file..."); LOGGER.fine("Building apk file...");
if (outApk.exists()) { if (outApk.exists()) {
outApk.delete(); outApk.delete();
} else { } else {

View File

@ -91,7 +91,7 @@ public class ApkDecoder {
} }
outDir.mkdirs(); outDir.mkdirs();
LOGGER.info("Using Apktool " + Androlib.getVersion() + " on " + mApkFile.getName()); LOGGER.fine("Using Apktool " + Androlib.getVersion() + " on " + mApkFile.getName());
if (hasResources()) { if (hasResources()) {
switch (mDecodeResources) { switch (mDecodeResources) {

View File

@ -61,7 +61,7 @@ final public class AndrolibResources {
public ResPackage loadMainPkg(ResTable resTable, ExtFile apkFile) public ResPackage loadMainPkg(ResTable resTable, ExtFile apkFile)
throws AndrolibException { throws AndrolibException {
LOGGER.info("Loading resource table..."); LOGGER.fine("Loading resource table...");
ResPackage[] pkgs = getResPackagesFromApk(apkFile, resTable, sKeepBroken); ResPackage[] pkgs = getResPackagesFromApk(apkFile, resTable, sKeepBroken);
ResPackage pkg; ResPackage pkg;
@ -108,7 +108,7 @@ final public class AndrolibResources {
throws AndrolibException { throws AndrolibException {
File apk = getFrameworkApk(id, frameTag); File apk = getFrameworkApk(id, frameTag);
LOGGER.info("Loading resource table from file: " + apk); LOGGER.fine("Loading resource table from file: " + apk);
mFramework = new ExtFile(apk); mFramework = new ExtFile(apk);
ResPackage[] pkgs = getResPackagesFromApk(mFramework, resTable, true); ResPackage[] pkgs = getResPackagesFromApk(mFramework, resTable, true);
@ -147,7 +147,7 @@ final public class AndrolibResources {
inApk = apkFile.getDirectory(); inApk = apkFile.getDirectory();
out = new FileDirectory(outDir); out = new FileDirectory(outDir);
LOGGER.info("Decoding AndroidManifest.xml with only framework resources..."); LOGGER.fine("Decoding AndroidManifest.xml with only framework resources...");
fileDecoder.decodeManifest(inApk, "AndroidManifest.xml", out, "AndroidManifest.xml"); fileDecoder.decodeManifest(inApk, "AndroidManifest.xml", out, "AndroidManifest.xml");
} catch (DirectoryException ex) { } catch (DirectoryException ex) {
@ -169,9 +169,9 @@ final public class AndrolibResources {
// 1) Check if pkgOriginal === mPackageRenamed // 1) Check if pkgOriginal === mPackageRenamed
// 2) Check if pkgOriginal is ignored via IGNORED_PACKAGES // 2) Check if pkgOriginal is ignored via IGNORED_PACKAGES
if (pkgOriginal.equalsIgnoreCase(mPackageRenamed) || (Arrays.asList(IGNORED_PACKAGES).contains(pkgOriginal))) { if (pkgOriginal.equalsIgnoreCase(mPackageRenamed) || (Arrays.asList(IGNORED_PACKAGES).contains(pkgOriginal))) {
LOGGER.info("Regular manifest package..."); LOGGER.fine("Regular manifest package...");
} else { } else {
LOGGER.info("Renamed manifest package found! Replacing " + mPackageRenamed + " with " + pkgOriginal); LOGGER.fine("Renamed manifest package found! Replacing " + mPackageRenamed + " with " + pkgOriginal);
ResXmlPatcher.renameManifestPackage(new File(filePath), pkgOriginal); ResXmlPatcher.renameManifestPackage(new File(filePath), pkgOriginal);
} }
} }
@ -189,7 +189,7 @@ final public class AndrolibResources {
try { try {
inApk = apkFile.getDirectory(); inApk = apkFile.getDirectory();
out = new FileDirectory(outDir); out = new FileDirectory(outDir);
LOGGER.info("Decoding AndroidManifest.xml with resources..."); LOGGER.fine("Decoding AndroidManifest.xml with resources...");
fileDecoder.decodeManifest(inApk, "AndroidManifest.xml", out, "AndroidManifest.xml"); fileDecoder.decodeManifest(inApk, "AndroidManifest.xml", out, "AndroidManifest.xml");
@ -243,12 +243,12 @@ final public class AndrolibResources {
for (ResPackage pkg : resTable.listMainPackages()) { for (ResPackage pkg : resTable.listMainPackages()) {
attrDecoder.setCurrentPackage(pkg); attrDecoder.setCurrentPackage(pkg);
LOGGER.info("Decoding file-resources..."); LOGGER.fine("Decoding file-resources...");
for (ResResource res : pkg.listFiles()) { for (ResResource res : pkg.listFiles()) {
fileDecoder.decode(res, in, out); fileDecoder.decode(res, in, out);
} }
LOGGER.info("Decoding values */* XMLs..."); LOGGER.fine("Decoding values */* XMLs...");
for (ResValuesFile valuesFile : pkg.listValuesFiles()) { for (ResValuesFile valuesFile : pkg.listValuesFiles()) {
generateValuesFile(valuesFile, out, xmlSerializer); generateValuesFile(valuesFile, out, xmlSerializer);
} }
@ -837,7 +837,7 @@ final public class AndrolibResources {
} else { } else {
for (File file : dir.listFiles()) { for (File file : dir.listFiles()) {
if (file.isFile() && file.getName().endsWith(".apk")) { if (file.isFile() && file.getName().endsWith(".apk")) {
LOGGER.info("Removing " + file.getName() + " framework file..."); LOGGER.fine("Removing " + file.getName() + " framework file...");
file.delete(); file.delete();
} }
} }
@ -857,7 +857,7 @@ final public class AndrolibResources {
for (File file : Objects.requireNonNull(dir.listFiles())) { for (File file : Objects.requireNonNull(dir.listFiles())) {
if (file.isFile() && file.getName().endsWith(".apk")) { if (file.isFile() && file.getName().endsWith(".apk")) {
LOGGER.info(file.getName()); LOGGER.fine(file.getName());
} }
} }
} }
@ -917,7 +917,7 @@ final public class AndrolibResources {
} }
zip.close(); zip.close();
LOGGER.info("Framework installed to: " + outFile); LOGGER.fine("Framework installed to: " + outFile);
} catch (IOException ex) { } catch (IOException ex) {
throw new AndrolibException(ex); throw new AndrolibException(ex);
} finally { } finally {

View File

@ -159,7 +159,7 @@ public class ARSCDecoder {
for (int i = 0; i < libraryCount; i++) { for (int i = 0; i < libraryCount; i++) {
packageId = mIn.readInt(); packageId = mIn.readInt();
packageName = mIn.readNullEndedString(128, true); packageName = mIn.readNullEndedString(128, true);
LOGGER.info(String.format("Decoding Shared Library (%s), pkgId: %d", packageName, packageId)); LOGGER.fine(String.format("Decoding Shared Library (%s), pkgId: %d", packageName, packageId));
} }
while(nextChunk().type == Header.XML_TYPE_TYPE) { while(nextChunk().type == Header.XML_TYPE_TYPE) {
@ -171,7 +171,7 @@ public class ARSCDecoder {
int count = mIn.readInt(); int count = mIn.readInt();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
LOGGER.info(String.format("Skipping staged alias stagedId (%h) finalId: %h", mIn.readInt(), mIn.readInt())); LOGGER.fine(String.format("Skipping staged alias stagedId (%h) finalId: %h", mIn.readInt(), mIn.readInt()));
} }
nextChunk(); nextChunk();
@ -182,7 +182,7 @@ public class ARSCDecoder {
int count = mIn.readInt(); int count = mIn.readInt();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
LOGGER.info(String.format("Skipping overlay (%h)", mIn.readInt())); LOGGER.fine(String.format("Skipping overlay (%h)", mIn.readInt()));
} }
nextChunk(); nextChunk();
@ -264,7 +264,7 @@ public class ARSCDecoder {
} }
if (typeFlags == 1) { if (typeFlags == 1) {
LOGGER.info("Sparse type flags detected: " + mTypeSpec.getName()); LOGGER.fine("Sparse type flags detected: " + mTypeSpec.getName());
} }
int[] entryOffsets = mIn.readIntArray(entryCount); int[] entryOffsets = mIn.readIntArray(entryCount);
@ -685,7 +685,7 @@ public class ARSCDecoder {
throw new AndrolibException("Arsc file contains zero packages"); throw new AndrolibException("Arsc file contains zero packages");
} else if (mPackages.length != 1) { } else if (mPackages.length != 1) {
int id = findPackageWithMostResSpecs(); int id = findPackageWithMostResSpecs();
LOGGER.info("Arsc file contains multiple packages. Using package " LOGGER.fine("Arsc file contains multiple packages. Using package "
+ mPackages[id].getName() + " as default."); + mPackages[id].getName() + " as default.");
return mPackages[id]; return mPackages[id];

View File

@ -36,17 +36,17 @@ public class AndroidOreoNotSparseTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "issue1594-orig"); sTestOrigDir = new ExtFile(sTmpDir, "issue1594-orig");
sTestNewDir = new ExtFile(sTmpDir, "issue1594-new"); sTestNewDir = new ExtFile(sTmpDir, "issue1594-new");
LOGGER.info("Unpacking not_sparse.apk..."); LOGGER.fine("Unpacking not_sparse.apk...");
TestUtils.copyResourceDir(AndroidOreoNotSparseTest.class, "aapt1/issue1594", sTestOrigDir); TestUtils.copyResourceDir(AndroidOreoNotSparseTest.class, "aapt1/issue1594", sTestOrigDir);
File testApk = new File(sTestOrigDir, "not_sparse.apk"); File testApk = new File(sTestOrigDir, "not_sparse.apk");
LOGGER.info("Decoding not_sparse.apk..."); LOGGER.fine("Decoding not_sparse.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();
LOGGER.info("Building not_sparse.apk..."); LOGGER.fine("Building not_sparse.apk...");
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
new Androlib(buildOptions).build(sTestNewDir, testApk); new Androlib(buildOptions).build(sTestNewDir, testApk);
} }

View File

@ -36,17 +36,17 @@ public class AndroidOreoSparseTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "issue1594-orig"); sTestOrigDir = new ExtFile(sTmpDir, "issue1594-orig");
sTestNewDir = new ExtFile(sTmpDir, "issue1594-new"); sTestNewDir = new ExtFile(sTmpDir, "issue1594-new");
LOGGER.info("Unpacking sparse.apk..."); LOGGER.fine("Unpacking sparse.apk...");
TestUtils.copyResourceDir(AndroidOreoSparseTest.class, "aapt1/issue1594", sTestOrigDir); TestUtils.copyResourceDir(AndroidOreoSparseTest.class, "aapt1/issue1594", sTestOrigDir);
File testApk = new File(sTestOrigDir, "sparse.apk"); File testApk = new File(sTestOrigDir, "sparse.apk");
LOGGER.info("Decoding sparse.apk..."); LOGGER.fine("Decoding sparse.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();
LOGGER.info("Building sparse.apk..."); LOGGER.fine("Building sparse.apk...");
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
new Androlib(buildOptions).build(sTestNewDir, testApk); new Androlib(buildOptions).build(sTestNewDir, testApk);
} }

View File

@ -39,14 +39,14 @@ public class BuildAndDecodeJarTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "testjar-orig"); sTestOrigDir = new ExtFile(sTmpDir, "testjar-orig");
sTestNewDir = new ExtFile(sTmpDir, "testjar-new"); sTestNewDir = new ExtFile(sTmpDir, "testjar-new");
LOGGER.info("Unpacking testjar..."); LOGGER.fine("Unpacking testjar...");
TestUtils.copyResourceDir(BuildAndDecodeJarTest.class, "aapt1/testjar/", sTestOrigDir); TestUtils.copyResourceDir(BuildAndDecodeJarTest.class, "aapt1/testjar/", sTestOrigDir);
LOGGER.info("Building testjar.jar..."); LOGGER.fine("Building testjar.jar...");
File testJar = new File(sTmpDir, "testjar.jar"); File testJar = new File(sTmpDir, "testjar.jar");
new Androlib().build(sTestOrigDir, testJar); new Androlib().build(sTestOrigDir, testJar);
LOGGER.info("Decoding testjar.jar..."); LOGGER.fine("Decoding testjar.jar...");
ApkDecoder apkDecoder = new ApkDecoder(testJar); ApkDecoder apkDecoder = new ApkDecoder(testJar);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();

View File

@ -47,14 +47,14 @@ public class BuildAndDecodeTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig"); sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
sTestNewDir = new ExtFile(sTmpDir, "testapp-new"); sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
LOGGER.info("Unpacking testapp..."); LOGGER.fine("Unpacking testapp...");
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "aapt1/testapp/", sTestOrigDir); TestUtils.copyResourceDir(BuildAndDecodeTest.class, "aapt1/testapp/", sTestOrigDir);
LOGGER.info("Building testapp.apk..."); LOGGER.fine("Building testapp.apk...");
File testApk = new File(sTmpDir, "testapp.apk"); File testApk = new File(sTmpDir, "testapp.apk");
new Androlib().build(sTestOrigDir, testApk); new Androlib().build(sTestOrigDir, testApk);
LOGGER.info("Decoding testapp.apk..."); LOGGER.fine("Decoding testapp.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();

View File

@ -43,17 +43,17 @@ public class DebugTagRetainedTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "issue1235-orig"); sTestOrigDir = new ExtFile(sTmpDir, "issue1235-orig");
sTestNewDir = new ExtFile(sTmpDir, "issue1235-new"); sTestNewDir = new ExtFile(sTmpDir, "issue1235-new");
LOGGER.info("Unpacking issue1235..."); LOGGER.fine("Unpacking issue1235...");
TestUtils.copyResourceDir(DebugTagRetainedTest.class, "aapt1/issue1235/", sTestOrigDir); TestUtils.copyResourceDir(DebugTagRetainedTest.class, "aapt1/issue1235/", sTestOrigDir);
LOGGER.info("Building issue1235.apk..."); LOGGER.fine("Building issue1235.apk...");
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
buildOptions.debugMode = true; buildOptions.debugMode = true;
File testApk = new File(sTmpDir, "issue1235.apk"); File testApk = new File(sTmpDir, "issue1235.apk");
new Androlib(buildOptions).build(sTestOrigDir, testApk); new Androlib(buildOptions).build(sTestOrigDir, testApk);
LOGGER.info("Decoding issue1235.apk..."); LOGGER.fine("Decoding issue1235.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();

View File

@ -41,14 +41,14 @@ public class DefaultBaksmaliVariableTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "testjar-orig"); sTestOrigDir = new ExtFile(sTmpDir, "testjar-orig");
sTestNewDir = new ExtFile(sTmpDir, "testjar-new"); sTestNewDir = new ExtFile(sTmpDir, "testjar-new");
LOGGER.info("Unpacking testjar..."); LOGGER.fine("Unpacking testjar...");
TestUtils.copyResourceDir(DefaultBaksmaliVariableTest.class, "aapt1/issue1481/", sTestOrigDir); TestUtils.copyResourceDir(DefaultBaksmaliVariableTest.class, "aapt1/issue1481/", sTestOrigDir);
LOGGER.info("Building issue1481.jar..."); LOGGER.fine("Building issue1481.jar...");
File testJar = new File(sTmpDir, "issue1481.jar"); File testJar = new File(sTmpDir, "issue1481.jar");
new Androlib().build(sTestOrigDir, testJar); new Androlib().build(sTestOrigDir, testJar);
LOGGER.info("Decoding issue1481.jar..."); LOGGER.fine("Decoding issue1481.jar...");
ApkDecoder apkDecoder = new ApkDecoder(testJar); ApkDecoder apkDecoder = new ApkDecoder(testJar);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();

View File

@ -39,17 +39,17 @@ public class EmptyResourcesArscTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "issue1730-orig"); sTestOrigDir = new ExtFile(sTmpDir, "issue1730-orig");
sTestNewDir = new ExtFile(sTmpDir, "issue1730-new"); sTestNewDir = new ExtFile(sTmpDir, "issue1730-new");
LOGGER.info("Unpacking issue1730.apk..."); LOGGER.fine("Unpacking issue1730.apk...");
TestUtils.copyResourceDir(EmptyResourcesArscTest.class, "aapt1/issue1730", sTestOrigDir); TestUtils.copyResourceDir(EmptyResourcesArscTest.class, "aapt1/issue1730", sTestOrigDir);
File testApk = new File(sTestOrigDir, "issue1730.apk"); File testApk = new File(sTestOrigDir, "issue1730.apk");
LOGGER.info("Decoding issue1730.apk..."); LOGGER.fine("Decoding issue1730.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();
LOGGER.info("Building issue1730.apk..."); LOGGER.fine("Building issue1730.apk...");
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
new Androlib(buildOptions).build(sTestNewDir, testApk); new Androlib(buildOptions).build(sTestNewDir, testApk);
} }

View File

@ -40,18 +40,18 @@ public class BuildAndDecodeTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig"); sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
sTestNewDir = new ExtFile(sTmpDir, "testapp-new"); sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
LOGGER.info("Unpacking testapp..."); LOGGER.fine("Unpacking testapp...");
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "aapt2/testapp/", sTestOrigDir); TestUtils.copyResourceDir(BuildAndDecodeTest.class, "aapt2/testapp/", sTestOrigDir);
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
buildOptions.useAapt2 = true; buildOptions.useAapt2 = true;
buildOptions.verbose = true; buildOptions.verbose = true;
LOGGER.info("Building testapp.apk..."); LOGGER.fine("Building testapp.apk...");
File testApk = new File(sTmpDir, "testapp.apk"); File testApk = new File(sTmpDir, "testapp.apk");
new Androlib(buildOptions).build(sTestOrigDir, testApk); new Androlib(buildOptions).build(sTestOrigDir, testApk);
LOGGER.info("Decoding testapp.apk..."); LOGGER.fine("Decoding testapp.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();

View File

@ -43,10 +43,10 @@ public class DebuggableFalseChangeToTrueTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "issue2328-debuggable-false-orig"); sTestOrigDir = new ExtFile(sTmpDir, "issue2328-debuggable-false-orig");
sTestNewDir = new ExtFile(sTmpDir, "issue2328-debuggable-flase-new"); sTestNewDir = new ExtFile(sTmpDir, "issue2328-debuggable-flase-new");
LOGGER.info("Unpacking issue2328-debuggable-flase..."); LOGGER.fine("Unpacking issue2328-debuggable-flase...");
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.fine("Building issue2328-debuggable-flase.apk...");
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
buildOptions.debugMode = true; buildOptions.debugMode = true;
buildOptions.useAapt2 = true; buildOptions.useAapt2 = true;
@ -55,7 +55,7 @@ public class DebuggableFalseChangeToTrueTest extends BaseTest {
File testApk = new File(sTmpDir, "issue2328-debuggable-flase.apk"); File testApk = new File(sTmpDir, "issue2328-debuggable-flase.apk");
new Androlib(buildOptions).build(sTestOrigDir, testApk); new Androlib(buildOptions).build(sTestOrigDir, testApk);
LOGGER.info("Decoding issue2328-debuggable-flase.apk..."); LOGGER.fine("Decoding issue2328-debuggable-flase.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();

View File

@ -43,10 +43,10 @@ public class DebuggableTrueAddedTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "issue2328-debuggable-missing-orig"); sTestOrigDir = new ExtFile(sTmpDir, "issue2328-debuggable-missing-orig");
sTestNewDir = new ExtFile(sTmpDir, "issue2328-debuggable-missing-new"); sTestNewDir = new ExtFile(sTmpDir, "issue2328-debuggable-missing-new");
LOGGER.info("Unpacking issue2328-debuggable-missing..."); LOGGER.fine("Unpacking issue2328-debuggable-missing...");
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.fine("Building issue2328-debuggable-missing.apk...");
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
buildOptions.debugMode = true; buildOptions.debugMode = true;
buildOptions.useAapt2 = true; buildOptions.useAapt2 = true;
@ -55,7 +55,7 @@ public class DebuggableTrueAddedTest extends BaseTest {
File testApk = new File(sTmpDir, "issue2328-debuggable-missing.apk"); File testApk = new File(sTmpDir, "issue2328-debuggable-missing.apk");
new Androlib(buildOptions).build(sTestOrigDir, testApk); new Androlib(buildOptions).build(sTestOrigDir, testApk);
LOGGER.info("Decoding issue2328-debuggable-missing.apk..."); LOGGER.fine("Decoding issue2328-debuggable-missing.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();

View File

@ -43,10 +43,10 @@ public class DebuggableTrueRetainedTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "issue2328-debuggable-true-orig"); sTestOrigDir = new ExtFile(sTmpDir, "issue2328-debuggable-true-orig");
sTestNewDir = new ExtFile(sTmpDir, "issue2328-debuggable-true-new"); sTestNewDir = new ExtFile(sTmpDir, "issue2328-debuggable-true-new");
LOGGER.info("Unpacking issue2328-debuggable-true..."); LOGGER.fine("Unpacking issue2328-debuggable-true...");
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.fine("Building issue2328-debuggable-true.apk...");
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
buildOptions.debugMode = true; buildOptions.debugMode = true;
buildOptions.useAapt2 = true; buildOptions.useAapt2 = true;
@ -55,7 +55,7 @@ public class DebuggableTrueRetainedTest extends BaseTest {
File testApk = new File(sTmpDir, "issue2328-debuggable-true.apk"); File testApk = new File(sTmpDir, "issue2328-debuggable-true.apk");
new Androlib(buildOptions).build(sTestOrigDir, testApk); new Androlib(buildOptions).build(sTestOrigDir, testApk);
LOGGER.info("Decoding issue2328-debuggable-true.apk..."); LOGGER.fine("Decoding issue2328-debuggable-true.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();

View File

@ -49,17 +49,17 @@ public class NetworkConfigTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig"); sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
sTestNewDir = new ExtFile(sTmpDir, "testapp-new"); sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
LOGGER.info("Unpacking testapp..."); LOGGER.fine("Unpacking testapp...");
TestUtils.copyResourceDir(NetworkConfigTest.class, "aapt2/network_config/", sTestOrigDir); TestUtils.copyResourceDir(NetworkConfigTest.class, "aapt2/network_config/", sTestOrigDir);
LOGGER.info("Building testapp.apk..."); LOGGER.fine("Building testapp.apk...");
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
buildOptions.netSecConf = true; buildOptions.netSecConf = true;
buildOptions.useAapt2 = true; buildOptions.useAapt2 = true;
File testApk = new File(sTmpDir, "testapp.apk"); File testApk = new File(sTmpDir, "testapp.apk");
new Androlib(buildOptions).build(sTestOrigDir, testApk); new Androlib(buildOptions).build(sTestOrigDir, testApk);
LOGGER.info("Decoding testapp.apk..."); LOGGER.fine("Decoding testapp.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();
@ -77,7 +77,7 @@ public class NetworkConfigTest extends BaseTest {
@Test @Test
public void netSecConfGeneric() throws IOException, SAXException { public void netSecConfGeneric() throws IOException, SAXException {
LOGGER.info("Comparing network security configuration file..."); LOGGER.fine("Comparing network security configuration file...");
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
"<network-security-config><base-config><trust-anchors><certificates src=\"system\"/><certificates src=\"us" + "<network-security-config><base-config><trust-anchors><certificates src=\"system\"/><certificates src=\"us" +
"er\"/></trust-anchors></base-config></network-security-config>"); "er\"/></trust-anchors></base-config></network-security-config>");
@ -94,7 +94,7 @@ public class NetworkConfigTest extends BaseTest {
@Test @Test
public void netSecConfInManifest() throws IOException, ParserConfigurationException, SAXException { public void netSecConfInManifest() throws IOException, ParserConfigurationException, SAXException {
LOGGER.info("Validating network security config in Manifest..."); LOGGER.fine("Validating network security config in Manifest...");
Document doc = loadDocument(new File(sTestNewDir + "/AndroidManifest.xml")); Document doc = loadDocument(new File(sTestNewDir + "/AndroidManifest.xml"));
Node application = doc.getElementsByTagName("application").item(0); Node application = doc.getElementsByTagName("application").item(0);
NamedNodeMap attr = application.getAttributes(); NamedNodeMap attr = application.getAttributes();

View File

@ -52,17 +52,17 @@ public class NoNetworkConfigTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig"); sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
sTestNewDir = new ExtFile(sTmpDir, "testapp-new"); sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
LOGGER.info("Unpacking testapp..."); LOGGER.fine("Unpacking testapp...");
TestUtils.copyResourceDir(NoNetworkConfigTest.class, "aapt2/testapp/", sTestOrigDir); TestUtils.copyResourceDir(NoNetworkConfigTest.class, "aapt2/testapp/", sTestOrigDir);
LOGGER.info("Building testapp.apk..."); LOGGER.fine("Building testapp.apk...");
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
buildOptions.netSecConf = true; buildOptions.netSecConf = true;
buildOptions.useAapt2 = true; buildOptions.useAapt2 = true;
File testApk = new File(sTmpDir, "testapp.apk"); File testApk = new File(sTmpDir, "testapp.apk");
new Androlib(buildOptions).build(sTestOrigDir, testApk); new Androlib(buildOptions).build(sTestOrigDir, testApk);
LOGGER.info("Decoding testapp.apk..."); LOGGER.fine("Decoding testapp.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();
@ -80,7 +80,7 @@ public class NoNetworkConfigTest extends BaseTest {
@Test @Test
public void netSecConfGeneric() throws IOException, SAXException { public void netSecConfGeneric() throws IOException, SAXException {
LOGGER.info("Comparing network security configuration file..."); LOGGER.fine("Comparing network security configuration file...");
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
"<network-security-config><base-config><trust-anchors><certificates src=\"system\"/><certificates src=\"us" + "<network-security-config><base-config><trust-anchors><certificates src=\"system\"/><certificates src=\"us" +
"er\"/></trust-anchors></base-config></network-security-config>"); "er\"/></trust-anchors></base-config></network-security-config>");
@ -97,7 +97,7 @@ public class NoNetworkConfigTest extends BaseTest {
@Test @Test
public void netSecConfInManifest() throws IOException, ParserConfigurationException, SAXException { public void netSecConfInManifest() throws IOException, ParserConfigurationException, SAXException {
LOGGER.info("Validating network security config in Manifest..."); LOGGER.fine("Validating network security config in Manifest...");
Document doc = loadDocument(new File(sTestNewDir + "/AndroidManifest.xml")); Document doc = loadDocument(new File(sTestNewDir + "/AndroidManifest.xml"));
Node application = doc.getElementsByTagName("application").item(0); Node application = doc.getElementsByTagName("application").item(0);
NamedNodeMap attr = application.getAttributes(); NamedNodeMap attr = application.getAttributes();

View File

@ -41,18 +41,18 @@ public class NonStandardPkgIdTest extends BaseTest {
sTestOrigDir = new ExtFile(sTmpDir, "pkgid8-orig"); sTestOrigDir = new ExtFile(sTmpDir, "pkgid8-orig");
sTestNewDir = new ExtFile(sTmpDir, "pkgid8-new"); sTestNewDir = new ExtFile(sTmpDir, "pkgid8-new");
LOGGER.info("Unpacking pkgid8..."); LOGGER.fine("Unpacking pkgid8...");
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "aapt2/pkgid8/", sTestOrigDir); TestUtils.copyResourceDir(BuildAndDecodeTest.class, "aapt2/pkgid8/", sTestOrigDir);
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
buildOptions.useAapt2 = true; buildOptions.useAapt2 = true;
buildOptions.verbose = true; buildOptions.verbose = true;
LOGGER.info("Building pkgid8.apk..."); LOGGER.fine("Building pkgid8.apk...");
File testApk = new File(sTmpDir, "pkgid8.apk"); File testApk = new File(sTmpDir, "pkgid8.apk");
new Androlib(buildOptions).build(sTestOrigDir, testApk); new Androlib(buildOptions).build(sTestOrigDir, testApk);
LOGGER.info("Decoding pkgid8.apk..."); LOGGER.fine("Decoding pkgid8.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();

View File

@ -35,7 +35,7 @@ public class DuplicateDexTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "duplicatedex-orig"); sTestOrigDir = new ExtFile(sTmpDir, "duplicatedex-orig");
sTestNewDir = new ExtFile(sTmpDir, "duplicatedex-new"); sTestNewDir = new ExtFile(sTmpDir, "duplicatedex-new");
LOGGER.info("Unpacking duplicatedex.apk..."); LOGGER.fine("Unpacking duplicatedex.apk...");
TestUtils.copyResourceDir(DuplicateDexTest.class, "decode/duplicatedex", sTestOrigDir); TestUtils.copyResourceDir(DuplicateDexTest.class, "decode/duplicatedex", sTestOrigDir);
} }
@ -48,12 +48,12 @@ public class DuplicateDexTest extends BaseTest {
public void decodeAllSourcesShouldThrowException() throws BrutException, IOException { public void decodeAllSourcesShouldThrowException() throws BrutException, IOException {
File testApk = new File(sTestOrigDir, "duplicatedex.apk"); File testApk = new File(sTestOrigDir, "duplicatedex.apk");
LOGGER.info("Decoding duplicatedex.apk..."); LOGGER.fine("Decoding duplicatedex.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();
LOGGER.info("Building duplicatedex.apk..."); LOGGER.fine("Building duplicatedex.apk...");
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
new Androlib(buildOptions).build(sTestNewDir, testApk); new Androlib(buildOptions).build(sTestNewDir, testApk);
} }
@ -62,13 +62,13 @@ public class DuplicateDexTest extends BaseTest {
public void decodeUsingOnlyMainClassesMode() throws BrutException, IOException { public void decodeUsingOnlyMainClassesMode() throws BrutException, IOException {
File testApk = new File(sTestOrigDir, "duplicatedex.apk"); File testApk = new File(sTestOrigDir, "duplicatedex.apk");
LOGGER.info("Decoding duplicatedex.apk..."); LOGGER.fine("Decoding duplicatedex.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setDecodeSources(ApkDecoder.DECODE_SOURCES_SMALI_ONLY_MAIN_CLASSES); apkDecoder.setDecodeSources(ApkDecoder.DECODE_SOURCES_SMALI_ONLY_MAIN_CLASSES);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.decode(); apkDecoder.decode();
LOGGER.info("Building duplicatedex.apk..."); LOGGER.fine("Building duplicatedex.apk...");
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
new Androlib(buildOptions).build(sTestNewDir, testApk); new Androlib(buildOptions).build(sTestNewDir, testApk);
} }

View File

@ -41,11 +41,11 @@ public class ExternalEntityTest extends BaseTest {
sTestOrigDir = new ExtFile(OS.createTempDirectory()); sTestOrigDir = new ExtFile(OS.createTempDirectory());
TestUtils.copyResourceDir(ExternalEntityTest.class, "decode/doctype/", sTestOrigDir); TestUtils.copyResourceDir(ExternalEntityTest.class, "decode/doctype/", sTestOrigDir);
LOGGER.info("Building doctype.apk..."); LOGGER.fine("Building doctype.apk...");
File testApk = new File(sTestOrigDir, "doctype.apk"); File testApk = new File(sTestOrigDir, "doctype.apk");
new Androlib().build(sTestOrigDir, testApk); new Androlib().build(sTestOrigDir, testApk);
LOGGER.info("Decoding doctype.apk..."); LOGGER.fine("Decoding doctype.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(new File(sTestOrigDir + File.separator + "output")); apkDecoder.setOutDir(new File(sTestOrigDir + File.separator + "output"));
apkDecoder.decode(); apkDecoder.decode();

View File

@ -42,16 +42,16 @@ public class DexStaticFieldValueTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestOrigDir = new ExtFile(sTmpDir, "issue2543-orig"); sTestOrigDir = new ExtFile(sTmpDir, "issue2543-orig");
sTestNewDir = new ExtFile(sTmpDir, "issue2543-new"); sTestNewDir = new ExtFile(sTmpDir, "issue2543-new");
LOGGER.info("Unpacking issue2543..."); LOGGER.fine("Unpacking issue2543...");
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "decode/issue2543/", sTestOrigDir); TestUtils.copyResourceDir(BuildAndDecodeTest.class, "decode/issue2543/", sTestOrigDir);
BuildOptions buildOptions = new BuildOptions(); BuildOptions buildOptions = new BuildOptions();
LOGGER.info("Building issue2543.apk..."); LOGGER.fine("Building issue2543.apk...");
File testApk = new File(sTmpDir, "issue2543.apk"); File testApk = new File(sTmpDir, "issue2543.apk");
new Androlib(buildOptions).build(sTestOrigDir, testApk); new Androlib(buildOptions).build(sTestOrigDir, testApk);
LOGGER.info("Decoding issue2543.apk..."); LOGGER.fine("Decoding issue2543.apk...");
ApkDecoder apkDecoder = new ApkDecoder(testApk); ApkDecoder apkDecoder = new ApkDecoder(testApk);
apkDecoder.setOutDir(sTestNewDir); apkDecoder.setOutDir(sTestNewDir);
apkDecoder.setBaksmaliDebugMode(false); apkDecoder.setBaksmaliDebugMode(false);

View File

@ -37,7 +37,7 @@ public class MaliciousYamlTest extends BaseTest {
sTmpDir = new ExtFile(OS.createTempDirectory()); sTmpDir = new ExtFile(OS.createTempDirectory());
sTestNewDir = new ExtFile(sTmpDir, "cve20220476"); sTestNewDir = new ExtFile(sTmpDir, "cve20220476");
LOGGER.info("Unpacking cve20220476..."); LOGGER.fine("Unpacking cve20220476...");
TestUtils.copyResourceDir(MaliciousYamlTest.class, "yaml/cve20220476/", sTestNewDir); TestUtils.copyResourceDir(MaliciousYamlTest.class, "yaml/cve20220476/", sTestNewDir);
} }

View File

@ -158,7 +158,7 @@ public class OS {
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
if (mType.equals("OUTPUT")) { if (mType.equals("OUTPUT")) {
LOGGER.info(line); LOGGER.fine(line);
} else { } else {
LOGGER.warning(line); LOGGER.warning(line);
} }