mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 21:05:36 +00:00
Bug 1029386: Asynchronous authentification in Bluedroid, r=shuang
This commit is contained in:
parent
d03babe552
commit
ae8327a31e
@ -752,19 +752,33 @@ BluetoothInterface::CancelBond(const bt_bdaddr_t* aBdAddr,
|
||||
|
||||
/* Authentication */
|
||||
|
||||
int
|
||||
void
|
||||
BluetoothInterface::PinReply(const bt_bdaddr_t* aBdAddr, uint8_t aAccept,
|
||||
uint8_t aPinLen, bt_pin_code_t* aPinCode)
|
||||
uint8_t aPinLen, bt_pin_code_t* aPinCode,
|
||||
BluetoothResultHandler* aRes)
|
||||
{
|
||||
return mInterface->pin_reply(aBdAddr, aAccept, aPinLen, aPinCode);
|
||||
int status = mInterface->pin_reply(aBdAddr, aAccept, aPinLen, aPinCode);
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothResult(aRes,
|
||||
&BluetoothResultHandler::PinReply,
|
||||
status);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
BluetoothInterface::SspReply(const bt_bdaddr_t* aBdAddr,
|
||||
bt_ssp_variant_t aVariant,
|
||||
uint8_t aAccept, uint32_t aPasskey)
|
||||
uint8_t aAccept, uint32_t aPasskey,
|
||||
BluetoothResultHandler* aRes)
|
||||
{
|
||||
return mInterface->ssp_reply(aBdAddr, aVariant, aAccept, aPasskey);
|
||||
int status = mInterface->ssp_reply(aBdAddr, aVariant, aAccept, aPasskey);
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothResult(aRes,
|
||||
&BluetoothResultHandler::SspReply,
|
||||
status);
|
||||
}
|
||||
}
|
||||
|
||||
/* DUT Mode */
|
||||
|
@ -277,11 +277,13 @@ public:
|
||||
|
||||
/* Authentication */
|
||||
|
||||
int PinReply(const bt_bdaddr_t* aBdAddr, uint8_t aAccept,
|
||||
uint8_t aPinLen, bt_pin_code_t* aPinCode);
|
||||
void PinReply(const bt_bdaddr_t* aBdAddr, uint8_t aAccept,
|
||||
uint8_t aPinLen, bt_pin_code_t* aPinCode,
|
||||
BluetoothResultHandler* aRes);
|
||||
|
||||
int SspReply(const bt_bdaddr_t* aBdAddr, bt_ssp_variant_t aVariant,
|
||||
uint8_t aAccept, uint32_t aPasskey);
|
||||
void SspReply(const bt_bdaddr_t* aBdAddr, bt_ssp_variant_t aVariant,
|
||||
uint8_t aAccept, uint32_t aPasskey,
|
||||
BluetoothResultHandler* aRes);
|
||||
|
||||
/* DUT Mode */
|
||||
|
||||
|
@ -1365,6 +1365,27 @@ BluetoothServiceBluedroid::RemoveDeviceInternal(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class PinReplyResultHandler MOZ_FINAL : public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
PinReplyResultHandler(BluetoothReplyRunnable* aRunnable)
|
||||
: mRunnable(aRunnable)
|
||||
{ }
|
||||
|
||||
void PinReply() MOZ_OVERRIDE
|
||||
{
|
||||
DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString());
|
||||
}
|
||||
|
||||
void OnError(int aStatus) MOZ_OVERRIDE
|
||||
{
|
||||
ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("SetPinCode"));
|
||||
}
|
||||
|
||||
private:
|
||||
BluetoothReplyRunnable* mRunnable;
|
||||
};
|
||||
|
||||
bool
|
||||
BluetoothServiceBluedroid::SetPinCodeInternal(
|
||||
const nsAString& aDeviceAddress, const nsAString& aPinCode,
|
||||
@ -1377,15 +1398,10 @@ BluetoothServiceBluedroid::SetPinCodeInternal(
|
||||
bt_bdaddr_t remoteAddress;
|
||||
StringToBdAddressType(aDeviceAddress, &remoteAddress);
|
||||
|
||||
int ret = sBtInterface->PinReply(
|
||||
&remoteAddress, true, aPinCode.Length(),
|
||||
(bt_pin_code_t*)NS_ConvertUTF16toUTF8(aPinCode).get());
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
ReplyStatusError(aRunnable, ret, NS_LITERAL_STRING("SetPinCode"));
|
||||
} else {
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
|
||||
}
|
||||
sBtInterface->PinReply(
|
||||
&remoteAddress, true, aPinCode.Length(),
|
||||
(bt_pin_code_t*)NS_ConvertUTF16toUTF8(aPinCode).get(),
|
||||
new PinReplyResultHandler(aRunnable));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1398,6 +1414,28 @@ BluetoothServiceBluedroid::SetPasskeyInternal(
|
||||
return true;
|
||||
}
|
||||
|
||||
class SspReplyResultHandler MOZ_FINAL : public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
SspReplyResultHandler(BluetoothReplyRunnable* aRunnable)
|
||||
: mRunnable(aRunnable)
|
||||
{ }
|
||||
|
||||
void SspReply() MOZ_OVERRIDE
|
||||
{
|
||||
DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString());
|
||||
}
|
||||
|
||||
void OnError(int aStatus) MOZ_OVERRIDE
|
||||
{
|
||||
ReplyStatusError(mRunnable, aStatus,
|
||||
NS_LITERAL_STRING("SetPairingConfirmation"));
|
||||
}
|
||||
|
||||
private:
|
||||
BluetoothReplyRunnable* mRunnable;
|
||||
};
|
||||
|
||||
bool
|
||||
BluetoothServiceBluedroid::SetPairingConfirmationInternal(
|
||||
const nsAString& aDeviceAddress, bool aConfirm,
|
||||
@ -1410,15 +1448,8 @@ BluetoothServiceBluedroid::SetPairingConfirmationInternal(
|
||||
bt_bdaddr_t remoteAddress;
|
||||
StringToBdAddressType(aDeviceAddress, &remoteAddress);
|
||||
|
||||
int ret = sBtInterface->SspReply(&remoteAddress, (bt_ssp_variant_t)0,
|
||||
aConfirm, 0);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
ReplyStatusError(aRunnable, ret,
|
||||
NS_LITERAL_STRING("SetPairingConfirmation"));
|
||||
} else {
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
|
||||
}
|
||||
|
||||
sBtInterface->SspReply(&remoteAddress, (bt_ssp_variant_t)0, aConfirm, 0,
|
||||
new SspReplyResultHandler(aRunnable));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user