Skip to content

Commit eb6da19

Browse files
committed
[Mono.Android] Bind Android 12L Beta 1.
1 parent 72462c5 commit eb6da19

File tree

19 files changed

+238
-37
lines changed

19 files changed

+238
-37
lines changed

Configuration.Override.props.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
kept consistent with each other, lest Bad Things Happen™
77
-->
88
<!-- The default Android API level to bind in src/Mono.Android -->
9-
<AndroidApiLevel>31</AndroidApiLevel>
9+
<AndroidApiLevel>32</AndroidApiLevel>
1010
<!-- The Xamarin.Android $(TargetFrameworkVersion) value that corresponds to $(AndroidApiLevel) -->
11-
<AndroidFrameworkVersion>v12.0</AndroidFrameworkVersion>
11+
<AndroidFrameworkVersion>v12.1</AndroidFrameworkVersion>
1212
<!-- The default Android API "id" that corresponds to $(AndroidApiLevel) -->
13-
<AndroidPlatformId>31</AndroidPlatformId>
13+
<AndroidPlatformId>32</AndroidPlatformId>
1414

1515
<!--
1616
Colon-separated list of ABIs to build the mono JIT for.

Configuration.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
<AndroidMinimumDotNetApiLevel Condition="'$(AndroidMinimumDotNetApiLevel)' == ''">21</AndroidMinimumDotNetApiLevel>
3131
<AndroidFirstPlatformId Condition="'$(AndroidFirstPlatformId)' == ''">$(AndroidFirstApiLevel)</AndroidFirstPlatformId>
3232
<!-- *Latest* *stable* API level binding that we support; used when building src/Xamarin.Android.Build.Tasks -->
33-
<AndroidLatestStableApiLevel Condition="'$(AndroidLatestStableApiLevel)' == ''">31</AndroidLatestStableApiLevel>
33+
<AndroidLatestStableApiLevel Condition="'$(AndroidLatestStableApiLevel)' == ''">32</AndroidLatestStableApiLevel>
3434
<AndroidLatestStablePlatformId Condition="'$(AndroidLatestStablePlatformId)' == ''">$(AndroidLatestStableApiLevel)</AndroidLatestStablePlatformId>
35-
<AndroidLatestStableFrameworkVersion Condition="'$(AndroidLatestStableFrameworkVersion)'==''">v12.0</AndroidLatestStableFrameworkVersion>
35+
<AndroidLatestStableFrameworkVersion Condition="'$(AndroidLatestStableFrameworkVersion)'==''">v12.1</AndroidLatestStableFrameworkVersion>
3636
<!-- *Latest* *unstable* API level binding that we support; this can be the same as *stable* -->
3737
<AndroidLatestUnstableApiLevel Condition="'$(AndroidLatestUnstableApiLevel)' == ''">32</AndroidLatestUnstableApiLevel>
38-
<AndroidLatestUnstablePlatformId Condition="'$(AndroidLatestUnstablePlatformId)' == ''">Sv2</AndroidLatestUnstablePlatformId>
39-
<AndroidLatestUnstableFrameworkVersion Condition="'$(AndroidLatestUnstableFrameworkVersion)'==''">v12.0.99</AndroidLatestUnstableFrameworkVersion>
38+
<AndroidLatestUnstablePlatformId Condition="'$(AndroidLatestUnstablePlatformId)' == ''">32</AndroidLatestUnstablePlatformId>
39+
<AndroidLatestUnstableFrameworkVersion Condition="'$(AndroidLatestUnstableFrameworkVersion)'==''">v12.1</AndroidLatestUnstableFrameworkVersion>
4040
<!-- The API level and TargetFrameworkVersion for the default Mono.Android.dll build -->
4141
<AndroidApiLevel Condition=" '$(AndroidApiLevel)' == '' ">$(AndroidLatestStableApiLevel)</AndroidApiLevel>
4242
<AndroidPlatformId Condition=" '$(AndroidPlatformId)' == '' ">$(AndroidLatestStablePlatformId)</AndroidPlatformId>

Documentation/workflow/HowToAddNewApiLevel.md

Lines changed: 165 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,174 @@ acceptable "breaks":
5454

5555
When Google announces that the APIs are frozen, additional work such as enumification is needed.
5656

