Skip to content

Commit 04f545d

Browse files
committed
[Mono.Android] add backlash enumification fix on bug#5473 (BletoothGattServerCallback)
from xamarin/xamarin-android-api-compatibility#5 (comment)
1 parent 8125c0d commit 04f545d

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using Android.Runtime;
3+
4+
namespace Android.Bluetooth
5+
{
6+
// Proposed
7+
partial class BluetoothGattServerCallback
8+
{
9+
// Old and busted
10+
[Obsolete ("Use OnServiceAdded(Android.Bluetooth.GattStatus, Android.Bluetooth.BluetoothGattService)", true)]
11+
[Register ("onServiceAdded", "(ILandroid/bluetooth/BluetoothGattService;)V", "GetOnServiceAdded_ILandroid_bluetooth_BluetoothGattService_Handler_ext")]
12+
public virtual void OnServiceAdded (ProfileState status, BluetoothGattService service)
13+
{
14+
ActualOnServiceAdded (status, service);
15+
}
16+
17+
void ActualOnServiceAdded (ProfileState status, BluetoothGattService service)
18+
{
19+
this.OnServiceAdded ((GattStatus) (int) status, service);
20+
}
21+
22+
static Delegate cb_onServiceAdded_ILandroid_bluetooth_BluetoothGattService_ext;
23+
#pragma warning disable 0169
24+
static Delegate GetOnServiceAdded_ILandroid_bluetooth_BluetoothGattService_Handler_ext ()
25+
{
26+
if (cb_onServiceAdded_ILandroid_bluetooth_BluetoothGattService_ext == null)
27+
cb_onServiceAdded_ILandroid_bluetooth_BluetoothGattService_ext = JNINativeWrapper.CreateDelegate ((Action<IntPtr, IntPtr, int, IntPtr>) n_OnServiceAdded_ILandroid_bluetooth_BluetoothGattService_ext);
28+
return cb_onServiceAdded_ILandroid_bluetooth_BluetoothGattService_ext;
29+
}
30+
31+
static void n_OnServiceAdded_ILandroid_bluetooth_BluetoothGattService_ext (IntPtr jnienv, IntPtr native__this, int native_status, IntPtr native_service)
32+
{
33+
Android.Bluetooth.BluetoothGattServerCallback __this = global::Java.Lang.Object.GetObject<Android.Bluetooth.BluetoothGattServerCallback> (jnienv, native__this, JniHandleOwnership.DoNotTransfer);
34+
Android.Bluetooth.ProfileState status = (Android.Bluetooth.ProfileState) native_status;
35+
Android.Bluetooth.BluetoothGattService service = global::Java.Lang.Object.GetObject<Android.Bluetooth.BluetoothGattService> (native_service, JniHandleOwnership.DoNotTransfer);
36+
__this.ActualOnServiceAdded (status, service);
37+
}
38+
#pragma warning restore 0169
39+
}
40+
}

src/Mono.Android/Mono.Android.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
<Compile Include="Android.App\UsesPermissionAttribute.cs" />
122122
<Compile Include="Android.App.Admin\DevicePolicyManager.cs" />
123123
<Compile Include="Android.Bluetooth\BluetoothGattServer.cs" />
124+
<Compile Include="Android.Bluetooth\BluetoothGattServerCallback.cs" />
124125
<Compile Include="Android.Content\ContentProvider.cs" />
125126
<Compile Include="Android.Content\ContentValues.cs" />
126127
<Compile Include="Android.Content\Context.cs" />

0 commit comments

Comments
 (0)