Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mono.Android] Add properties for all documented AndroidManifest.xml attributes to [Activity], [Application], etc. #9096

Merged
merged 1 commit into from
Aug 5, 2024
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
249 changes: 139 additions & 110 deletions build-tools/manifest-attribute-codegen/metadata.xml

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions src/Mono.Android/Android.App/RequiredContentUriPermission.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace Android.App;

// Used by AndroidManifest.xml for the attribute 'activity.requireContentUriPermissionFromCaller'.
public enum RequiredContentUriPermission
{
/// <summary>
/// Default, no specific permissions are required.
/// </summary>
None = 0,

/// <summary>
/// Enforces the invoker to have read access to the passed content URIs.
/// </summary>
Read = 1,

/// <summary>
/// Enforces the invoker to have write access to the passed content URIs.
/// </summary>
Write = 2,

/// <summary>
/// Enforces the invoker to have either read or write access to the passed content URIs.
/// </summary>
ReadOrWrite = 3,

/// <summary>
/// Enforces the invoker to have write access to the passed content URIs.
/// </summary>
ReadAndWrite = 4,
}
1 change: 1 addition & 0 deletions src/Mono.Android/Mono.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<Compile Include="Android.App\IntentFilterAttribute.Partial.cs" />
<Compile Include="Android.App\MetaDataAttribute.Partial.cs" />
<Compile Include="Android.App\PropertyAttribute.Partial.cs" />
<Compile Include="Android.App\RequiredContentUriPermission.cs" />
<Compile Include="Android.App\UsesFeatureAttribute.Partial.cs" />
<Compile Include="Android.App\UsesLibraryAttribute.Partial.cs" />
<Compile Include="Android.App\UsesPermissionAttribute.Partial.cs" />
Expand Down
30 changes: 30 additions & 0 deletions src/Mono.Android/PublicAPI/API-35/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,34 @@ Android.AdServices.Topics.EncryptedTopic.KeyIdentifier.get -> string!
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
Android.AdServices.Topics.GetTopicsResponse.EncryptedTopics.get -> System.Collections.Generic.IList<Android.AdServices.Topics.EncryptedTopic!>!
Android.App.Activity.RequestPermissions(string![]! permissions, int requestCode, int deviceId) -> void
Android.App.ActivityAttribute.CanDisplayOnRemoteDevices.get -> bool
Android.App.ActivityAttribute.CanDisplayOnRemoteDevices.set -> void
Android.App.ActivityAttribute.EnableOnBackInvokedCallback.get -> bool
Android.App.ActivityAttribute.EnableOnBackInvokedCallback.set -> void
Android.App.ActivityAttribute.RequireContentUriPermissionFromCaller.get -> Android.App.RequiredContentUriPermission
Android.App.ActivityAttribute.RequireContentUriPermissionFromCaller.set -> void
Android.App.Admin.ContentProtectionPolicy
Android.App.Admin.ContentProtectionPolicy.Disabled = 1 -> Android.App.Admin.ContentProtectionPolicy
Android.App.Admin.ContentProtectionPolicy.Enabled = 2 -> Android.App.Admin.ContentProtectionPolicy
Android.App.Admin.ContentProtectionPolicy.NotControlledByPolicy = 0 -> Android.App.Admin.ContentProtectionPolicy
Android.App.Admin.HeadlessDeviceOwnerMode.SingleUser = 2 -> Android.App.Admin.HeadlessDeviceOwnerMode
Android.App.Admin.SecurityLogTags.BackupServiceToggled = 210044 -> Android.App.Admin.SecurityLogTags
Android.App.ApplicationAttribute.AllowCrossUidActivitySwitchFromBelow.get -> bool
Android.App.ApplicationAttribute.AllowCrossUidActivitySwitchFromBelow.set -> void
Android.App.ApplicationAttribute.AllowNativeHeapPointerTagging.get -> bool
Android.App.ApplicationAttribute.AllowNativeHeapPointerTagging.set -> void
Android.App.ApplicationAttribute.AppCategory.get -> Android.Content.PM.ApplicationCategories
Android.App.ApplicationAttribute.AppCategory.set -> void
Android.App.ApplicationAttribute.DataExtractionRules.get -> string?
Android.App.ApplicationAttribute.DataExtractionRules.set -> void
Android.App.ApplicationAttribute.GwpAsanMode.get -> Android.Content.PM.GwpAsan
Android.App.ApplicationAttribute.GwpAsanMode.set -> void
Android.App.ApplicationAttribute.HasFragileUserData.get -> bool
Android.App.ApplicationAttribute.HasFragileUserData.set -> void
Android.App.ApplicationAttribute.RequestLegacyExternalStorage.get -> bool
Android.App.ApplicationAttribute.RequestLegacyExternalStorage.set -> void
Android.App.ApplicationAttribute.TestOnly.get -> bool
Android.App.ApplicationAttribute.TestOnly.set -> void
Android.App.ApplicationStartInfo
Android.App.ApplicationStartInfo.DefiningUid.get -> int
Android.App.ApplicationStartInfo.DescribeContents() -> int
Expand Down Expand Up @@ -735,6 +757,12 @@ Android.App.PropertyAttribute.Resource.get -> string?
Android.App.PropertyAttribute.Resource.set -> void
Android.App.PropertyAttribute.Value.get -> string?
Android.App.PropertyAttribute.Value.set -> void
Android.App.RequiredContentUriPermission
Android.App.RequiredContentUriPermission.None = 0 -> Android.App.RequiredContentUriPermission
Android.App.RequiredContentUriPermission.Read = 1 -> Android.App.RequiredContentUriPermission
Android.App.RequiredContentUriPermission.ReadAndWrite = 4 -> Android.App.RequiredContentUriPermission
Android.App.RequiredContentUriPermission.ReadOrWrite = 3 -> Android.App.RequiredContentUriPermission
Android.App.RequiredContentUriPermission.Write = 2 -> Android.App.RequiredContentUriPermission
Android.App.SdkSandbox.AppOwnedSdkSandboxInterface
Android.App.SdkSandbox.AppOwnedSdkSandboxInterface.AppOwnedSdkSandboxInterface(string! name, long version, Android.OS.IBinder! binder) -> void
Android.App.SdkSandbox.AppOwnedSdkSandboxInterface.DescribeContents() -> int
Expand All @@ -746,6 +774,8 @@ Android.App.SdkSandbox.AppOwnedSdkSandboxInterface.WriteToParcel(Android.OS.Parc
Android.App.SdkSandbox.SdkSandboxManager.AppOwnedSdkSandboxInterfaces.get -> System.Collections.Generic.IList<Android.App.SdkSandbox.AppOwnedSdkSandboxInterface!>!
Android.App.SdkSandbox.SdkSandboxManager.RegisterAppOwnedSdkSandboxInterface(Android.App.SdkSandbox.AppOwnedSdkSandboxInterface! appOwnedSdkSandboxInterface) -> void
Android.App.SdkSandbox.SdkSandboxManager.UnregisterAppOwnedSdkSandboxInterface(string! name) -> void
Android.App.ServiceAttribute.Description.get -> string?
Android.App.ServiceAttribute.Description.set -> void
Android.App.Usage.StorageStats.GetAppBytesByDataType(Android.App.Usage.StorageStatsAppDataType dataType) -> long
Android.App.Usage.StorageStatsAppDataType
Android.App.Usage.StorageStatsAppDataType.FileTypeApk = 3 -> Android.App.Usage.StorageStatsAppDataType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,14 @@ string ToAttributeValue (string name, T value, ICustomAttributeProvider provider
{ typeof (float), (value, p, r, v, c) => value.ToString () },
{ typeof (string), (value, p, r, v, c) => value.ToString () },
{ typeof (ActivityPersistableMode), (value, p, r, v, c) => ToString ((ActivityPersistableMode) value) },
{ typeof (ApplicationCategories), (value, p, r, v, c) => ToString ((ApplicationCategories) value) },
{ typeof (ConfigChanges), (value, p, r, v, c) => ToString ((ConfigChanges) value) },
{ typeof (DocumentLaunchMode), (value, p, r, v, c) => ToString ((DocumentLaunchMode) value) },
{ typeof (ForegroundService), (value, p, r, v, c) => ToString ((ForegroundService) value) },
{ typeof (GwpAsan), (value, p, r, v, c) => ToString ((GwpAsan) value) },
{ typeof (LaunchMode), (value, p, r, v, c) => ToString ((LaunchMode) value) },
{ typeof (Protection), (value, p, r, v, c) => ToString ((Protection) value) },
{ typeof (RequiredContentUriPermission), (value, p, r, v, c) => ToString ((RequiredContentUriPermission) value) },
{ typeof (ScreenOrientation), (value, p, r, v, c) => ToString ((ScreenOrientation) value, v) },
{ typeof (SoftInput), (value, p, r, v, c) => ToString ((SoftInput) value) },
{ typeof (UiOptions), (value, p, r, v, c) => ToString ((UiOptions) value) },
Expand Down Expand Up @@ -408,6 +411,44 @@ static string ToString (ForegroundService value)
return string.Join ("|", values.ToArray ());
}

static string ToString (ApplicationCategories value)
{
return value switch {
ApplicationCategories.Accessibility => "accessibility",
ApplicationCategories.Audio => "audio",
ApplicationCategories.Game => "game",
ApplicationCategories.Image => "image",
ApplicationCategories.Maps => "maps",
ApplicationCategories.News => "news",
ApplicationCategories.Productivity => "productivity",
ApplicationCategories.Social => "social",
ApplicationCategories.Video => "video",
_ => throw new ArgumentException ($"Unsupported ApplicationCategories value '{value}'."),
};
}

static string ToString (RequiredContentUriPermission value)
{
return value switch {
RequiredContentUriPermission.None => "none",
RequiredContentUriPermission.Read => "read",
RequiredContentUriPermission.Write => "write",
RequiredContentUriPermission.ReadOrWrite => "readOrWrite",
RequiredContentUriPermission.ReadAndWrite => "readAndWrite",
_ => throw new ArgumentException ($"Unsupported RequiredContentUriPermission value '{value}'."),
};
}

static string ToString (GwpAsan value)
{
return value switch {
GwpAsan.Always => "always",
GwpAsan.Default => "never",
GwpAsan.Never => "never",
_ => throw new ArgumentException ($"Unsupported GwpAsan value '{value}'."),
};
}

IEnumerator<string> IEnumerable<string>.GetEnumerator ()
{
return Mappings.Keys.GetEnumerator ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@
<Compile Include="..\..\build-tools\xa-prep-tasks\Xamarin.Android.BuildTools.PrepTasks\Sleep.cs">
<Link>Xamarin.Android.BuildTools.PrepTasks\Sleep.cs</Link>
</Compile>
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.ApplicationCategories.cs" />
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.GwpAsan.cs" />
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.LaunchMode.cs" />
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.ScreenOrientation.cs" />
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.ConfigChanges.cs" />
Expand All @@ -172,6 +174,7 @@
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.ActivityPersistableMode.cs" />
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.DocumentLaunchMode.cs" />
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Views.WindowRotationAnimation.cs" />
<_MonoAndroidEnum Include="..\Mono.Android\Android.App\RequiredContentUriPermission.cs" />
<Compile Include="@(_MonoAndroidEnum)">
<Link>Mono.Android\%(Filename)%(Extension)</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public ActivityAttribute ()

public string? Banner { get; set; }

public bool CanDisplayOnRemoteDevices { get; set; }

public bool ClearTaskOnLaunch { get; set; }

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

public bool Enabled { get; set; }

public bool EnableOnBackInvokedCallback { get; set; }

public string? EnableVrMode { get; set; }

public bool ExcludeFromRecents { get; set; }
Expand Down Expand Up @@ -90,6 +94,8 @@ public ActivityAttribute ()

public bool RelinquishTaskIdentity { get; set; }

public Android.App.RequiredContentUriPermission RequireContentUriPermissionFromCaller { get; set; }

public bool ResizeableActivity { get; set; }

public bool ResumeWhilePausing { get; set; }
Expand Down Expand Up @@ -160,6 +166,12 @@ static ActivityAttribute ()
getter: self => self.Banner,
setter: (self, value) => self.Banner = (string?) value
);
mapping.Add (
member: "CanDisplayOnRemoteDevices",
attributeName: "canDisplayOnRemoteDevices",
getter: self => self.CanDisplayOnRemoteDevices,
setter: (self, value) => self.CanDisplayOnRemoteDevices = (bool) value
);
mapping.Add (
member: "ClearTaskOnLaunch",
attributeName: "clearTaskOnLaunch",
Expand Down Expand Up @@ -202,6 +214,12 @@ static ActivityAttribute ()
getter: self => self.Enabled,
setter: (self, value) => self.Enabled = (bool) value
);
mapping.Add (
member: "EnableOnBackInvokedCallback",
attributeName: "enableOnBackInvokedCallback",
getter: self => self.EnableOnBackInvokedCallback,
setter: (self, value) => self.EnableOnBackInvokedCallback = (bool) value
);
mapping.Add (
member: "EnableVrMode",
attributeName: "enableVrMode",
Expand Down Expand Up @@ -334,6 +352,12 @@ static ActivityAttribute ()
getter: self => self.RelinquishTaskIdentity,
setter: (self, value) => self.RelinquishTaskIdentity = (bool) value
);
mapping.Add (
member: "RequireContentUriPermissionFromCaller",
attributeName: "requireContentUriPermissionFromCaller",
getter: self => self.RequireContentUriPermissionFromCaller,
setter: (self, value) => self.RequireContentUriPermissionFromCaller = (Android.App.RequiredContentUriPermission) value
);
mapping.Add (
member: "ResizeableActivity",
attributeName: "resizeableActivity",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@ public ApplicationAttribute ()

public bool AllowClearUserData { get; set; }

public bool AllowCrossUidActivitySwitchFromBelow { get; set; }

public bool AllowNativeHeapPointerTagging { get; set; }

public bool AllowTaskReparenting { get; set; }

public Android.Content.PM.ApplicationCategories AppCategory { get; set; }

public Type? BackupAgent { get; set; }

public bool BackupInForeground { get; set; }

public string? Banner { get; set; }

public string? DataExtractionRules { get; set; }

public bool Debuggable { get; set; }

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

public bool FullBackupOnly { get; set; }

public Android.Content.PM.GwpAsan GwpAsanMode { get; set; }

public bool HardwareAccelerated { get; set; }

public bool HasCode { get; set; }

public bool HasFragileUserData { get; set; }

public string? Icon { get; set; }

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

public string? Process { get; set; }

public bool RequestLegacyExternalStorage { get; set; }

public string? RequiredAccountType { get; set; }

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

public string? TaskAffinity { get; set; }

public bool TestOnly { get; set; }

public string? Theme { get; set; }

public Android.Content.PM.UiOptions UiOptions { get; set; }
Expand All @@ -111,12 +127,30 @@ static ApplicationAttribute ()
getter: self => self.AllowClearUserData,
setter: (self, value) => self.AllowClearUserData = (bool) value
);
mapping.Add (
member: "AllowCrossUidActivitySwitchFromBelow",
attributeName: "allowCrossUidActivitySwitchFromBelow",
getter: self => self.AllowCrossUidActivitySwitchFromBelow,
setter: (self, value) => self.AllowCrossUidActivitySwitchFromBelow = (bool) value
);
mapping.Add (
member: "AllowNativeHeapPointerTagging",
attributeName: "allowNativeHeapPointerTagging",
getter: self => self.AllowNativeHeapPointerTagging,
setter: (self, value) => self.AllowNativeHeapPointerTagging = (bool) value
);
mapping.Add (
member: "AllowTaskReparenting",
attributeName: "allowTaskReparenting",
getter: self => self.AllowTaskReparenting,
setter: (self, value) => self.AllowTaskReparenting = (bool) value
);
mapping.Add (
member: "AppCategory",
attributeName: "appCategory",
getter: self => self.AppCategory,
setter: (self, value) => self.AppCategory = (Android.Content.PM.ApplicationCategories) value
);
mapping.Add (
member: "BackupInForeground",
attributeName: "backupInForeground",
Expand All @@ -129,6 +163,12 @@ static ApplicationAttribute ()
getter: self => self.Banner,
setter: (self, value) => self.Banner = (string?) value
);
mapping.Add (
member: "DataExtractionRules",
attributeName: "dataExtractionRules",
getter: self => self.DataExtractionRules,
setter: (self, value) => self.DataExtractionRules = (string?) value
);
mapping.Add (
member: "Debuggable",
attributeName: "debuggable",
Expand Down Expand Up @@ -171,6 +211,12 @@ static ApplicationAttribute ()
getter: self => self.FullBackupOnly,
setter: (self, value) => self.FullBackupOnly = (bool) value
);
mapping.Add (
member: "GwpAsanMode",
attributeName: "gwpAsanMode",
getter: self => self.GwpAsanMode,
setter: (self, value) => self.GwpAsanMode = (Android.Content.PM.GwpAsan) value
);
mapping.Add (
member: "HardwareAccelerated",
attributeName: "hardwareAccelerated",
Expand All @@ -183,6 +229,12 @@ static ApplicationAttribute ()
getter: self => self.HasCode,
setter: (self, value) => self.HasCode = (bool) value
);
mapping.Add (
member: "HasFragileUserData",
attributeName: "hasFragileUserData",
getter: self => self.HasFragileUserData,
setter: (self, value) => self.HasFragileUserData = (bool) value
);
mapping.Add (
member: "Icon",
attributeName: "icon",
Expand Down Expand Up @@ -237,6 +289,12 @@ static ApplicationAttribute ()
getter: self => self.Process,
setter: (self, value) => self.Process = (string?) value
);
mapping.Add (
member: "RequestLegacyExternalStorage",
attributeName: "requestLegacyExternalStorage",
getter: self => self.RequestLegacyExternalStorage,
setter: (self, value) => self.RequestLegacyExternalStorage = (bool) value
);
mapping.Add (
member: "RequiredAccountType",
attributeName: "requiredAccountType",
Expand Down Expand Up @@ -279,6 +337,12 @@ static ApplicationAttribute ()
getter: self => self.TaskAffinity,
setter: (self, value) => self.TaskAffinity = (string?) value
);
mapping.Add (
member: "TestOnly",
attributeName: "testOnly",
getter: self => self.TestOnly,
setter: (self, value) => self.TestOnly = (bool) value
);
mapping.Add (
member: "Theme",
attributeName: "theme",
Expand Down
Loading
Loading