Bug 1132343 - Patch1: Add accept/reject method in BluetoothPairingHandle interface for supporting consent and displaypasskey pairing requests. r=shuang, r=mrbkap

This commit is contained in:
Jocelyn Liu 2015-04-08 13:49:14 +08:00
parent 7c39df3da3
commit 99a5de2460
24 changed files with 327 additions and 88 deletions

View File

@ -953,7 +953,7 @@ public:
const nsAString& aPinCode,
BluetoothResultHandler* aRes) = 0;
virtual void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
virtual void SspReply(const nsAString& aBdAddr, BluetoothSspVariant aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes) = 0;

View File

@ -75,7 +75,7 @@ BluetoothPairingHandle::SetPinCode(const nsAString& aPinCode, ErrorResult& aRv)
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
BT_ENSURE_TRUE_REJECT(mType.EqualsLiteral("enterpincodereq"),
BT_ENSURE_TRUE_REJECT(mType.EqualsLiteral(PAIRING_REQ_TYPE_ENTERPINCODE),
NS_ERROR_DOM_INVALID_STATE_ERR);
BluetoothService* bs = BluetoothService::Get();
@ -85,13 +85,13 @@ BluetoothPairingHandle::SetPinCode(const nsAString& aPinCode, ErrorResult& aRv)
new BluetoothVoidReplyRunnable(nullptr /* DOMRequest */,
promise,
NS_LITERAL_STRING("SetPinCode"));
bs->SetPinCodeInternal(mDeviceAddress, aPinCode, result);
bs->PinReplyInternal(mDeviceAddress, true /* accept */, aPinCode, result);
return promise.forget();
}
already_AddRefed<Promise>
BluetoothPairingHandle::SetPairingConfirmation(bool aConfirm, ErrorResult& aRv)
BluetoothPairingHandle::Accept(ErrorResult& aRv)
{
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
if (!global) {
@ -102,24 +102,79 @@ BluetoothPairingHandle::SetPairingConfirmation(bool aConfirm, ErrorResult& aRv)
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
BT_ENSURE_TRUE_REJECT(mType.EqualsLiteral("pairingconfirmationreq"),
BT_ENSURE_TRUE_REJECT(mType.EqualsLiteral(PAIRING_REQ_TYPE_CONFIRMATION) ||
mType.EqualsLiteral(PAIRING_REQ_TYPE_CONSENT),
NS_ERROR_DOM_INVALID_STATE_ERR);
BluetoothService* bs = BluetoothService::Get();
BT_ENSURE_TRUE_REJECT(bs, NS_ERROR_NOT_AVAILABLE);
BluetoothSspVariant variant;
BT_ENSURE_TRUE_REJECT(GetSspVariant(variant), NS_ERROR_DOM_OPERATION_ERR);
nsRefPtr<BluetoothReplyRunnable> result =
new BluetoothVoidReplyRunnable(nullptr /* DOMRequest */,
promise,
NS_LITERAL_STRING("Accept"));
bs->SspReplyInternal(
mDeviceAddress, variant, true /* aAccept */, result);
return promise.forget();
}
already_AddRefed<Promise>
BluetoothPairingHandle::Reject(ErrorResult& aRv)
{
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
if (!global) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
BluetoothService* bs = BluetoothService::Get();
BT_ENSURE_TRUE_REJECT(bs, NS_ERROR_NOT_AVAILABLE);
nsRefPtr<BluetoothReplyRunnable> result =
new BluetoothVoidReplyRunnable(nullptr /* DOMRequest */,
promise,
NS_LITERAL_STRING(
"SetPairingConfirmation"));
NS_LITERAL_STRING("Reject"));
if (mType.EqualsLiteral(PAIRING_REQ_TYPE_ENTERPINCODE)) { // Pin request
bs->PinReplyInternal(
mDeviceAddress, false /* aAccept */, EmptyString(), result);
} else { // Ssp request
BluetoothSspVariant variant;
BT_ENSURE_TRUE_REJECT(GetSspVariant(variant), NS_ERROR_DOM_OPERATION_ERR);
bs->SspReplyInternal(
mDeviceAddress, variant, false /* aAccept */, result);
}
bs->SetPairingConfirmationInternal(mDeviceAddress,
aConfirm,
result);
return promise.forget();
}
bool
BluetoothPairingHandle::GetSspVariant(BluetoothSspVariant& aVariant)
{
if (mType.EqualsLiteral(PAIRING_REQ_TYPE_DISPLAYPASSKEY)) {
aVariant = BluetoothSspVariant::SSP_VARIANT_PASSKEY_NOTIFICATION;
} else if (mType.EqualsLiteral(PAIRING_REQ_TYPE_CONFIRMATION)) {
aVariant = BluetoothSspVariant::SSP_VARIANT_PASSKEY_CONFIRMATION;
} else if (mType.EqualsLiteral(PAIRING_REQ_TYPE_CONSENT)) {
aVariant = BluetoothSspVariant::SSP_VARIANT_CONSENT;
} else {
BT_LOGR("Invalid SSP variant name: %s",
NS_ConvertUTF16toUTF8(mType).get());
aVariant = SSP_VARIANT_PASSKEY_CONFIRMATION; // silences compiler warning
return false;
}
return true;
}
JSObject*
BluetoothPairingHandle::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)

