Skip to content

Commit

Permalink
Prompt enable bluetooth
Browse files Browse the repository at this point in the history
  • Loading branch information
ShortDevelopment committed Jan 5, 2024
1 parent 36ef0d3 commit 1bdb5fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Nearby Sharing Windows/AndroidBluetoothHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Nearby_Sharing_Windows;
public sealed class AndroidBluetoothHandler(BluetoothAdapter adapter, PhysicalAddress macAddress) : IBluetoothHandler
{
public BluetoothAdapter Adapter { get; } = adapter;

public bool IsEnabled => Adapter.IsEnabled;
public PhysicalAddress MacAddress { get; } = macAddress;

#region BLe Scan
Expand Down
7 changes: 7 additions & 0 deletions Nearby Sharing Windows/SendActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ private async void SendData(CdpDevice remoteSystem)
StatusTextView.Text = GetString(Resource.String.wait_for_acceptance);
try
{
if (remoteSystem.Endpoint.TransportType == CdpTransportType.Rfcomm &&
_cdp.TryGetTransport<BluetoothTransport>()?.Handler.IsEnabled == false)
{
StartActivityForResult(new Intent(BluetoothAdapter.ActionRequestEnable), 42);
throw new TaskCanceledException("Bluetooth is disabled");
}

Progress<NearShareProgress>? progress = null;

Task? transferPromise = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public interface IBluetoothHandler
Task ListenRfcommAsync(RfcommOptions options, CancellationToken cancellationToken = default);

PhysicalAddress MacAddress { get; }
bool IsEnabled => true;
}

0 comments on commit 1bdb5fe

Please sign in to comment.