Skip to content

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 18, 2025

Backport of #119826 to release/10.0

/cc @akoeplinger @jonathanpeppers

Allows Environment.OSVersion and System.IsAndroidVersionAtLeast() to support the new minor Android releases concept.

Customer Impact

  • Customer reported
  • Found internally

Context: https://developer.android.com/about/versions/16/qpr2/
Context: dotnet/android@35d471e
Context: https://developer.android.com/reference/android/os/Build.VERSION#SDK_INT_FULL

Android 16 Quarterly Platform Release 2 (QPR2) Beta 2 has been released.

Android 16 QPR2 adds a new concept, "minor" SDK versions.

Reviewing Android's implementation of Build.VERSION.SDK_INT_FULL we can check the ro.build.version.sdk_full system property to get the minor version and falling back to ro.build.version.sdk otherwise.

libSystem.Native.so can return the value from SystemNative_GetUnixRelease() making both Environment.OSVersion and System.IsAndroidVersionAtLeast() support minor Android releases.

Regression

  • Yes
  • No

Testing

Local testing using a test app to confirm that the value returned by Java and .NET agree. A unit test will be added in dotnet/android since testing this without the Java integration in dotnet/runtime is cumbersome.

Risk

Low. This just adds checking for a new system property that will be defined on new OS releases and fallback to the previous property otherwise.

…eleases

Context: https://developer.android.com/about/versions/16/qpr2/
Context: dotnet/android@35d471e
Context: https://developer.android.com/reference/android/os/Build.VERSION#SDK_INT_FULL

Android 16 Quarterly Platform Release 2 (QPR2) Beta 2 has been released.

Android 16 QPR2 adds a new concept, "minor" SDK versions:

    > The new [`SDK_INT_FULL`][0] constant can be used for API checks…
    >
    >     if (SDK_INT_FULL >= VERSION_CODES_FULL.[MAJOR or MINOR RELEASE]) {
    >       // Use APIs introduced in a major or minor release
    >     }
    >
    > You can also use the [`Build.getMinorSdkVersion()`][1] method to
    > get just the minor SDK version:
    >
    >     minorSdkVersion = Build.getMinorSdkVersion(Build.VERSION_CODES_FULL.BAKLAVA);

To mirror this in .NET, we introduced a new `$(TargetFramework)` such as
`net10.0-android36.1` where C# developers could use:

    if (OperatingSystem.IsAndroidVersionAtLeast(36, 1))
    {
        // Use APIs introduced in Android 36.1
    }

Reviewing Android's implementation of `Build.VERSION.SDK_INT_FULL` we
can check the `ro.build.version.sdk_full` system property to get the
minor version and falling back to `ro.build.version.sdk` otherwise.

`libSystem.Native.so` can return the value from
`SystemNative_GetUnixRelease()` making both `Environment.OSVersion`
and `System.IsAndroidVersionAtLeast()` support minor Android releases.

An example of the system properties available on the latest emulator:

    % adb shell getprop | grep ro.build.version.sdk
    [ro.build.version.sdk]: [36]
    [ro.build.version.sdk_full]: [36.1]

The release notes mention QPR2 Beta 2 is API stable, so we should be
safe to rely on this behavior going forward:

> QPR2 Beta 2 is now available and has released Platform Stability.
> That means that the API surface is locked, and the app-facing behaviors
> are final, so you can incorporate them into your apps and take advantage
> of our latest platform innovations.

To test this behavior, I set `$DOTNET_ANDROID_VERSION_FROM_JAVA` in the
Android test runner, to verify we get the same value from Java and .NET.

[0]: https://developer.android.com/reference/android/os/Build.VERSION#SDK_INT_FULL
[1]: https://developer.android.com/reference/android/os/Build#getMinorSdkVersion(int)
These were useful to at least test the new code works:

09-17 16:41:13.701  7106  7121 D DOTNET  : Setting env var: DOTNET_ANDROID_VERSION_FROM_JAVA=36.1
...
09-17 16:41:14.927  7106  7130 I DOTNET  :     [PASS] System.Tests.EnvironmentTests.OSVersion_ValidVersion_AndroidMinor
@akoeplinger akoeplinger added Servicing-consider Issue for next servicing release review area-System.Runtime os-android labels Sep 18, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

@akoeplinger akoeplinger added this to the 10.0.0 milestone Sep 18, 2025
@steveisok steveisok added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Sep 18, 2025
@steveisok steveisok merged commit 68641b5 into release/10.0 Sep 18, 2025
120 of 129 checks passed
@steveisok steveisok deleted the backport/pr-119826-to-release/10.0 branch September 18, 2025 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants