Bug 1153796: Unify variants of |BluetoothInterface::SspReply|, r=btian

Bluetooth use different types for the second argument of their variant
of |BluetoothInterface::SspReply|. This patch standardizes them on the
v2 version.
This commit is contained in:
Thomas Zimmermann 2015-04-15 11:46:33 +02:00
parent e3df58001f
commit 2375784a70
10 changed files with 3 additions and 157 deletions

View File

@ -598,29 +598,6 @@ Convert(const nsAString& aIn, BluetoothServiceName& aOut)
return NS_OK;
}
#ifdef MOZ_B2G_BT_API_V2
// Removed in bluetooth2
#else
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;
}
#endif
nsresult
Convert(BluetoothAclState aIn, bool& aOut)
{
@ -962,22 +939,6 @@ Convert(BluetoothSspVariant aIn, uint8_t& aOut)
return NS_OK;
}
nsresult
Convert(BluetoothSspVariant aIn, nsAString& aOut)
{
static const char* const sString[] = {
CONVERT(SSP_VARIANT_PASSKEY_CONFIRMATION, "PasskeyConfirmation"),
CONVERT(SSP_VARIANT_PASSKEY_ENTRY, "PasskeyEntry"),
CONVERT(SSP_VARIANT_CONSENT, "Consent"),
CONVERT(SSP_VARIANT_PASSKEY_NOTIFICATION, "PasskeyNotification")
};
if (NS_WARN_IF(aIn >= MOZ_ARRAY_LENGTH(sString))) {
return NS_ERROR_ILLEGAL_VALUE;
}
aOut = NS_ConvertUTF8toUTF16(sString[aIn]);
return NS_OK;
}
nsresult
Convert(ControlPlayStatus aIn, uint8_t& aOut)
{

View File

@ -261,13 +261,6 @@ Convert(const nsAString& aIn, BluetoothPropertyType& aOut);
nsresult
Convert(const nsAString& aIn, BluetoothServiceName& aOut);
#ifdef MOZ_B2G_BT_API_V2
// Removed in bluetooth2
#else
nsresult
Convert(const nsAString& aIn, BluetoothSspVariant& aOut);
#endif
nsresult
Convert(BluetoothAclState aIn, bool& aOut);
@ -334,9 +327,6 @@ Convert(BluetoothSocketType aIn, uint8_t& aOut);
nsresult
Convert(BluetoothSspVariant aIn, uint8_t& aOut);
nsresult
Convert(BluetoothSspVariant aIn, nsAString& aOut);
nsresult
Convert(ControlPlayStatus aIn, uint8_t& aOut);

View File

@ -508,7 +508,6 @@ public:
return rv;
}
#ifdef MOZ_B2G_BT_API_V2
nsresult SspReplyCmd(const nsAString& aBdAddr, BluetoothSspVariant aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes)
@ -530,30 +529,6 @@ public:
unused << pdu.forget();
return rv;
}
#else
nsresult SspReplyCmd(const nsAString& aBdAddr, const nsAString& aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
nsAutoPtr<BluetoothDaemonPDU> pdu(new BluetoothDaemonPDU(0x01, 0x11, 0));
nsresult rv = PackPDU(
PackConversion<nsAString, BluetoothAddress>(aBdAddr),
PackConversion<nsAString, BluetoothSspVariant>(aVariant),
aAccept, aPasskey, *pdu);
if (NS_FAILED(rv)) {
return rv;
}
rv = Send(pdu, aRes);
if (NS_FAILED(rv)) {
return rv;
}
unused << pdu.forget();
return rv;
}
#endif
nsresult DutModeConfigureCmd(bool aEnable, BluetoothResultHandler* aRes)
{
@ -2429,7 +2404,6 @@ BluetoothDaemonInterface::PinReply(const nsAString& aBdAddr, bool aAccept,
}
}
#ifdef MOZ_B2G_BT_API_V2
void
BluetoothDaemonInterface::SspReply(const nsAString& aBdAddr,
BluetoothSspVariant aVariant,
@ -2442,20 +2416,6 @@ BluetoothDaemonInterface::SspReply(const nsAString& aBdAddr,
DispatchError(aRes, rv);
}
}
#else
void
BluetoothDaemonInterface::SspReply(const nsAString& aBdAddr,
const nsAString& aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes)
{
nsresult rv = static_cast<BluetoothDaemonCoreModule*>
(mProtocol)->SspReplyCmd(aBdAddr, aVariant, aAccept, aPasskey, aRes);
if (NS_FAILED(rv)) {
DispatchError(aRes, rv);
}
}
#endif
/* DUT Mode */

