Skip to content

Commit

Permalink
Check api versions
Browse files Browse the repository at this point in the history
  • Loading branch information
uholeschak committed Dec 20, 2024
1 parent 73384a1 commit 9d683ff
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions EdiabasLib/EdiabasLib/BtLeGattSpp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ public bool ConnectLeGattDevice(Context context, BluetoothDevice device)
_btGattSppInStream = new MemoryQueueBufferStream(true);
_btGattSppOutStream = new BGattOutputStream(this);
BGattBaseCallback bGattCallback = Build.VERSION.SdkInt >= BuildVersionCodes.Tiramisu ? new BGatt2Callback(this) : new BGatt1Callback(this);
#pragma warning disable CA1416
_bluetoothGatt = device.ConnectGatt(context, false, bGattCallback, BluetoothTransports.Le);
#pragma warning restore CA1416
if (_bluetoothGatt == null)
{
LogString("*** ConnectGatt failed");
Expand Down Expand Up @@ -309,7 +311,9 @@ public bool ConnectLeGattDevice(Context context, BluetoothDevice device)
byte[] enableNotifyArray = BluetoothGattDescriptor.EnableNotificationValue.ToArray();
if (Build.VERSION.SdkInt >= BuildVersionCodes.Tiramisu)
{
#pragma warning disable CA1416
if (_bluetoothGatt.WriteDescriptor(descriptor, enableNotifyArray) != (int) CurrentBluetoothStatusCodes.Success)
#pragma warning restore CA1416
{
LogString("*** GATT SPP write config descriptor failed");
return false;
Expand Down Expand Up @@ -646,6 +650,7 @@ public BGattOutputStream(BtLeGattSpp btLeGattSpp) : base(true)
_btLeGattSpp = btLeGattSpp;
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416: Validate platform compatibility")]
public override void Write(byte[] buffer, int offset, int count)
{
base.Write(buffer, offset, count);
Expand Down
1 change: 1 addition & 0 deletions EdiabasLib/EdiabasLib/EdBluetoothInterfaceAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ public override void OnReceive(Android.Content.Context context, Android.Content.

public static class AndroidExtensions
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416: Validate platform compatibility")]
public static T GetParcelableExtraType<T>(this Android.Content.Intent intent, string name)
{
object parcel;
Expand Down
2 changes: 2 additions & 0 deletions EdiabasLib/EdiabasLib/EdCustomWiFiInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public static bool InterfaceConnect(string port, object parameter, bool reconnec
{
Android.Net.NetworkCapabilities networkCapabilities = connectivityManager.GetNetworkCapabilities(network);
Android.Net.LinkProperties linkProperties = connectivityManager.GetLinkProperties(network);
#pragma warning disable CA1416
if (networkCapabilities != null && linkProperties != null && linkProperties.DhcpServerAddress != null)
{
if (networkCapabilities.TransportInfo is Android.Net.Wifi.WifiInfo)
Expand All @@ -201,6 +202,7 @@ public static bool InterfaceConnect(string port, object parameter, bool reconnec
}
}
}
#pragma warning restore CA1416
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions EdiabasLib/EdiabasLib/MemoryStreamReaderAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Android.OS;
// ReSharper disable ConvertPropertyToExpressionBody

Expand Down Expand Up @@ -344,6 +345,7 @@ private static Dictionary<string, string> GetDirDict(string dirName)
}
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416: Validate platform compatibility")]
private static string GetRealFileName(string filePath, bool enableNameEncoding)
{
if (File.Exists(filePath))
Expand Down Expand Up @@ -443,6 +445,7 @@ public DirectoryObserver(String rootPath)
{
}

[SupportedOSPlatform("android29.0")]
public DirectoryObserver(Java.IO.File rootPath)
: base(rootPath, Events)
{
Expand Down
1 change: 1 addition & 0 deletions EdiabasLib/EdiabasLib/TcpClientWithTimeout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public TcpClient Connect(System.Threading.ManualResetEvent resetEvent = null)
return _connection;
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416: Validate platform compatibility")]
public static void ExecuteNetworkCommand(ExecuteNetworkDelegate command, IPAddress ipAddr, object networkDataObject)
{
#if ANDROID
Expand Down
4 changes: 2 additions & 2 deletions EdiabasLib/EdiabasLibAndroidNet/EdiabasLibAndroidNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;CA1416</NoWarn>
<NoWarn>1701;1702</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<NoWarn>1701;1702;CA1416</NoWarn>
<NoWarn>1701;1702</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\EdiabasLib\BtLeGattSpp.cs" Link="BtLeGattSpp.cs" />
Expand Down

0 comments on commit 9d683ff

Please sign in to comment.