mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1121930: Sync Bluetooth daemon protocol with BlueZ 5.27, r=shuang
This commit is contained in:
parent
04a5a1efb3
commit
899a86f835
@ -485,15 +485,28 @@ BluetoothDaemonHandsfreeModule::PhoneStateChangeCmd(
|
||||
|
||||
nsresult
|
||||
BluetoothDaemonHandsfreeModule::ConfigureWbsCmd(
|
||||
const nsAString& aBdAddr,
|
||||
const nsAString& aRemoteAddr,
|
||||
BluetoothHandsfreeWbsConfig aConfig,
|
||||
BluetoothHandsfreeResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// TODO: to be implemented
|
||||
nsAutoPtr<BluetoothDaemonPDU> pdu(
|
||||
new BluetoothDaemonPDU(SERVICE_ID, OPCODE_CONFIGURE_WBS,
|
||||
6 + // Address
|
||||
1)); // Config
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsresult rv = PackPDU(
|
||||
PackConversion<nsAString, BluetoothAddress>(aRemoteAddr), aConfig, *pdu);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Send(pdu, aRes);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
unused << pdu.forget();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Responses
|
||||
@ -646,6 +659,16 @@ BluetoothDaemonHandsfreeModule::PhoneStateChangeRsp(
|
||||
UnpackPDUInitOp(aPDU));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonHandsfreeModule::ConfigureWbsRsp(
|
||||
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU,
|
||||
BluetoothHandsfreeResultHandler* aRes)
|
||||
{
|
||||
ResultRunnable::Dispatch(
|
||||
aRes, &BluetoothHandsfreeResultHandler::ConfigureWbs,
|
||||
UnpackPDUInitOp(aPDU));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonHandsfreeModule::HandleRsp(
|
||||
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU,
|
||||
@ -684,7 +707,9 @@ BluetoothDaemonHandsfreeModule::HandleRsp(
|
||||
INIT_ARRAY_AT(OPCODE_CLCC_RESPONSE,
|
||||
&BluetoothDaemonHandsfreeModule::ClccResponseRsp),
|
||||
INIT_ARRAY_AT(OPCODE_PHONE_STATE_CHANGE,
|
||||
&BluetoothDaemonHandsfreeModule::PhoneStateChangeRsp)
|
||||
&BluetoothDaemonHandsfreeModule::PhoneStateChangeRsp),
|
||||
INIT_ARRAY_AT(OPCODE_CONFIGURE_WBS,
|
||||
&BluetoothDaemonHandsfreeModule::ConfigureWbsRsp)
|
||||
};
|
||||
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
|
@ -37,7 +37,8 @@ public:
|
||||
OPCODE_FORMATTED_AT_RESPONSE = 0x0b,
|
||||
OPCODE_AT_RESPONSE = 0x0c,
|
||||
OPCODE_CLCC_RESPONSE = 0x0d,
|
||||
OPCODE_PHONE_STATE_CHANGE = 0x0e
|
||||
OPCODE_PHONE_STATE_CHANGE = 0x0e,
|
||||
OPCODE_CONFIGURE_WBS = 0x0f
|
||||
};
|
||||
|
||||
virtual nsresult Send(BluetoothDaemonPDU* aPDU, void* aUserData) = 0;
|
||||
@ -201,6 +202,10 @@ protected:
|
||||
BluetoothDaemonPDU& aPDU,
|
||||
BluetoothHandsfreeResultHandler* aRes);
|
||||
|
||||
void ConfigureWbsRsp(const BluetoothDaemonPDUHeader& aHeader,
|
||||
BluetoothDaemonPDU& aPDU,
|
||||
BluetoothHandsfreeResultHandler* aRes);
|
||||
|
||||
void HandleRsp(const BluetoothDaemonPDUHeader& aHeader,
|
||||
BluetoothDaemonPDU& aPDU,
|
||||
void* aUserData);
|
||||
|
@ -375,6 +375,21 @@ Convert(uint8_t aIn, BluetoothHandsfreeVolumeType& aOut)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
Convert(uint8_t aIn, BluetoothHandsfreeWbsConfig& aOut)
|
||||
{
|
||||
static const BluetoothHandsfreeWbsConfig sWbsConfig[] = {
|
||||
CONVERT(0x00, HFP_WBS_NONE),
|
||||
CONVERT(0x01, HFP_WBS_NO),
|
||||
CONVERT(0x02, HFP_WBS_YES)
|
||||
};
|
||||
if (NS_WARN_IF(aIn >= MOZ_ARRAY_LENGTH(sWbsConfig))) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
aOut = sWbsConfig[aIn];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
Convert(uint8_t aIn, BluetoothPropertyType& aOut)
|
||||
{
|
||||
@ -812,6 +827,22 @@ Convert(BluetoothHandsfreeVolumeType aIn, uint8_t& aOut)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
Convert(BluetoothHandsfreeWbsConfig aIn, uint8_t& aOut)
|
||||
{
|
||||
static const uint8_t sWbsConfig[] = {
|
||||
CONVERT(HFP_WBS_NONE, 0x00),
|
||||
CONVERT(HFP_WBS_NO, 0x01),
|
||||
CONVERT(HFP_WBS_YES, 0x02)
|
||||
};
|
||||
if (NS_WARN_IF(aIn >= MOZ_ARRAY_LENGTH(sWbsConfig))) {
|
||||
aOut = 0x00; // silences compiler warning
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
aOut = sWbsConfig[aIn];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
Convert(BluetoothPropertyType aIn, uint8_t& aOut)
|
||||
{
|
||||
|
@ -205,6 +205,9 @@ Convert(uint8_t aIn, BluetoothHandsfreeVoiceRecognitionState& aOut);
|
||||
nsresult
|
||||
Convert(uint8_t aIn, BluetoothHandsfreeVolumeType& aOut);
|
||||
|
||||
nsresult
|
||||
Convert(uint8_t aIn, BluetoothHandsfreeWbsConfig& aOut);
|
||||
|
||||
nsresult
|
||||
Convert(uint8_t aIn, BluetoothBondState& aOut);
|
||||
|
||||
@ -289,6 +292,9 @@ Convert(BluetoothHandsfreeServiceType aIn, uint8_t& aOut);
|
||||
nsresult
|
||||
Convert(BluetoothHandsfreeVolumeType aIn, uint8_t& aOut);
|
||||
|
||||
nsresult
|
||||
Convert(BluetoothHandsfreeWbsConfig aIn, uint8_t& aOut);
|
||||
|
||||
nsresult
|
||||
Convert(BluetoothPropertyType aIn, uint8_t& aOut);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user