mirror of
https://github.com/revanced/Apktool.git
synced 2025-06-12 05:07:41 +02:00
Move build functions from Androlib to the ApkBuilder (#3103)
This commit is contained in:
@ -37,8 +37,8 @@ import static org.junit.Assert.*;
|
||||
public class BaseTest {
|
||||
|
||||
protected void compareUnknownFiles() throws BrutException {
|
||||
MetaInfo control = new Androlib().readMetaFile(sTestOrigDir);
|
||||
MetaInfo test = new Androlib().readMetaFile(sTestNewDir);
|
||||
MetaInfo control = MetaInfo.readMetaFile(sTestOrigDir);
|
||||
MetaInfo test = MetaInfo.readMetaFile(sTestNewDir);
|
||||
assertNotNull(control.unknownFiles);
|
||||
assertNotNull(test.unknownFiles);
|
||||
|
||||
|
@ -43,12 +43,11 @@ public class AndroidOreoNotSparseTest extends BaseTest {
|
||||
|
||||
LOGGER.info("Decoding not_sparse.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
|
||||
LOGGER.info("Building not_sparse.apk...");
|
||||
Config config = Config.getDefaultConfig();
|
||||
new Androlib(config).build(sTestNewDir, testApk);
|
||||
new ApkBuilder(config, sTestNewDir).build(testApk);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -43,12 +43,11 @@ public class AndroidOreoSparseTest extends BaseTest {
|
||||
|
||||
LOGGER.info("Decoding sparse.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
|
||||
LOGGER.info("Building sparse.apk...");
|
||||
Config config = Config.getDefaultConfig();
|
||||
new Androlib(config).build(sTestNewDir, testApk);
|
||||
new ApkBuilder(config, sTestNewDir).build(testApk);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkBuilder;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
@ -44,12 +44,11 @@ public class BuildAndDecodeJarTest extends BaseTest {
|
||||
|
||||
LOGGER.info("Building testjar.jar...");
|
||||
File testJar = new File(sTmpDir, "testjar.jar");
|
||||
new Androlib().build(sTestOrigDir, testJar);
|
||||
new ApkBuilder(sTestOrigDir).build(testJar);
|
||||
|
||||
LOGGER.info("Decoding testjar.jar...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testJar);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkBuilder;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
@ -52,12 +52,11 @@ public class BuildAndDecodeTest extends BaseTest {
|
||||
|
||||
LOGGER.info("Building testapp.apk...");
|
||||
File testApk = new File(sTmpDir, "testapp.apk");
|
||||
new Androlib().build(sTestOrigDir, testApk);
|
||||
new ApkBuilder(sTestOrigDir).build(testApk);
|
||||
|
||||
LOGGER.info("Decoding testapp.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@ -492,7 +491,7 @@ public class BuildAndDecodeTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void confirmZeroByteFileExtensionIsNotStored() throws BrutException {
|
||||
MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir);
|
||||
MetaInfo metaInfo = MetaInfo.readMetaFile(sTestNewDir);
|
||||
|
||||
for (String item : metaInfo.doNotCompress) {
|
||||
assertNotEquals("jpg", item);
|
||||
@ -501,7 +500,7 @@ public class BuildAndDecodeTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void confirmZeroByteFileIsStored() throws BrutException {
|
||||
MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir);
|
||||
MetaInfo metaInfo = MetaInfo.readMetaFile(sTestNewDir);
|
||||
assertTrue(metaInfo.doNotCompress.contains("assets/0byte_file.jpg"));
|
||||
}
|
||||
|
||||
|
@ -51,12 +51,11 @@ public class DebugTagRetainedTest extends BaseTest {
|
||||
config.debugMode = true;
|
||||
|
||||
File testApk = new File(sTmpDir, "issue1235.apk");
|
||||
new Androlib(config).build(sTestOrigDir, testApk);
|
||||
new ApkBuilder(config, sTestOrigDir).build(testApk);
|
||||
|
||||
LOGGER.info("Decoding issue1235.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkBuilder;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
@ -46,12 +46,11 @@ public class DefaultBaksmaliVariableTest extends BaseTest {
|
||||
|
||||
LOGGER.info("Building issue1481.jar...");
|
||||
File testJar = new File(sTmpDir, "issue1481.jar");
|
||||
new Androlib().build(sTestOrigDir, testJar);
|
||||
new ApkBuilder(sTestOrigDir).build(testJar);
|
||||
|
||||
LOGGER.info("Decoding issue1481.jar...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testJar);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkBuilder;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.Config;
|
||||
import brut.androlib.TestUtils;
|
||||
@ -46,12 +46,11 @@ public class EmptyResourcesArscTest {
|
||||
|
||||
LOGGER.info("Decoding issue1730.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
|
||||
LOGGER.info("Building issue1730.apk...");
|
||||
Config config = Config.getDefaultConfig();
|
||||
new Androlib(config).build(sTestNewDir, testApk);
|
||||
new ApkBuilder(config, sTestNewDir).build(testApk);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkBuilder;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
@ -50,20 +50,20 @@ public class LargeIntsInManifestTest extends BaseTest {
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||
sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
// build issue767
|
||||
ExtFile testApk = new ExtFile(sTmpDir, apk + ".out");
|
||||
new Androlib().build(testApk, null);
|
||||
new ApkBuilder(testApk).build(null);
|
||||
String newApk = apk + ".out" + File.separator + "dist" + File.separator + apk;
|
||||
|
||||
// decode issue767 again
|
||||
apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + newApk));
|
||||
sTestNewDir = new ExtFile(sTmpDir + File.separator + apk + ".out.two");
|
||||
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out.two"));
|
||||
apkDecoder.decode();
|
||||
outDir = new File(sTmpDir + File.separator + apk + ".out.two");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
compareXmlFiles("AndroidManifest.xml");
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkBuilder;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
@ -57,19 +57,19 @@ public class ProviderAttributeTest extends BaseTest {
|
||||
|
||||
// decode issue636.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
// build issue636
|
||||
ExtFile testApk = new ExtFile(sTmpDir, apk + ".out");
|
||||
new Androlib().build(testApk, null);
|
||||
new ApkBuilder(testApk).build(null);
|
||||
String newApk = apk + ".out" + File.separator + "dist" + File.separator + apk;
|
||||
assertTrue(fileExists(newApk));
|
||||
|
||||
// decode issues636 again
|
||||
apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + newApk));
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out.two"));
|
||||
apkDecoder.decode();
|
||||
outDir = new File(sTmpDir + File.separator + apk + ".out.two");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n" +
|
||||
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" android:compileSdkVersion=\"23\" android:compileSdkVersionCodename=\"6.0-2438415\" package=\"com.ibotpeaches.issue636\" platformBuildVersionCode=\"22\" platformBuildVersionName=\"5.1-1756733\">\n" +
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkBuilder;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
@ -54,10 +54,10 @@ public class ReferenceVersionCodeTest extends BaseTest {
|
||||
// decode issue1234.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new ExtFile(sTmpDir + File.separator + apk));
|
||||
ExtFile decodedApk = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
MetaInfo metaInfo = new Androlib().readMetaFile(decodedApk);
|
||||
MetaInfo metaInfo = MetaInfo.readMetaFile(decodedApk);
|
||||
assertEquals("v1.0.0", metaInfo.versionInfo.versionName);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.*;
|
||||
import brut.androlib.exceptions.AndrolibException;
|
||||
import brut.androlib.res.AndrolibResources;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
@ -54,7 +55,7 @@ public class SharedLibraryTest extends BaseTest {
|
||||
config.frameworkDirectory = sTmpDir.getAbsolutePath();
|
||||
config.frameworkTag = "building";
|
||||
|
||||
new Androlib(config).installFramework(new File(sTmpDir + File.separator + apkName));
|
||||
new AndrolibResources(config).installFramework(new File(sTmpDir + File.separator + apkName));
|
||||
|
||||
assertTrue(fileExists("2-building.apk"));
|
||||
}
|
||||
@ -66,7 +67,7 @@ public class SharedLibraryTest extends BaseTest {
|
||||
Config config = Config.getDefaultConfig();
|
||||
config.frameworkDirectory = sTmpDir.getAbsolutePath();
|
||||
|
||||
new Androlib(config).installFramework(new File(sTmpDir + File.separator + apkName));
|
||||
new AndrolibResources(config).installFramework(new File(sTmpDir + File.separator + apkName));
|
||||
|
||||
assertTrue(fileExists("2.apk"));
|
||||
}
|
||||
@ -82,27 +83,27 @@ public class SharedLibraryTest extends BaseTest {
|
||||
config.frameworkTag = "shared";
|
||||
|
||||
// install library/framework
|
||||
new Androlib(config).installFramework(new File(sTmpDir + File.separator + library));
|
||||
new AndrolibResources(config).installFramework(new File(sTmpDir + File.separator + library));
|
||||
assertTrue(fileExists("2-shared.apk"));
|
||||
|
||||
// decode client.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(config, new ExtFile(sTmpDir + File.separator + client));
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + client + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + client + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
// decode library.apk
|
||||
ApkDecoder libraryDecoder = new ApkDecoder(config, new ExtFile(sTmpDir + File.separator + library));
|
||||
libraryDecoder.setOutDir(new File(sTmpDir + File.separator + library + ".out"));
|
||||
libraryDecoder.decode();
|
||||
outDir = new File(sTmpDir + File.separator + library + ".out");
|
||||
libraryDecoder.decode(outDir);
|
||||
|
||||
// build client.apk
|
||||
ExtFile clientApk = new ExtFile(sTmpDir, client + ".out");
|
||||
new Androlib(config).build(clientApk, null);
|
||||
new ApkBuilder(config, clientApk).build(null);
|
||||
assertTrue(fileExists(client + ".out" + File.separator + "dist" + File.separator + client));
|
||||
|
||||
// build library.apk (shared library)
|
||||
ExtFile libraryApk = new ExtFile(sTmpDir, library + ".out");
|
||||
new Androlib(config).build(libraryApk, null);
|
||||
new ApkBuilder(config, libraryApk).build(null);
|
||||
assertTrue(fileExists(library + ".out" + File.separator + "dist" + File.separator + library));
|
||||
}
|
||||
|
||||
|
@ -54,9 +54,7 @@ public class SkipAssetTest extends BaseTest {
|
||||
// decode issue1605.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(config, new ExtFile(sTmpDir + File.separator + apk));
|
||||
sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
|
||||
apkDecoder.setOutDir(sTestOrigDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestOrigDir);
|
||||
|
||||
checkFileDoesNotExist("assets" + File.separator + "kotlin.kotlin_builtins");
|
||||
checkFileDoesNotExist("assets" + File.separator + "ranges" + File.separator + "ranges.kotlin_builtins");
|
||||
@ -73,9 +71,7 @@ public class SkipAssetTest extends BaseTest {
|
||||
// decode issue1605.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(config, new ExtFile(sTmpDir + File.separator + apk));
|
||||
sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
|
||||
apkDecoder.setOutDir(sTestOrigDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestOrigDir);
|
||||
|
||||
checkFileDoesExist("assets" + File.separator + "kotlin.kotlin_builtins");
|
||||
checkFileDoesExist("assets" + File.separator + "ranges" + File.separator + "ranges.kotlin_builtins");
|
||||
|
@ -48,12 +48,12 @@ public class UnknownCompressionTest extends BaseTest {
|
||||
// decode deflated_unknowns.apk
|
||||
// need new ExtFile because closed in decode()
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new ExtFile(sTestOrigDir));
|
||||
apkDecoder.setOutDir(new File(sTestOrigDir.getAbsolutePath() + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTestOrigDir.getAbsolutePath() + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
// build deflated_unknowns
|
||||
ExtFile clientApkFolder = new ExtFile(sTestOrigDir.getAbsolutePath() + ".out");
|
||||
new Androlib(config).build(clientApkFolder, null);
|
||||
new ApkBuilder(config, clientApkFolder).build(null);
|
||||
sTestNewDir = new ExtFile(clientApkFolder, "dist" + File.separator + apk);
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ package brut.androlib.aapt2;
|
||||
import brut.androlib.*;
|
||||
import brut.androlib.meta.MetaInfo;
|
||||
import brut.androlib.Config;
|
||||
import brut.androlib.res.AndrolibResources;
|
||||
import brut.common.BrutException;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.util.OS;
|
||||
@ -49,12 +50,11 @@ public class BuildAndDecodeTest extends BaseTest {
|
||||
|
||||
LOGGER.info("Building testapp.apk...");
|
||||
File testApk = new File(sTmpDir, "testapp.apk");
|
||||
new Androlib(config).build(sTestOrigDir, testApk);
|
||||
new ApkBuilder(config, sTestOrigDir).build(testApk);
|
||||
|
||||
LOGGER.info("Decoding testapp.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@ -79,13 +79,13 @@ public class BuildAndDecodeTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void confirmZeroByteFileExtensionIsNotStored() throws BrutException {
|
||||
MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir);
|
||||
MetaInfo metaInfo = MetaInfo.readMetaFile(sTestNewDir);
|
||||
assertFalse(metaInfo.doNotCompress.contains("jpg"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confirmZeroByteFileIsStored() throws BrutException {
|
||||
MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir);
|
||||
MetaInfo metaInfo = MetaInfo.readMetaFile(sTestNewDir);
|
||||
assertTrue(metaInfo.doNotCompress.contains("assets/0byte_file.jpg"));
|
||||
}
|
||||
|
||||
|
@ -53,12 +53,11 @@ public class DebuggableFalseChangeToTrueTest extends BaseTest {
|
||||
config.verbose = true;
|
||||
|
||||
File testApk = new File(sTmpDir, "issue2328-debuggable-flase.apk");
|
||||
new Androlib(config).build(sTestOrigDir, testApk);
|
||||
new ApkBuilder(config, sTestOrigDir).build(testApk);
|
||||
|
||||
LOGGER.info("Decoding issue2328-debuggable-flase.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -53,12 +53,11 @@ public class DebuggableTrueAddedTest extends BaseTest {
|
||||
config.verbose = true;
|
||||
|
||||
File testApk = new File(sTmpDir, "issue2328-debuggable-missing.apk");
|
||||
new Androlib(config).build(sTestOrigDir, testApk);
|
||||
new ApkBuilder(config, sTestOrigDir).build(testApk);
|
||||
|
||||
LOGGER.info("Decoding issue2328-debuggable-missing.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -53,12 +53,11 @@ public class DebuggableTrueRetainedTest extends BaseTest {
|
||||
config.verbose = true;
|
||||
|
||||
File testApk = new File(sTmpDir, "issue2328-debuggable-true.apk");
|
||||
new Androlib(config).build(sTestOrigDir, testApk);
|
||||
new ApkBuilder(config, sTestOrigDir).build(testApk);
|
||||
|
||||
LOGGER.info("Decoding issue2328-debuggable-true.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -57,12 +57,11 @@ public class NetworkConfigTest extends BaseTest {
|
||||
config.netSecConf = true;
|
||||
config.useAapt2 = true;
|
||||
File testApk = new File(sTmpDir, "testapp.apk");
|
||||
new Androlib(config).build(sTestOrigDir, testApk);
|
||||
new ApkBuilder(config, sTestOrigDir).build(testApk);
|
||||
|
||||
LOGGER.info("Decoding testapp.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -60,12 +60,11 @@ public class NoNetworkConfigTest extends BaseTest {
|
||||
config.netSecConf = true;
|
||||
config.useAapt2 = true;
|
||||
File testApk = new File(sTmpDir, "testapp.apk");
|
||||
new Androlib(config).build(sTestOrigDir, testApk);
|
||||
new ApkBuilder(config, sTestOrigDir).build(testApk);
|
||||
|
||||
LOGGER.info("Decoding testapp.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -50,12 +50,11 @@ public class NonStandardPkgIdTest extends BaseTest {
|
||||
|
||||
LOGGER.info("Building pkgid8.apk...");
|
||||
File testApk = new File(sTmpDir, "pkgid8.apk");
|
||||
new Androlib(config).build(sTestOrigDir, testApk);
|
||||
new ApkBuilder(config, sTestOrigDir).build(testApk);
|
||||
|
||||
LOGGER.info("Decoding pkgid8.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
mResTable = apkDecoder.getResTable();
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,8 @@ public class AndResGuardTest extends BaseTest {
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||
sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
File aPng = new File(sTestOrigDir,"res/mipmap-hdpi-v4/a.png");
|
||||
assertTrue(aPng.isFile());
|
||||
@ -67,8 +67,8 @@ public class AndResGuardTest extends BaseTest {
|
||||
String apk = "issue1170.apk";
|
||||
ApkDecoder apkDecoder = new ApkDecoder(config, new File(sTmpDir + File.separator + apk));
|
||||
sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".raw.out");
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".raw.out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".raw.out");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
File aPng = new File(sTestOrigDir,"r/a/a.png");
|
||||
assertTrue(aPng.isFile());
|
||||
|
@ -56,8 +56,8 @@ public class DecodeKotlinCoroutinesTest extends BaseTest {
|
||||
config.forceDelete = true;
|
||||
// decode kotlin coroutines
|
||||
ApkDecoder apkDecoder = new ApkDecoder(config, new File(sTmpDir + File.separator + apk));
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
File coroutinesExceptionHandler = new File(sTmpDir + File.separator + apk + ".out" + File.separator + "META-INF" + File.separator + "services", "kotlinx.coroutines.CoroutineExceptionHandler");
|
||||
File coroutinesMainDispatcherHandler = new File(sTmpDir + File.separator + apk + ".out" + File.separator + "META-INF" + File.separator + "services", "kotlinx.coroutines.internal.MainDispatcherFactory");
|
||||
|
||||
@ -72,19 +72,19 @@ public class DecodeKotlinCoroutinesTest extends BaseTest {
|
||||
config.forceDelete = true;
|
||||
// decode kotlin coroutines
|
||||
ApkDecoder apkDecoder = new ApkDecoder(config, new File(sTmpDir + File.separator + apk));
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
// build kotlin coroutines
|
||||
ExtFile testApk = new ExtFile(sTmpDir, apk + ".out");
|
||||
new Androlib(config).build(testApk, null);
|
||||
new ApkBuilder(config, testApk).build(null);
|
||||
String newApk = apk + ".out" + File.separator + "dist" + File.separator + apk;
|
||||
assertTrue(fileExists(newApk));
|
||||
|
||||
// decode kotlin coroutines again
|
||||
apkDecoder = new ApkDecoder(config, new File(sTmpDir + File.separator + newApk));
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out.two"));
|
||||
apkDecoder.decode();
|
||||
outDir = new File(sTmpDir + File.separator + apk + ".out.two");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
Files.readAllBytes(Paths.get(sTmpDir + File.separator + apk + ".out.two" + File.separator + "AndroidManifest.xml"));
|
||||
File coroutinesExceptionHandler = new File(sTmpDir + File.separator + apk + ".out.two" + File.separator + "META-INF" + File.separator + "services", "kotlinx.coroutines.CoroutineExceptionHandler");
|
||||
|
@ -46,8 +46,8 @@ public class DecodeKotlinTest extends BaseTest {
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||
sTestNewDir = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package brut.androlib.decode;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkBuilder;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
@ -55,10 +55,10 @@ public class DoubleExtensionUnknownFileTest extends BaseTest {
|
||||
// decode issue1244.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||
ExtFile decodedApk = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
MetaInfo metaInfo = new Androlib().readMetaFile(decodedApk);
|
||||
MetaInfo metaInfo = MetaInfo.readMetaFile(decodedApk);
|
||||
for (String string : metaInfo.doNotCompress) {
|
||||
if (StringUtils.countMatches(string, ".") > 1) {
|
||||
assertTrue(string.equalsIgnoreCase("assets/bin/Data/sharedassets1.assets.split0"));
|
||||
|
@ -50,12 +50,11 @@ public class DuplicateDexTest extends BaseTest {
|
||||
|
||||
LOGGER.info("Decoding duplicatedex.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
|
||||
LOGGER.info("Building duplicatedex.apk...");
|
||||
Config config = Config.getDefaultConfig();
|
||||
new Androlib(config).build(sTestNewDir, testApk);
|
||||
new ApkBuilder(config, sTestNewDir).build(testApk);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -67,11 +66,10 @@ public class DuplicateDexTest extends BaseTest {
|
||||
config.decodeSources = Config.DECODE_SOURCES_SMALI_ONLY_MAIN_CLASSES;
|
||||
|
||||
ApkDecoder apkDecoder = new ApkDecoder(config, testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
|
||||
LOGGER.info("Building duplicatedex.apk...");
|
||||
new Androlib(config).build(sTestNewDir, testApk);
|
||||
new ApkBuilder(config, sTestNewDir).build(testApk);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ public class Empty9PatchTest extends BaseTest {
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||
sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
File aPng = new File(sTestOrigDir,"res/drawable-xhdpi/empty.9.png");
|
||||
assertTrue(aPng.isFile());
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package brut.androlib.decode;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkBuilder;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
@ -43,12 +43,12 @@ public class ExternalEntityTest extends BaseTest {
|
||||
|
||||
LOGGER.info("Building doctype.apk...");
|
||||
File testApk = new File(sTestOrigDir, "doctype.apk");
|
||||
new Androlib().build(sTestOrigDir, testApk);
|
||||
new ApkBuilder(sTestOrigDir).build(testApk);
|
||||
|
||||
LOGGER.info("Decoding doctype.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(new File(sTestOrigDir + File.separator + "output"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTestOrigDir + File.separator + "output");
|
||||
apkDecoder.decode(outDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -140,7 +140,6 @@ public class ForceManifestDecodeNoResourcesTest extends BaseTest {
|
||||
config.decodeResources = decodeResources;
|
||||
config.forceDecodeManifest = decodeManifest;
|
||||
ApkDecoder apkDecoder = new ApkDecoder(config, new File(apk));
|
||||
apkDecoder.setOutDir(new File(output));
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(new File(output));
|
||||
}
|
||||
}
|
||||
|
@ -49,10 +49,8 @@ public class MinifiedArscTest extends BaseTest {
|
||||
config.forceDelete = true;
|
||||
// decode issue1157.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(config, new ExtFile(sTmpDir, apk));
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
|
||||
// this should not raise an exception:
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package brut.androlib.decode;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkBuilder;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
@ -54,10 +54,10 @@ public class MissingVersionManifestTest extends BaseTest {
|
||||
// decode issue1264.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||
ExtFile decodedApk = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
MetaInfo metaInfo = new Androlib().readMetaFile(decodedApk);
|
||||
MetaInfo metaInfo = MetaInfo.readMetaFile(decodedApk);
|
||||
assertNull(metaInfo.versionInfo.versionName);
|
||||
}
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ public class OutsideOfDirectoryEntryTest extends BaseTest {
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||
sTestNewDir = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -53,9 +53,8 @@ public class ParentDirectoryTraversalTest extends BaseTest {
|
||||
config.decodeResources = Config.DECODE_RESOURCES_NONE;
|
||||
// decode issue1498.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(config, new File(sTmpDir + File.separator + apk));
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
// this should not raise an exception:
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(outDir);
|
||||
}
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ public class VectorDrawableTest extends BaseTest {
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||
sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
File outDir = new File(sTmpDir + File.separator + apk + ".out");
|
||||
apkDecoder.decode(outDir);
|
||||
|
||||
checkFileExists("res/drawable/ic_arrow_drop_down_black_24dp.xml");
|
||||
checkFileExists("res/drawable/ic_android_black_24dp.xml");
|
||||
|
@ -49,13 +49,12 @@ public class DexStaticFieldValueTest extends BaseTest {
|
||||
|
||||
LOGGER.info("Building issue2543.apk...");
|
||||
File testApk = new File(sTmpDir, "issue2543.apk");
|
||||
new Androlib(config).build(sTestOrigDir, testApk);
|
||||
new ApkBuilder(config, sTestOrigDir).build(testApk);
|
||||
|
||||
LOGGER.info("Decoding issue2543.apk...");
|
||||
config.baksmaliDebugMode = false;
|
||||
ApkDecoder apkDecoder = new ApkDecoder(config, new ExtFile(testApk));
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
apkDecoder.decode(sTestNewDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package brut.androlib.yaml;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkBuilder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
import brut.androlib.Config;
|
||||
@ -45,6 +45,6 @@ public class MaliciousYamlTest extends BaseTest {
|
||||
public void testMaliciousYamlNotLoaded() throws BrutException {
|
||||
Config config = Config.getDefaultConfig();
|
||||
File testApk = new File(sTmpDir, "cve20220476.apk");
|
||||
new Androlib(config).build(sTestNewDir, testApk);
|
||||
new ApkBuilder(config, sTestNewDir).build(testApk);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user