mirror of
https://github.com/revanced/Apktool.git
synced 2024-09-27 08:36:42 +02:00
parent
eabe844a62
commit
08822dcb98
@ -28,7 +28,7 @@ public class BuildOptions {
|
||||
public final boolean updateFiles = false;
|
||||
public boolean isFramework = false;
|
||||
public boolean resourcesAreCompressed = false;
|
||||
public boolean useAapt2 = true; // ReVanced - default to v2
|
||||
public boolean useAapt2 = false;
|
||||
public boolean noCrunch = false;
|
||||
public int forceApi = 0;
|
||||
public Collection<String> doNotCompress;
|
||||
@ -37,9 +37,9 @@ public class BuildOptions {
|
||||
public String frameworkTag = null;
|
||||
public String aaptPath = "";
|
||||
|
||||
public int aaptVersion = 2; // default to v1 // ReVanced - default to v2
|
||||
public int aaptVersion = 1; // default to v1
|
||||
|
||||
public boolean isAapt2() {
|
||||
return true; // ReVanced - default to v2
|
||||
return this.useAapt2 || this.aaptVersion == 2;
|
||||
}
|
||||
}
|
||||
|
@ -45,18 +45,6 @@ import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
final public class AndrolibResources {
|
||||
// The aapt2 provider. Default is AaptManager for Mac, Linux & Windows.
|
||||
// May be overridden.
|
||||
private static AaptProvider AAPT_PROVIDER = new AaptManager();
|
||||
|
||||
public static AaptProvider getAaptProvider() {
|
||||
return AAPT_PROVIDER;
|
||||
}
|
||||
|
||||
public static void setAaptProvider(AaptProvider aaptProvider) {
|
||||
AAPT_PROVIDER = aaptProvider;
|
||||
}
|
||||
|
||||
public ResTable getResTable(ExtFile apkFile) throws AndrolibException {
|
||||
return getResTable(apkFile, true);
|
||||
}
|
||||
@ -1025,7 +1013,10 @@ final public class AndrolibResources {
|
||||
|
||||
private File getAaptBinaryFile() throws AndrolibException {
|
||||
try {
|
||||
return getAaptProvider().getAapt2();
|
||||
if (getAaptVersion() == 2) {
|
||||
return AaptManager.getAapt2();
|
||||
}
|
||||
return AaptManager.getAapt1();
|
||||
} catch (BrutException ex) {
|
||||
throw new AndrolibException(ex);
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.*;
|
||||
import brut.androlib.options.BuildOptions;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class AndroidOreoNotSparseTest extends BaseTest {
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
sTestOrigDir = new ExtFile(sTmpDir, "issue1594-orig");
|
||||
sTestNewDir = new ExtFile(sTmpDir, "issue1594-new");
|
||||
LOGGER.info("Unpacking not_sparse.apk...");
|
||||
TestUtils.copyResourceDir(AndroidOreoNotSparseTest.class, "aapt1/issue1594", sTestOrigDir);
|
||||
|
||||
File testApk = new File(sTestOrigDir, "not_sparse.apk");
|
||||
|
||||
LOGGER.info("Decoding not_sparse.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
|
||||
LOGGER.info("Building not_sparse.apk...");
|
||||
BuildOptions buildOptions = new BuildOptions();
|
||||
new Androlib(buildOptions).build(sTestNewDir, testApk);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildAndDecodeTest() {
|
||||
assertTrue(sTestNewDir.isDirectory());
|
||||
assertTrue(sTestOrigDir.isDirectory());
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.*;
|
||||
import brut.androlib.options.BuildOptions;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class AndroidOreoSparseTest extends BaseTest {
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
sTestOrigDir = new ExtFile(sTmpDir, "issue1594-orig");
|
||||
sTestNewDir = new ExtFile(sTmpDir, "issue1594-new");
|
||||
LOGGER.info("Unpacking sparse.apk...");
|
||||
TestUtils.copyResourceDir(AndroidOreoSparseTest.class, "aapt1/issue1594", sTestOrigDir);
|
||||
|
||||
File testApk = new File(sTestOrigDir, "sparse.apk");
|
||||
|
||||
LOGGER.info("Decoding sparse.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
|
||||
LOGGER.info("Building sparse.apk...");
|
||||
BuildOptions buildOptions = new BuildOptions();
|
||||
new Androlib(buildOptions).build(sTestNewDir, testApk);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildAndDecodeTest() {
|
||||
assertTrue(sTestNewDir.isDirectory());
|
||||
assertTrue(sTestOrigDir.isDirectory());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ensureStringsOreoTest() {
|
||||
assertTrue((new File(sTestNewDir, "res/values-v26/strings.xml").isFile()));
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BuildAndDecodeJarTest extends BaseTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
sTestOrigDir = new ExtFile(sTmpDir, "testjar-orig");
|
||||
sTestNewDir = new ExtFile(sTmpDir, "testjar-new");
|
||||
LOGGER.info("Unpacking testjar...");
|
||||
TestUtils.copyResourceDir(BuildAndDecodeJarTest.class, "aapt1/testjar/", sTestOrigDir);
|
||||
|
||||
LOGGER.info("Building testjar.jar...");
|
||||
File testJar = new File(sTmpDir, "testjar.jar");
|
||||
new Androlib().build(sTestOrigDir, testJar);
|
||||
|
||||
LOGGER.info("Decoding testjar.jar...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testJar);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildAndDecodeTest() {
|
||||
assertTrue(sTestNewDir.isDirectory());
|
||||
}
|
||||
}
|
@ -0,0 +1,574 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
import brut.androlib.meta.MetaInfo;
|
||||
import brut.common.BrutException;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.util.OS;
|
||||
import brut.util.OSDetection;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
public class BuildAndDecodeTest extends BaseTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
|
||||
sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
|
||||
LOGGER.info("Unpacking testapp...");
|
||||
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "aapt1/testapp/", sTestOrigDir);
|
||||
|
||||
LOGGER.info("Building testapp.apk...");
|
||||
File testApk = new File(sTmpDir, "testapp.apk");
|
||||
new Androlib().build(sTestOrigDir, testApk);
|
||||
|
||||
LOGGER.info("Decoding testapp.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildAndDecodeTest() {
|
||||
assertTrue(sTestNewDir.isDirectory());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void manifestTaggingNotSupressed() throws BrutException {
|
||||
compareXmlFiles("AndroidManifest.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesAnimsTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/anims.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesArraysTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/arrays.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesArraysCastingTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc002/arrays.xml");
|
||||
compareValuesFiles("values-mcc003/arrays.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesAttrsTest() throws BrutException {
|
||||
compareValuesFiles("values/attrs.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesBoolsTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/bools.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesColorsTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/colors.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug702Test() throws BrutException {
|
||||
compareValuesFiles("values-mcc001-mnc00/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesDimensTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/dimens.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesDrawablesTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/drawables.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesIdsTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/ids.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesIntegersTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/integers.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesLayoutsTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/layouts.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlPluralsTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/plurals.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesStringsTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesStylesTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/styles.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesReferencesTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc002/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesExtraLongTest() throws BrutException {
|
||||
compareValuesFiles("values-en/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesExtraLongExactLengthTest() throws BrutException {
|
||||
Map<String, String> strs = TestUtils.parseStringsXml(new File(sTestNewDir, "res/values-en/strings.xml"));
|
||||
|
||||
// long_string6 should be exactly 0x8888 chars of "a"
|
||||
// the valuesExtraLongTest() should handle this
|
||||
// but such an edge case, want a specific test
|
||||
String aaaa = strs.get("long_string6");
|
||||
assertEquals(0x8888, aaaa.length());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void storedMp3FilesAreNotCompressedTest() throws BrutException {
|
||||
ExtFile extFile = new ExtFile(sTmpDir, "testapp.apk");
|
||||
Integer built = extFile.getDirectory().getCompressionLevel("res/raw/rain.mp3");
|
||||
assertEquals(Integer.valueOf(0), built);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void crossTypeTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc003/strings.xml");
|
||||
compareValuesFiles("values-mcc003/integers.xml");
|
||||
compareValuesFiles("values-mcc003/bools.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlLiteralsTest() throws BrutException {
|
||||
compareXmlFiles("res/xml/literals.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlReferencesTest() throws BrutException {
|
||||
compareXmlFiles("res/xml/references.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlXsdFileTest() throws BrutException {
|
||||
compareXmlFiles("res/xml/ww_box_styles_schema.xsd");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlIdsEmptyTest() throws BrutException {
|
||||
compareXmlFiles("res/values/ids.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlReferenceAttributeTest() throws BrutException {
|
||||
compareXmlFiles("res/layout/issue1040.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlCustomAttributeTest() throws BrutException {
|
||||
compareXmlFiles("res/layout/issue1063.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlSmallNumbersDontEscapeTest() throws BrutException {
|
||||
compareXmlFiles("res/layout/issue1130.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlUniformAutoTextTest() throws BrutException {
|
||||
compareXmlFiles("res/layout/issue1674.xml");
|
||||
}
|
||||
|
||||
@Test(expected = AssertionError.class)
|
||||
public void xmlFillParentBecomesMatchTest() throws BrutException {
|
||||
compareXmlFiles("res/layout/issue1274.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlCustomAttrsNotAndroidTest() throws BrutException {
|
||||
compareXmlFiles("res/layout/issue1157.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void qualifiersTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc004-mnc4-en-rUS-ldrtl-sw100dp-w200dp-h300dp"
|
||||
+ "-long-round-highdr-land-desk-night-xhdpi-finger-keyssoft-12key"
|
||||
+ "-navhidden-dpad-v26/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortendedMncTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001-mnc1/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortMncHtcTest() throws BrutException {
|
||||
compareValuesFiles("values-mnc1/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortMncv2Test() throws BrutException {
|
||||
compareValuesFiles("values-mcc238-mnc6/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void longMncTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc238-mnc870/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anyDpiTest() throws BrutException {
|
||||
compareValuesFiles("values-watch/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void packed3CharsTest() throws BrutException {
|
||||
compareValuesFiles("values-ast-rES/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rightToLeftTest() throws BrutException {
|
||||
compareValuesFiles("values-ldrtl/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scriptBcp47Test() throws BrutException {
|
||||
compareValuesFiles("values-b+en+Latn+US/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void threeLetterLangBcp47Test() throws BrutException {
|
||||
compareValuesFiles("values-ast/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void androidOStringTest() throws BrutException {
|
||||
compareValuesFiles("values-ast/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void twoLetterNotHandledAsBcpTest() {
|
||||
checkFolderExists("res/values-fr");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void twoLetterLangBcp47Test() throws BrutException {
|
||||
compareValuesFiles("values-en-rUS/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void variantBcp47Test() throws BrutException {
|
||||
compareValuesFiles("values-b+en+US+POSIX/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fourpartBcp47Test() throws BrutException {
|
||||
compareValuesFiles("values-b+ast+Latn+IT+AREVELA/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void RegionLocaleBcp47Test() throws BrutException {
|
||||
compareValuesFiles("values-b+en+Latn+419/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void numericalRegionBcp47Test() throws BrutException {
|
||||
compareValuesFiles("values-b+eng+419/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void api23ConfigurationsTest() throws BrutException {
|
||||
compareValuesFiles("values-round/strings.xml");
|
||||
compareValuesFiles("values-notround/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void api26ConfigurationsTest() throws BrutException {
|
||||
compareValuesFiles("values-widecg-v26/strings.xml");
|
||||
compareValuesFiles("values-lowdr-v26/strings.xml");
|
||||
compareValuesFiles("values-nowidecg-v26/strings.xml");
|
||||
compareValuesFiles("values-vrheadset-v26/strings.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fontTest() throws BrutException {
|
||||
File fontXml = new File((sTestNewDir + "/res/font"), "lobster.xml");
|
||||
File fontFile = new File((sTestNewDir + "/res/font"), "lobster_regular.otf");
|
||||
|
||||
// Per #1662, ensure font file is not encoded.
|
||||
assertTrue(fontXml.isFile());
|
||||
compareXmlFiles("/res/font/lobster.xml");
|
||||
|
||||
// If we properly skipped decoding the font (otf) file, this file should not exist
|
||||
assertFalse((new File((sTestNewDir + "/res/values"), "fonts.xml")).isFile());
|
||||
assertTrue(fontFile.isFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableNoDpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-nodpi");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableAnyDpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-anydpi");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableNumberedDpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-534dpi");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableLdpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-ldpi");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableMdpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-mdpi");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableTvdpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-tvdpi");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableXhdpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-xhdpi");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ninePatchImageColorTest() throws IOException {
|
||||
char slash = File.separatorChar;
|
||||
String location = slash + "res" + slash + "drawable-xhdpi" + slash;
|
||||
|
||||
File control = new File((sTestOrigDir + location), "9patch.9.png");
|
||||
File test = new File((sTestNewDir + location), "9patch.9.png");
|
||||
|
||||
BufferedImage controlImage = ImageIO.read(control);
|
||||
BufferedImage testImage = ImageIO.read(test);
|
||||
|
||||
// lets start with 0,0 - empty
|
||||
assertEquals(controlImage.getRGB(0, 0), testImage.getRGB(0, 0));
|
||||
|
||||
// then with 30, 0 - black
|
||||
assertEquals(controlImage.getRGB(30, 0), testImage.getRGB(30, 0));
|
||||
|
||||
// then 30, 30 - blue
|
||||
assertEquals(controlImage.getRGB(30, 30), testImage.getRGB(30, 30));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void issue1508Test() throws IOException {
|
||||
char slash = File.separatorChar;
|
||||
String location = slash + "res" + slash + "drawable-xhdpi" + slash;
|
||||
|
||||
File control = new File((sTestOrigDir + location), "btn_zoom_up_normal.9.png");
|
||||
File test = new File((sTestNewDir + location), "btn_zoom_up_normal.9.png");
|
||||
|
||||
BufferedImage controlImage = ImageIO.read(control);
|
||||
BufferedImage testImage = ImageIO.read(test);
|
||||
|
||||
// 0, 0 = clear
|
||||
assertEquals(controlImage.getRGB(0, 0), testImage.getRGB(0, 0));
|
||||
|
||||
// 30, 0 = black line
|
||||
assertEquals(controlImage.getRGB(0, 30), testImage.getRGB(0, 30));
|
||||
|
||||
// 30, 30 = greyish button
|
||||
assertEquals(controlImage.getRGB(30, 30), testImage.getRGB(30, 30));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void issue1511Test() throws IOException {
|
||||
char slash = File.separatorChar;
|
||||
String location = slash + "res" + slash + "drawable-xxhdpi" + slash;
|
||||
|
||||
File control = new File((sTestOrigDir + location), "textfield_activated_holo_dark.9.png");
|
||||
File test = new File((sTestNewDir + location), "textfield_activated_holo_dark.9.png");
|
||||
|
||||
BufferedImage controlImage = ImageIO.read(control);
|
||||
BufferedImage testImage = ImageIO.read(test);
|
||||
|
||||
// Check entire image as we cannot mess this up
|
||||
final int w = controlImage.getWidth(),
|
||||
h = controlImage.getHeight();
|
||||
|
||||
final int[] controlImageGrid = controlImage.getRGB(0, 0, w, h, null, 0, w);
|
||||
final int[] testImageGrid = testImage.getRGB(0, 0, w, h, null, 0, w);
|
||||
|
||||
for (int i = 0; i < controlImageGrid.length; i++) {
|
||||
assertEquals("Image lost Optical Bounds at i = " + i, controlImageGrid[i], testImageGrid[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void robust9patchTest() throws IOException {
|
||||
String[] ninePatches = {"ic_notification_overlay.9.png", "status_background.9.png",
|
||||
"search_bg_transparent.9.png", "screenshot_panel.9.png", "recents_lower_gradient.9.png"};
|
||||
|
||||
char slash = File.separatorChar;
|
||||
String location = slash + "res" + slash + "drawable-xxhdpi" + slash;
|
||||
|
||||
for (String ninePatch : ninePatches) {
|
||||
File control = new File((sTestOrigDir + location), ninePatch);
|
||||
File test = new File((sTestNewDir + location), ninePatch);
|
||||
|
||||
BufferedImage controlImage = ImageIO.read(control);
|
||||
BufferedImage testImage = ImageIO.read(test);
|
||||
|
||||
int w = controlImage.getWidth(), h = controlImage.getHeight();
|
||||
|
||||
// Check the entire horizontal line
|
||||
for (int i = 1; i < w; i++) {
|
||||
if (isTransparent(controlImage.getRGB(i, 0))) {
|
||||
assertTrue(isTransparent(testImage.getRGB(i, 0)));
|
||||
} else {
|
||||
assertEquals("Image lost npTc chunk on image " + ninePatch + " at (x, y) (" + i + "," + 0 + ")",
|
||||
controlImage.getRGB(i, 0), testImage.getRGB(i, 0));
|
||||
}
|
||||
}
|
||||
|
||||
// Check the entire vertical line
|
||||
for (int i = 1; i < h; i++) {
|
||||
if (isTransparent(controlImage.getRGB(0, i))) {
|
||||
assertTrue(isTransparent(testImage.getRGB(0, i)));
|
||||
} else {
|
||||
assertEquals("Image lost npTc chunk on image " + ninePatch + " at (x, y) (" + 0 + "," + i + ")",
|
||||
controlImage.getRGB(0, i), testImage.getRGB(0, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confirmZeroByteFileExtensionIsNotStored() throws BrutException {
|
||||
MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir);
|
||||
|
||||
for (String item : metaInfo.doNotCompress) {
|
||||
assertNotEquals("jpg", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confirmZeroByteFileIsStored() throws BrutException {
|
||||
MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir);
|
||||
assertTrue(metaInfo.doNotCompress.contains("assets/0byte_file.jpg"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableXxhdpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-xxhdpi");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableQualifierXxhdpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-xxhdpi-v4");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableXxxhdpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-xxxhdpi");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resRawTest() throws BrutException, IOException {
|
||||
compareResFolder("raw");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void libsTest() throws BrutException, IOException {
|
||||
compareLibsFolder("libs");
|
||||
compareLibsFolder("lib");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknownFolderTest() throws BrutException {
|
||||
compareUnknownFiles();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fileAssetTest() throws BrutException, IOException {
|
||||
compareAssetsFolder("txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unicodeAssetTest() throws BrutException, IOException {
|
||||
assumeTrue(! OSDetection.isWindows());
|
||||
compareAssetsFolder("unicode-txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleDexTest() throws BrutException, IOException {
|
||||
compareBinaryFolder("/smali_classes2", false);
|
||||
compareBinaryFolder("/smali_classes3", false);
|
||||
|
||||
File classes2Dex = new File(sTestOrigDir, "build/apk/classes2.dex");
|
||||
File classes3Dex = new File(sTestOrigDir, "build/apk/classes3.dex");
|
||||
|
||||
assertTrue(classes2Dex.isFile());
|
||||
assertTrue(classes3Dex.isFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singleDexTest() throws BrutException, IOException {
|
||||
compareBinaryFolder("/smali", false);
|
||||
|
||||
File classesDex = new File(sTestOrigDir, "build/apk/classes.dex");
|
||||
assertTrue(classesDex.isFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confirmKotlinFolderPersistsTest() {
|
||||
checkFolderExists("/kotlin");
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.*;
|
||||
import brut.androlib.options.BuildOptions;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
import org.custommonkey.xmlunit.XMLUnit;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
|
||||
public class DebugTagRetainedTest extends BaseTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
sTestOrigDir = new ExtFile(sTmpDir, "issue1235-orig");
|
||||
sTestNewDir = new ExtFile(sTmpDir, "issue1235-new");
|
||||
LOGGER.info("Unpacking issue1235...");
|
||||
TestUtils.copyResourceDir(DebugTagRetainedTest.class, "aapt1/issue1235/", sTestOrigDir);
|
||||
|
||||
LOGGER.info("Building issue1235.apk...");
|
||||
BuildOptions buildOptions = new BuildOptions();
|
||||
buildOptions.debugMode = true;
|
||||
|
||||
File testApk = new File(sTmpDir, "issue1235.apk");
|
||||
new Androlib(buildOptions).build(sTestOrigDir, testApk);
|
||||
|
||||
LOGGER.info("Decoding issue1235.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildAndDecodeTest() {
|
||||
assertTrue(sTestNewDir.isDirectory());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void DebugIsTruePriorToBeingFalseTest() throws IOException, SAXException {
|
||||
String apk = "issue1235-new";
|
||||
|
||||
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>" +
|
||||
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" android:compileSdkVersion=\"23\" " +
|
||||
"android:compileSdkVersionCodename=\"6.0-2438415\" package=\"com.ibotpeaches.issue1235\" platformBuildVersionCode=\"20\" " +
|
||||
"platformBuildVersionName=\"4.4W.2-1537038\"> <application android:debuggable=\"true\"/></manifest>");
|
||||
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(sTmpDir + File.separator + apk + File.separator + "AndroidManifest.xml"));
|
||||
String obtained = TestUtils.replaceNewlines(new String(encoded));
|
||||
|
||||
XMLUnit.setIgnoreWhitespace(true);
|
||||
XMLUnit.setIgnoreAttributeOrder(true);
|
||||
XMLUnit.setCompareUnmatched(false);
|
||||
|
||||
assertXMLEqual(expected, obtained);
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
import brut.common.BrutException;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.util.OS;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DefaultBaksmaliVariableTest extends BaseTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
sTestOrigDir = new ExtFile(sTmpDir, "testjar-orig");
|
||||
sTestNewDir = new ExtFile(sTmpDir, "testjar-new");
|
||||
LOGGER.info("Unpacking testjar...");
|
||||
TestUtils.copyResourceDir(DefaultBaksmaliVariableTest.class, "aapt1/issue1481/", sTestOrigDir);
|
||||
|
||||
LOGGER.info("Building issue1481.jar...");
|
||||
File testJar = new File(sTmpDir, "issue1481.jar");
|
||||
new Androlib().build(sTestOrigDir, testJar);
|
||||
|
||||
LOGGER.info("Decoding issue1481.jar...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testJar);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confirmBaksmaliParamsAreTheSame() throws BrutException, IOException {
|
||||
String expected = TestUtils.replaceNewlines(".class public final Lcom/ibotpeaches/issue1481/BuildConfig;\n" +
|
||||
".super Ljava/lang/Object;\n" +
|
||||
".source \"BuildConfig.java\"\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"# static fields\n" +
|
||||
".field public static final APPLICATION_ID:Ljava/lang/String; = \"com.ibotpeaches.issue1481\"\n" +
|
||||
"\n" +
|
||||
".field public static final BUILD_TYPE:Ljava/lang/String; = \"debug\"\n" +
|
||||
"\n" +
|
||||
".field public static final DEBUG:Z\n" +
|
||||
"\n" +
|
||||
".field public static final FLAVOR:Ljava/lang/String; = \"\"\n" +
|
||||
"\n" +
|
||||
".field public static final VERSION_CODE:I = 0x1\n" +
|
||||
"\n" +
|
||||
".field public static final VERSION_NAME:Ljava/lang/String; = \"1.0\"\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"# direct methods\n" +
|
||||
".method static constructor <clinit>()V\n" +
|
||||
" .locals 1\n" +
|
||||
"\n" +
|
||||
" .prologue\n" +
|
||||
" .line 7\n" +
|
||||
" const-string v0, \"true\"\n" +
|
||||
"\n" +
|
||||
" invoke-static {v0}, Ljava/lang/Boolean;->parseBoolean(Ljava/lang/String;)Z\n" +
|
||||
"\n" +
|
||||
" move-result v0\n" +
|
||||
"\n" +
|
||||
" sput-boolean v0, Lcom/ibotpeaches/issue1481/BuildConfig;->DEBUG:Z\n" +
|
||||
"\n" +
|
||||
" return-void\n" +
|
||||
".end method\n" +
|
||||
"\n" +
|
||||
".method public constructor <init>()V\n" +
|
||||
" .locals 0\n" +
|
||||
"\n" +
|
||||
" .prologue\n" +
|
||||
" .line 6\n" +
|
||||
" invoke-direct {p0}, Ljava/lang/Object;-><init>()V\n" +
|
||||
"\n" +
|
||||
" return-void\n" +
|
||||
".end method");
|
||||
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(sTestNewDir + File.separator + "smali" + File.separator
|
||||
+ "com" + File.separator + "ibotpeaches" + File.separator + "issue1481" + File.separator + "BuildConfig.smali"));
|
||||
|
||||
String obtained = TestUtils.replaceNewlines(new String(encoded));
|
||||
assertEquals(expected, obtained);
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.options.BuildOptions;
|
||||
import brut.androlib.TestUtils;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class EmptyResourcesArscTest {
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
sTestOrigDir = new ExtFile(sTmpDir, "issue1730-orig");
|
||||
sTestNewDir = new ExtFile(sTmpDir, "issue1730-new");
|
||||
LOGGER.info("Unpacking issue1730.apk...");
|
||||
TestUtils.copyResourceDir(EmptyResourcesArscTest.class, "aapt1/issue1730", sTestOrigDir);
|
||||
|
||||
File testApk = new File(sTestOrigDir, "issue1730.apk");
|
||||
|
||||
LOGGER.info("Decoding issue1730.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.decode();
|
||||
|
||||
LOGGER.info("Building issue1730.apk...");
|
||||
BuildOptions buildOptions = new BuildOptions();
|
||||
new Androlib(buildOptions).build(sTestNewDir, testApk);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildAndDecodeTest() {
|
||||
assertTrue(sTestNewDir.isDirectory());
|
||||
assertTrue(sTestOrigDir.isDirectory());
|
||||
}
|
||||
|
||||
private static ExtFile sTmpDir;
|
||||
private static ExtFile sTestOrigDir;
|
||||
private static ExtFile sTestNewDir;
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(EmptyResourcesArscTest.class.getName());
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.*;
|
||||
|
||||
public class LargeIntsInManifestTest extends BaseTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
TestUtils.copyResourceDir(LargeIntsInManifestTest.class, "aapt1/issue767/", sTmpDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkIfLargeIntsAreHandledTest() throws BrutException, IOException {
|
||||
String apk = "issue767.apk";
|
||||
|
||||
// decode issue767.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();
|
||||
|
||||
// build issue767
|
||||
ExtFile testApk = new ExtFile(sTmpDir, apk + ".out");
|
||||
new Androlib().build(testApk, 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();
|
||||
|
||||
compareXmlFiles("AndroidManifest.xml");
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
import org.custommonkey.xmlunit.XMLUnit;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ProviderAttributeTest extends BaseTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws BrutException {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
TestUtils.copyResourceDir(ProviderAttributeTest.class, "aapt1/issue636/", sTmpDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isProviderStringReplacementWorking() throws BrutException, IOException, SAXException {
|
||||
String apk = "issue636.apk";
|
||||
|
||||
// decode issue636.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out"));
|
||||
apkDecoder.decode();
|
||||
|
||||
// build issue636
|
||||
ExtFile testApk = new ExtFile(sTmpDir, apk + ".out");
|
||||
new Androlib().build(testApk, 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();
|
||||
|
||||
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" +
|
||||
" <application android:allowBackup=\"true\" android:debuggable=\"true\" android:icon=\"@mipmap/ic_launcher\" android:label=\"@string/app_name\" android:theme=\"@style/AppTheme\">\n" +
|
||||
" <provider android:authorities=\"com.ibotpeaches.issue636.Provider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:label=\"@string/app_name\" android:multiprocess=\"false\" android:name=\"com.ibotpeaches.issue636.Provider\"/>\n" +
|
||||
" <provider android:authorities=\"com.ibotpeaches.issue636.ProviderTwo\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:label=\"@string/app_name\" android:multiprocess=\"false\" android:name=\"com.ibotpeaches.issue636.ProviderTwo\"/>\n" +
|
||||
" </application>\n" +
|
||||
"</manifest>");
|
||||
|
||||
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(sTmpDir + File.separator + apk + ".out.two" + File.separator + "AndroidManifest.xml"));
|
||||
String obtained = TestUtils.replaceNewlines(new String(encoded));
|
||||
|
||||
XMLUnit.setIgnoreWhitespace(true);
|
||||
XMLUnit.setIgnoreAttributeOrder(true);
|
||||
XMLUnit.setCompareUnmatched(false);
|
||||
|
||||
assertXMLEqual(expected, obtained);
|
||||
}
|
||||
|
||||
private boolean fileExists(String filepath) {
|
||||
return Files.exists(Paths.get(sTmpDir.getAbsolutePath() + File.separator + filepath));
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.Androlib;
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
import brut.androlib.meta.MetaInfo;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ReferenceVersionCodeTest extends BaseTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
TestUtils.copyResourceDir(ReferenceVersionCodeTest.class, "aapt1/issue1234/", sTmpDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.*;
|
||||
import brut.androlib.options.BuildOptions;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SharedLibraryTest extends BaseTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws BrutException {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
TestUtils.copyResourceDir(SharedLibraryTest.class, "aapt1/shared_libraries/", sTmpDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isFrameworkTaggingWorking() throws AndrolibException {
|
||||
String apkName = "library.apk";
|
||||
|
||||
BuildOptions buildOptions = new BuildOptions();
|
||||
buildOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
|
||||
buildOptions.frameworkTag = "building";
|
||||
|
||||
new Androlib(buildOptions).installFramework(new File(sTmpDir + File.separator + apkName));
|
||||
|
||||
assertTrue(fileExists("2-building.apk"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isFrameworkInstallingWorking() throws AndrolibException {
|
||||
String apkName = "library.apk";
|
||||
|
||||
BuildOptions buildOptions = new BuildOptions();
|
||||
buildOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
|
||||
|
||||
new Androlib(buildOptions).installFramework(new File(sTmpDir + File.separator + apkName));
|
||||
|
||||
assertTrue(fileExists("2.apk"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSharedResourceDecodingAndRebuildingWorking() throws IOException, BrutException {
|
||||
String library = "library.apk";
|
||||
String client = "client.apk";
|
||||
|
||||
// setup apkOptions
|
||||
BuildOptions buildOptions = new BuildOptions();
|
||||
buildOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
|
||||
buildOptions.frameworkTag = "shared";
|
||||
|
||||
// install library/framework
|
||||
new Androlib(buildOptions).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(buildOptions.frameworkFolderLocation);
|
||||
apkDecoder.setFrameworkTag(buildOptions.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(buildOptions.frameworkFolderLocation);
|
||||
libraryDecoder.setFrameworkTag(buildOptions.frameworkTag);
|
||||
libraryDecoder.decode();
|
||||
|
||||
// build client.apk
|
||||
ExtFile clientApk = new ExtFile(sTmpDir, client + ".out");
|
||||
new Androlib(buildOptions).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(buildOptions).build(libraryApk, null);
|
||||
assertTrue(fileExists(library + ".out" + File.separator + "dist" + File.separator + library));
|
||||
}
|
||||
|
||||
private boolean fileExists(String filepath) {
|
||||
return Files.exists(Paths.get(sTmpDir.getAbsolutePath() + File.separator + filepath));
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.ApkDecoder;
|
||||
import brut.androlib.BaseTest;
|
||||
import brut.androlib.TestUtils;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SkipAssetTest extends BaseTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
TestUtils.copyResourceDir(SkipAssetTest.class, "aapt1/issue1605/", sTmpDir);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkIfEnablingSkipAssetWorks() throws BrutException, IOException {
|
||||
String apk = "issue1605.apk";
|
||||
|
||||
// decode issue1605.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||
sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
|
||||
apkDecoder.setOutDir(sTestOrigDir);
|
||||
apkDecoder.setDecodeAssets(ApkDecoder.DECODE_ASSETS_NONE);
|
||||
apkDecoder.setForceDelete(true);
|
||||
apkDecoder.decode();
|
||||
|
||||
checkFileDoesNotExist("assets" + File.separator + "kotlin.kotlin_builtins");
|
||||
checkFileDoesNotExist("assets" + File.separator + "ranges" + File.separator + "ranges.kotlin_builtins");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkControl() throws BrutException, IOException {
|
||||
String apk = "issue1605.apk";
|
||||
|
||||
// decode issue1605.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||
sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".out");
|
||||
|
||||
apkDecoder.setOutDir(sTestOrigDir);
|
||||
apkDecoder.setDecodeAssets(ApkDecoder.DECODE_ASSETS_FULL);
|
||||
apkDecoder.setForceDelete(true);
|
||||
apkDecoder.decode();
|
||||
|
||||
checkFileDoesExist("assets" + File.separator + "kotlin.kotlin_builtins");
|
||||
checkFileDoesExist("assets" + File.separator + "ranges" + File.separator + "ranges.kotlin_builtins");
|
||||
}
|
||||
|
||||
private void checkFileDoesNotExist(String path) throws BrutException {
|
||||
File f = new File(sTestOrigDir, path);
|
||||
|
||||
assertFalse(f.isFile());
|
||||
}
|
||||
|
||||
private void checkFileDoesExist(String path) throws BrutException {
|
||||
File f = new File(sTestOrigDir, path);
|
||||
|
||||
assertTrue(f.isFile());
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib.aapt1;
|
||||
|
||||
import brut.androlib.*;
|
||||
import brut.androlib.options.BuildOptions;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.common.BrutException;
|
||||
import brut.util.OS;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
|
||||
public class UnknownCompressionTest extends BaseTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
TestUtils.copyResourceDir(UnknownCompressionTest.class, "aapt1/unknown_compression/", sTmpDir);
|
||||
|
||||
String apk = "deflated_unknowns.apk";
|
||||
BuildOptions buildOptions = new BuildOptions();
|
||||
buildOptions.frameworkFolderLocation = sTmpDir.getAbsolutePath();
|
||||
|
||||
sTestOrigDir = new ExtFile(sTmpDir, apk);
|
||||
|
||||
// decode deflated_unknowns.apk
|
||||
ApkDecoder apkDecoder = new ApkDecoder(sTestOrigDir);
|
||||
apkDecoder.setOutDir(new File(sTestOrigDir.getAbsolutePath() + ".out"));
|
||||
apkDecoder.decode();
|
||||
|
||||
// build deflated_unknowns
|
||||
ExtFile clientApkFolder = new ExtFile(sTestOrigDir.getAbsolutePath() + ".out");
|
||||
new Androlib(buildOptions).build(clientApkFolder, null);
|
||||
sTestNewDir = new ExtFile(clientApkFolder, "dist" + File.separator + apk);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pkmExtensionDeflatedTest() throws BrutException, IOException {
|
||||
Integer control = sTestOrigDir.getDirectory().getCompressionLevel("assets/bin/Data/test.pkm");
|
||||
Integer rebuilt = sTestNewDir.getDirectory().getCompressionLevel("assets/bin/Data/test.pkm");
|
||||
|
||||
// Check that control = rebuilt (both deflated)
|
||||
// Add extra check for checking not equal to 0, just in case control gets broken
|
||||
assertEquals(control, rebuilt);
|
||||
assertNotSame(0, rebuilt);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doubleExtensionStoredTest() throws BrutException, IOException {
|
||||
Integer control = sTestOrigDir.getDirectory().getCompressionLevel("assets/bin/Data/two.extension.file");
|
||||
Integer rebuilt = sTestNewDir.getDirectory().getCompressionLevel("assets/bin/Data/two.extension.file");
|
||||
|
||||
// Check that control = rebuilt (both stored)
|
||||
// Add extra check for checking = 0 to enforce check for stored just in case control breaks
|
||||
assertEquals(control, rebuilt);
|
||||
assertEquals(Integer.valueOf(0), rebuilt);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confirmJsonFileIsDeflatedTest() throws BrutException, IOException {
|
||||
Integer control = sTestOrigDir.getDirectory().getCompressionLevel("test.json");
|
||||
Integer rebuilt = sTestNewDir.getDirectory().getCompressionLevel("test.json");
|
||||
|
||||
assertEquals(control, rebuilt);
|
||||
assertEquals(Integer.valueOf(8), rebuilt);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confirmPngFileIsCorrectlyDeflatedTest() throws BrutException, IOException {
|
||||
Integer control = sTestOrigDir.getDirectory().getCompressionLevel("950x150.png");
|
||||
Integer rebuilt = sTestNewDir.getDirectory().getCompressionLevel("950x150.png");
|
||||
|
||||
assertEquals(control, rebuilt);
|
||||
assertEquals(Integer.valueOf(8), rebuilt);
|
||||
}
|
||||
}
|
@ -56,9 +56,7 @@ public class ExternalEntityTest extends BaseTest {
|
||||
OS.rmdir(sTestOrigDir);
|
||||
}
|
||||
|
||||
// @Test // ReVanced - disable test.
|
||||
// This test is made for aapt1, which was previously the default.
|
||||
// Now it breaks, and I'm too lazy to fix it :')
|
||||
@Test
|
||||
public void doctypeTest() throws IOException {
|
||||
|
||||
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
|
@ -23,6 +23,7 @@ import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class AaptVersionTest {
|
||||
|
||||
@Test
|
||||
public void testAapt2Iterations() throws BrutException {
|
||||
assertEquals(2, AaptManager.getAppVersionFromString("Android Asset Packaging Tool (aapt) 2:17"));
|
||||
|
@ -21,15 +21,19 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AaptManager implements AaptProvider {
|
||||
public class AaptManager {
|
||||
|
||||
public File getAapt2() throws BrutException {
|
||||
return getAapt();
|
||||
public static File getAapt2() throws BrutException {
|
||||
return getAapt(2);
|
||||
}
|
||||
|
||||
private static File getAapt() throws BrutException {
|
||||
public static File getAapt1() throws BrutException {
|
||||
return getAapt(1);
|
||||
}
|
||||
|
||||
private static File getAapt(Integer version) throws BrutException {
|
||||
File aaptBinary;
|
||||
String aaptVersion = getAaptBinaryName(2);
|
||||
String aaptVersion = getAaptBinaryName(version);
|
||||
|
||||
if (! OSDetection.is64Bit() && OSDetection.isMacOSX()) {
|
||||
throw new BrutException("32 bit OS detected. No 32 bit binaries available.");
|
||||
|
@ -1,9 +0,0 @@
|
||||
package brut.util;
|
||||
|
||||
import brut.common.BrutException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public interface AaptProvider {
|
||||
File getAapt2() throws BrutException;
|
||||
}
|
@ -20,7 +20,6 @@ import brut.common.BrutException;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
@ -52,7 +51,7 @@ public abstract class Jar {
|
||||
File fileOut = File.createTempFile(tmpPrefix, suffix + ".tmp");
|
||||
fileOut.deleteOnExit();
|
||||
|
||||
OutputStream out = Files.newOutputStream(fileOut.toPath());
|
||||
OutputStream out = new FileOutputStream(fileOut);
|
||||
IOUtils.copy(in, out);
|
||||
in.close();
|
||||
out.close();
|
||||
|
Loading…
Reference in New Issue
Block a user