Repository navigation
Audit Mono.Android enums for missing [Flags] #7416
Description
Activity
- addedArea: Mono.AndroidIssues with the Android API binding (Mono.Android.dll).Issues with the Android API binding (Mono.Android.dll).
on Sep 27, 2022 - ghost addedneeds-triageIssues that need to be assigned.Issues that need to be assigned.
on Sep 27, 2022 - removedneeds-triageIssues that need to be assigned.Issues that need to be assigned.
on Sep 27, 2022 There are a lot of missing flag attributes if I take a look in map.csv.
It could be autodetected by parsing the Java class annotations:
For example in the Android source for TextUtils.SAFE_STRING_FLAG_TRIM :public class TextUtils { ... @IntDef(flag = true, prefix = "CLEAN_STRING_FLAG_", value = {SAFE_STRING_FLAG_TRIM, SAFE_STRING_FLAG_SINGLE_LINE, SAFE_STRING_FLAG_FIRST_LINE}) ... public static final int SAFE_STRING_FLAG_TRIM = 0x1;flag = trueindicates it's a flag.More documentation: https://developer.android.com/reference/androidx/annotation/IntDef
I explored using the annotations, and while it gives us hints, there appear to be plenty of examples where they are wrong, so we can't just automatically trust them. For example, it lists these microphone locations as a set of flags:
https://developer.android.com/reference/android/media/MicrophoneInfo?hl=en#getLocation()
The values are:
- LOCATION_UNKNOWN - 0 - LOCATION_MAINBODY - 1 - LOCATION_MAINBODY_MOVABLE - 2 - LOCATION_PERIPHERAL - 3I do not think a mic located on a "peripheral" is a combination of a mic on the "mainbody" and a movable mic on the "mainbody".
Some more examples that annotations declare as flags that I am skeptical about:
- https://developer.android.com/reference/android/media/MicrophoneInfo?hl=en#getDirectionality()
- https://developer.android.com/reference/android/media/AudioManager#getDirectPlaybackSupport(android.media.AudioFormat,%20android.media.AudioAttributes)
- https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceStateChangedCallback#setPlaybackState(int,%20int,%20android.os.Bundle)
- added a commit that references this issue
on Sep 1, 2023 - locked and limited conversation to collaborators
on Jan 24, 2024
Context: #7409
I suspect there are many enums that are intended to be
[Flags]but are missing the attribute.It would be nice to write something that looks at the integer values of each enum and gave us a heads-up if the values look "flag-like" but the attribute has not been specified.