Skip to content

Commit

Permalink
fix: some more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed May 17, 2024
1 parent 50b1738 commit 44146c9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
2 changes: 1 addition & 1 deletion GalaxyBudsClient.Platform.WindowsRT/BluetoothDeviceRT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace GalaxyBudsClient.Platform.WindowsRT
{
internal class BluetoothDeviceRt(DeviceInformation info, IEnumerable<Guid> services) : BluetoothDevice(0)
internal class BluetoothDeviceRt(DeviceInformation info, IEnumerable<Guid>? services) : BluetoothDevice(0)
{
public DeviceInformation DeviceInfo { get; } = info;
private IEnumerable<Guid>? _services = services;
Expand Down
10 changes: 1 addition & 9 deletions GalaxyBudsClient.Platform.WindowsRT/BluetoothService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
#if Windows
using Windows.Devices.Bluetooth;
#endif
using Windows.Devices.Bluetooth.Rfcomm;
using Windows.Devices.Enumeration;
using Windows.Networking.Sockets;
Expand Down Expand Up @@ -34,9 +32,7 @@ public class BluetoothService : IBluetoothService
private StreamSocket? _socket;
private DataWriter? _writer;
private RfcommDeviceService? _service;
#if Windows
private global::Windows.Devices.Bluetooth.BluetoothDevice? _bluetoothDevice;
#endif

private Task? _loop;
private CancellationTokenSource _readerCancellation = new();
Expand Down Expand Up @@ -84,8 +80,7 @@ public BluetoothService()
_deviceCache.Add(new BluetoothDeviceRt(deviceInfo, knownServices));
}
};

#if Windows

_deviceWatcher.Updated += async (watcher, deviceInfoUpdate) =>
{
Log.Debug("WindowsRT.BluetoothService: Device updated: {Id}", deviceInfoUpdate?.Id);
Expand Down Expand Up @@ -140,7 +135,6 @@ await ConnectAsync(x.Address,
});
_deviceCache?.RemoveWhere(x => x?.Id == deviceInfoUpdate?.Id);
};
#endif

_deviceWatcher.EnumerationCompleted += (watcher, obj) =>
{
Expand Down Expand Up @@ -214,7 +208,6 @@ public async Task ConnectAsync(string macAddress, string serviceUuid, Cancellati
return;
}

#if Windows
// If not, try to get the Bluetooth device
try
{
Expand Down Expand Up @@ -295,7 +288,6 @@ public async Task ConnectAsync(string macAddress, string serviceUuid, Cancellati
"Target address already in use. Only one app can talk to the Galaxy Buds at a time. " +
"Please make sure to close duplicate instances of this app and close all applications that are interacting with the configuration protocol of the earbuds, such as Samsung's official app."));
}
#endif
}
catch (Exception ex)
{
Expand Down
4 changes: 0 additions & 4 deletions GalaxyBudsClient.Platform.WindowsRT/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;

#if Windows
using System.Text.RegularExpressions;
using Windows.Devices.Bluetooth;
#endif

namespace GalaxyBudsClient.Platform.WindowsRT
{
Expand All @@ -16,13 +14,11 @@ public static byte[] ShrinkTo(this byte[] byteArray, int len)
return tmp;
}

#if Windows
public static string BluetoothAddressAsString(this BluetoothDevice dev)
{
return Regex.Replace(dev.BluetoothAddress.ToString("X12"),
"(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})",
"$1:$2:$3:$4:$5:$6");
}
#endif
}
}
3 changes: 2 additions & 1 deletion GalaxyBudsClient.Platform/Stubs/HotkeyReceiver.Dummy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public async Task ValidateHotkeyAsync(IHotkey hotkey)
Log.Warning("Dummy.HotkeyReceiver: Platform not supported");
}

#pragma warning disable CS0067
public event EventHandler<IHotkey>? HotkeyPressed;

#pragma warning restore CS0067
public void Dispose()
{

Expand Down

0 comments on commit 44146c9

Please sign in to comment.