Skip to content

Commit

Permalink
[Mono.Android] Android.Telecom.InCallService.SetAudioRoute() + enum (#…
Browse files Browse the repository at this point in the history
…7711)

Fixes: #2472

Context: xamarin/monodroid@ebb6d5d

Enumification of API-23 in xamarin/monodroid@ebb6d5df incorrectly
enumified [`android.telecom.InCallService.setAudioRoute(int)`][0],
enumifying the `int` parameter as `Android.Telecom.VideoQuality`
instead of `Android.Telecom.CallAudioRoute`.

Fix this by changing `src/Mono.Android/methodmap.csv` to use
`Android.Telecom.CallAudioRoute`, which results in the binding:

	namespace Android.Telecom {
	    partial class InCallServices {
	        [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android23.0")]
	        [Register ("setAudioRoute", "(I)V", "", ApiSince = 23)]
	        public unsafe void SetAudioRoute ([global::Android.Runtime.GeneratedEnum] Android.Telecom.CallAudioRoute route) => …
	    }
	}

For backwards compatibility, we need to add an `[Obsolete]` overload
containing the incorrect enumification:

	namespace Android.Telecom {
	    partial class InCallServices {
	        [Obsolete ("Incorrect enum parameter, use the overload that takes a CallAudioRoute paramter instead.")]
	        [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android23.0")]
	        public void SetAudioRoute ([global::Android.Runtime.GeneratedEnum] Android.Telecom.VideoQuality route) =>
	            SetAudioRoute ((CallAudioRoute) route);
	    }
	}

The change to `acceptable-breakages*.txt` is due to the `[Register]`
attribute being moved from the old overload to the corrected overload.

[0]: https://developer.android.com/reference/android/telecom/InCallService#setAudioRoute(int)
  • Loading branch information
jpobst authored Jan 18, 2023
1 parent 8cb94dc commit 639b216
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/Mono.Android/Android.Telecom/InCallService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using Android.Content;

namespace Android.Telecom
{
public abstract partial class InCallService : Android.App.Service
{
#if ANDROID_23
[Obsolete ("Incorrect enum parameter, use the overload that takes a CallAudioRoute paramter instead.")]
[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android23.0")]
public void SetAudioRoute ([global::Android.Runtime.GeneratedEnum] Android.Telecom.VideoQuality route)
{
SetAudioRoute ((CallAudioRoute) route);
}
#endif
}
}


1 change: 1 addition & 0 deletions src/Mono.Android/Mono.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<Compile Include="Android.Icu\DateIntervalFormat.cs" />
<Compile Include="Android.Runtime\DynamicMethodNameCounter.cs" />
<Compile Include="Android.Runtime\IJavaObjectValueMarshaler.cs" />
<Compile Include="Android.Telecom\InCallService.cs" />
</ItemGroup>

<Import Project="..\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.projitems" Label="Shared" Condition="Exists('..\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.projitems')" />
Expand Down
2 changes: 1 addition & 1 deletion src/Mono.Android/methodmap.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@
23, android.telecom, InCallService.VideoCall.Callback, onCallSessionEvent, event, Android.Telecom.VideoSessionEvent
23, android.telecom, InCallService.VideoCall.Callback, onSessionModifyResponseReceived, status, Android.Telecom.ModifyRequestResult
23, android.telecom, InCallService.VideoCall.Callback, onVideoQualityChanged, videoQuality, Android.Telecom.VideoQuality
23, android.telecom, InCallService, setAudioRoute, route, Android.Telecom.VideoQuality
23, android.telecom, InCallService, setAudioRoute, route, Android.Telecom.CallAudioRoute
23, android.telecom, PhoneAccount, hasCapabilities, capability, Android.Telecom.ConnectionCapability
23, android.telecom, PhoneAccount, getCapabilities, return, Android.Telecom.ConnectionCapability
23, android.telecom, RemoteConference, getConnectionCapabilities, return, Android.Telecom.ConnectionCapability
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3079,3 +3079,4 @@ CannotRemoveAttribute : Attribute 'System.ObsoleteAttribute' exists on 'Org.Apac
CannotRemoveAttribute : Attribute 'System.ObsoleteAttribute' exists on 'Org.Apache.Http.Conn.Ssl.SSLSocketFactory..ctor(Java.Security.KeyStore, System.String)' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.ObsoleteAttribute' exists on 'Org.Apache.Http.Conn.Ssl.SSLSocketFactory..ctor(Java.Security.KeyStore, System.String, Java.Security.KeyStore)' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.ObsoleteAttribute' exists on 'Org.Apache.Http.Conn.Ssl.SSLSocketFactory.CreateSocket(Java.Net.Socket, System.String, System.Int32, System.Boolean)' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'Android.Runtime.RegisterAttribute' exists on 'Android.Telecom.InCallService.SetAudioRoute(Android.Telecom.VideoQuality)' in the contract but not the implementation.
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Compat issues with assembly Mono.Android:
CannotRemoveAttribute : Attribute 'Android.Runtime.RegisterAttribute' exists on 'Android.Telecom.InCallService.SetAudioRoute(Android.Telecom.VideoQuality)' in the contract but not the implementation.

0 comments on commit 639b216

Please sign in to comment.