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

[XA.Build.Tasks] Update possible values for manifest foregroundServiceType. #4753

Merged
merged 1 commit into from
Jun 3, 2020

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Jun 2, 2020

Fixes: #4752
Context: https://developer.android.com/preview/privacy/foreground-service-types

In #3810 we added foregroundServiceType as an attribute for <service>. This attribute supports multiple values like:

android:foregroundServiceType="location|camera|microphone"

However, our code only supports a single value, so you will end up with an error like Unsupported ForegroundServiceType value '9' if you attempt to pass it ForegroundService.TypeDataSync | ForegroundService.TypeLocation.

This PR:

  • Fixes our code to support multiple values
  • Adds the [Flags] attribute to Android.Content.PM.ForegroundService
  • Adds support for new camera and microphone values added in API-R

Note we cannot use the enum values yet for API-R because Xamarin.Android.Build.Tasks is built against the stable version of Mono.Android.dll (29) which does not have these values.

I also audited the rest of the enumerations used in ManifestDocumenetElements to ensure no other values were added in API-R.

@jpobst jpobst marked this pull request as ready for review June 2, 2020 21:52
@jonpryor jonpryor merged commit d97ae6a into master Jun 3, 2020
@jonpryor jonpryor deleted the foreground-manifest branch June 3, 2020 00:00
jonpryor pushed a commit that referenced this pull request Jun 3, 2020
…4753)

Fixes: #4752
Context: https://developer.android.com/preview/privacy/foreground-service-types

In 6e55c22 we added a `ServiceAttribute.ForegroundServiceType`
property to support emitting the
`//service/@android:foregroundServiceType` XML attribute within
`AndroidManifest.xml`.  `//service/@android:foregroundServiceType`
supports multiple `|`-separated values, e.g.:

	<service …
	    android:foregroundServiceType="location|camera|microphone"
	/>

Unfortunately, the code in 6e55c22 only supported a single value, so
if you attempted to do e.g.:

	[Service (…,
	    ForegroundServiceType = ForegroundService.TypeDataSync | ForegroundService.TypeLocation)]
	partial class MyService : Service {
	}

you would get an error such as:

	…\Xamarin.Android.Common.targets(2004,3): error XAGJS7004: System.ArgumentException: Unsupported ForegroundServiceType value '9'.
	…\Xamarin.Android.Common.targets(2004,3): error XAGJS7004: Parameter name: value
	…\Xamarin.Android.Common.targets(2004,3): error XAGJS7004:    at Xamarin.Android.Manifest.ManifestDocumentElement`1.ToString(ForegroundService value)
	…

Make the `ForegroundService` enum a `[Flags]` enum, and update
`ManifestDocumentElement<T>.ToString(ForegroundService)` so that
`ForegroundService` is handled appropriately, allowing it to emit
`|`-separated values.

Additionally, add "preview" support for the `camera` and `microphone`
values which are added in API-R.

Note that we cannot use the enum values yet for API-R because
`Xamarin.Android.Build.Tasks.dll` is built against the stable version
of `Mono.Android.dll` (API-29), which does not have these values.

I also audited the rest of the enumerations used in
`ManifestDocumenetElements` to ensure no other values were added in
API-R.
jonpryor pushed a commit that referenced this pull request Jun 3, 2020
…4753)

Fixes: #4752
Context: https://developer.android.com/preview/privacy/foreground-service-types

In 6e55c22 we added a `ServiceAttribute.ForegroundServiceType`
property to support emitting the
`//service/@android:foregroundServiceType` XML attribute within
`AndroidManifest.xml`.  `//service/@android:foregroundServiceType`
supports multiple `|`-separated values, e.g.:

	<service …
	    android:foregroundServiceType="location|camera|microphone"
	/>

Unfortunately, the code in 6e55c22 only supported a single value, so
if you attempted to do e.g.:

	[Service (…,
	    ForegroundServiceType = ForegroundService.TypeDataSync | ForegroundService.TypeLocation)]
	partial class MyService : Service {
	}

you would get an error such as:

	…\Xamarin.Android.Common.targets(2004,3): error XAGJS7004: System.ArgumentException: Unsupported ForegroundServiceType value '9'.
	…\Xamarin.Android.Common.targets(2004,3): error XAGJS7004: Parameter name: value
	…\Xamarin.Android.Common.targets(2004,3): error XAGJS7004:    at Xamarin.Android.Manifest.ManifestDocumentElement`1.ToString(ForegroundService value)
	…

Make the `ForegroundService` enum a `[Flags]` enum, and update
`ManifestDocumentElement<T>.ToString(ForegroundService)` so that
`ForegroundService` is handled appropriately, allowing it to emit
`|`-separated values.

Additionally, add "preview" support for the `camera` and `microphone`
values which are added in API-R.

Note that we cannot use the enum values yet for API-R because
`Xamarin.Android.Build.Tasks.dll` is built against the stable version
of `Mono.Android.dll` (API-29), which does not have these values.

I also audited the rest of the enumerations used in
`ManifestDocumenetElements` to ensure no other values were added in
API-R.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Flags] attribute missing in Android.Content.PM.ForegroundService enum
3 participants