57-
---- Somewhat outdated docs below, update when we do this year's stabilization ----
57+
There have been many, many attempts to "automate" the enumification process in the past, to varying
58+
degrees of success. The main problem is that no automated process is going to be perfect, so
59+
they all rely on a human verifying and modifying the results.
60+
61+
However this verification process is long and tedious. Doing it correctly requires almost as much
62+
effort as doing the full process manually. Thus it generally isn't done correctly and many errors
63+
slip in, leaving our users with bad bindings that are hard to fix in the future without breaking API.
64+
65+
Currently we have taken the opposite approach and do the process completely manually, but we
66+
have invested in tooling to make the process as easy as possible.
67+
68+
This tooling is BindingStudio:
69+
https://github.com/jpobst/BindingStudio
70+
71+
It's a Winforms app, so it only runs on Windows. It's ugly as sin, and has very poor UX. However,
72+
it prompts you with the exact decisions you need to make, and handles as much dirty work as possible,
73+
allowing enumification to be done in a few days.
74+
75+
### Extract constants from API
76+
77+
Using BindingStudio:
78+
79+
- Update `CURRENT_API_LEVEL` in MainForm.cs
80+
- Choose `Tools` -> `Add API Level Constants`
81+
- Fill in existing `map.csv`: `xamarin-android/src/Mono.Android/map.csv`
82+
- Fill in new `api.xml`: ex: `xamarin-android/src/Mono.Android/obj/Debug/net6.0/android-32/mcw/api.xml`
83+
- Choose `File` -> `Save`
84+
85+
This adds all the new possible constants from the API level to `map.csv`. They will be
86+
marked with a `?` indicating no determination has been made if they should be enumified or not.
87+
88+
Example:
89+
```
90+
?,32,android/media/Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_MULTICHANNEL,1,,,,
91+
?,32,android/media/Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_NONE,0,,,,
92+
?,32,android/media/Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_OTHER,-1,,,,
93+
```
94+
95+
### Creating enums
96+
97+
Using BindingStudio:
98+
99+
- Choose `File` -> `Open Constant Map`
100+
- Choose existing `map.csv`: `xamarin-android/src/Mono.Android/map.csv`
101+
102+
The left tree view will be populated with every type that has possible constants that require
103+
a decision. Clicking a tree node will show the grid of all constants in the type. The ones
104+
that need to be handled are the ones with `Action` = `None`. (The others are shown because
105+
sometimes the correct action is to add a new constant to an existing enum.)
106+
107+
Select the row(s) containing the constants you want to act on. (Use Control and Shift to select
108+
multiple rows.) There are 3 possible options for constants:
109+
110+
1) Ignore
111+
112+
If the constant(s) should not be part of an enum (like `Math.PI`), click the `Ignore` toolbar
113+
button to leave them as constants.
114+
115+
2) Add to existing enum
116+
117+
If the constant(s) should be added to an existing enum:
118+
- Click the `Add to existing enum` toolbar button.
119+
- The dialog will show all other enums in this type
120+
- Choose the existing enum to add the new constant(s) to
121+
- After accepting the dialog, you may need to click the grid to cause it to refresh
122+
- The constant(s) will be marked as `Enumify` with the `EnumFullType` you specified
123+
- The enum member names may need to be tweaked by changing the `EnumMember` column
124+
125+
3) Create a new enum
126+
127+
If the constant(s) should be added to a brand new enum:
128+
- Click the `Create Enum` toolbar button
129+
- In the dialog, a suggested enum namespace and name will be pre-populated. This may need to be
130+
tweaked as needed.
131+
- Mark `Is Flags` if this should be a `[Flags]` enum type.
132+
- After accepting the dialog, you may need to click the grid to cause it to refresh
133+
- The constant(s) will be marked as `Enumify` with the `EnumFullType` you specified
134+
- The enum member names may need to be tweaked by changing the `EnumMember` column
135+
136+
Once decisions have been made for all new constants in a type, use the left tree view to move
137+
to the next type. You should periodically save your progress with `File` -> `Save` in case
138+
BindingStudio crashes.
139+
140+
The left tree view can be updated by saving and reopening the `map.csv` file.
141+
142+
### Extract methods that possibly need enums
58143

59-
5) enumification
144+
Using BindingStudio:
60145

61-
See `build-tools/enumification-helpers/README`. Usually it takes many days to complete...
146+
- Update the file paths in `MainForm.FindAPILevelMethodsToolStripMenuItem_Click`
147+
- Run BindingStudio and choose `Tools` -> `Find API Level Methods`
62148

