diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/xml/ResXmlUtils.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/xml/ResXmlUtils.java
index 683181e252..825d134ab5 100644
--- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/xml/ResXmlUtils.java
+++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/xml/ResXmlUtils.java
@@ -257,7 +257,7 @@ public static void renameManifestPackage(File file, String packageOriginal) {
public static String[] pullManifestFeatureFlags(File file) {
try {
Document doc = XmlUtils.loadDocument(file, true);
- String expression = "/manifest/permission/@android:featureFlag";
+ String expression = "/manifest//@android:featureFlag";
NodeList nodes = XmlUtils.evaluateXPath(doc, expression, NodeList.class);
String[] featureFlags = new String[nodes.getLength()];
diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BaseTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BaseTest.java
index 51ca50207a..0e6811dd01 100644
--- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BaseTest.java
+++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BaseTest.java
@@ -17,7 +17,6 @@
package brut.androlib;
import brut.androlib.Config;
-import brut.androlib.apk.ApkInfo;
import brut.androlib.res.Framework;
import brut.common.BrutException;
import brut.directory.ExtFile;
@@ -47,7 +46,6 @@ public class BaseTest {
protected static File sTmpDir;
protected static ExtFile sTestOrigDir;
protected static ExtFile sTestNewDir;
- protected static ApkInfo sTestApkInfo;
private static void cleanFrameworkFile() throws BrutException {
File apkFile = new File(new Framework(sConfig).getDirectory(), "1.apk");
diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/BuildAndDecodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/BuildAndDecodeTest.java
index 9db80e21c3..324e4290db 100644
--- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/BuildAndDecodeTest.java
+++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/BuildAndDecodeTest.java
@@ -172,10 +172,10 @@ public void valuesExtraLongExactLengthTest() throws BrutException {
@Test
public void storedMp3FilesAreNotCompressedTest() throws BrutException, IOException {
- ExtFile testApk = new ExtFile(sTmpDir, "testapp.apk");
- Integer compLevel = testApk.getDirectory().getCompressionLevel("res/raw/rain.mp3");
- testApk.close();
- assertEquals(Integer.valueOf(0), compLevel);
+ try (ExtFile testApk = new ExtFile(sTmpDir, "testapp.apk")) {
+ Integer compLevel = testApk.getDirectory().getCompressionLevel("res/raw/rain.mp3");
+ assertEquals(Integer.valueOf(0), compLevel);
+ }
}
@Test
@@ -503,9 +503,7 @@ private static boolean isTransparent(int pixel) {
@Test
public void confirmZeroByteFileExtensionIsNotStored() throws BrutException {
ApkInfo testInfo = ApkInfo.load(sTestNewDir);
- for (String path : testInfo.doNotCompress) {
- assertNotEquals("jpg", path);
- }
+ assertFalse(testInfo.doNotCompress.contains("jpg"));
}
@Test
diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt2/BuildAndDecodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt2/BuildAndDecodeTest.java
index 04477be7ac..f0a45c2e9e 100644
--- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt2/BuildAndDecodeTest.java
+++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt2/BuildAndDecodeTest.java
@@ -49,7 +49,7 @@ public static void beforeClass() throws Exception {
new ApkBuilder(sTestOrigDir, sConfig).build(testApk);
LOGGER.info("Decoding testapp.apk...");
- sTestApkInfo = new ApkDecoder(testApk, sConfig).decode(sTestNewDir);
+ new ApkDecoder(testApk, sConfig).decode(sTestNewDir);
}
@Test
@@ -89,6 +89,13 @@ public void valuesBcp47LanguageScriptRegionVariantTest() throws BrutException {
compareValuesFiles("values-b+ast+Hant+IT+ARABEXT/strings.xml");
}
+ @Test
+ public void confirmFeatureFlagsRecorded() throws BrutException {
+ ApkInfo testInfo = ApkInfo.load(sTestNewDir);
+ assertTrue(testInfo.featureFlags.get("brut.feature.permission"));
+ assertTrue(testInfo.featureFlags.get("brut.feature.activity"));
+ }
+
@Test
public void confirmZeroByteFileExtensionIsNotStored() throws BrutException {
ApkInfo testInfo = ApkInfo.load(sTestNewDir);
@@ -159,15 +166,6 @@ public void unknownFolderTest() throws BrutException {
compareBinaryFolder("unknown");
}
- @Test
- public void featureFlagTest() {
- assertNotNull(sTestApkInfo.featureFlags);
- assertTrue(sTestApkInfo.featureFlags.containsKey("brut.feature.flag"));
- // assertTrue(sTestApkInfo.featureFlags.containsKey("brut.activity.flag"));
- assertEquals(true, sTestApkInfo.featureFlags.get("brut.feature.flag"));
- // assertEquals(true, sTestApkInfo.featureFlags.get("brut.activity.flag"));
- }
-
@Test
public void confirmPlatformManifestValuesTest() throws BrutException {
Document doc = loadDocument(new File(sTestNewDir, "AndroidManifest.xml"));
diff --git a/brut.apktool/apktool-lib/src/test/resources/aapt2/testapp/AndroidManifest.xml b/brut.apktool/apktool-lib/src/test/resources/aapt2/testapp/AndroidManifest.xml
index c1d4df9f02..6756377173 100644
--- a/brut.apktool/apktool-lib/src/test/resources/aapt2/testapp/AndroidManifest.xml
+++ b/brut.apktool/apktool-lib/src/test/resources/aapt2/testapp/AndroidManifest.xml
@@ -10,12 +10,12 @@
-
+
-
+
diff --git a/brut.apktool/apktool-lib/src/test/resources/aapt2/testapp/apktool.yml b/brut.apktool/apktool-lib/src/test/resources/aapt2/testapp/apktool.yml
index cff49cd6f0..d0981b6652 100644
--- a/brut.apktool/apktool-lib/src/test/resources/aapt2/testapp/apktool.yml
+++ b/brut.apktool/apktool-lib/src/test/resources/aapt2/testapp/apktool.yml
@@ -10,8 +10,8 @@ versionInfo:
versionCode: '1'
versionName: '1.0'
featureFlags:
- brut.feature.flag: true
- brut.activity.flag: true
+ brut.feature.permission: true
+ brut.feature.activity: true
doNotCompress:
- assets/0byte_file.jpg
sparseResources: false