Skip to content

Commit 328b6ed

Browse files
authored
[Mono.Android] Add documented AndroidManifest.xml-related properties (#9096)
Fixes: #9092 Context: 3ab74db Previously in commit 3ab74db, we created a process for automatically determining the possible attributes for elements in `AndroidManifest.xml` and generating the `[Application]`, `[Activity]`, etc. attributes within `Mono.Android.dll` for users to consume. At the time, we merely created the process, but did not use it to expose any new attributes that have been added in previous Android API levels that we never exposed. This commit exposes all Google-documented manifest attributes for the elements we support. The undocumented manifest attributes were moved around in the file to a section denoted as "undocumented".
1 parent 1934eab commit 328b6ed

File tree

9 files changed

+340
-110
lines changed

9 files changed

+340
-110
lines changed

build-tools/manifest-attribute-codegen/metadata.xml

Lines changed: 139 additions & 110 deletions
Large diffs are not rendered by default.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace Android.App;
2+
3+
// Used by AndroidManifest.xml for the attribute 'activity.requireContentUriPermissionFromCaller'.
4+
public enum RequiredContentUriPermission
5+
{
6+
/// <summary>
7+
/// Default, no specific permissions are required.
8+
/// </summary>
9+
None = 0,
10+
11+
/// <summary>
12+
/// Enforces the invoker to have read access to the passed content URIs.
13+
/// </summary>
14+
Read = 1,
15+
16+
/// <summary>
17+
/// Enforces the invoker to have write access to the passed content URIs.
18+
/// </summary>
19+
Write = 2,
20+
21+
/// <summary>
22+
/// Enforces the invoker to have either read or write access to the passed content URIs.
23+
/// </summary>
24+
ReadOrWrite = 3,
25+
26+
/// <summary>
27+
/// Enforces the invoker to have write access to the passed content URIs.
28+
/// </summary>
29+
ReadAndWrite = 4,
30+
}

src/Mono.Android/Mono.Android.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
<Compile Include="Android.App\IntentFilterAttribute.Partial.cs" />
8383
<Compile Include="Android.App\MetaDataAttribute.Partial.cs" />
8484
<Compile Include="Android.App\PropertyAttribute.Partial.cs" />
85+
<Compile Include="Android.App\RequiredContentUriPermission.cs" />
8586
<Compile Include="Android.App\UsesFeatureAttribute.Partial.cs" />
8687
<Compile Include="Android.App\UsesLibraryAttribute.Partial.cs" />
8788
<Compile Include="Android.App\UsesPermissionAttribute.Partial.cs" />

src/Mono.Android/PublicAPI/API-35/PublicAPI.Unshipped.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,12 +502,34 @@ Android.AdServices.Topics.EncryptedTopic.KeyIdentifier.get -> string!
502502
Android.AdServices.Topics.GetTopicsResponse.Builder.Builder(System.Collections.Generic.IList<Android.AdServices.Topics.Topic!>! topics, System.Collections.Generic.IList<Android.AdServices.Topics.EncryptedTopic!>! encryptedTopics) -> void
503503
Android.AdServices.Topics.GetTopicsResponse.EncryptedTopics.get -> System.Collections.Generic.IList<Android.AdServices.Topics.EncryptedTopic!>!
504504
Android.App.Activity.RequestPermissions(string![]! permissions, int requestCode, int deviceId) -> void
505+
Android.App.ActivityAttribute.CanDisplayOnRemoteDevices.get -> bool
506+
Android.App.ActivityAttribute.CanDisplayOnRemoteDevices.set -> void
507+
Android.App.ActivityAttribute.EnableOnBackInvokedCallback.get -> bool
508+
Android.App.ActivityAttribute.EnableOnBackInvokedCallback.set -> void
509+
Android.App.ActivityAttribute.RequireContentUriPermissionFromCaller.get -> Android.App.RequiredContentUriPermission
510+
Android.App.ActivityAttribute.RequireContentUriPermissionFromCaller.set -> void
505511
Android.App.Admin.ContentProtectionPolicy
506512
Android.App.Admin.ContentProtectionPolicy.Disabled = 1 -> Android.App.Admin.ContentProtectionPolicy
507513
Android.App.Admin.ContentProtectionPolicy.Enabled = 2 -> Android.App.Admin.ContentProtectionPolicy
508514
Android.App.Admin.ContentProtectionPolicy.NotControlledByPolicy = 0 -> Android.App.Admin.ContentProtectionPolicy
509515
Android.App.Admin.HeadlessDeviceOwnerMode.SingleUser = 2 -> Android.App.Admin.HeadlessDeviceOwnerMode
510516
Android.App.Admin.SecurityLogTags.BackupServiceToggled = 210044 -> Android.App.Admin.SecurityLogTags
517+
Android.App.ApplicationAttribute.AllowCrossUidActivitySwitchFromBelow.get -> bool
518+
Android.App.ApplicationAttribute.AllowCrossUidActivitySwitchFromBelow.set -> void
519+
Android.App.ApplicationAttribute.AllowNativeHeapPointerTagging.get -> bool
520+
Android.App.ApplicationAttribute.AllowNativeHeapPointerTagging.set -> void
521+
Android.App.ApplicationAttribute.AppCategory.get -> Android.Content.PM.ApplicationCategories
522+
Android.App.ApplicationAttribute.AppCategory.set -> void
523+
Android.App.ApplicationAttribute.DataExtractionRules.get -> string?
524+
Android.App.ApplicationAttribute.DataExtractionRules.set -> void
525+
Android.App.ApplicationAttribute.GwpAsanMode.get -> Android.Content.PM.GwpAsan
526+
Android.App.ApplicationAttribute.GwpAsanMode.set -> void
527+
Android.App.ApplicationAttribute.HasFragileUserData.get -> bool
528+
Android.App.ApplicationAttribute.HasFragileUserData.set -> void
529+
Android.App.ApplicationAttribute.RequestLegacyExternalStorage.get -> bool
530+
Android.App.ApplicationAttribute.RequestLegacyExternalStorage.set -> void
531+
Android.App.ApplicationAttribute.TestOnly.get -> bool
532+
Android.App.ApplicationAttribute.TestOnly.set -> void
511533
Android.App.ApplicationStartInfo
512534
Android.App.ApplicationStartInfo.DefiningUid.get -> int
513535
Android.App.ApplicationStartInfo.DescribeContents() -> int
@@ -735,6 +757,12 @@ Android.App.PropertyAttribute.Resource.get -> string?
735757
Android.App.PropertyAttribute.Resource.set -> void
736758
Android.App.PropertyAttribute.Value.get -> string?
737759
Android.App.PropertyAttribute.Value.set -> void
760+
Android.App.RequiredContentUriPermission
761+
Android.App.RequiredContentUriPermission.None = 0 -> Android.App.RequiredContentUriPermission
762+
Android.App.RequiredContentUriPermission.Read = 1 -> Android.App.RequiredContentUriPermission
763+
Android.App.RequiredContentUriPermission.ReadAndWrite = 4 -> Android.App.RequiredContentUriPermission
764+
Android.App.RequiredContentUriPermission.ReadOrWrite = 3 -> Android.App.RequiredContentUriPermission
765+
Android.App.RequiredContentUriPermission.Write = 2 -> Android.App.RequiredContentUriPermission
738766
Android.App.SdkSandbox.AppOwnedSdkSandboxInterface
739767
Android.App.SdkSandbox.AppOwnedSdkSandboxInterface.AppOwnedSdkSandboxInterface(string! name, long version, Android.OS.IBinder! binder) -> void
740768
Android.App.SdkSandbox.AppOwnedSdkSandboxInterface.DescribeContents() -> int
@@ -746,6 +774,8 @@ Android.App.SdkSandbox.AppOwnedSdkSandboxInterface.WriteToParcel(Android.OS.Parc
746774
Android.App.SdkSandbox.SdkSandboxManager.AppOwnedSdkSandboxInterfaces.get -> System.Collections.Generic.IList<Android.App.SdkSandbox.AppOwnedSdkSandboxInterface!>!
747775
Android.App.SdkSandbox.SdkSandboxManager.RegisterAppOwnedSdkSandboxInterface(Android.App.SdkSandbox.AppOwnedSdkSandboxInterface! appOwnedSdkSandboxInterface) -> void
748776
Android.App.SdkSandbox.SdkSandboxManager.UnregisterAppOwnedSdkSandboxInterface(string! name) -> void
777+
Android.App.ServiceAttribute.Description.get -> string?
778+
Android.App.ServiceAttribute.Description.set -> void
749779
Android.App.Usage.StorageStats.GetAppBytesByDataType(Android.App.Usage.StorageStatsAppDataType dataType) -> long
750780
Android.App.Usage.StorageStatsAppDataType
751781
Android.App.Usage.StorageStatsAppDataType.FileTypeApk = 3 -> Android.App.Usage.StorageStatsAppDataType

src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocumentElement.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,14 @@ string ToAttributeValue (string name, T value, ICustomAttributeProvider provider
184184
{ typeof (float), (value, p, r, v, c) => value.ToString () },
185185
{ typeof (string), (value, p, r, v, c) => value.ToString () },
186186
{ typeof (ActivityPersistableMode), (value, p, r, v, c) => ToString ((ActivityPersistableMode) value) },
187+
{ typeof (ApplicationCategories), (value, p, r, v, c) => ToString ((ApplicationCategories) value) },
187188
{ typeof (ConfigChanges), (value, p, r, v, c) => ToString ((ConfigChanges) value) },
188189
{ typeof (DocumentLaunchMode), (value, p, r, v, c) => ToString ((DocumentLaunchMode) value) },
189190
{ typeof (ForegroundService), (value, p, r, v, c) => ToString ((ForegroundService) value) },
191+
{ typeof (GwpAsan), (value, p, r, v, c) => ToString ((GwpAsan) value) },
190192
{ typeof (LaunchMode), (value, p, r, v, c) => ToString ((LaunchMode) value) },
191193
{ typeof (Protection), (value, p, r, v, c) => ToString ((Protection) value) },
194+
{ typeof (RequiredContentUriPermission), (value, p, r, v, c) => ToString ((RequiredContentUriPermission) value) },
192195
{ typeof (ScreenOrientation), (value, p, r, v, c) => ToString ((ScreenOrientation) value, v) },
193196
{ typeof (SoftInput), (value, p, r, v, c) => ToString ((SoftInput) value) },
194197
{ typeof (UiOptions), (value, p, r, v, c) => ToString ((UiOptions) value) },
@@ -408,6 +411,44 @@ static string ToString (ForegroundService value)
408411
return string.Join ("|", values.ToArray ());
409412
}
410413

414+
static string ToString (ApplicationCategories value)
415+
{
416+
return value switch {
417+
ApplicationCategories.Accessibility => "accessibility",
418+
ApplicationCategories.Audio => "audio",
419+
ApplicationCategories.Game => "game",
420+
ApplicationCategories.Image => "image",
421+
ApplicationCategories.Maps => "maps",
422+
ApplicationCategories.News => "news",
423+
ApplicationCategories.Productivity => "productivity",
424+
ApplicationCategories.Social => "social",
425+
ApplicationCategories.Video => "video",
426+
_ => throw new ArgumentException ($"Unsupported ApplicationCategories value '{value}'."),
427+
};
428+
}
429+
430+
static string ToString (RequiredContentUriPermission value)
431+
{
432+
return value switch {
433+
RequiredContentUriPermission.None => "none",
434+
RequiredContentUriPermission.Read => "read",
435+
RequiredContentUriPermission.Write => "write",
436+
RequiredContentUriPermission.ReadOrWrite => "readOrWrite",
437+
RequiredContentUriPermission.ReadAndWrite => "readAndWrite",
438+
_ => throw new ArgumentException ($"Unsupported RequiredContentUriPermission value '{value}'."),
439+
};
440+
}
441+
442+
static string ToString (GwpAsan value)
443+
{
444+
return value switch {
445+
GwpAsan.Always => "always",
446+
GwpAsan.Default => "never",
447+
GwpAsan.Never => "never",
448+
_ => throw new ArgumentException ($"Unsupported GwpAsan value '{value}'."),
449+
};
450+
}
451+
411452
IEnumerator<string> IEnumerable<string>.GetEnumerator ()
412453
{
413454
return Mappings.Keys.GetEnumerator ();

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@
161161
<Compile Include="..\..\build-tools\xa-prep-tasks\Xamarin.Android.BuildTools.PrepTasks\Sleep.cs">
162162
<Link>Xamarin.Android.BuildTools.PrepTasks\Sleep.cs</Link>
163163
</Compile>
164+
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.ApplicationCategories.cs" />
165+
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.GwpAsan.cs" />
164166
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.LaunchMode.cs" />
165167
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.ScreenOrientation.cs" />
166168
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.ConfigChanges.cs" />
@@ -172,6 +174,7 @@
172174
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.ActivityPersistableMode.cs" />
173175
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.DocumentLaunchMode.cs" />
174176
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Views.WindowRotationAnimation.cs" />
177+
<_MonoAndroidEnum Include="..\Mono.Android\Android.App\RequiredContentUriPermission.cs" />
175178
<Compile Include="@(_MonoAndroidEnum)">
176179
<Link>Mono.Android\%(Filename)%(Extension)</Link>
177180
</Compile>

src/Xamarin.Android.NamingCustomAttributes/Android.App/ActivityAttribute.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public ActivityAttribute ()
3030

3131
public string? Banner { get; set; }
3232

33+
public bool CanDisplayOnRemoteDevices { get; set; }
34+
3335
public bool ClearTaskOnLaunch { get; set; }
3436

3537
public string? ColorMode { get; set; }
@@ -44,6 +46,8 @@ public ActivityAttribute ()
4446

4547
public bool Enabled { get; set; }
4648

49+
public bool EnableOnBackInvokedCallback { get; set; }
50+
4751
public string? EnableVrMode { get; set; }
4852

4953
public bool ExcludeFromRecents { get; set; }
@@ -90,6 +94,8 @@ public ActivityAttribute ()
9094

9195
public bool RelinquishTaskIdentity { get; set; }
9296

97+
public Android.App.RequiredContentUriPermission RequireContentUriPermissionFromCaller { get; set; }
98+
9399
public bool ResizeableActivity { get; set; }
94100

95101
public bool ResumeWhilePausing { get; set; }
@@ -160,6 +166,12 @@ static ActivityAttribute ()
160166
getter: self => self.Banner,
161167
setter: (self, value) => self.Banner = (string?) value
162168
);
169+
mapping.Add (
170+
member: "CanDisplayOnRemoteDevices",
171+
attributeName: "canDisplayOnRemoteDevices",
172+
getter: self => self.CanDisplayOnRemoteDevices,
173+
setter: (self, value) => self.CanDisplayOnRemoteDevices = (bool) value
174+
);
163175
mapping.Add (
164176
member: "ClearTaskOnLaunch",
165177
attributeName: "clearTaskOnLaunch",
@@ -202,6 +214,12 @@ static ActivityAttribute ()
202214
getter: self => self.Enabled,
203215
setter: (self, value) => self.Enabled = (bool) value
204216
);
217+
mapping.Add (
218+
member: "EnableOnBackInvokedCallback",
219+
attributeName: "enableOnBackInvokedCallback",
220+
getter: self => self.EnableOnBackInvokedCallback,
221+
setter: (self, value) => self.EnableOnBackInvokedCallback = (bool) value
222+
);
205223
mapping.Add (
206224
member: "EnableVrMode",
207225
attributeName: "enableVrMode",
@@ -334,6 +352,12 @@ static ActivityAttribute ()
334352
getter: self => self.RelinquishTaskIdentity,
335353
setter: (self, value) => self.RelinquishTaskIdentity = (bool) value
336354
);
355+
mapping.Add (
356+
member: "RequireContentUriPermissionFromCaller",
357+
attributeName: "requireContentUriPermissionFromCaller",
358+
getter: self => self.RequireContentUriPermissionFromCaller,
359+
setter: (self, value) => self.RequireContentUriPermissionFromCaller = (Android.App.RequiredContentUriPermission) value
360+
);
337361
mapping.Add (
338362
member: "ResizeableActivity",
339363
attributeName: "resizeableActivity",

src/Xamarin.Android.NamingCustomAttributes/Android.App/ApplicationAttribute.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,22 @@ public ApplicationAttribute ()
2424

2525
public bool AllowClearUserData { get; set; }
2626

27+
public bool AllowCrossUidActivitySwitchFromBelow { get; set; }
28+
29+
public bool AllowNativeHeapPointerTagging { get; set; }
30+
2731
public bool AllowTaskReparenting { get; set; }
2832

33+
public Android.Content.PM.ApplicationCategories AppCategory { get; set; }
34+
2935
public Type? BackupAgent { get; set; }
3036

3137
public bool BackupInForeground { get; set; }
3238

3339
public string? Banner { get; set; }
3440

41+
public string? DataExtractionRules { get; set; }
42+
3543
public bool Debuggable { get; set; }
3644

3745
public string? Description { get; set; }
@@ -46,10 +54,14 @@ public ApplicationAttribute ()
4654

4755
public bool FullBackupOnly { get; set; }
4856

57+
public Android.Content.PM.GwpAsan GwpAsanMode { get; set; }
58+
4959
public bool HardwareAccelerated { get; set; }
5060

5161
public bool HasCode { get; set; }
5262

63+
public bool HasFragileUserData { get; set; }
64+
5365
public string? Icon { get; set; }
5466

5567
public bool KillAfterRestore { get; set; }
@@ -72,6 +84,8 @@ public ApplicationAttribute ()
7284

7385
public string? Process { get; set; }
7486

87+
public bool RequestLegacyExternalStorage { get; set; }
88+
7589
public string? RequiredAccountType { get; set; }
7690

7791
public bool ResizeableActivity { get; set; }
@@ -86,6 +100,8 @@ public ApplicationAttribute ()
86100

87101
public string? TaskAffinity { get; set; }
88102

103+
public bool TestOnly { get; set; }
104+
89105
public string? Theme { get; set; }
90106

91107
public Android.Content.PM.UiOptions UiOptions { get; set; }
@@ -111,12 +127,30 @@ static ApplicationAttribute ()
111127
getter: self => self.AllowClearUserData,
112128
setter: (self, value) => self.AllowClearUserData = (bool) value
113129
);
130+
mapping.Add (
131+
member: "AllowCrossUidActivitySwitchFromBelow",
132+
attributeName: "allowCrossUidActivitySwitchFromBelow",
133+
getter: self => self.AllowCrossUidActivitySwitchFromBelow,
134+
setter: (self, value) => self.AllowCrossUidActivitySwitchFromBelow = (bool) value
135+
);
136+
mapping.Add (
137+
member: "AllowNativeHeapPointerTagging",
138+
attributeName: "allowNativeHeapPointerTagging",
139+
getter: self => self.AllowNativeHeapPointerTagging,
140+
setter: (self, value) => self.AllowNativeHeapPointerTagging = (bool) value
141+
);
114142
mapping.Add (
115143
member: "AllowTaskReparenting",
116144
attributeName: "allowTaskReparenting",
117145
getter: self => self.AllowTaskReparenting,
118146
setter: (self, value) => self.AllowTaskReparenting = (bool) value
119147
);
148+
mapping.Add (
149+
member: "AppCategory",
150+
attributeName: "appCategory",
151+
getter: self => self.AppCategory,
152+
setter: (self, value) => self.AppCategory = (Android.Content.PM.ApplicationCategories) value
153+
);
120154
mapping.Add (
121155
member: "BackupInForeground",
122156
attributeName: "backupInForeground",
@@ -129,6 +163,12 @@ static ApplicationAttribute ()
129163
getter: self => self.Banner,
130164
setter: (self, value) => self.Banner = (string?) value
131165
);
166+
mapping.Add (
167+
member: "DataExtractionRules",
168+
attributeName: "dataExtractionRules",
169+
getter: self => self.DataExtractionRules,
170+
setter: (self, value) => self.DataExtractionRules = (string?) value
171+
);
132172
mapping.Add (
133173
member: "Debuggable",
134174
attributeName: "debuggable",
@@ -171,6 +211,12 @@ static ApplicationAttribute ()
171211
getter: self => self.FullBackupOnly,
172212
setter: (self, value) => self.FullBackupOnly = (bool) value
173213
);
214+
mapping.Add (
215+
member: "GwpAsanMode",
216+
attributeName: "gwpAsanMode",
217+
getter: self => self.GwpAsanMode,
218+
setter: (self, value) => self.GwpAsanMode = (Android.Content.PM.GwpAsan) value
219+
);
174220
mapping.Add (
175221
member: "HardwareAccelerated",
176222
attributeName: "hardwareAccelerated",
@@ -183,6 +229,12 @@ static ApplicationAttribute ()
183229
getter: self => self.HasCode,
184230
setter: (self, value) => self.HasCode = (bool) value
185231
);
232+
mapping.Add (
233+
member: "HasFragileUserData",
234+
attributeName: "hasFragileUserData",
235+
getter: self => self.HasFragileUserData,
236+
setter: (self, value) => self.HasFragileUserData = (bool) value
237+
);
186238
mapping.Add (
187239
member: "Icon",
188240
attributeName: "icon",
@@ -237,6 +289,12 @@ static ApplicationAttribute ()
237289
getter: self => self.Process,
238290
setter: (self, value) => self.Process = (string?) value
239291
);
292+
mapping.Add (
293+
member: "RequestLegacyExternalStorage",
294+
attributeName: "requestLegacyExternalStorage",
295+
getter: self => self.RequestLegacyExternalStorage,
296+
setter: (self, value) => self.RequestLegacyExternalStorage = (bool) value
297+
);
240298
mapping.Add (
241299
member: "RequiredAccountType",
242300
attributeName: "requiredAccountType",
@@ -279,6 +337,12 @@ static ApplicationAttribute ()
279337
getter: self => self.TaskAffinity,
280338
setter: (self, value) => self.TaskAffinity = (string?) value
281339
);
340+
mapping.Add (
341+
member: "TestOnly",
342+
attributeName: "testOnly",
343+
getter: self => self.TestOnly,
344+
setter: (self, value) => self.TestOnly = (bool) value
345+
);
282346
mapping.Add (
283347
member: "Theme",
284348
attributeName: "theme",

0 commit comments

Comments
 (0)