63-
Enumification work can be delayed and only the final API has to be enumified.
149+
This will create a file of every method in the new API level that takes an `int` as a parameter
150+
or returns an `int` as a return value. Each method will be marked with a `?` in the file
151+
to indicate a decision needs to be made to ignore it or map it to an enum.
152+
153+
Example:
154+
```
155+
?,32,android/media,AudioAttributes,getSpatializationBehavior,return,
156+
?,32,android/media,AudioAttributes$Builder,setSpatializationBehavior,sb,
157+
```
158+
159+
### Mapping methods
160+
161+
Using BindingStudio:
162+
163+
- Choose `File` -> `Open Constant Map`
164+
- Choose existing `map.csv`: `xamarin-android/src/Mono.Android/map.csv`
165+
- Choose `File` -> `Open Method Map`
166+
- Choose the new `.csv` created in the previous step
167+
168+
The left tree will populate with every method that possibly should be enumified and
169+
needs a decision to be made. Clicking a method shows the Android documentation for
170+
the method to help make the decision, as well as an area to input the decision.
171+
172+
Note a method may show up multiple times, once for each parameter or return type
173+
(Parameter Name = "return") that is an int. Each one may require a different action.
174+
175+
There are 3 possible options for a method parameter/return type:
176+
177+
1) Unknown
178+
179+
You don't how to handle this method currently, so leaving it in the initial state
180+
of "Unknown" will leave it alone until a decision can be made.
181+
182+
2) Ignore
183+
184+
The method parameter/return type should remain an `int` and not be converted to an enum.
185+
186+
Ex:
187+
```
188+
int Add (int value1, int value2) { ... }
189+
```
190+
191+
Click the "Ignore" radio button and then the "Save" button.
192+
193+
3) Enumify
194+
195+
The method parameter/return type should be changed to an enum.
196+
197+
Ex:
198+
```
199+
void AudioAttributesBuilder.SetSpatializationBehavior (int sb) { ... }
200+
```
201+
202+
- Choose the "Enumify" radio option
203+
- Use the DropDown in the middle to select the enum to use
204+
- When selected, the members of that enum will be shown in the box below the enum
205+
- Alternatively, search for a enum by enum member name using the Search box in the right
206+
- If desired enum is found, clicking it will populate dropdown
207+
- Click "Save"
208+
209+
Use `File` -> `Save` to save your work often!
210+
211+
### Finishing the method map
212+
213+
The official `methodmap.csv` uses a slightly different format than the one used for enumification.
214+
215+
Using BindingStudio:
216+
- Ensure the "new api level method map" CSV file is loaded.
217+
- Choose `Tools` -> `Export Final Method Map`
218+
- Choose a temporary file name
219+
- Open the temporary file, copy the contents to the bottom of the official:
220+
- xamarin-android/src/Mono.Android/methodmap.csv
221+
222+
Congrats! Enumification is complete!
223+
224+
---- Somewhat outdated docs below, update when we do this year's stabilization ----
64225

65226
6) new AndroidManifest.xml elements and attributes
66227

build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public sealed class CheckApiCompatibility : Task
2929
{ "v10.0", "v9.0" },
3030
{ "v11.0", "v10.0" },
3131
{ "v12.0", "v11.0" },
32-
{ "v12.0.99", "v12.0" },
32+
{ "v12.1", "v12.0" },
3333
};
3434

3535
static readonly string assemblyToValidate = "Mono.Android.dll";

build-tools/api-merge/merge-configuration.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<File Path="api-29.xml.in" Level="29" />
2121
<File Path="api-30.xml.in" Level="30" />
2222
<File Path="api-31.xml.in" Level="31" />
23-
<File Path="api-Sv2.xml.in" Level="Sv2" />
23+
<File Path="api-32.xml.in" Level="32" />
2424
</Inputs>
2525
<Outputs>
2626
<File Path="android-19\mcw\api.xml" LastLevel="19" />
@@ -36,6 +36,6 @@
3636
<File Path="android-29\mcw\api.xml" LastLevel="29" />
3737
<File Path="android-30\mcw\api.xml" LastLevel="30" />
3838
<File Path="android-31\mcw\api.xml" LastLevel="31" />
39-
<File Path="android-Sv2\mcw\api.xml" LastLevel="Sv2" />
39+
<File Path="android-32\mcw\api.xml" LastLevel="32" />
4040
</Outputs>
4141
</Configuration>

