Skip to content

Commit 8cb94dc

Browse files
authored
[Mono.Android] Fix some incorrect enums. (#7670)
Context: dotnet/java-interop@5c5dc08 Using Android's API-33 `annotations.zip`, some missing and incorrect enum mappings were found. ~~ Missed Enumeration ~~ Enums that were previously left as constants have been enumified and have had the old members added back to the API with manual additions code marked with `[Obsolete]`. Original `map.csv` entries such as: I,23,android/hardware/camera2/CameraAccessException.MAX_CAMERAS_IN_USE,5,,,, become: E,23,android/hardware/camera2/CameraAccessException.MAX_CAMERAS_IN_USE,5,Android.Hardware.Camera2.CameraAccessErrorType,MaxCameraInUse,keep, with added C# code to maintain API compatibility: namespace Android.Hardware.Camera2 { partial class CameraAccessException { [Obsolete ("This constant will be removed in the future version. Use Android.Hardware.Camera2.CameraAccessErrorType enum directly instead of this field.")] [Register ("MAX_CAMERAS_IN_USE", ApiSince=23)] public const int MaxCamerasInUse = 5; } } ~~ Incorrect Enumerations ~~ Some other constants were assigned to the wrong enumeration. These have been marked as `[Obsolete]` and new values have been added to the correct enumeration. For example: E,30,android/app/usage/UsageStatsManager.STANDBY_BUCKET_RESTRICTED,45,Android.App.Usage.UsageStatsInterval,Restricted,remove, becomes: E,30,android/app/usage/UsageStatsManager.STANDBY_BUCKET_RESTRICTED,45,Android.App.Usage.UsageStatsInterval,Restricted,remove,,-1 A,30,,45,Android.App.Usage.StandbyBucket,Restricted,remove,, which will result in: namespace Android.App.Usage { /* partial */ enum UsageStatsInterval { [Obsolete ("This value was incorrectly added to the enumeration and is not a valid value")] Restricted = 45, // Removed incorrect entry } /* partial */ enum StandbyBucket { Restricted = 45, // Entry added to correct enum } }
1 parent 3ec1b15 commit 8cb94dc

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using Android.Runtime;
3+
4+
#if ANDROID_23
5+
namespace Android.Hardware.Camera2
6+
{
7+
// This was converted to an enum in .NET 8
8+
partial class CameraAccessException
9+
{
10+
[Obsolete ("This constant will be removed in the future version. Use Android.Hardware.Camera2.CameraAccessErrorType enum directly instead of this field.")]
11+
[Register ("MAX_CAMERAS_IN_USE", ApiSince=23)]
12+
public const int MaxCamerasInUse = 5;
13+
}
14+
}
15+
#endif // ANDROID_23

src/Mono.Android/Android.Media/AudioManager.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
2-
32
using Android.Content;
3+
using Android.Runtime;
44

55
namespace Android.Media {
66

@@ -10,6 +10,13 @@ public partial class AudioManager {
1010
{
1111
return context.GetSystemService (Context.AudioService!) as AudioManager;
1212
}
13+
14+
#if ANDROID_26
15+
// This was converted to an enum in .NET 8
16+
[Obsolete ("This constant will be removed in the future version. Use Android.Media.Stream enum directly instead of this field.")]
17+
[Register ("STREAM_ACCESSIBILITY", ApiSince=26)]
18+
public const int StreamAccessibility = 10;
19+
#endif // ANDROID_26
1320
}
1421
}
1522

src/Mono.Android/Mono.Android.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
<Compile Include="Android.Graphics.Drawables\RotateDrawable.cs" />
206206
<Compile Include="Android.Graphics.Drawables\ScaleDrawable.cs" />
207207
<Compile Include="Android.Hardware\SensorManager.cs" />
208+
<Compile Include="Android.Hardware.Camera2\CameraAccessException.cs" />
208209
<Compile Include="Android.Hardware.Camera2.Params\LensShadingMap.cs" />
209210
<Compile Include="Android.Hardware.Camera2.Params\RggbChannelVector.cs" />
210211
<Compile Include="Android.Hardware.Camera2.Params\TonemapCurve.cs" />

src/Mono.Android/map.csv

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,8 @@ E,21,android/app/usage/UsageStatsManager.INTERVAL_YEARLY,3,Android.App.Usage.Usa
739739
E,28,android/app/usage/UsageStatsManager.STANDBY_BUCKET_ACTIVE,10,Android.App.Usage.StandbyBucket,Active,remove,
740740
E,28,android/app/usage/UsageStatsManager.STANDBY_BUCKET_FREQUENT,30,Android.App.Usage.StandbyBucket,Frequent,remove,
741741
E,28,android/app/usage/UsageStatsManager.STANDBY_BUCKET_RARE,40,Android.App.Usage.StandbyBucket,Rare,remove,
742-
E,30,android/app/usage/UsageStatsManager.STANDBY_BUCKET_RESTRICTED,45,Android.App.Usage.UsageStatsInterval,Restricted,remove,
742+
E,30,android/app/usage/UsageStatsManager.STANDBY_BUCKET_RESTRICTED,45,Android.App.Usage.UsageStatsInterval,Restricted,remove,,-1
743+
A,30,,45,Android.App.Usage.StandbyBucket,Restricted,remove,,
743744
E,28,android/app/usage/UsageStatsManager.STANDBY_BUCKET_WORKING_SET,20,Android.App.Usage.StandbyBucket,WorkingSet,remove,
744745
E,31,android/app/WallpaperColors.HINT_SUPPORTS_DARK_TEXT,1,Android.App.WallpaperColorsHint,SupportsDarkText,remove,flags
745746
E,31,android/app/WallpaperColors.HINT_SUPPORTS_DARK_THEME,2,Android.App.WallpaperColorsHint,SupportsDarkTheme,remove,flags
@@ -1885,7 +1886,7 @@ E,10,android/database/sqlite/SQLiteDatabase.CONFLICT_NONE,0,Android.Database.Sql
18851886
E,10,android/database/sqlite/SQLiteDatabase.CONFLICT_REPLACE,5,Android.Database.Sqlite.Conflict,Replace,remove,
18861887
E,10,android/database/sqlite/SQLiteDatabase.CONFLICT_ROLLBACK,1,Android.Database.Sqlite.Conflict,Rollback,remove,
18871888
E,10,android/database/sqlite/SQLiteDatabase.CREATE_IF_NECESSARY,268435456,Android.Database.Sqlite.DatabaseOpenFlags,CreateIfNecessary,keep,flags
1888-
I,16,android/database/sqlite/SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING,536870912,,,,
1889+
E,16,android/database/sqlite/SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING,536870912,Android.Database.Sqlite.DatabaseOpenFlags,EnableWriteAheadLogging,keep,flags
18891890
I,15,android/database/sqlite/SQLiteDatabase.MAX_SQL_CACHE_SIZE,100,,,,
18901891
E,10,android/database/sqlite/SQLiteDatabase.NO_LOCALIZED_COLLATORS,16,Android.Database.Sqlite.DatabaseOpenFlags,NoLocalizedCollators,keep,flags
18911892
E,10,android/database/sqlite/SQLiteDatabase.OPEN_READONLY,1,Android.Database.Sqlite.DatabaseOpenFlags,OpenReadonly,keep,flags
@@ -2166,7 +2167,7 @@ E,21,android/hardware/camera2/CameraAccessException.CAMERA_DISABLED,1,Android.Ha
21662167
E,21,android/hardware/camera2/CameraAccessException.CAMERA_DISCONNECTED,2,Android.Hardware.Camera2.CameraAccessErrorType,Disconnected,keep,
21672168
E,21,android/hardware/camera2/CameraAccessException.CAMERA_ERROR,3,Android.Hardware.Camera2.CameraAccessErrorType,Error,keep,
21682169
E,23,android/hardware/camera2/CameraAccessException.CAMERA_IN_USE,4,Android.Hardware.Camera2.CameraAccessErrorType,InUse,keep,
2169-
I,23,android/hardware/camera2/CameraAccessException.MAX_CAMERAS_IN_USE,5,,,,
2170+
E,23,android/hardware/camera2/CameraAccessException.MAX_CAMERAS_IN_USE,5,Android.Hardware.Camera2.CameraAccessErrorType,MaxCamerasInUse,keep,
21702171
E,30,android/hardware/camera2/CameraDevice.AUDIO_RESTRICTION_NONE,0,Android.Hardware.Camera2.CameraDeviceAudioRestrictionType,None,remove,
21712172
E,30,android/hardware/camera2/CameraDevice.AUDIO_RESTRICTION_VIBRATION,1,Android.Hardware.Camera2.CameraDeviceAudioRestrictionType,Vibration,remove,
21722173
E,30,android/hardware/camera2/CameraDevice.AUDIO_RESTRICTION_VIBRATION_SOUND,3,Android.Hardware.Camera2.CameraDeviceAudioRestrictionType,VibrationSound,remove,
@@ -3696,9 +3697,12 @@ E,24,android/location/GnssNavigationMessage.TYPE_GPS_CNAV2,260,Android.Locations
36963697
E,24,android/location/GnssNavigationMessage.TYPE_GPS_L1CA,257,Android.Locations.GnssNavigationType,GpsL1ca,remove,
36973698
E,24,android/location/GnssNavigationMessage.TYPE_GPS_L2CNAV,258,Android.Locations.GnssNavigationType,GpsL2cnav,remove,
36983699
E,24,android/location/GnssNavigationMessage.TYPE_GPS_L5CNAV,259,Android.Locations.GnssNavigationType,GpsL5cnav,remove,
3699-
E,30,android/location/GnssNavigationMessage.TYPE_IRN_L5CA,1793,Android.Locations.GnssNavigationStatus,IrnL5ca,remove,
3700-
E,30,android/location/GnssNavigationMessage.TYPE_QZS_L1CA,1025,Android.Locations.GnssNavigationStatus,QzsL1ca,remove,
3701-
E,30,android/location/GnssNavigationMessage.TYPE_SBS,513,Android.Locations.GnssNavigationStatus,Sbs,remove,
3700+
A,30,,1793,Android.Locations.GnssNavigationType,IrnL5ca,remove,,
3701+
A,30,,1025,Android.Locations.GnssNavigationType,QzsL1ca,remove,,
3702+
A,30,,513,Android.Locations.GnssNavigationType,Sbs,remove,,
3703+
E,30,android/location/GnssNavigationMessage.TYPE_IRN_L5CA,1793,Android.Locations.GnssNavigationStatus,IrnL5ca,remove,,-1
3704+
E,30,android/location/GnssNavigationMessage.TYPE_QZS_L1CA,1025,Android.Locations.GnssNavigationStatus,QzsL1ca,remove,,-1
3705+
E,30,android/location/GnssNavigationMessage.TYPE_SBS,513,Android.Locations.GnssNavigationStatus,Sbs,remove,,-1
37023706
E,24,android/location/GnssNavigationMessage.TYPE_UNKNOWN,0,Android.Locations.GnssNavigationType,Unknown,remove,
37033707
E,24,android/location/GnssNavigationMessage$Callback.STATUS_LOCATION_DISABLED,2,Android.Locations.GnssNavigationCallbackStatus,LocationDisabled,remove,
37043708
E,24,android/location/GnssNavigationMessage$Callback.STATUS_NOT_SUPPORTED,0,Android.Locations.GnssNavigationCallbackStatus,NotSupported,remove,
@@ -4019,7 +4023,7 @@ E,10,android/media/AudioManager.SCO_AUDIO_STATE_CONNECTED,1,Android.Media.ScoAud
40194023
E,15,android/media/AudioManager.SCO_AUDIO_STATE_CONNECTING,2,Android.Media.ScoAudioState,Connecting,remove,
40204024
E,10,android/media/AudioManager.SCO_AUDIO_STATE_DISCONNECTED,0,Android.Media.ScoAudioState,Disconnected,remove,
40214025
E,10,android/media/AudioManager.SCO_AUDIO_STATE_ERROR,-1,Android.Media.ScoAudioState,Error,remove,
4022-
I,26,android/media/AudioManager.STREAM_ACCESSIBILITY,10,,,,
4026+
E,26,android/media/AudioManager.STREAM_ACCESSIBILITY,10,Android.Media.Stream,Accessibility,keep,
40234027
E,1,android/media/AudioManager.STREAM_ALARM,4,Android.Media.Stream,Alarm,keep,
40244028
E,5,android/media/AudioManager.STREAM_DTMF,8,Android.Media.Stream,Dtmf,keep,
40254029
E,1,android/media/AudioManager.STREAM_MUSIC,3,Android.Media.Stream,Music,keep,

0 commit comments

Comments
 (0)