Skip to content

Commit 8bbe616

Browse files
committed
[enumification-helpers] API O method enumification.
1 parent 13dfe55 commit 8bbe616

File tree

12 files changed

+904
-57
lines changed

12 files changed

+904
-57
lines changed

Documentation/HowToAddNewApiLevel.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
# How to deal with new API Level
3+
4+
## This documentation is incomplete
5+
6+
In Xamarin ages, we used to have (more complete) API upgrade guide internally. But since then we switched to new xamarin-android repository which entirely changed the build system from Makefile to MSBuild solution, as well as the managed API for manipulating Android SDK, the old documentation almost does not make sense anymore. Even though I am writing this documentation, I don't know everything required (nor those who changed the build system didn't care about API upgrades).
7+
8+
Hence, this documentation is written from the ground, exploring everything around.
9+
10+
And since the build system has changed between the first preview of Android O and the latest Android O preview (3), and it is quite possible that the build system changes over and over again, it might still not make much sense in the future.
11+
12+
## Steps
13+
14+
Anyhow, this commit would tell you what needs to be changed when the new API preview arrives (and that becomes stable): https://github.com/xamarin/xamarin-android/pull/642
15+
16+
1) Add/update new download to build-tools/android-toolchain.
17+
The new API archive should be found on the web repository description
18+
that Google Android SDK Manager uses (which can be now shown as part
19+
of SDK Manager options in Android Studio).
20+
21+
As of Android O ages, it could be found at https://dl-ssl.google.com/android/repository/repository2-1.xml . It used to be different repository description URL, and it will be different URL in the future.
22+
23+
2) Create and add api-O.xml.in under src/Mono.Android/Profile directory.
24+
It can be done from within `build-tools/api-xml-adjuster` directory. See `README.md` in that directory for details. You will have to make changes to Makefile in that directory to generate it. Also note that it often happens that Google does not ship documentation archive (!) and in such case we will have to scrape DroidDoc from the web and create our own docs archive.
25+
26+
3) Review new API (or review the changes in case of API updates).
27+
28+
Some of the changes are caused by API removal. Usually they come with
29+
"deprecated" state in the previous API Level first, but that's not always true.
30+
31+
4) enumification: See `build-tools/enumification-helpers/README`.
32+

build-tools/enumification-helpers/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
map.ext.csv
22
const-list-*.xml
3+
remaining-int-methods.txt
34
*.exe
45
*.mdb
56
*.pdb

build-tools/enumification-helpers/README

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,15 @@ The results are to be saved as "map.ext.csv" and "methodmap.ext.csv" that are to
231231
convert to enums" methods, or blacklist-field.txt for fields.
232232
- in general those notes do not describe *everything*. git diff
233233
would tell what is new and what should be taken care this time.
234+
- Here is how I worked on it at API Level 26 to add new lines to methodmap.ext.csv:
235+
- Read git diff on remaining-int-consts.txt to iterate all the new enum types.
236+
- For each new enum type that (typically) has prefix P_ in type T, I run `grep -R P_ | grep T | grep "\w*.html:"` in the local reference docs, to see which documentation HTML mention that const (I ran the command on GNOME terminal, so I got the final grep matches with color highlights).
237+
- And for each HTML doc, look up that const and add records to methodmap.ext.csv.
238+
- I usually bring in mistakes. When there are wrong const mappings, they will result in binding generator warnings for unmatched XPath selectors that you can find them by looking up enummetadata.
239+
- For method mappings, mistakes can be twofolds:
240+
- For the wrong matching, you'll see them as binding generator warnings for unmatched XPath selectors just like const mappings.
241+
- For the wrong replacement enum type, that's NOT going to be unmatched XPath. Instead it will result in a reference to missing type warning that can be still found as a generator warning (but harder to find).
242+
- It is often hard to identify why the mappings are regarded as invalid; sometimes Google API reference tells you lies(!) that there are some methods that actually don't exist(!). You'd like to check `obj/Debug/android-*/api.xml`, `obj/Debug/android-*/api.xml.fixed` (XML after applying metadata fixup) or `Profiles/api-*.xml.in` (for "raw" API data before `api-merge` step).
234243
- At some stage, go to src/Mono.Android and append
235244
methodmap.ext.csv contents to methodmap.csv and run
236245
"make API_LEVELS=[latest] clean all" to get enumified dll.

build-tools/enumification-helpers/enum-conversion-mappings.xml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@
5656
<map package="android.app" class="DownloadManager.Request" fields="" prefix="VISIBILITY_" enum-name="DownloadVisibility" />
5757
<map package="android.app" class="FragmentManager" fields="" prefix="POP_BACK_STACK_" enum-name="PopBackStackFlags" extra-default="None" />
5858
<map package="android.app" class="FragmentTransaction" fields="" prefix="TRANSIT_" enum-name="FragmentTransit" is-transient="false" />
59-
<map package="android.app" class="Notification" fields="" prefix="BADGE_ICON_" enum-name="NotificationBadgeIcon" is-transient="false" api-since="26" />
59+
<map package="android.app" class="Notification" fields="" prefix="BADGE_ICON_" enum-name="NotificationBadgeIconType" is-transient="false" api-since="26" />
6060
<map package="android.app" class="Notification" fields="" prefix="FLAG_" enum-name="NotificationFlags" is-transient="false" />
6161
<map package="android.app" class="Notification" fields="" prefix="DEFAULT_" enum-name="NotificationDefaults" is-transient="false" />
62-
<map package="android.app" class="Notification" fields="" prefix="GROUP_ALERT_" enum-name="NotificationGroupAlert" is-transient="false" api-since="26" />
62+
<map package="android.app" class="Notification" fields="" prefix="GROUP_ALERT_" enum-name="NotificationGroupAlertBehavior" is-transient="false" api-since="26" />
6363
<map package="android.app" class="Notification" fields="" prefix="VISIBILITY_" enum-name="NotificationVisibility" is-transient="false" api-level="20" />
6464
<map package="android.app" class="Notification.WearableExtender" fields="" prefix="SIZE_" enum-name="WearableSizePreset" is-transient="false" api-level="20" />
6565
<map package='android.app' class='PendingIntent' prefix='FLAG_' enum-name='PendingIntentFlags' is-transient='false' />
@@ -97,6 +97,8 @@
9797
<map package="android.bluetooth" class="BluetoothDevice" fields="" prefix="BOND_" enum-name="Bond" is-transient="false" />
9898
<map package="android.bluetooth" class="BluetoothDevice" fields="PHY_LE_*" prefix="PHY_" enum-name="BluetoothPhy" is-transient="false" api-level="26" />
9999
<map package="android.bluetooth" class="BluetoothDevice" prefix="PHY_OPTION_" enum-name="BluetoothPhyOption" is-transient="false" api-level="26" />
100+
<!-- used by ScanResult#getSecondaryPhy() -->
101+
<map package="android.bluetooth.le" class="ScanResult" fields="PHY_UNUSED" prefix="PHY_" enum-name="BluetoothPhy" is-transient="false" api-level="26" />
100102
<map package="android.bluetooth" class="BluetoothGatt" fields="" prefix="GATT_" enum-name="GattStatus" api-level="18" />
101103
<map package="android.bluetooth" class="BluetoothGatt" fields="" prefix="CONNECTION_PRIORITY_" enum-name="GattConnectionPriority" api-level="21" />
102104
<map package="android.bluetooth" class="BluetoothGattCharacteristic" fields="" prefix="FORMAT_" enum-name="GattFormat" api-level="18" />
@@ -118,10 +120,9 @@
118120
<map package="android.bluetooth.le" class="AdvertiseSettings" fields="" prefix="ADVERTISE_TX_" enum-name="AdvertiseTx" is-transient="false" api-level="21" />
119121
<map package="android.bluetooth.le" class="AdvertiseSettings" fields="" prefix="ADVERTISE_TYPE_" enum-name="AdvertiseType" is-transient="false" api-level="21" />
120122
<map package="android.bluetooth.le" class="AdvertisingSetCallback" fields="" prefix="ADVERTISE_" enum-name="AdvertiseResult" is-transient="false" api-level="26" />
121-
<map package="android.bluetooth.le" class="AdvertisingSetParameters" fields="" prefix="INTERVAL_" enum-name="AdvertiseInterval" is-transient="false" api-level="26" />
122123
<map package="android.bluetooth.le" class="AdvertisingSetParameters" fields="" prefix="TX_POWER_" enum-name="AdvertiseTxPower" is-transient="false" api-level="26" />
123124
<map package="android.bluetooth.le" class="ScanCallback" fields="" prefix="SCAN_FAILED_" enum-name="ScanFailure" is-transient="false" api-level="21" />
124-
<map package="android.bluetooth.le" class="ScanResult" fields="*" prefix="" enum-name="ScanResultCode" is-transient="false" api-level="26" />
125+
<map package="android.bluetooth.le" class="ScanResult" prefix="DATA_" enum-name="DataStatus" is-transient="false" api-level="26" />
125126
<map package="android.bluetooth.le" class="ScanSettings" fields="" prefix="SCAN_MODE_" enum-name="ScanMode" is-transient="false" api-level="21" />
126127
<map package="android.bluetooth.le" class="ScanSettings" fields="" prefix="CALLBACK_TYPE_" enum-name="ScanCallbackType" is-transient="false" api-level="21" />
127128
<map package="android.bluetooth.le" class="ScanSettings" fields="" prefix="PHY_LE_" enum-name="ScanSettingsPhy" is-transient="false" api-level="26" />
@@ -198,11 +199,12 @@
198199
<map package='android.hardware' class='Camera$CameraInfo' fields='' prefix='CAMERA_FACING_' enum-name="CameraFacing" />
199200
<map package='android.hardware' class='Camera$Parameters' fields='' prefix='FOCUS_DISTANCE_' enum-name="FocusDistance" />
200201
<map package='android.hardware' class='Camera$Parameters' fields='' prefix='PREVIEW_' enum-name="Preview" />
201-
<map package='android.hardware' class='HardwareBuffer' fields='*' enum-name="HardwareBufferFlags" is-transient="false" api-level="26" />
202+
<map package='android.hardware' class='HardwareBuffer' fields='RGB.* BLOB' enum-name="HardwareBufferFormat" is-transient="false" api-level="26" />
203+
<map package='android.hardware' class='HardwareBuffer' prefix='USAGE_' enum-name="HardwareBufferUsage" is-transient="false" api-level="26" />
202204
<map package='android.hardware' class='Sensor' prefix='REPORTING_MODE_' enum-name="ReportingMode" is-transient="false" api-level="21" />
203205
<map package='android.hardware' class='Sensor' fields='' prefix='TYPE_' enum-name="SensorType" is-transient="false" />
204206
<map package='android.hardware' class='SensorDirectChannel' prefix='RATE_' enum-name="SensorDirectRateLevel" is-transient="false" api-level="26" />
205-
<map package='android.hardware' class='SensorDirectChannel' prefix='TYPE_' enum-name="SensorDirectType" is-transient="false" api-level="26" />
207+
<map package='android.hardware' class='SensorDirectChannel' prefix='TYPE_' enum-name="SensorDirectChannelType" is-transient="false" api-level="26" />
206208
<map package='android.hardware.camera2' class='CameraAccessException' fields='' prefix='CAMERA_' enum-name="CameraAccessErrorType" is-transient="false" api-level="21" />
207209
<map package='android.hardware.camera2' class='CameraDevice.StateCallback' fields='' prefix='ERROR_' enum-name="CameraError" is-transient="false" api-level="21" />
208210
<map package='android.hardware.camera2' class='CameraDevice' fields='' prefix='TEMPLATE_' enum-name="CameraTemplate" is-transient="false" api-level="21" />
@@ -1000,7 +1002,6 @@
10001002
<map package='android.icu.util' class='Calendar' fields='AM_PM DATE DAY_OF_MONTH DAY_OF_WEEK DAY_OF_WEEK_IN_MONTH DAY_OF_YEAR DOW_LOCAL DST_OFFSET ERA EXTENDED_YEAR HOUR HOUR_OF_DAY JULIAN_DAY MILLISECOND MILLISECONDS_IN_DAY MINUTE MONTH SECOND WEEK_OF_MONTH WEEK_OF_YEAR YEAR YEAR_WOY ZONE_OFFSET' prefix='' enum-name="CalendarField" />
10011003
<map package="android.icu.util" class="Calendar" fields="" prefix="WALLTIME_" enum-name="WalltimeOptions" api-level="24" />
10021004
<map package="android.icu.util" class="Currency" fields="" suffix="_NAME" enum-name="CurrencyNameStyle" api-level="24" />
1003-
<map package="android.icu.util" class="EthiopicCalendar" fields="*" prefix="" enum-name="EthiopicMonth" api-level="26" />
10041005
<map package="android.icu.util" class="TimeZone" fields="GENERIC_LOCATION LONG* SHORT*" enum-name="TimeZoneNameStyle" api-level="24" />
10051006
<map package="android.icu.util" class="TimeZone" prefix="TIMEZONE_" enum-name="TimeZoneType" api-level="26" />
10061007
<map package="android.icu.util" class="UniversalTimeScale" fields=".*_TIME MAX_SCALE" enum-name="UniversalTimeScaleType" api-level="26" />

0 commit comments

Comments
 (0)