Search in sources :

Example 1 with ExtFile

use of brut.directory.ExtFile in project Apktool by iBotPeaches.

the class ReferenceVersionCodeTest method referenceBecomesLiteralTest.

@Test
public void referenceBecomesLiteralTest() throws BrutException, IOException {
    String apk = "issue1234.apk";
    // decode issue1234.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();
    MetaInfo metaInfo = new Androlib().readMetaFile(decodedApk);
    assertEquals("v1.0.0", metaInfo.versionInfo.versionName);
}
Also used : MetaInfo(brut.androlib.meta.MetaInfo) ExtFile(brut.directory.ExtFile) ExtFile(brut.directory.ExtFile) File(java.io.File) Test(org.junit.Test)

Example 2 with ExtFile

use of brut.directory.ExtFile in project Apktool by iBotPeaches.

the class ReferenceVersionCodeTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception, BrutException {
    TestUtils.cleanFrameworkFile();
    sTmpDir = new ExtFile(OS.createTempDirectory());
    TestUtils.copyResourceDir(LargeIntsInManifestTest.class, "brut/apktool/issue1234/", sTmpDir);
}
Also used : ExtFile(brut.directory.ExtFile) BeforeClass(org.junit.BeforeClass)

Example 3 with ExtFile

use of brut.directory.ExtFile in project Apktool by iBotPeaches.

the class SharedLibraryTest method isSharedResourceDecodingAndRebuildingWorking.

@Test
public void isSharedResourceDecodingAndRebuildingWorking() throws IOException, BrutException {
    String library = "library.apk";
    String client = "client.apk";
    // setup apkOptions
    ApkOptions apkOptions = new ApkOptions();
    apkOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
    apkOptions.frameworkTag = "shared";
    // install library/framework
    new Androlib(apkOptions).installFramework(new File(sTmpDir + File.separator + library));
    assertTrue(fileExists("2-shared.apk"));
    // decode client.apk
    ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + client));
    apkDecoder.setOutDir(new File(sTmpDir + File.separator + client + ".out"));
    apkDecoder.setFrameworkDir(apkOptions.frameworkFolderLocation);
    apkDecoder.setFrameworkTag(apkOptions.frameworkTag);
    apkDecoder.decode();
    // decode library.apk
    ApkDecoder libraryDecoder = new ApkDecoder(new File(sTmpDir + File.separator + library));
    libraryDecoder.setOutDir(new File(sTmpDir + File.separator + library + ".out"));
    libraryDecoder.setFrameworkDir(apkOptions.frameworkFolderLocation);
    libraryDecoder.setFrameworkTag(apkOptions.frameworkTag);
    libraryDecoder.decode();
    // build client.apk
    ExtFile clientApk = new ExtFile(sTmpDir, client + ".out");
    new Androlib(apkOptions).build(clientApk, 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(apkOptions).build(libraryApk, null);
    assertTrue(fileExists(library + ".out" + File.separator + "dist" + File.separator + library));
}
Also used : ExtFile(brut.directory.ExtFile) ExtFile(brut.directory.ExtFile) File(java.io.File) Test(org.junit.Test)

Example 4 with ExtFile

use of brut.directory.ExtFile in project Apktool by iBotPeaches.

the class UnknownCompressionTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception, BrutException {
    TestUtils.cleanFrameworkFile();
    sTmpDir = new ExtFile(OS.createTempDirectory());
    TestUtils.copyResourceDir(LargeIntsInManifestTest.class, "brut/apktool/unknown_compression/", sTmpDir);
    String apk = "deflated_unknowns.apk";
    ApkOptions apkOptions = new ApkOptions();
    apkOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
    sOriginalFile = new ExtFile(sTmpDir, apk);
    // decode deflated_unknowns.apk
    ApkDecoder apkDecoder = new ApkDecoder(sOriginalFile);
    apkDecoder.setOutDir(new File(sOriginalFile.getAbsolutePath() + ".out"));
    apkDecoder.decode();
    // build deflated_unknowns
    ExtFile clientApkFolder = new ExtFile(sOriginalFile.getAbsolutePath() + ".out");
    new Androlib(apkOptions).build(clientApkFolder, null);
    sBuiltFile = new ExtFile(clientApkFolder, "dist" + File.separator + apk);
}
Also used : ExtFile(brut.directory.ExtFile) ExtFile(brut.directory.ExtFile) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 5 with ExtFile

use of brut.directory.ExtFile in project Apktool by iBotPeaches.

the class AndResGuardTest method checkifAndResDecodeRemapsRFolder.

@Test
public void checkifAndResDecodeRemapsRFolder() throws BrutException, IOException {
    String apk = "issue1170.apk";
    // decode issue1170.apk
    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();
    checkFileExists("res/mipmap-hdpi-v4/a.png");
}
Also used : ExtFile(brut.directory.ExtFile) ExtFile(brut.directory.ExtFile) File(java.io.File)

Aggregations

ExtFile (brut.directory.ExtFile)31 ZipFile (java.util.zip.ZipFile)12 File (java.io.File)10 BeforeClass (org.junit.BeforeClass)8 Test (org.junit.Test)5 MetaInfo (brut.androlib.meta.MetaInfo)4 AndrolibException (brut.androlib.AndrolibException)2 BrutException (brut.common.BrutException)1 Directory (brut.directory.Directory)1 DirectoryException (brut.directory.DirectoryException)1 FileDirectory (brut.directory.FileDirectory)1