build-tools/api-xml-adjuster/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ API_XML_TOOL = $(BUILDBIN)/api-xml-adjuster.exe
1717
RUNTIME = mono --debug
1818
RUN_CLASS_PARSE = $(RUNTIME) $(CLASS_PARSE)
1919
RUN_API_XML_TOOL = $(RUNTIME) $(API_XML_TOOL)
20-
API_LEVELS = 10 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Sv2
20+
API_LEVELS = 10 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
2121

2222
XML_OUTPUT_DIR = .
2323

build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class BuildAndroidPlatforms
4040
new AndroidPlatform (apiName: "Q", apiLevel: 29, platformID: "29", include: "v10.0", framework: "v10.0"),
4141
new AndroidPlatform (apiName: "R", apiLevel: 30, platformID: "30", include: "v11.0", framework: "v11.0"),
4242
new AndroidPlatform (apiName: "S", apiLevel: 31, platformID: "31", include: "v12.0", framework: "v12.0"),
43-
new AndroidPlatform (apiName: "Sv2", apiLevel: 32, platformID: "Sv2", include: "v12.0.99",framework: "v12.0.99", stable: false),
43+
new AndroidPlatform (apiName: "Sv2", apiLevel: 32, platformID: "32", include: "v12.1", framework: "v12.1"),
4444
};
4545

4646
// These are here until we can drop "legacy" targets and use only .NET6+

build-tools/xaprepare/xaprepare/ConfigAndData/Dependencies/AndroidToolchain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public AndroidToolchain ()
6363
new AndroidPlatformComponent ("platform-29_r01", apiLevel: "29", pkgRevision: "1"),
6464
new AndroidPlatformComponent ("platform-30_r01", apiLevel: "30", pkgRevision: "1"),
6565
new AndroidPlatformComponent ("platform-31_r01", apiLevel: "31", pkgRevision: "1"),
66-
new AndroidPlatformComponent ("platform-Sv2_r01", apiLevel: "Sv2", pkgRevision: "1"),
66+
new AndroidPlatformComponent ("platform-32_r01", apiLevel: "32", pkgRevision: "1"),
6767

6868
new AndroidToolchainComponent ("sources-31_r01", destDir: Path.Combine ("platforms", $"android-31", "src"), pkgRevision: "1", dependencyType: AndroidToolchainComponentType.BuildDependency),
6969

src/Mono.Android/Profiles/api-Sv2.params.txt renamed to src/Mono.Android/Profiles/api-32.params.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6856,6 +6856,9 @@ package android.hardware.camera2.params
68566856
copyElements(int[] destination, int offset)
68576857
equals(java.lang.Object obj)
68586858
getElement(int column, int row)
6859+
class DeviceStateSensorOrientationMap
6860+
equals(java.lang.Object obj)
6861+
getSensorOrientation(long deviceState)
68596862
class ExtensionSessionConfiguration
68606863
#ctor(int extension, java.util.List<android.hardware.camera2.params.OutputConfiguration> outputs, java.util.concurrent.Executor executor, android.hardware.camera2.CameraExtensionSession.StateCallback listener)
68616864
class InputConfiguration
@@ -18985,12 +18988,12 @@ package android.view
1898518988
interface ActionProvider.VisibilityListener
1898618989
onActionProviderVisibilityChanged(boolean isVisible)
1898718990
interface AttachedSurfaceControl
18988-
addOnSurfaceTransformHintChangedListener(android.view.AttachedSurfaceControl.OnSurfaceTransformHintChangedListener listener)
18991+
addOnBufferTransformHintChangedListener(android.view.AttachedSurfaceControl.OnBufferTransformHintChangedListener listener)
1898918992
applyTransactionOnDraw(android.view.SurfaceControl.Transaction t)
1899018993
buildReparentTransaction(android.view.SurfaceControl child)
18991-
removeOnSurfaceTransformHintChangedListener(android.view.AttachedSurfaceControl.OnSurfaceTransformHintChangedListener listener)
18992-
interface AttachedSurfaceControl.OnSurfaceTransformHintChangedListener
18993-
onSurfaceTransformHintChanged(int hint)
18994+
removeOnBufferTransformHintChangedListener(android.view.AttachedSurfaceControl.OnBufferTransformHintChangedListener listener)
18995+
interface AttachedSurfaceControl.OnBufferTransformHintChangedListener
18996+
onBufferTransformHintChanged(int hint)
1899418997
class Choreographer
1899518998
postFrameCallback(android.view.Choreographer.FrameCallback callback)
1899618999
postFrameCallbackDelayed(android.view.Choreographer.FrameCallback callback, long delayMillis)

0 commit comments

Comments
 (0)