View File

@ -89,15 +89,9 @@ public:
const nsAString& aPinCode,
BluetoothResultHandler* aRes);
#ifdef MOZ_B2G_BT_API_V2
void SspReply(const nsAString& aBdAddr, BluetoothSspVariant aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes);
#else
void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes);
#endif
/* DUT Mode */

View File

@ -80,7 +80,6 @@ Convert(const nsAString& aIn, bt_bdaddr_t& aOut)
return NS_OK;
}
#ifdef MOZ_B2G_BT_API_V2
nsresult
Convert(const BluetoothSspVariant aIn, bt_ssp_variant_t& aOut)
{
@ -98,26 +97,6 @@ Convert(const BluetoothSspVariant aIn, bt_ssp_variant_t& aOut)
aOut = sSspVariant[aIn];
return NS_OK;
}
#else
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;
}
#endif
nsresult
Convert(const uint8_t aIn[16], bt_uuid_t& aOut)

View File

@ -119,13 +119,8 @@ Convert(ConvertNamedValue& aIn, bt_property_t& aOut);
nsresult
Convert(const nsAString& aIn, bt_bdaddr_t& aOut);
#ifdef MOZ_B2G_BT_API_V2
nsresult
Convert(BluetoothSspVariant aIn, bt_ssp_variant_t& aOut);
#else
nsresult
Convert(const nsAString& aIn, bt_ssp_variant_t& aOut);
#endif
inline nsresult
Convert(const bt_ssp_variant_t& aIn, BluetoothSspVariant& aOut)

View File

@ -883,7 +883,6 @@ BluetoothHALInterface::PinReply(const nsAString& aBdAddr, bool aAccept,
}
}
#ifdef MOZ_B2G_BT_API_V2
void
BluetoothHALInterface::SspReply(const nsAString& aBdAddr,
BluetoothSspVariant aVariant,
@ -909,33 +908,6 @@ BluetoothHALInterface::SspReply(const nsAString& aBdAddr,
ConvertDefault(status, STATUS_FAIL));
}
}
#else
void
BluetoothHALInterface::SspReply(const nsAString& aBdAddr,
const nsAString& aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes)
{
int status;
bt_bdaddr_t bdAddr;
bt_ssp_variant_t variant;
uint8_t accept;
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) &&
NS_SUCCEEDED(Convert(aVariant, variant)) &&
NS_SUCCEEDED(Convert(aAccept, accept))) {
status = mInterface->ssp_reply(&bdAddr, variant, accept, aPasskey);
} else {
status = BT_STATUS_PARM_INVALID;
}
if (aRes) {
DispatchBluetoothHALResult(aRes,
&BluetoothResultHandler::SspReply,
ConvertDefault(status, STATUS_FAIL));
}
}
#endif
/* DUT Mode */

View File

@ -75,15 +75,9 @@ public:
const nsAString& aPinCode,
BluetoothResultHandler* aRes);
#ifdef MOZ_B2G_BT_API_V2
void SspReply(const nsAString& aBdAddr, BluetoothSspVariant aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes);
#else
void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
bool aAccept, uint32_t aPasskey,
BluetoothResultHandler* aRes);
#endif
/* DUT Mode */

View File

@ -1566,7 +1566,7 @@ BluetoothServiceBluedroid::SetPairingConfirmationInternal(
ENSURE_BLUETOOTH_IS_READY(aRunnable, false);
sBtInterface->SspReply(aDeviceAddress,
NS_ConvertUTF8toUTF16("PasskeyConfirmation"),
SSP_VARIANT_PASSKEY_CONFIRMATION,
aConfirm, 0, new SspReplyResultHandler(aRunnable));
return true;
}

View File

@ -653,7 +653,8 @@ 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;