View File

@ -47,11 +47,15 @@ public:
aPasskey = mPasskey;
}
// Reply to the enterpincodereq pairing request
already_AddRefed<Promise>
SetPinCode(const nsAString& aPinCode, ErrorResult& aRv);
already_AddRefed<Promise>
SetPairingConfirmation(bool aConfirm, ErrorResult& aRv);
// Accept the pairingconfirmationreq or pairingconsentreq pairing request
already_AddRefed<Promise> Accept(ErrorResult& aRv);
// Reject the pairing request
already_AddRefed<Promise> Reject(ErrorResult& aRv);
private:
BluetoothPairingHandle(nsPIDOMWindow* aOwner,
@ -60,6 +64,15 @@ private:
const nsAString& aPasskey);
~BluetoothPairingHandle();
/**
* Map mType into a BluetoothSspVariant enum value.
*
* @param aVariant [out] BluetoothSspVariant value mapped from mType.
* @return a boolean value to indicate whether mType can map into a
* BluetoothSspVariant value.
*/
bool GetSspVariant(BluetoothSspVariant& aVariant);
nsCOMPtr<nsPIDOMWindow> mOwner;
nsString mDeviceAddress;
nsString mType;

View File

@ -236,13 +236,35 @@ public:
BluetoothProfileManagerBase* aManager) = 0;
virtual void
SetPinCodeInternal(const nsAString& aDeviceAddress, const nsAString& aPinCode,
PinReplyInternal(const nsAString& aDeviceAddress,
bool aAccept,
const nsAString& aPinCode,
BluetoothReplyRunnable* aRunnable) = 0;
virtual void
SspReplyInternal(const nsAString& aDeviceAddress,
BluetoothSspVariant aVariant,
bool aAccept,
BluetoothReplyRunnable* aRunnable) = 0;
/**
* Legacy method used by bluez only to reply pincode request.
*/
virtual void
SetPinCodeInternal(const nsAString& aDeviceAddress,
const nsAString& aPinCode,
BluetoothReplyRunnable* aRunnable) = 0;
/**
* Legacy method used by bluez only to reply passkey entry request.
*/
virtual void
SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey,
BluetoothReplyRunnable* aRunnable) = 0;
/**
* Legacy method used by bluez only to reply pairing confirmation request.
*/
virtual void
SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm,
BluetoothReplyRunnable* aRunnable) = 0;

View File

