mDeviceState = BtDeviceState.Paired;
BtModel.NotifyDeviceChanged(this);
//BtModel.NotifyOperationStateChanged(BtOperationState.Activated);
+ if (mIsA2dpSupported)
+ {
+ Log.Info(SettingBluetooth.LogTag, "Automatically connect to the remote audio device after pairing");
+ ConnectAudio();
+ }
+ else if (mIsHidSupported)
+ {
+ Log.Info(SettingBluetooth.LogTag, "Automatically connect to the remote hid device after pairing");
+ ConnectHid();
+ }
}
else
{
foreach (BluetoothDevice device in devices)
{
Log.Info(SettingBluetooth.LogTag, "GetBondedDevices. Address: " + device.Address + ", Name: " + device.Name);
- btDevice = new BtDevice(device, BtDeviceState.Paired);
+ if (device.IsConnected)
+ {
+ btDevice = new BtDevice(device, BtDeviceState.Connected);
+ }
+ else
+ {
+ btDevice = new BtDevice(device, BtDeviceState.Paired);
+ }
args = new BtDeviceChangedEventArgs(btDevice);
mDeviceChanged?.Invoke(null, args);
}
protected override void OnDestroy()
{
Log.Info(LogTag, "OnDestroy");
+ if (BtModel.IsScanning)
+ {
+ BtModel.StopDiscovery();
+ }
base.OnDestroy();
}
if (mDeviceSource.FindInPaired(ev.BtDevice) == null)
{
mDeviceSource.AddToPaired(ev.BtDevice);
- if (ev.BtDevice.IsA2dpSupported)
- {
- DeviceController.ConnectA2dp(ev.BtDevice);
- }
}
else // audio disconnected case
{
mDeviceSource.AddToPaired(ev.BtDevice);
mDeviceSource.UpdateState(ev.BtDevice);
}
+ else
+ {
+ mDeviceSource.AddToPaired(ev.BtDevice);
+ }
break;
case BtDeviceState.Disconnecting:
if (mDeviceSource.FindInPaired(ev.BtDevice) != null)