Skip to content

[Mono.Android] Fix incorrect Context.RegisterReceiver enumification. #7735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Mono.Android/Android.Content/Context.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Android.OS;
using Android.Runtime;

namespace Android.Content {
Expand All @@ -16,5 +17,14 @@ public void StartActivity (Type type)
[Obsolete ("This constant will be removed in the future version. Use Android.Content.ReceiverFlags enum directly instead of this field.")]
public const int ReceiverVisibleToInstantApps = 1;
#endif

#if ANDROID_34
// Add correctly enumified overloads
public Intent? RegisterReceiver (BroadcastReceiver? receiver, IntentFilter? filter, ReceiverFlags flags)
=> RegisterReceiver (receiver, filter, (ActivityFlags)flags);

public Intent? RegisterReceiver (BroadcastReceiver? receiver, IntentFilter? filter, string? broadcastPermission, Handler? scheduler, ReceiverFlags flags)
=> RegisterReceiver (receiver, filter, broadcastPermission, scheduler, (ActivityFlags)flags);
#endif
}
}
5 changes: 5 additions & 0 deletions src/Mono.Android/Mono.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@
<PropertyGroup>
<DefineConstants Condition=" '$(AndroidApiLevel)' &gt; '$(AndroidLatestStableApiLevel)' ">$(DefineConstants);ANDROID_UNSTABLE</DefineConstants>
<OutputPath>$(_MonoAndroidNETDefaultOutDir)</OutputPath>

<!-- Allow PublicApiAnalyzers to be turned off -->
<RunAnalyzers Condition=" '$(DisableApiCompatibilityCheck)' == 'True' ">false</RunAnalyzers>

<!-- PublicApiAnalyzers warnings should be errors, but building in VS throws incorrect extra warnings -->
<WarningsAsErrors Condition=" '$(BuildingInsideVisualStudio)' != 'True' ">$(WarningsAsErrors);RS0016,RS0017</WarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition=" '$(IncludeAndroidJavadoc)' == 'True' ">
Expand Down
2 changes: 2 additions & 0 deletions src/Mono.Android/PublicAPI/API-34/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8448,6 +8448,8 @@ Android.Content.Context.ObtainStyledAttributes(Android.Util.IAttributeSet? set,
Android.Content.Context.ObtainStyledAttributes(Android.Util.IAttributeSet? set, int[]! attrs, int defStyleAttr, int defStyleRes) -> Android.Content.Res.TypedArray!
Android.Content.Context.ObtainStyledAttributes(int resid, int[]! attrs) -> Android.Content.Res.TypedArray!
Android.Content.Context.ObtainStyledAttributes(int[]! attrs) -> Android.Content.Res.TypedArray!
Android.Content.Context.RegisterReceiver(Android.Content.BroadcastReceiver? receiver, Android.Content.IntentFilter? filter, Android.Content.ReceiverFlags flags) -> Android.Content.Intent?
Android.Content.Context.RegisterReceiver(Android.Content.BroadcastReceiver? receiver, Android.Content.IntentFilter? filter, string? broadcastPermission, Android.OS.Handler? scheduler, Android.Content.ReceiverFlags flags) -> Android.Content.Intent?
Android.Content.Context.StartActivity(System.Type! type) -> void
Android.Content.ContextParams
Android.Content.ContextParams.AttributionTag.get -> string?
Expand Down
8 changes: 8 additions & 0 deletions src/Mono.Android/metadata
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,14 @@

<!-- 2 conflicting copies of ErrorEventArgs -->
<attr api-since="34" path="/api/package[@name='android.speech']/interface[@name='ModelDownloadListener']/method[@name='onError' and count(parameter)=1 and parameter[1][@type='int']]" name="argsType">ModelDownloadErrorEventArgs</attr>

<!-- Fix some incorrectly enumified methods -->
<attr api-since="34" path="/api/package[@name='android.content']/class[@name='Context']/method[@name='registerReceiver' and count(parameter)=3 and parameter[1][@type='android.content.BroadcastReceiver'] and parameter[2][@type='android.content.IntentFilter'] and parameter[3][@type='int']]" name="deprecated">This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead.</attr>
<attr api-since="34" path="/api/package[@name='android.content']/class[@name='Context']/method[@name='registerReceiver' and count(parameter)=5 and parameter[1][@type='android.content.BroadcastReceiver'] and parameter[2][@type='android.content.IntentFilter'] and parameter[3][@type='java.lang.String'] and parameter[4][@type='android.os.Handler'] and parameter[5][@type='int']]" name="deprecated">This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead.</attr>
<attr api-since="34" path="/api/package[@name='android.content']/class[@name='ContextWrapper']/method[@name='registerReceiver' and count(parameter)=3 and parameter[1][@type='android.content.BroadcastReceiver'] and parameter[2][@type='android.content.IntentFilter'] and parameter[3][@type='int']]" name="deprecated">This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead.</attr>
<attr api-since="34" path="/api/package[@name='android.content']/class[@name='ContextWrapper']/method[@name='registerReceiver' and count(parameter)=5 and parameter[1][@type='android.content.BroadcastReceiver'] and parameter[2][@type='android.content.IntentFilter'] and parameter[3][@type='java.lang.String'] and parameter[4][@type='android.os.Handler'] and parameter[5][@type='int']]" name="deprecated">This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead.</attr>
<attr api-since="34" path="/api/package[@name='android.test.mock']/class[@name='MockContext']/method[@name='registerReceiver' and count(parameter)=3 and parameter[1][@type='android.content.BroadcastReceiver'] and parameter[2][@type='android.content.IntentFilter'] and parameter[3][@type='int']]" name="deprecated">This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead.</attr>
<attr api-since="34" path="/api/package[@name='android.test.mock']/class[@name='MockContext']/method[@name='registerReceiver' and count(parameter)=5 and parameter[1][@type='android.content.BroadcastReceiver'] and parameter[2][@type='android.content.IntentFilter'] and parameter[3][@type='java.lang.String'] and parameter[4][@type='android.os.Handler'] and parameter[5][@type='int']]" name="deprecated">This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead.</attr>

<!--
***********************************************************************
Expand Down