-
Notifications
You must be signed in to change notification settings - Fork 528
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
Unable to specify PROPERTY_SPECIAL_USE_FGS_SUBTYPE via Service Attribute #8729
Comments
Related: https://developer.android.com/guide/topics/manifest/property-element We should probably introduce a [AttributeUsage (AttributeTargets.Class, AllowMultiple=true)]
public partial class PropertyAttribute : Attribute {
public PropertyAttribute (string name);
public string Resource {get; set;}
public string Value {get; set;}
} which would allow: [Service]
[Property ("android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE", Value="Explanation")]
partial class FocusSessionService : Service {
} Open design question: from the
Given this, it might instead be better to have |
…8781) Fixes: #8272 Context: #8235 Context: #8729 Context: e790874 Previously, we did not have an established process for detecting new XML elements and attributes allowed in `AndroidManifest.xml` and surfacing them to users via our manifest attributes like `[ActivityAttribute]`. This leads to users having to use manual workarounds until our attributes can be updated. Additionally, whenever we do add new properties to these attributes, it requires manually updating multiple files by hand that must remain in sync, eg: * [src/Mono.Android/Android.App/IntentFilterAttribute.cs](https://github.com/xamarin/xamarin-android/blob/180dd5205ab270bb74bb853754665db9cb5d65f1/src/Mono.Android/Android.App/IntentFilterAttribute.cs#L9) * [src/Xamarin.Android.Build.Tasks/Mono.Android/IntentFilterAttribute.Partial.cs](https://github.com/xamarin/xamarin-android/blob/180dd5205ab270bb74bb853754665db9cb5d65f1/src/Xamarin.Android.Build.Tasks/Mono.Android/IntentFilterAttribute.Partial.cs#L14) The `build-tools/manifest-attribute-codegen` utility (e790874) has support to parse Android SDK `attrs_manifest.xml` files, which specifies what elements and attributes are valid within `AndroidManifest.xml`. Update `manifest-attribute-codegen` to do what it's name already implied: generate code! It now reads a `metadata.xml` file which controls which custom attributes to emit, where to emit them, and what members those custom attributes should have (among other things). This makes it easier to ensure that code shared by `src/Mono.Android` and `src/Xamarin.Android.Build.Tasks` are consistent, meaking it easier to correctly add support for new attributes and/or attribute members. Generated file semantics and naming conventions: consider the C# type `Android.App.ActivityAttribute`. * `src\Xamarin.Android.NamingCustomAttributes\Android.App\ActivityAttribute.cs` contains the C# `partial` class declaration that can be shared by both `src\Mono.Android` and `src\Xamarin.Android.Build.Tasks`. This file also contains a `#if XABT_MANIFEST_EXTENSIONS` block which is only used by `src\Xamarin.Android.Build.Tasks`. * `src/Xamarin.Android.Build.Tasks/Mono.Android/ActivityAttribute.Partial.cs` contains the C# `partial` class declaration with code specific to `Xamarin.Android.Build.Tasks.dll`. * `src/Xamarin.Android.NamingCustomAttributes/Android.App/ActivityAttribute.Partial.cs` contains the C# `partial` class declaration with code specific to `Mono.Android.dll`. `metadata.xml` contents and the update process is documented in `build-tools/manifest-attribute-codegen/README.md`. Also removed the `ANDROID_*` values from `$(DefineConstants)` for `Xamarin.Android.Build.Tasks.csproj` as we no longer build separate assemblies for old Android API levels. Note this commit does not change any existing manifest attributes or the properties they expose. It merely generates what we expose today. We will determine additional properties to expose in a future commit.
Android application type
.NET Android (net7.0-android, net8.0-android, etc.)
Affected platform version
VS2022, NET8
Description
The goal is to specify a
FOREGROUND_SERVICE_SPECIAL_USE
permission using a Service attribute.This issue is a continuation of this issue: #8409, which was closed after fixing a problem that prevented the foregroundServiceType to be filled in the
AndroidManifest.xml
.The issue that remains is that is isn't possible to declare the
PROPERTY_SPECIAL_USE_FGS_SUBTYPE
for "special use" via an attribute: https://developer.android.com/about/versions/14/changes/fgs-types-required#special-useDid you find any workaround?
I was able to workaround the problem by manually adding the service tag in the AndroidManifex.xml and giving my Service an explicit name
The text was updated successfully, but these errors were encountered: