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 @@ -141,12 +141,31 @@ public void CheckElementReOrdering ([Values (true, false)] bool useAapt2)
var manifestFile = Path.Combine (Root, builder.ProjectDirectory, proj.IntermediateOutputPath, "android", "AndroidManifest.xml");
XDocument doc = XDocument.Load (manifestFile);
var ns = doc.Root.GetNamespaceOfPrefix ("android");
var manifest = doc.Element ("manifest");
Assert.IsNotNull (manifest, "manifest element should not be null.");
var app = manifest.Element ("application");
Assert.IsNotNull (app, "application element should not be null.");
var manifest = GetElement (doc, "manifest");
var app = GetElement (manifest, "application");
Assert.AreEqual (0, app.ElementsAfterSelf ().Count (),
"There should be no elements after the application element");
var activity = GetElement (app, "activity");
AssertAttribute (activity, ns + "exported", "true");
var intent_filter = GetElement (activity, "intent-filter");
var action = GetElement (intent_filter, "action");
AssertAttribute (action, ns + "name", "android.intent.action.MAIN");
var category = GetElement (intent_filter, "category");
AssertAttribute (category, ns + "name", "android.intent.category.LAUNCHER");
}

static XElement GetElement (XContainer parent, XName name)
{
var e = parent.Element (name);
Assert.IsNotNull (e, $"{name} element should not be null.");
return e;
}

static void AssertAttribute (XElement parent, XName name, string expected)
{
var a = parent.Attribute (name);
Assert.IsNotNull (a, $"{name} attribute should not be null.");
Assert.AreEqual (expected, a.Value, $"{name} attribute value did not match.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ void AddLauncherIntentElements (XElement activity)
return;

var filter = new XElement ("intent-filter");
activity.Add (new XAttribute (androidNs + "exported", "true"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add this for all Android versions or should we only be doing it for Android 12 + ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not appear that //activity/@android:exported attribute has a minimum API level. Since this is a security feature, we're probably good to set this across the board?

Usually the way new attributes work in AndroidManifest.xml, is that older Android versions just ignore the values they don't know about.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh okay awesome then ! thank you

activity.AddFirst (filter);
foreach (KeyValuePair<string, string> e in LauncherIntentElements) {
if (!filter.Elements (e.Key).Any (x => ((string) x.Attribute (attName)) == e.Value))
Expand Down