Skip to content

Commit

Permalink
chore: add testcase for feature flags (api 35) (#3774)
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches authored Jan 17, 2025
1 parent 4b2c9ab commit 8886275
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;
Expand Down Expand Up @@ -46,6 +47,7 @@ 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void beforeClass() throws Exception {
new ApkBuilder(sTestOrigDir, sConfig).build(testApk);

LOGGER.info("Decoding testapp.apk...");
new ApkDecoder(testApk, sConfig).decode(sTestNewDir);
sTestApkInfo = new ApkDecoder(testApk, sConfig).decode(sTestNewDir);
}

@Test
Expand Down Expand Up @@ -159,6 +159,15 @@ 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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
<meta-data name="test_int_as_string" value="\ 12345" />
<meta-data name="test_int" value="12345" />
</application>
<activity android:name=".MainActivity" android:featureFlag="brut.activity.flag">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<permission android:featureFlag="brut.feature.flag" android:label="Test Permission" android:name="brut.permission.TEST" android:permissionGroup="android.permission-group.UNDEFINED" android:protectionLevel="signature" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ versionInfo:
versionName: '1.0'
featureFlags:
brut.feature.flag: true
brut.activity.flag: true
doNotCompress:
- assets/0byte_file.jpg
sparseResources: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.class public LMainActivity;
.super Landroid/app/Activity;

.method protected onCreate(Landroid/os/Bundle;)V
.locals 2

.prologue
const/4 v0, 0x1

.line 8
invoke-super {p0, p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V

.line 10
new-instance v1, Landroid/widget/TextView;

invoke-direct {v1, p0}, Landroid/widget/TextView;-><init>(Landroid/content/Context;)V

.line 11
const-string v0, "Hello, World!"

invoke-virtual {v1, v0}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

.line 12
invoke-virtual {p0, v1}, Landroid/app/Activity;->setContentView(Landroid/view/View;)V

.line 13
return-void
.end method

0 comments on commit 8886275

Please sign in to comment.