Skip to content

Commit

Permalink
[Mono.Android] Bind and enumify API-33 (#7105)
Browse files Browse the repository at this point in the history
Context: https://developer.android.com/about/versions/13
Context: https://android-developers.googleblog.com/2022/06/android-13-beta-3-platform-stability.html

Android 13 Beta 3 has been released.

  * [API diff vs. API-32][0]
  * [API diff vs. API-Tiramisu Beta 2][1]

The Android 13 Developer Preview Program Overview
[Timeline and updates][2] section suggests the following timeline:

  * May: Beta 2
  * June: Beta 3: First Platform Stability milestone.
    Final APIs and behaviors.
  * July: Beta 4: Near-final build for final testing.
  * ???: Final

In particular, Beta 3 has "Final APIs".  We now have API-33!

Enumify API-33, and declare it stable.

API-33 will be available as:

  * Classic Xamarin.Android: `$(TargetFrameworkVersion)`=v13.0
  * .NET 6: `$(TargetFramework)`=net6.0-android33.0
  * .NET 7: `$(TargetFramework)`=net7.0-android33.0

The default API-level for `net6.0-android` remains API-31.
The default API-level for `net7.0-android` will be API-33.


~~ Enumification Issue ~~

The following methods look like they should be enumified, however the
constants referenced by their [documentation][3] do not exist.
Perhaps this will be fixed later and we should revisit them?  For now,
they are not enumified.

	?,33,android/net/wifi/aware,PublishConfig,getInstantCommunicationBand,return,
	?,33,android/net/wifi/aware,PublishConfig$Builder,setInstantCommunicationModeEnabled,band,
	?,33,android/net/wifi/aware,SubscribeConfig,getInstantCommunicationBand,return,
	?,33,android/net/wifi/aware,SubscribeConfig$Builder,setInstantCommunicationModeEnabled,band,
	?,33,android/net/wifi,MloLink,getBand,return,


~~ API Compat Changes ~~

We now ignore `[Android.Runtime.StringDefAttribute]` and
`[Android.Runtime.IntDefAttribute]` in `<CheckApiCompatibility/>`.
These attributes frequently churn on each preview and release, causing
lots of noise in our `acceptable-breakages*` files.  As we do not
consume these attributes, we don't really need to track changes.

Relevant existing entries from `acceptable-breakages*` files were removed.


~~ Update `CodeDiffGen` ~~

The logic for running `Microsoft.DotNet.GenAPI` was failing with:

	/Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/Mono.Android.targets(270,5):
	error MSB4018: System.ComponentModel.Win32Exception (8): An error occurred trying to start process
	'/Users/builder/.nuget/packages/microsoft.dotnet.genapi/7.0.0-beta.22103.1/tools/net472/Microsoft.DotNet.GenAPI.exe'
	with working directory '/Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android'.
	Exec format error

Fix this by using the `netcoreapp3.1/Microsoft.DotNet.GenAPI.dll`
version when running under `dotnet`.

Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>

[0]: https://developer.android.com/sdk/api_diff/33/changes
[1]: https://developer.android.com/sdk/api_diff/33-incr/changes
[2]: https://web.archive.org/web/20220627195145/https://developer.android.com/about/versions/13/overview#platform_stability
[3]: https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig#getinstantcommunicationband
  • Loading branch information
jpobst authored Jun 28, 2022
1 parent aa4315b commit df6c716
Show file tree
Hide file tree
Showing 30 changed files with 1,931 additions and 271 deletions.
6 changes: 3 additions & 3 deletions Configuration.Override.props.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
kept consistent with each other, lest Bad Things Happen™
-->
<!-- The default Android API level to bind in src/Mono.Android -->
<AndroidApiLevel>32</AndroidApiLevel>
<AndroidApiLevel>33</AndroidApiLevel>
<!-- The Xamarin.Android $(TargetFrameworkVersion) value that corresponds to $(AndroidApiLevel) -->
<AndroidFrameworkVersion>v12.1</AndroidFrameworkVersion>
<AndroidFrameworkVersion>v13.0</AndroidFrameworkVersion>
<!-- The default Android API "id" that corresponds to $(AndroidApiLevel) -->
<AndroidPlatformId>32</AndroidPlatformId>
<AndroidPlatformId>33</AndroidPlatformId>

<!--
Colon-separated list of ABIs to build the mono JIT for.
Expand Down
10 changes: 5 additions & 5 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
<AndroidMinimumDotNetApiLevel Condition="'$(AndroidMinimumDotNetApiLevel)' == ''">21</AndroidMinimumDotNetApiLevel>
<AndroidFirstPlatformId Condition="'$(AndroidFirstPlatformId)' == ''">$(AndroidFirstApiLevel)</AndroidFirstPlatformId>
<!-- *Latest* *stable* API level binding that we support; used when building src/Xamarin.Android.Build.Tasks -->
<AndroidLatestStableApiLevel Condition="'$(AndroidLatestStableApiLevel)' == ''">32</AndroidLatestStableApiLevel>
<AndroidLatestStableApiLevel Condition="'$(AndroidLatestStableApiLevel)' == ''">33</AndroidLatestStableApiLevel>
<AndroidLatestStablePlatformId Condition="'$(AndroidLatestStablePlatformId)' == ''">$(AndroidLatestStableApiLevel)</AndroidLatestStablePlatformId>
<AndroidLatestStableFrameworkVersion Condition="'$(AndroidLatestStableFrameworkVersion)'==''">v12.1</AndroidLatestStableFrameworkVersion>
<AndroidLatestStableFrameworkVersion Condition="'$(AndroidLatestStableFrameworkVersion)'==''">v13.0</AndroidLatestStableFrameworkVersion>
<!-- *Latest* *unstable* API level binding that we support; this can be the same as *stable* -->
<AndroidLatestUnstableApiLevel Condition="'$(AndroidLatestUnstableApiLevel)' == ''">33</AndroidLatestUnstableApiLevel>
<AndroidLatestUnstableApiLevel Condition="'$(AndroidLatestUnstableApiLevel)' == ''">$(AndroidLatestStableApiLevel)</AndroidLatestUnstableApiLevel>
<AndroidLatestUnstablePlatformId Condition="'$(AndroidLatestUnstablePlatformId)' == ''">Tiramisu</AndroidLatestUnstablePlatformId>
<AndroidLatestUnstableFrameworkVersion Condition="'$(AndroidLatestUnstableFrameworkVersion)'==''">v12.1.99</AndroidLatestUnstableFrameworkVersion>
<AndroidLatestUnstableFrameworkVersion Condition="'$(AndroidLatestUnstableFrameworkVersion)'==''">v13.0</AndroidLatestUnstableFrameworkVersion>
<!-- The default API level used for $(TargetPlatformVersion) -->
<AndroidDefaultTargetDotnetApiLevel Condition=" '$(AndroidDefaultTargetDotnetApiLevel)' == '' ">32</AndroidDefaultTargetDotnetApiLevel>
<AndroidDefaultTargetDotnetApiLevel Condition=" '$(AndroidDefaultTargetDotnetApiLevel)' == '' ">33</AndroidDefaultTargetDotnetApiLevel>
<!-- The API level and TargetFrameworkVersion for the default Mono.Android.dll build -->
<AndroidApiLevel Condition=" '$(AndroidApiLevel)' == '' ">$(AndroidLatestStableApiLevel)</AndroidApiLevel>
<AndroidPlatformId Condition=" '$(AndroidPlatformId)' == '' ">$(AndroidLatestStablePlatformId)</AndroidPlatformId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public sealed class CheckApiCompatibility : Task
{ "v11.0", "v10.0" },
{ "v12.0", "v11.0" },
{ "v12.1", "v12.0" },
{ "v12.1.99", "v12.1" },
{ "v13.0", "v12.1" },
};

static readonly string assemblyToValidate = "Mono.Android.dll";
Expand Down Expand Up @@ -151,7 +151,7 @@ void ValidateApiCompat (string contractPath, bool validateAgainstReference)
{
var contractAssembly = new FileInfo (Path.Combine (contractPath, assemblyToValidate));
if (!contractAssembly.Exists) {
LogError ($"Contract assembly {assemblyToValidate} does not exists in the contract path.");
LogError ($"Contract assembly {assemblyToValidate} does not exists in the contract path. {contractPath} - {validateAgainstReference}");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,18 @@ static ObjectDescription GenerateObjectDescription (string codeGenPath, string a
var objectStack = new Stack<ObjectDescription> ();
objectStack.Push (currentObject);

var codeGen = Path.Combine (codeGenPath, "Microsoft.DotNet.GenAPI.exe");
using (var genApiProcess = new Process ()) {

genApiProcess.StartInfo.FileName = codeGen;
genApiProcess.StartInfo.Arguments = $"\"{assembly}\"";
if (Environment.Version.Major >= 5) {
var apiCompat = new FileInfo (Path.Combine (codeGenPath, "..", "netcoreapp3.1", "Microsoft.DotNet.GenAPI.dll"));
genApiProcess.StartInfo.FileName = "dotnet";
genApiProcess.StartInfo.Arguments = $"\"{apiCompat}\" ";
} else {
var apiCompat = new FileInfo (Path.Combine (codeGenPath, "Microsoft.DotNet.GenAPI.exe"));
genApiProcess.StartInfo.FileName = apiCompat.FullName;
}

genApiProcess.StartInfo.Arguments += $"\"{assembly}\"";

genApiProcess.StartInfo.UseShellExecute = false;
genApiProcess.StartInfo.CreateNoWindow = true;
Expand Down
4 changes: 2 additions & 2 deletions build-tools/api-merge/merge-configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<File Path="api-30.xml.in" Level="30" />
<File Path="api-31.xml.in" Level="31" />
<File Path="api-32.xml.in" Level="32" />
<File Path="api-Tiramisu.xml.in" Level="33" />
<File Path="api-33.xml.in" Level="33" />
</Inputs>
<Outputs>
<File Path="api-19.xml" LastLevel="19" />
Expand All @@ -38,6 +38,6 @@
<File Path="api-30.xml" LastLevel="30" />
<File Path="api-31.xml" LastLevel="31" />
<File Path="api-32.xml" LastLevel="32" />
<File Path="api-Tiramisu.xml" LastLevel="33" />
<File Path="api-33.xml" LastLevel="33" />
</Outputs>
</Configuration>
2 changes: 1 addition & 1 deletion build-tools/api-xml-adjuster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ API_XML_TOOL = $(BUILDBIN)/api-xml-adjuster.exe
RUNTIME = mono --debug
RUN_CLASS_PARSE = $(RUNTIME) $(CLASS_PARSE)
RUN_API_XML_TOOL = $(RUNTIME) $(API_XML_TOOL)
API_LEVELS = 10 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Tiramisu
API_LEVELS = 10 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

XML_OUTPUT_DIR = .

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ steps:

- template: run-xaprepare.yaml
parameters:
arguments: --s=AndroidTestDependencies --android-sdk-platforms="19,21,26,32,Tiramisu"
arguments: --s=AndroidTestDependencies --android-sdk-platforms="19,21,26,32,33"
xaSourcePath: ${{ parameters.xaSourcePath }}

- task: DotNetCoreCLI@2
Expand Down
2 changes: 1 addition & 1 deletion build-tools/installers/create-installers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<Target Name="_FindFrameworkDirs">
<ItemGroup>
<_FrameworkDirs Include="@(AndroidApiInfo->'$(FrameworkSrcDir)%(Identity)\')" />
<_FrameworkDirsThatExist Condition="Exists('%(Identity)')" Include="@(_FrameworkDirs)" Exclude="$(FrameworkSrcDir)v12.1.99\" />
<_FrameworkDirsThatExist Condition="Exists('%(Identity)')" Include="@(_FrameworkDirs)" />
<_EarlierFrameworkDir Include="@(_FrameworkDirsThatExist)" Exclude="$(_LatestStableFrameworkDir)" />
</ItemGroup>
</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BuildAndroidPlatforms
new AndroidPlatform (apiName: "R", apiLevel: 30, platformID: "30", include: "v11.0", framework: "v11.0"),
new AndroidPlatform (apiName: "S", apiLevel: 31, platformID: "31", include: "v12.0", framework: "v12.0"),
new AndroidPlatform (apiName: "Sv2", apiLevel: 32, platformID: "32", include: "v12.1", framework: "v12.1"),
new AndroidPlatform (apiName: "Tiramisu", apiLevel: 33, platformID: "Tiramisu", include: "v12.1.99", framework: "v12.1.99", stable: false),
new AndroidPlatform (apiName: "Tiramisu", apiLevel: 33, platformID: "33", include: "v13.0", framework: "v13.0"),
};

public static readonly Dictionary<string, uint> NdkMinimumAPIMap = new Dictionary<string, uint> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public AndroidToolchain ()
new AndroidPlatformComponent ("platform-30_r01", apiLevel: "30", pkgRevision: "1"),
new AndroidPlatformComponent ("platform-31_r01", apiLevel: "31", pkgRevision: "1"),
new AndroidPlatformComponent ("platform-32_r01", apiLevel: "32", pkgRevision: "1"),
new AndroidPlatformComponent ("platform-Tiramisu_r04", apiLevel: "Tiramisu", pkgRevision: "4"),
new AndroidPlatformComponent ("platform-33_r01", apiLevel: "33", pkgRevision: "1"),

new AndroidToolchainComponent ("sources-31_r01",
destDir: Path.Combine ("platforms", $"android-31", "src"),
Expand Down
6 changes: 6 additions & 0 deletions src/Mono.Android/Android.Content/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ public void StartActivity (Type type)
Intent intent = new Intent (this, type);
StartActivity (intent);
}

#if ANDROID_26
// Added in API-26, converted to enum in API-33, constant needed for backwards compatibility
[Obsolete ("This constant will be removed in the future version. Use Android.Content.ReceiverFlags enum directly instead of this field.")]
public const int ReceiverVisibleToInstantApps = 1;
#endif
}
}
Loading

0 comments on commit df6c716

Please sign in to comment.