dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 530 forks source link

Incorrect enum ApplicationExitInfoReason #9000

Closed rgroenewoudt closed 5 months ago

rgroenewoudt commented 5 months ago

Android framework version

net8.0-android

Affected platform version

VS2022 17.10.1

Description

The enum Android.App.ApplicationExitInfoReason contains value Other but it has the incorrect numeric value.

Defined with value 10:

[IntDefinition("Android.App.ApplicationExitInfo.ReasonOther", JniField = "android/app/ApplicationExitInfo.REASON_OTHER"), SupportedOSPlatform("android30.0")]
Other = 10, // 0x0000000A

which is duplicate with:

[IntDefinition("Android.App.ApplicationExitInfo.ReasonUserRequested", JniField = "android/app/ApplicationExitInfo.REASON_USER_REQUESTED"), SupportedOSPlatform("android30.0")] 
UserRequested = 10, // 0x0000000A

According to Android documentation it should be value 13

We noticed this we have a lot of ApplicationExitInfo records with value '13' instead of a pretty enum name.

jpobst commented 5 months ago

Wrote a quick script to compare map.csv to api-34.xml to find all instances where our enum values do not match what is actually in API-34. It would appear that api-merge does not update constant values if they change when building api.xml.

// Changed value in API-26:
// https://developer.android.com/sdk/api_diff/26/changes/android.app.ActivityManager.RunningAppProcessInfo#android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE
// We have the correct value, api-34.xml is incorrect.
android/app/ActivityManager$RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE 230 != 130 [API-10]

// Changed value in API-28:
// https://developer.android.com/sdk/api_diff/28/changes/android.app.ActivityManager.RunningAppProcessInfo
// We have the correct value, api-34.xml is incorrect.
android/app/ActivityManager$RunningAppProcessInfo.IMPORTANCE_TOP_SLEEPING 325 != 150 [API-23]

// We bound this constant when API-30 was only Developer Preview 2, and it changed afterwards.
// Nowadays we do not do enumification until Google marks the API as "stable".
android/app/ApplicationExitInfo.REASON_OTHER 10 != 13 [API-30]

// https://developer.android.com/reference/android/content/pm/PermissionInfo#PROTECTION_MASK_FLAGS
// We have the correct value, api-34.xml is incorrect.
android/content/pm/PermissionInfo.PROTECTION_MASK_FLAGS 65520 != 240 [API-16]

// This "constant" is deprecated and documented as "can change from release to release":
// https://developer.android.com/reference/android/net/http/SslError#SSL_MAX_ERROR
// We have the correct value, api-34.xml is incorrect.
android/net/http/SslError.SSL_MAX_ERROR 6 != 4 [API-10]

// These values are correct, not sure why api-34.xml is missing them
android/view/animation/Transformation.TYPE_ALPHA 1 !=  [API-10]
android/view/animation/Transformation.TYPE_BOTH 3 !=  [API-10]
android/view/animation/Transformation.TYPE_IDENTITY 0 !=  [API-10]
android/view/animation/Transformation.TYPE_MATRIX 2 !=  [API-10]