@ -583,25 +583,6 @@ Convert(const nsAString& aIn, BluetoothServiceName& aOut)
return NS_OK;
}
nsresult
Convert(const nsAString& aIn, BluetoothSspVariant& aOut)
{
if (aIn.EqualsLiteral("PasskeyConfirmation")) {
aOut = SSP_VARIANT_PASSKEY_CONFIRMATION;
} else if (aIn.EqualsLiteral("PasskeyEntry")) {
aOut = SSP_VARIANT_PASSKEY_ENTRY;
} else if (aIn.EqualsLiteral("Consent")) {
aOut = SSP_VARIANT_CONSENT;
} else if (aIn.EqualsLiteral("PasskeyNotification")) {
aOut = SSP_VARIANT_PASSKEY_NOTIFICATION;
} else {
BT_LOGR("Invalid SSP variant name: %s", NS_ConvertUTF16toUTF8(aIn).get());
aOut = SSP_VARIANT_PASSKEY_CONFIRMATION; // silences compiler warning
return NS_ERROR_ILLEGAL_VALUE;
}
return NS_OK;
}
nsresult
Convert(BluetoothAclState aIn, bool& aOut)
{

View File

@ -221,9 +221,6 @@ Convert(const nsAString& aIn, BluetoothPropertyType& aOut);
nsresult
Convert(const nsAString& aIn, BluetoothServiceName& aOut);
nsresult
Convert(const nsAString& aIn, BluetoothSspVariant& aOut);
nsresult
Convert(BluetoothAclState aIn, bool& aOut);

View File

@ -569,7 +569,7 @@ public:
return rv;
}
nsresult SspReplyCmd(const nsAString& aBdAddr, const nsAString& aVariant,
nsresult SspReplyCmd(const nsAString& aBdAddr, BluetoothSspVariant aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes)
{
@ -580,8 +580,7 @@ public:
nsresult rv = PackPDU(
PackConversion<nsAString, BluetoothAddress>(aBdAddr),
PackConversion<nsAString, BluetoothSspVariant>(aVariant),
aAccept, aPasskey, *pdu);
aVariant, aAccept, aPasskey, *pdu);
if (NS_FAILED(rv)) {
return rv;
}
@ -2420,7 +2419,7 @@ BluetoothDaemonInterface::PinReply(const nsAString& aBdAddr, bool aAccept,
void
BluetoothDaemonInterface::SspReply(const nsAString& aBdAddr,
const nsAString& aVariant,
BluetoothSspVariant aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes)
{

View File

@ -83,7 +83,7 @@ public:
const nsAString& aPinCode,
BluetoothResultHandler* aRes);
void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
void SspReply(const nsAString& aBdAddr, BluetoothSspVariant aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes);

View File

@ -80,25 +80,6 @@ Convert(const nsAString& aIn, bt_bdaddr_t& aOut)
return NS_OK;
}
nsresult
Convert(const nsAString& aIn, bt_ssp_variant_t& aOut)
{
if (aIn.EqualsLiteral("PasskeyConfirmation")) {
aOut = BT_SSP_VARIANT_PASSKEY_CONFIRMATION;
} else if (aIn.EqualsLiteral("PasskeyEntry")) {
aOut = BT_SSP_VARIANT_PASSKEY_ENTRY;
} else if (aIn.EqualsLiteral("Consent")) {
aOut = BT_SSP_VARIANT_CONSENT;
} else if (aIn.EqualsLiteral("PasskeyNotification")) {
aOut = BT_SSP_VARIANT_PASSKEY_NOTIFICATION;
} else {
BT_LOGR("Invalid SSP variant name: %s", NS_ConvertUTF16toUTF8(aIn).get());
aOut = BT_SSP_VARIANT_PASSKEY_CONFIRMATION; // silences compiler warning
return NS_ERROR_ILLEGAL_VALUE;
}
return NS_OK;
}
nsresult
Convert(const uint8_t aIn[16], bt_uuid_t& aOut)
{

View File

@ -110,9 +110,6 @@ Convert(ConvertNamedValue& aIn, bt_property_t& aOut);
nsresult
Convert(const nsAString& aIn, bt_bdaddr_t& aOut);
nsresult
Convert(const nsAString& aIn, bt_ssp_variant_t& aOut);
inline nsresult
Convert(const bt_ssp_variant_t& aIn, BluetoothSspVariant& aOut)
{
@ -131,6 +128,24 @@ Convert(const bt_ssp_variant_t& aIn, BluetoothSspVariant& aOut)
return NS_OK;
}
inline nsresult
Convert(const BluetoothSspVariant& aIn, bt_ssp_variant_t& aOut)
{
static const bt_ssp_variant_t sSspVariant[] = {
CONVERT(SSP_VARIANT_PASSKEY_CONFIRMATION,
BT_SSP_VARIANT_PASSKEY_CONFIRMATION),
CONVERT(SSP_VARIANT_PASSKEY_ENTRY, BT_SSP_VARIANT_PASSKEY_ENTRY),
CONVERT(SSP_VARIANT_CONSENT, BT_SSP_VARIANT_CONSENT),
CONVERT(SSP_VARIANT_PASSKEY_NOTIFICATION,
BT_SSP_VARIANT_PASSKEY_NOTIFICATION)
};
if (aIn >= MOZ_ARRAY_LENGTH(sSspVariant)) {
return NS_ERROR_ILLEGAL_VALUE;
}
aOut = sSspVariant[aIn];
return NS_OK;
}
inline nsresult
Convert(const bool& aIn, uint8_t& aOut)
{

View File

@ -769,7 +769,7 @@ BluetoothHALInterface::PinReply(const nsAString& aBdAddr, bool aAccept,
void
BluetoothHALInterface::SspReply(const nsAString& aBdAddr,
const nsAString& aVariant,
BluetoothSspVariant aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes)
{

View File

@ -69,7 +69,7 @@ public:
const nsAString& aPinCode,
BluetoothResultHandler* aRes);
void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
void SspReply(const nsAString& aBdAddr, BluetoothSspVariant aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes);

View File

@ -768,25 +768,18 @@ private:
};
void
BluetoothServiceBluedroid::SetPinCodeInternal(
const nsAString& aDeviceAddress, const nsAString& aPinCode,
BluetoothReplyRunnable* aRunnable)
BluetoothServiceBluedroid::PinReplyInternal(
const nsAString& aDeviceAddress, bool aAccept,
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
sBtInterface->PinReply(aDeviceAddress, true, aPinCode,
new PinReplyResultHandler(aRunnable));
sBtInterface->PinReply(aDeviceAddress, aAccept, aPinCode,
new PinReplyResultHandler(aRunnable));
}
void
BluetoothServiceBluedroid::SetPasskeyInternal(
const nsAString& aDeviceAddress, uint32_t aPasskey,
BluetoothReplyRunnable* aRunnable)
{
return;
}
class BluetoothServiceBluedroid::SspReplyResultHandler final
: public BluetoothResultHandler
@ -811,19 +804,43 @@ private:
};
void
BluetoothServiceBluedroid::SetPairingConfirmationInternal(
const nsAString& aDeviceAddress, bool aConfirm,
BluetoothReplyRunnable* aRunnable)
BluetoothServiceBluedroid::SspReplyInternal(
const nsAString& aDeviceAddress, BluetoothSspVariant aVariant,
bool aAccept, BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
sBtInterface->SspReply(aDeviceAddress,
NS_ConvertUTF8toUTF16("PasskeyConfirmation"),
aConfirm, 0, new SspReplyResultHandler(aRunnable));
sBtInterface->SspReply(aDeviceAddress, aVariant, aAccept, 0 /* passkey */,
new SspReplyResultHandler(aRunnable));
}
void
BluetoothServiceBluedroid::SetPinCodeInternal(
const nsAString& aDeviceAddress, const nsAString& aPinCode,
BluetoothReplyRunnable* aRunnable)
{
// Legacy method used by bluez only.
}
void
BluetoothServiceBluedroid::SetPasskeyInternal(
const nsAString& aDeviceAddress, uint32_t aPasskey,
BluetoothReplyRunnable* aRunnable)
{
// Legacy method used by bluez only.
}
void
BluetoothServiceBluedroid::SetPairingConfirmationInternal(
const nsAString& aDeviceAddress, bool aConfirm,
BluetoothReplyRunnable* aRunnable)
{
// Legacy method used by bluez only.
}
void
BluetoothServiceBluedroid::NextBluetoothProfileController()
{

View File

@ -81,15 +81,30 @@ public:
BluetoothReplyRunnable* aRunnable);
virtual void
SetPinCodeInternal(const nsAString& aDeviceAddress, const nsAString& aPinCode,
PinReplyInternal(const nsAString& aDeviceAddress,
bool aAccept,
const nsAString& aPinCode,
BluetoothReplyRunnable* aRunnable);
virtual void
SspReplyInternal(const nsAString& aDeviceAddress,
BluetoothSspVariant aVariant,
bool aAccept,
BluetoothReplyRunnable* aRunnable);
virtual void
SetPinCodeInternal(const nsAString& aDeviceAddress,
const nsAString& aPinCode,
BluetoothReplyRunnable* aRunnable);
virtual void
SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey,
SetPasskeyInternal(const nsAString& aDeviceAddress,
uint32_t aPasskey,
BluetoothReplyRunnable* aRunnable);
virtual void
SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm,
SetPairingConfirmationInternal(const nsAString& aDeviceAddress,
bool aConfirm,
BluetoothReplyRunnable* aRunnable);
virtual void

View File

@ -4277,6 +4277,10 @@ BluetoothDBusService::UpdateNotification(ControlEventId aEventId,
DispatchToDBusThread(task);
}
//
// Methods for BT APIv2 implementation which currently only supports bluedroid
//
void
BluetoothDBusService::ConnectGattClientInternal(
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
@ -4309,3 +4313,17 @@ BluetoothDBusService::GattClientReadRemoteRssiInternal(
BluetoothReplyRunnable* aRunnable)
{
}
void
BluetoothDBusService::PinReplyInternal(
const nsAString& aDeviceAddress, bool aAccept,
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
{
}
void
BluetoothDBusService::SspReplyInternal(
const nsAString& aDeviceAddress, BluetoothSspVariant aVariant,
bool aAccept, BluetoothReplyRunnable* aRunnable)
{
}

View File

@ -94,7 +94,20 @@ public:
BluetoothReplyRunnable* aRunnable) override;
virtual void
SetPinCodeInternal(const nsAString& aDeviceAddress, const nsAString& aPinCode,
PinReplyInternal(const nsAString& aDeviceAddress,
bool aAccept,
const nsAString& aPinCode,
BluetoothReplyRunnable* aRunnable)
virtual void
SspReplyInternal(const nsAString& aDeviceAddress,
BluetoothSspVariant aVariant,
bool aAccept,
BluetoothReplyRunnable* aRunnable)
virtual void
SetPinCodeInternal(const nsAString& aDeviceAddress,
const nsAString& aPinCode,
BluetoothReplyRunnable* aRunnable) override;
virtual void
@ -102,7 +115,8 @@ public:
BluetoothReplyRunnable* aRunnable) override;
virtual void
SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm,
SetPairingConfirmationInternal(const nsAString& aDeviceAddress,
bool aConfirm,
BluetoothReplyRunnable* aRunnable) override;
virtual void

View File

@ -20,6 +20,14 @@ struct ParamTraits<mozilla::dom::bluetooth::BluetoothObjectType>
mozilla::dom::bluetooth::TYPE_INVALID>
{ };
template <>
struct ParamTraits<mozilla::dom::bluetooth::BluetoothSspVariant>
: public ContiguousEnumSerializer<
mozilla::dom::bluetooth::BluetoothSspVariant,
mozilla::dom::bluetooth::SSP_VARIANT_PASSKEY_CONFIRMATION,
mozilla::dom::bluetooth::SSP_VARIANT_PASSKEY_NOTIFICATION>
{ };
template <>
struct ParamTraits<mozilla::dom::bluetooth::BluetoothStatus>
: public ContiguousEnumSerializer<

View File

@ -212,6 +212,10 @@ BluetoothParent::RecvPBluetoothRequestConstructor(
return actor->DoRequest(aRequest.get_ConnectedDevicePropertiesRequest());
case Request::TFetchUuidsRequest:
return actor->DoRequest(aRequest.get_FetchUuidsRequest());
case Request::TPinReplyRequest:
return actor->DoRequest(aRequest.get_PinReplyRequest());
case Request::TSspReplyRequest:
return actor->DoRequest(aRequest.get_SspReplyRequest());
case Request::TSetPinCodeRequest:
return actor->DoRequest(aRequest.get_SetPinCodeRequest());
case Request::TSetPasskeyRequest:
@ -470,6 +474,34 @@ BluetoothRequestParent::DoRequest(const FetchUuidsRequest& aRequest)
return true;
}
bool
BluetoothRequestParent::DoRequest(const PinReplyRequest& aRequest)
{
MOZ_ASSERT(mService);
MOZ_ASSERT(mRequestType == Request::TPinReplyRequest);
mService->PinReplyInternal(aRequest.address(),
aRequest.accept(),
aRequest.pinCode(),
mReplyRunnable.get());
return true;
}
bool
BluetoothRequestParent::DoRequest(const SspReplyRequest& aRequest)
{
MOZ_ASSERT(mService);
MOZ_ASSERT(mRequestType == Request::TSspReplyRequest);
mService->SspReplyInternal(aRequest.address(),
aRequest.variant(),
aRequest.accept(),
mReplyRunnable.get());
return true;
}
bool
BluetoothRequestParent::DoRequest(const SetPinCodeRequest& aRequest)
{

View File

@ -173,6 +173,12 @@ protected:
bool
DoRequest(const DenyPairingConfirmationRequest& aRequest);
bool
DoRequest(const PinReplyRequest& aRequest);
bool
DoRequest(const SspReplyRequest& aRequest);
bool
DoRequest(const ConnectRequest& aRequest);

View File

@ -208,6 +208,28 @@ BluetoothServiceChildProcess::UpdateSdpRecords(const nsAString& aDeviceAddress,
MOZ_CRASH("This should never be called!");
}
void
BluetoothServiceChildProcess::PinReplyInternal(
const nsAString& aDeviceAddress, bool aAccept,
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
{
SendRequest(aRunnable,
PinReplyRequest(nsString(aDeviceAddress),
aAccept,
nsString(aPinCode)));
}
void
BluetoothServiceChildProcess::SspReplyInternal(
const nsAString& aDeviceAddress, BluetoothSspVariant aVariant,
bool aAccept, BluetoothReplyRunnable* aRunnable)
{
SendRequest(aRunnable,
SspReplyRequest(nsString(aDeviceAddress),
aVariant,
aAccept));
}
void
BluetoothServiceChildProcess::SetPinCodeInternal(
const nsAString& aDeviceAddress,

View File

@ -110,6 +110,18 @@ public:
BluetoothReplyRunnable* aRunnable)
override;
virtual void
PinReplyInternal(const nsAString& aDeviceAddress,
bool aAccept,
const nsAString& aPinCode,
BluetoothReplyRunnable* aRunnable) override;
virtual void
SspReplyInternal(const nsAString& aDeviceAddress,
BluetoothSspVariant aVariant,
bool aAccept,
BluetoothReplyRunnable* aRunnable) override;
virtual void
Connect(const nsAString& aDeviceAddress,
uint32_t aCod,

View File

@ -8,6 +8,8 @@ using mozilla::dom::bluetooth::BluetoothGattId
from "mozilla/dom/bluetooth/BluetoothCommon.h";
using mozilla::dom::bluetooth::BluetoothGattServiceId
from "mozilla/dom/bluetooth/BluetoothCommon.h";
using mozilla::dom::bluetooth::BluetoothSspVariant
from "mozilla/dom/bluetooth/BluetoothCommon.h";
using mozilla::dom::bluetooth::BluetoothStatus
from "mozilla/dom/bluetooth/BluetoothCommon.h";

View File

@ -64,6 +64,20 @@ struct UnpairRequest
nsString address;
};
struct PinReplyRequest
{
nsString address;
bool accept;
nsString pinCode;
};
struct SspReplyRequest
{
nsString address;
BluetoothSspVariant variant;
bool accept;
};
struct SetPinCodeRequest
{
nsString path;
@ -215,6 +229,8 @@ union Request
StopDiscoveryRequest;
PairRequest;
UnpairRequest;
PinReplyRequest;
SspReplyRequest;
SetPinCodeRequest;
SetPasskeyRequest;
ConfirmPairingConfirmationRequest;

View File

@ -13,8 +13,22 @@ interface BluetoothPairingHandle
*/
readonly attribute DOMString passkey;
/**
* Reply pin code for enterpincodereq. The promise will be rejected if the
* pairing request type is not enterpincodereq or operation fails.
*/
[NewObject]
Promise<void> setPinCode(DOMString aPinCode);
/**
* Accept pairing requests. The promise will be rejected if the pairing
* request type is not pairingconfirmationreq or pairingconsentreq or
* operation fails.
*/
[NewObject]
Promise<void> setPairingConfirmation(boolean aConfirm);
Promise<void> accept();
// Reject pairing requests. The promise will be rejected if operation fails.
[NewObject]
Promise<void> reject();
};