Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,56 @@ public void OverlayManifestTest ([Values] AndroidRuntime runtime)
}
}

[Test]
public void OverlayManifestIncrementalBuildTest ([Values] AndroidRuntime runtime)
{
const bool isRelease = true;
if (IgnoreUnsupportedConfiguration (runtime, release: isRelease)) {
return;
}
var proj = new XamarinAndroidApplicationProject () {
IsRelease = isRelease,
ManifestMerger = "manifestmerger.jar",
};
proj.SetRuntime (runtime);
proj.AndroidManifest = @"<?xml version=""1.0"" encoding=""utf-8""?>
<manifest xmlns:android=""http://schemas.android.com/apk/res/android"" android:versionCode=""1"" android:versionName=""1.0"" package=""foo.foo"">
<application android:label=""foo"">
</application>
</manifest>";
var overlay = new BuildItem ("AndroidManifestOverlay", "ManifestOverlay.xml") {
TextContent = () => @"<?xml version=""1.0"" encoding=""utf-8""?>
<manifest xmlns:android=""http://schemas.android.com/apk/res/android"">
<uses-permission android:name=""android.permission.CAMERA"" />
</manifest>
"
};
proj.OtherBuildItems.Add (overlay);
using (var b = CreateApkBuilder (cleanupAfterSuccessfulBuild: false, cleanupOnDispose: false)) {
Assert.IsTrue (b.Build (proj), "First build should have succeeded.");
var text = b.Output.GetIntermediaryAsText ("android/AndroidManifest.xml");
StringAssert.Contains ("android.permission.CAMERA", text, "Merged manifest should contain the initial overlay permission.");
StringAssert.DoesNotContain ("android.permission.RECORD_AUDIO", text, "Merged manifest should not contain the updated overlay permission yet.");

Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true, saveProject: false), "Second build should have succeeded.");
b.Output.AssertTargetIsSkipped ("_ManifestMerger");

overlay.TextContent = () => @"<?xml version=""1.0"" encoding=""utf-8""?>
<manifest xmlns:android=""http://schemas.android.com/apk/res/android"">
<uses-permission android:name=""android.permission.CAMERA"" />
<uses-permission android:name=""android.permission.RECORD_AUDIO"" />
</manifest>
";
proj.Touch ("ManifestOverlay.xml");

Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true, saveProject: false), "Third build should have succeeded.");
b.Output.AssertTargetIsNotSkipped ("_ManifestMerger");

text = b.Output.GetIntermediaryAsText ("android/AndroidManifest.xml");
StringAssert.Contains ("android.permission.RECORD_AUDIO", text, "Merged manifest should include permissions from the updated overlay.");
}
}

[Test]
public void RemovePermissionTest ([Values] AndroidRuntime runtime)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ because xbuild doesn't support framework reference assemblies.

<Target Name="_ManifestMerger"
Condition=" '$(AndroidManifestMerger)' == 'manifestmerger.jar' "
Inputs="$(IntermediateOutputPath)AndroidManifest.xml;@(ExtractedManifestDocuments);$(_AndroidBuildPropertiesCache);@(_AndroidMSBuildAllProjects)"
Inputs="$(IntermediateOutputPath)AndroidManifest.xml;@(ExtractedManifestDocuments);@(AndroidManifestOverlay);$(_AndroidBuildPropertiesCache);@(_AndroidMSBuildAllProjects)"
Outputs="$(IntermediateOutputPath)android\AndroidManifest.xml"
>
<ItemGroup>
Expand Down
Loading