Cannot find PairingParams.PAIRING_VARIANT_CONSENT in Xamarin.Android

Viewed 286

I have faced with issue that when pairing request happens I got the following PairingParams.PAIRING_VARIANT_CONSENT (= 3) pairing variant, but it is absent in ...

object obj = intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);
BluetoothDevice device = (obj as BluetoothDevice)!;
var extraPairingVariant = intent.GetIntExtra(BluetoothDevice.ExtraPairingVariant, 0);
switch (extraPairingVariant)
{
  case BluetoothDevice.PairingVariantPin:
  {
    ...
  }
    break;
  case BluetoothDevice.PairingVariantPasskeyConfirmation:
  {
    ...
  }
    break;
  case \* 3, what constant should be here ?? *\
  {
    ...
  }
    break;
}

... BluetoothDevice do not contain the something like PAIRING_VARIANT_CONSENT ...

Does somebody faced with the same issue ?

1 Answers

In my case I call abortBroadcast() to not show the pin dialog but only if the BluetoothDevice.ExtraPairingVariant is not 3. Otherwise a dialog must be shown for the user to accept the pairing. This state occurs when you remove the already paired device and ask to pair it again. (https://developer.android.com/reference/com/google/android/things/bluetooth/PairingParams.html#pairing_variant_consent)

BluetoothDevice device = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);
if (action == BluetoothDevice.ActionPairingRequest)
        {
            device.SetPin(System.Text.Encoding.UTF8.GetBytes("####"));
            int exraPairingVariant = intent.GetIntExtra(BluetoothDevice.ExtraPairingVariant, 0);
            if (exraPairingVariant == BluetoothDevice.PairingVariantPasskeyConfirmation || exraPairingVariant == BluetoothDevice.PairingVariantPin)
            {
                InvokeAbortBroadcast();
            }
        }
Related