Bug 1102703: (3/10) Extend internal interfaces to sync with android lollipop and bluez 5.26 (handsfree) r=btian, r=tzimmermann

This commit is contained in:
Bruce Sun 2015-01-09 13:35:01 +08:00
Родитель 0581a40170
Коммит 602a02a783
8 изменённых файлов: 642 добавлений и 159 удалений

Просмотреть файл

@ -322,6 +322,12 @@ enum BluetoothHandsfreeNetworkState {
HFP_NETWORK_STATE_AVAILABLE
};
enum BluetoothHandsfreeWbsConfig {
HFP_WBS_NONE, /* Neither CVSD nor mSBC codec, but other optional codec.*/
HFP_WBS_NO, /* CVSD */
HFP_WBS_YES /* mSBC */
};
enum BluetoothHandsfreeNRECState {
HFP_NREC_STOPPED,
HFP_NREC_STARTED

Просмотреть файл

@ -80,59 +80,72 @@ public:
{ }
virtual void
VoiceRecognitionNotification(BluetoothHandsfreeVoiceRecognitionState aState)
VoiceRecognitionNotification(BluetoothHandsfreeVoiceRecognitionState aState,
const nsAString& aBdAddr)
{ }
virtual void
AnswerCallNotification()
AnswerCallNotification(const nsAString& aBdAddr)
{ }
virtual void
HangupCallNotification()
HangupCallNotification(const nsAString& aBdAddr)
{ }
virtual void
VolumeNotification(BluetoothHandsfreeVolumeType aType, int aVolume)
VolumeNotification(BluetoothHandsfreeVolumeType aType,
int aVolume,
const nsAString& aBdAddr)
{ }
virtual void
DialCallNotification(const nsAString& aNumber)
DialCallNotification(const nsAString& aNumber,
const nsAString& aBdAddr)
{ }
virtual void
DtmfNotification(char aDtmf)
DtmfNotification(char aDtmf,
const nsAString& aBdAddr)
{ }
virtual void
NRECNotification(BluetoothHandsfreeNRECState aNrec)
NRECNotification(BluetoothHandsfreeNRECState aNrec,
const nsAString& aBdAddr)
{ }
virtual void
CallHoldNotification(BluetoothHandsfreeCallHoldType aChld)
WbsNotification(BluetoothHandsfreeWbsConfig aWbs,
const nsAString& aBdAddr)
{ }
virtual void
CnumNotification()
CallHoldNotification(BluetoothHandsfreeCallHoldType aChld,
const nsAString& aBdAddr)
{ }
virtual void
CindNotification()
CnumNotification(const nsAString& aBdAddr)
{ }
virtual void
CopsNotification()
CindNotification(const nsAString& aBdAddr)
{ }
virtual void
ClccNotification()
CopsNotification(const nsAString& aBdAddr)
{ }
virtual void
UnknownAtNotification(const nsACString& aAtString)
ClccNotification(const nsAString& aBdAddr)
{ }
virtual void
KeyPressedNotification()
UnknownAtNotification(const nsACString& aAtString,
const nsAString& aBdAddr)
{ }
virtual void
KeyPressedNotification(const nsAString& aBdAddr)
{ }
protected:
@ -173,6 +186,8 @@ public:
virtual void AtResponse() { }
virtual void ClccResponse() { }
virtual void PhoneStateChange() { }
virtual void ConfigureWbs() { }
};
class BluetoothHandsfreeInterface
@ -180,7 +195,7 @@ class BluetoothHandsfreeInterface
public:
virtual void Init(
BluetoothHandsfreeNotificationHandler* aNotificationHandler,
BluetoothHandsfreeResultHandler* aRes) = 0;
int aMaxNumClients, BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void Cleanup(BluetoothHandsfreeResultHandler* aRes) = 0;
/* Connect / Disconnect */
@ -196,12 +211,15 @@ public:
/* Voice Recognition */
virtual void StartVoiceRecognition(BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void StopVoiceRecognition(BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void StartVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void StopVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
/* Volume */
virtual void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
/* Device status */
@ -213,15 +231,17 @@ public:
/* Responses */
virtual void CopsResponse(const char* aCops,
virtual void CopsResponse(const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void CindResponse(int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState,
int aSignal, int aRoam, int aBattChg,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void FormattedAtResponse(const char* aRsp,
virtual void FormattedAtResponse(const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void AtResponse(BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
virtual void AtResponse(BluetoothHandsfreeAtResponse aResponseCode,
int aErrorCode, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir,
BluetoothHandsfreeCallState aState,
@ -229,6 +249,7 @@ public:
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
/* Phone State */
@ -239,6 +260,11 @@ public:
BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes) = 0;
/* Wide Band Speech */
virtual void ConfigureWbs(const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes) = 0;
protected:
BluetoothHandsfreeInterface();
virtual ~BluetoothHandsfreeInterface();

Просмотреть файл

@ -17,6 +17,9 @@ BEGIN_BLUETOOTH_NAMESPACE
BluetoothHandsfreeNotificationHandler*
BluetoothDaemonHandsfreeModule::sNotificationHandler;
nsString BluetoothDaemonHandsfreeModule::sConnectedDeviceAddress(
NS_ConvertUTF8toUTF16(BLUETOOTH_ADDRESS_NONE));
void
BluetoothDaemonHandsfreeModule::SetNotificationHandler(
BluetoothHandsfreeNotificationHandler* aNotificationHandler)
@ -409,6 +412,19 @@ BluetoothDaemonHandsfreeModule::PhoneStateChangeCmd(
return NS_OK;
}
nsresult
BluetoothDaemonHandsfreeModule::ConfigureWbsCmd(
const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
// TODO: to be implemented
return NS_ERROR_NOT_IMPLEMENTED;
}
// Responses
//
@ -662,6 +678,12 @@ public:
if (NS_FAILED(rv)) {
return rv;
}
if (aArg1 == HFP_CONNECTION_STATE_CONNECTED) {
sConnectedDeviceAddress = aArg2;
} else if (aArg1 == HFP_CONNECTION_STATE_DISCONNECTED) {
sConnectedDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
}
WarnAboutTrailingData();
return NS_OK;
}
@ -686,8 +708,7 @@ public:
{ }
nsresult
operator () (BluetoothHandsfreeAudioState& aArg1,
nsString& aArg2) const
operator () (BluetoothHandsfreeAudioState& aArg1, nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
@ -717,31 +738,100 @@ BluetoothDaemonHandsfreeModule::AudioStateNtf(
AudioStateInitOp(aPDU));
}
// Init operator class for VoiceRecognitionNotification
class BluetoothDaemonHandsfreeModule::VoiceRecognitionInitOp MOZ_FINAL
: private PDUInitOp
{
public:
VoiceRecognitionInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (BluetoothHandsfreeVoiceRecognitionState& aArg1,
nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
/* Read state */
nsresult rv = UnpackPDU(pdu, aArg1);
if (NS_FAILED(rv)) {
return rv;
}
/* Read address */
// TODO
aArg2 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::VoiceRecognitionNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
VoiceRecognitionNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::VoiceRecognitionNotification,
UnpackPDUInitOp(aPDU));
VoiceRecognitionInitOp(aPDU));
}
// Init operator class for AnswerCallNotification
class BluetoothDaemonHandsfreeModule::AnswerCallInitOp MOZ_FINAL
: private PDUInitOp
{
public:
AnswerCallInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
// TODO
aArg1 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::AnswerCallNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
AnswerCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::AnswerCallNotification,
UnpackPDUInitOp(aPDU));
AnswerCallInitOp(aPDU));
}
// Init operator class for HangupCallNotification
class BluetoothDaemonHandsfreeModule::HangupCallInitOp MOZ_FINAL
: private PDUInitOp
{
public:
HangupCallInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
// TODO
aArg1 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::HangupCallNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
HangupCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::HangupCallNotification,
UnpackPDUInitOp(aPDU));
HangupCallInitOp(aPDU));
}
// Init operator class for VolumeNotification
@ -754,7 +844,8 @@ public:
{ }
nsresult
operator () (BluetoothHandsfreeVolumeType& aArg1, int& aArg2) const
operator () (BluetoothHandsfreeVolumeType& aArg1, int& aArg2,
nsString& aArg3) const
{
BluetoothDaemonPDU& pdu = GetPDU();
@ -769,6 +860,10 @@ public:
if (NS_FAILED(rv)) {
return rv;
}
/* Read address */
// TODO
aArg3 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
@ -793,13 +888,19 @@ public:
{ }
nsresult
operator () (nsString& aArg1) const
operator () (nsString& aArg1, nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
/* Read number */
nsresult rv = UnpackPDU(GetPDU(), UnpackString0(aArg1));
nsresult rv = UnpackPDU(pdu, UnpackString0(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
/* Read address */
// TODO
aArg2 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
@ -814,67 +915,231 @@ BluetoothDaemonHandsfreeModule::DialCallNtf(
DialCallInitOp(aPDU));
}
// Init operator class for DtmfNotification
class BluetoothDaemonHandsfreeModule::DtmfInitOp MOZ_FINAL
: private PDUInitOp
{
public:
DtmfInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (char& aArg1, nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
/* Read tone */
nsresult rv = UnpackPDU(pdu, aArg1);
if (NS_FAILED(rv)) {
return rv;
}
/* Read address */
// TODO
aArg2 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::DtmfNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
DtmfNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::DtmfNotification,
UnpackPDUInitOp(aPDU));
DtmfInitOp(aPDU));
}
// Init operator class for NRECNotification
class BluetoothDaemonHandsfreeModule::NRECInitOp MOZ_FINAL
: private PDUInitOp
{
public:
NRECInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (BluetoothHandsfreeNRECState& aArg1, nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
/* Read state */
nsresult rv = UnpackPDU(pdu, aArg1);
if (NS_FAILED(rv)) {
return rv;
}
/* Read address */
// TODO
aArg2 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::NRECNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
NRECNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::NRECNotification,
UnpackPDUInitOp(aPDU));
NRECInitOp(aPDU));
}
// Init operator class for CallHoldNotification
class BluetoothDaemonHandsfreeModule::CallHoldInitOp MOZ_FINAL
: private PDUInitOp
{
public:
CallHoldInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (BluetoothHandsfreeCallHoldType& aArg1, nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
/* Read type */
nsresult rv = UnpackPDU(pdu, aArg1);
if (NS_FAILED(rv)) {
return rv;
}
/* Read address */
// TODO
aArg2 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::CallHoldNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
CallHoldNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CallHoldNotification,
UnpackPDUInitOp(aPDU));
CallHoldInitOp(aPDU));
}
// Init operator class for CnumNotification
class BluetoothDaemonHandsfreeModule::CnumInitOp MOZ_FINAL
: private PDUInitOp
{
public:
CnumInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
// TODO
aArg1 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::CnumNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
CnumNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CnumNotification,
UnpackPDUInitOp(aPDU));
CnumInitOp(aPDU));
}
// Init operator class for CindNotification
class BluetoothDaemonHandsfreeModule::CindInitOp MOZ_FINAL
: private PDUInitOp
{
public:
CindInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
// TODO
aArg1 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::CindNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
CindNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CindNotification,
UnpackPDUInitOp(aPDU));
CindInitOp(aPDU));
}
// Init operator class for CopsNotification
class BluetoothDaemonHandsfreeModule::CopsInitOp MOZ_FINAL
: private PDUInitOp
{
public:
CopsInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
// TODO
aArg1 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::CopsNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
CopsNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CopsNotification,
UnpackPDUInitOp(aPDU));
CopsInitOp(aPDU));
}
// Init operator class for ClccNotification
class BluetoothDaemonHandsfreeModule::ClccInitOp MOZ_FINAL
: private PDUInitOp
{
public:
ClccInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
// TODO
aArg1 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::ClccNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
ClccNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::ClccNotification,
UnpackPDUInitOp(aPDU));
ClccInitOp(aPDU));
}
// Init operator class for UnknownAtNotification
@ -887,13 +1152,19 @@ public:
{ }
nsresult
operator () (nsCString& aArg1) const
operator () (nsCString& aArg1, nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
/* Read string */
nsresult rv = UnpackPDU(GetPDU(), UnpackCString0(aArg1));
nsresult rv = UnpackPDU(pdu, UnpackCString0(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
/* Read address */
// TODO
aArg2 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
@ -908,13 +1179,33 @@ BluetoothDaemonHandsfreeModule::UnknownAtNtf(
UnknownAtInitOp(aPDU));
}
// Init operator class for KeyPressedNotification
class BluetoothDaemonHandsfreeModule::KeyPressedInitOp MOZ_FINAL
: private PDUInitOp
{
public:
KeyPressedInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
// TODO
aArg1 = sConnectedDeviceAddress;
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::KeyPressedNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
KeyPressedNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::KeyPressedNotification,
UnpackPDUInitOp(aPDU));
KeyPressedInitOp(aPDU));
}
void
@ -997,7 +1288,7 @@ private:
void
BluetoothDaemonHandsfreeInterface::Init(
BluetoothHandsfreeNotificationHandler* aNotificationHandler,
BluetoothHandsfreeResultHandler* aRes)
int aMaxNumClients, BluetoothHandsfreeResultHandler* aRes)
{
// Set notification handler _before_ registering the module. It could
// happen that we receive notifications, before the result handler runs.
@ -1110,7 +1401,7 @@ BluetoothDaemonHandsfreeInterface::DisconnectAudio(
void
BluetoothDaemonHandsfreeInterface::StartVoiceRecognition(
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
@ -1119,7 +1410,7 @@ BluetoothDaemonHandsfreeInterface::StartVoiceRecognition(
void
BluetoothDaemonHandsfreeInterface::StopVoiceRecognition(
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
@ -1130,7 +1421,7 @@ BluetoothDaemonHandsfreeInterface::StopVoiceRecognition(
void
BluetoothDaemonHandsfreeInterface::VolumeControl(
BluetoothHandsfreeVolumeType aType, int aVolume,
BluetoothHandsfreeVolumeType aType, int aVolume, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
@ -1156,7 +1447,8 @@ BluetoothDaemonHandsfreeInterface::DeviceStatusNotification(
void
BluetoothDaemonHandsfreeInterface::CopsResponse(
const char* aCops, BluetoothHandsfreeResultHandler* aRes)
const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
@ -1168,7 +1460,7 @@ BluetoothDaemonHandsfreeInterface::CindResponse(
int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState,
int aSignal, int aRoam, int aBattChg,
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
@ -1178,7 +1470,8 @@ BluetoothDaemonHandsfreeInterface::CindResponse(
void
BluetoothDaemonHandsfreeInterface::FormattedAtResponse(
const char* aRsp, BluetoothHandsfreeResultHandler* aRes)
const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
@ -1188,7 +1481,7 @@ BluetoothDaemonHandsfreeInterface::FormattedAtResponse(
void
BluetoothDaemonHandsfreeInterface::AtResponse(
BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
@ -1203,6 +1496,7 @@ BluetoothDaemonHandsfreeInterface::ClccResponse(
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
@ -1227,6 +1521,18 @@ BluetoothDaemonHandsfreeInterface::PhoneStateChange(
aType, aRes);
}
/* Wide Band Speech */
void
BluetoothDaemonHandsfreeInterface::ConfigureWbs(
const nsAString& aBdAddr, BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
mModule->ConfigureWbsCmd(aBdAddr, aConfig, aRes);
}
void
BluetoothDaemonHandsfreeInterface::DispatchError(
BluetoothHandsfreeResultHandler* aRes, BluetoothStatus aStatus)

Просмотреть файл

@ -111,6 +111,12 @@ public:
BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes);
/* Wide Band Speech */
nsresult ConfigureWbsCmd(const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes);
protected:
nsresult Send(BluetoothDaemonPDU* aPDU,
BluetoothHandsfreeResultHandler* aRes);
@ -213,60 +219,93 @@ protected:
const nsAString&>
AudioStateNotification;
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
BluetoothHandsfreeVoiceRecognitionState>
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
BluetoothHandsfreeVoiceRecognitionState, nsString,
BluetoothHandsfreeVoiceRecognitionState, const nsAString&>
VoiceRecognitionNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
AnswerCallNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
HangupCallNotification;
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
BluetoothHandsfreeVolumeType, int>
typedef BluetoothNotificationRunnable3<NotificationHandlerWrapper, void,
BluetoothHandsfreeVolumeType, int, nsString,
BluetoothHandsfreeVolumeType, int, const nsAString&>
VolumeNotification;
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString, const nsAString&>
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
nsString, nsString,
const nsAString&, const nsAString&>
DialCallNotification;
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
char>
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
char, nsString,
char, const nsAString&>
DtmfNotification;
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
BluetoothHandsfreeNRECState>
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
BluetoothHandsfreeNRECState, nsString,
BluetoothHandsfreeNRECState, const nsAString&>
NRECNotification;
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
BluetoothHandsfreeCallHoldType>
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
BluetoothHandsfreeCallHoldType, nsString,
BluetoothHandsfreeCallHoldType, const nsAString&>
CallHoldNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
CnumNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
CindNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
CopsNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
ClccNotification;
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsCString, const nsACString&>
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
nsCString, nsString,
const nsACString&, const nsAString&>
UnknownAtNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
KeyPressedNotification;
class AudioStateInitOp;
class ConnectionStateInitOp;
class AudioStateInitOp;
class VoiceRecognitionInitOp;
class AnswerCallInitOp;
class HangupCallInitOp;
class VolumeInitOp;
class DialCallInitOp;
class DtmfInitOp;
class NRECInitOp;
class CallHoldInitOp;
class CnumInitOp;
class CindInitOp;
class CopsInitOp;
class ClccInitOp;
class VolumeInitOp;
class UnknownAtInitOp;
class KeyPressedInitOp;
void ConnectionStateNtf(const BluetoothDaemonPDUHeader& aHeader,
BluetoothDaemonPDU& aPDU);
@ -321,6 +360,7 @@ protected:
void* aUserData);
static BluetoothHandsfreeNotificationHandler* sNotificationHandler;
static nsString sConnectedDeviceAddress;
};
class BluetoothDaemonHandsfreeInterface MOZ_FINAL
@ -341,7 +381,7 @@ public:
void Init(
BluetoothHandsfreeNotificationHandler* aNotificationHandler,
BluetoothHandsfreeResultHandler* aRes);
int aMaxNumClients, BluetoothHandsfreeResultHandler* aRes);
void Cleanup(BluetoothHandsfreeResultHandler* aRes);
/* Connect / Disconnect */
@ -357,12 +397,15 @@ public:
/* Voice Recognition */
void StartVoiceRecognition(BluetoothHandsfreeResultHandler* aRes);
void StopVoiceRecognition(BluetoothHandsfreeResultHandler* aRes);
void StartVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void StopVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Volume */
void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Device status */
@ -374,15 +417,17 @@ public:
/* Responses */
void CopsResponse(const char* aCops,
void CopsResponse(const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void CindResponse(int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState,
int aSignal, int aRoam, int aBattChg,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void FormattedAtResponse(const char* aRsp,
void FormattedAtResponse(const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void AtResponse(BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir,
BluetoothHandsfreeCallState aState,
@ -390,6 +435,7 @@ public:
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Phone State */
@ -400,6 +446,11 @@ public:
BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes);
/* Wide Band Speech */
void ConfigureWbs(const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes);
private:
void DispatchError(BluetoothHandsfreeResultHandler* aRes,
BluetoothStatus aStatus);

Просмотреть файл

@ -75,62 +75,78 @@ struct BluetoothHandsfreeHALCallback
BluetoothHandsfreeAudioState, const nsAString&>
AudioStateNotification;
typedef BluetoothNotificationHALRunnable1<
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
BluetoothHandsfreeVoiceRecognitionState>
BluetoothHandsfreeVoiceRecognitionState, nsString,
BluetoothHandsfreeVoiceRecognitionState, const nsAString&>
VoiceRecognitionNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
AnswerCallNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
HangupCallNotification;
typedef BluetoothNotificationHALRunnable3<
HandsfreeNotificationHandlerWrapper, void,
BluetoothHandsfreeVolumeType, int, nsString,
BluetoothHandsfreeVolumeType, int, const nsAString&>
VolumeNotification;
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
BluetoothHandsfreeVolumeType, int>
VolumeNotification;
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void, nsString, const nsAString&>
nsString, nsString, const nsAString&, const nsAString&>
DialCallNotification;
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void, char>
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
char, nsString, char, const nsAString&>
DtmfNotification;
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void, BluetoothHandsfreeNRECState>
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
BluetoothHandsfreeNRECState, nsString,
BluetoothHandsfreeNRECState, const nsAString&>
NRECNotification;
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void, BluetoothHandsfreeCallHoldType>
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
BluetoothHandsfreeCallHoldType, nsString,
BluetoothHandsfreeCallHoldType, const nsAString&>
CallHoldNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
CnumNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
CindNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
CopsNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
ClccNotification;
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void, nsCString, const nsACString&>
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
nsCString, nsString, const nsACString&, const nsAString&>
UnknownAtNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
KeyPressedNotification;
// Bluedroid Handsfree callbacks
@ -138,6 +154,14 @@ struct BluetoothHandsfreeHALCallback
static void
ConnectionState(bthf_connection_state_t aState, bt_bdaddr_t* aBdAddr)
{
if (aState == BTHF_CONNECTION_STATE_CONNECTED && aBdAddr) {
memcpy(&sConnectedDeviceAddress, aBdAddr,
sizeof(sConnectedDeviceAddress));
} else if (aState == BTHF_CONNECTION_STATE_DISCONNECTED) {
memset(&sConnectedDeviceAddress, 0,
sizeof(sConnectedDeviceAddress));
}
ConnectionStateNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::ConnectionStateNotification,
aState, aBdAddr);
@ -156,21 +180,23 @@ struct BluetoothHandsfreeHALCallback
{
VoiceRecognitionNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::VoiceRecognitionNotification,
aState);
aState, &sConnectedDeviceAddress);
}
static void
AnswerCall()
{
AnswerCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::AnswerCallNotification);
&BluetoothHandsfreeNotificationHandler::AnswerCallNotification,
&sConnectedDeviceAddress);
}
static void
HangupCall()
{
HangupCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::HangupCallNotification);
&BluetoothHandsfreeNotificationHandler::HangupCallNotification,
&sConnectedDeviceAddress);
}
static void
@ -178,63 +204,71 @@ struct BluetoothHandsfreeHALCallback
{
VolumeNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::VolumeNotification,
aType, aVolume);
aType, aVolume, &sConnectedDeviceAddress);
}
static void
DialCall(char* aNumber)
{
DialCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::DialCallNotification, aNumber);
&BluetoothHandsfreeNotificationHandler::DialCallNotification,
aNumber, &sConnectedDeviceAddress);
}
static void
Dtmf(char aDtmf)
{
DtmfNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::DtmfNotification, aDtmf);
&BluetoothHandsfreeNotificationHandler::DtmfNotification,
aDtmf, &sConnectedDeviceAddress);
}
static void
NoiseReductionEchoCancellation(bthf_nrec_t aNrec)
{
NRECNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::NRECNotification, aNrec);
&BluetoothHandsfreeNotificationHandler::NRECNotification,
aNrec, &sConnectedDeviceAddress);
}
static void
CallHold(bthf_chld_type_t aChld)
{
CallHoldNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CallHoldNotification, aChld);
&BluetoothHandsfreeNotificationHandler::CallHoldNotification,
aChld, &sConnectedDeviceAddress);
}
static void
Cnum()
{
CnumNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CnumNotification);
&BluetoothHandsfreeNotificationHandler::CnumNotification,
&sConnectedDeviceAddress);
}
static void
Cind()
{
CindNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CindNotification);
&BluetoothHandsfreeNotificationHandler::CindNotification,
&sConnectedDeviceAddress);
}
static void
Cops()
{
CopsNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CopsNotification);
&BluetoothHandsfreeNotificationHandler::CopsNotification,
&sConnectedDeviceAddress);
}
static void
Clcc()
{
ClccNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::ClccNotification);
&BluetoothHandsfreeNotificationHandler::ClccNotification,
&sConnectedDeviceAddress);
}
static void
@ -242,15 +276,22 @@ struct BluetoothHandsfreeHALCallback
{
UnknownAtNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::UnknownAtNotification,
aAtString);
aAtString, &sConnectedDeviceAddress);
}
static void
KeyPressed()
{
KeyPressedNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::KeyPressedNotification);
&BluetoothHandsfreeNotificationHandler::KeyPressedNotification,
&sConnectedDeviceAddress);
}
static bt_bdaddr_t sConnectedDeviceAddress;
};
bt_bdaddr_t BluetoothHandsfreeHALCallback::sConnectedDeviceAddress = {
{0, 0, 0, 0, 0, 0}
};
// Interface
@ -269,7 +310,7 @@ BluetoothHandsfreeHALInterface::~BluetoothHandsfreeHALInterface()
void
BluetoothHandsfreeHALInterface::Init(
BluetoothHandsfreeNotificationHandler* aNotificationHandler,
BluetoothHandsfreeResultHandler* aRes)
int aMaxNumClients, BluetoothHandsfreeResultHandler* aRes)
{
static bthf_callbacks_t sCallbacks = {
sizeof(sCallbacks),
@ -400,6 +441,7 @@ BluetoothHandsfreeHALInterface::DisconnectAudio(
void
BluetoothHandsfreeHALInterface::StartVoiceRecognition(
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status = mInterface->start_voice_recognition();
@ -413,6 +455,7 @@ BluetoothHandsfreeHALInterface::StartVoiceRecognition(
void
BluetoothHandsfreeHALInterface::StopVoiceRecognition(
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status = mInterface->stop_voice_recognition();
@ -428,7 +471,7 @@ BluetoothHandsfreeHALInterface::StopVoiceRecognition(
void
BluetoothHandsfreeHALInterface::VolumeControl(
BluetoothHandsfreeVolumeType aType, int aVolume,
BluetoothHandsfreeVolumeType aType, int aVolume, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status;
@ -478,7 +521,8 @@ BluetoothHandsfreeHALInterface::DeviceStatusNotification(
void
BluetoothHandsfreeHALInterface::CopsResponse(
const char* aCops, BluetoothHandsfreeResultHandler* aRes)
const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status = mInterface->cops_response(aCops);
@ -494,6 +538,7 @@ BluetoothHandsfreeHALInterface::CindResponse(
int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState,
int aSignal, int aRoam, int aBattChg,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status;
@ -516,7 +561,8 @@ BluetoothHandsfreeHALInterface::CindResponse(
void
BluetoothHandsfreeHALInterface::FormattedAtResponse(
const char* aRsp, BluetoothHandsfreeResultHandler* aRes)
const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status = mInterface->formatted_at_response(aRsp);
@ -530,6 +576,7 @@ BluetoothHandsfreeHALInterface::FormattedAtResponse(
void
BluetoothHandsfreeHALInterface::AtResponse(
BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status;
@ -557,6 +604,7 @@ BluetoothHandsfreeHALInterface::ClccResponse(
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status;
@ -613,4 +661,23 @@ BluetoothHandsfreeHALInterface::PhoneStateChange(int aNumActive, int aNumHeld,
}
}
/* Wide Band Speech */
void
BluetoothHandsfreeHALInterface::ConfigureWbs(
const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes)
{
// TODO: to be implemented
bt_status_t status = BT_STATUS_UNSUPPORTED;
if (aRes) {
DispatchBluetoothHandsfreeHALResult(
aRes, &BluetoothHandsfreeResultHandler::ConfigureWbs,
ConvertDefault(status, STATUS_FAIL));
}
}
END_BLUETOOTH_NAMESPACE

Просмотреть файл

@ -23,6 +23,7 @@ public:
friend class BluetoothHALInterface;
void Init(BluetoothHandsfreeNotificationHandler* aNotificationHandler,
int aMaxNumClients,
BluetoothHandsfreeResultHandler* aRes);
void Cleanup(BluetoothHandsfreeResultHandler* aRes);
@ -39,12 +40,15 @@ public:
/* Voice Recognition */
void StartVoiceRecognition(BluetoothHandsfreeResultHandler* aRes);
void StopVoiceRecognition(BluetoothHandsfreeResultHandler* aRes);
void StartVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void StopVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Volume */
void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Device status */
@ -56,15 +60,16 @@ public:
/* Responses */
void CopsResponse(const char* aCops,
void CopsResponse(const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void CindResponse(int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState, int aSignal,
int aRoam, int aBattChg,
int aRoam, int aBattChg, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void FormattedAtResponse(const char* aRsp,
void FormattedAtResponse(const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void AtResponse(BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir,
BluetoothHandsfreeCallState aState,
@ -72,6 +77,7 @@ public:
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Phone State */
@ -82,6 +88,12 @@ public:
BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes);
/* Wide Band Speech */
void ConfigureWbs(const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes);
protected:
BluetoothHandsfreeHALInterface(const bthf_interface_t* aInterface);
~BluetoothHandsfreeHALInterface();

Просмотреть файл

@ -57,6 +57,8 @@ namespace {
static int sBusyToneInterval = 3700; //unit: ms
} // anonymous namespace
const int BluetoothHfpManager::MAX_NUM_CLIENTS = 1;
static bool
IsValidDtmf(const char aChar) {
// Valid DTMF: [*#0-9ABCD]
@ -308,7 +310,7 @@ public:
{
BluetoothHfpManager* hfpManager = BluetoothHfpManager::Get();
mInterface->Init(hfpManager, this);
mInterface->Init(hfpManager, BluetoothHfpManager::MAX_NUM_CLIENTS, this);
}
private:
@ -638,8 +640,9 @@ BluetoothHfpManager::HandleVolumeChanged(nsISupports* aSubject)
// Only send volume back when there's a connected headset
if (IsConnected()) {
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
sBluetoothHfpInterface->VolumeControl(HFP_VOLUME_TYPE_SPEAKER, mCurrentVgs,
new VolumeControlResultHandler());
sBluetoothHfpInterface->VolumeControl(
HFP_VOLUME_TYPE_SPEAKER, mCurrentVgs, mDeviceAddress,
new VolumeControlResultHandler());
}
}
@ -767,7 +770,7 @@ BluetoothHfpManager::SendCLCC(Call& aCall, int aIndex)
sBluetoothHfpInterface->ClccResponse(
aIndex, aCall.mDirection, callState, HFP_CALL_MODE_VOICE,
HFP_CALL_MPTY_TYPE_SINGLE, aCall.mNumber,
aCall.mType, new ClccResponseResultHandler());
aCall.mType, mDeviceAddress, new ClccResponseResultHandler());
}
class FormattedAtResponseResultHandler MOZ_FINAL
@ -787,7 +790,7 @@ BluetoothHfpManager::SendLine(const char* aMessage)
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
sBluetoothHfpInterface->FormattedAtResponse(
aMessage, new FormattedAtResponseResultHandler());
aMessage, mDeviceAddress, new FormattedAtResponseResultHandler());
}
class AtResponseResultHandler MOZ_FINAL
@ -807,7 +810,7 @@ BluetoothHfpManager::SendResponse(BluetoothHandsfreeAtResponse aResponseCode)
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
sBluetoothHfpInterface->AtResponse(
aResponseCode, 0, new AtResponseResultHandler());
aResponseCode, 0, mDeviceAddress, new AtResponseResultHandler());
}
class PhoneStateChangeResultHandler MOZ_FINAL
@ -1361,7 +1364,7 @@ BluetoothHfpManager::AudioStateNotification(
}
void
BluetoothHfpManager::AnswerCallNotification()
BluetoothHfpManager::AnswerCallNotification(const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1369,7 +1372,7 @@ BluetoothHfpManager::AnswerCallNotification()
}
void
BluetoothHfpManager::HangupCallNotification()
BluetoothHfpManager::HangupCallNotification(const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1378,7 +1381,7 @@ BluetoothHfpManager::HangupCallNotification()
void
BluetoothHfpManager::VolumeNotification(
BluetoothHandsfreeVolumeType aType, int aVolume)
BluetoothHandsfreeVolumeType aType, int aVolume, const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1405,7 +1408,7 @@ BluetoothHfpManager::VolumeNotification(
}
void
BluetoothHfpManager::DtmfNotification(char aDtmf)
BluetoothHfpManager::DtmfNotification(char aDtmf, const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1417,7 +1420,8 @@ BluetoothHfpManager::DtmfNotification(char aDtmf)
}
void
BluetoothHfpManager::CallHoldNotification(BluetoothHandsfreeCallHoldType aChld)
BluetoothHfpManager::CallHoldNotification(BluetoothHandsfreeCallHoldType aChld,
const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1435,7 +1439,8 @@ BluetoothHfpManager::CallHoldNotification(BluetoothHandsfreeCallHoldType aChld)
NotifyDialer(NS_ConvertUTF8toUTF16(message));
}
void BluetoothHfpManager::DialCallNotification(const nsAString& aNumber)
void BluetoothHfpManager::DialCallNotification(const nsAString& aNumber,
const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1476,7 +1481,7 @@ void BluetoothHfpManager::DialCallNotification(const nsAString& aNumber)
}
void
BluetoothHfpManager::CnumNotification()
BluetoothHfpManager::CnumNotification(const nsAString& aBdAddress)
{
static const uint8_t sAddressType[] {
[HFP_CALL_ADDRESS_TYPE_UNKNOWN] = 0x81,
@ -1510,7 +1515,7 @@ public:
};
void
BluetoothHfpManager::CindNotification()
BluetoothHfpManager::CindNotification(const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1521,9 +1526,11 @@ BluetoothHfpManager::CindNotification()
BluetoothHandsfreeCallState callState =
ConvertToBluetoothHandsfreeCallState(GetCallSetupState());
sBluetoothHfpInterface->CindResponse(mService, numActive, numHeld,
callState, mSignal, mRoam, mBattChg,
new CindResponseResultHandler());
sBluetoothHfpInterface->CindResponse(
mService, numActive, numHeld,
callState, mSignal, mRoam, mBattChg,
aBdAddress,
new CindResponseResultHandler());
}
class CopsResponseResultHandler MOZ_FINAL
@ -1538,7 +1545,7 @@ public:
};
void
BluetoothHfpManager::CopsNotification()
BluetoothHfpManager::CopsNotification(const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1546,11 +1553,11 @@ BluetoothHfpManager::CopsNotification()
sBluetoothHfpInterface->CopsResponse(
NS_ConvertUTF16toUTF8(mOperatorName).get(),
new CopsResponseResultHandler());
aBdAddress, new CopsResponseResultHandler());
}
void
BluetoothHfpManager::ClccNotification()
BluetoothHfpManager::ClccNotification(const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1571,7 +1578,8 @@ BluetoothHfpManager::ClccNotification()
}
void
BluetoothHfpManager::UnknownAtNotification(const nsACString& aAtString)
BluetoothHfpManager::UnknownAtNotification(const nsACString& aAtString,
const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1581,7 +1589,7 @@ BluetoothHfpManager::UnknownAtNotification(const nsACString& aAtString)
}
void
BluetoothHfpManager::KeyPressedNotification()
BluetoothHfpManager::KeyPressedNotification(const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());

Просмотреть файл

@ -77,6 +77,8 @@ class BluetoothHfpManager : public BluetoothHfpManagerBase
public:
BT_DECL_HFP_MGR_BASE
static const int MAX_NUM_CLIENTS;
void OnConnectError();
void OnDisconnectError();
@ -117,19 +119,24 @@ public:
const nsAString& aBdAddress) MOZ_OVERRIDE;
void AudioStateNotification(BluetoothHandsfreeAudioState aState,
const nsAString& aBdAddress) MOZ_OVERRIDE;
void AnswerCallNotification() MOZ_OVERRIDE;
void HangupCallNotification() MOZ_OVERRIDE;
void AnswerCallNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
void HangupCallNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
void VolumeNotification(BluetoothHandsfreeVolumeType aType,
int aVolume) MOZ_OVERRIDE;
void DtmfNotification(char aDtmf) MOZ_OVERRIDE;
void CallHoldNotification(BluetoothHandsfreeCallHoldType aChld) MOZ_OVERRIDE;
void DialCallNotification(const nsAString& aNumber) MOZ_OVERRIDE;
void CnumNotification() MOZ_OVERRIDE;
void CindNotification() MOZ_OVERRIDE;
void CopsNotification() MOZ_OVERRIDE;
void ClccNotification() MOZ_OVERRIDE;
void UnknownAtNotification(const nsACString& aAtString) MOZ_OVERRIDE;
void KeyPressedNotification() MOZ_OVERRIDE;
int aVolume,
const nsAString& aBdAddress) MOZ_OVERRIDE;
void DtmfNotification(char aDtmf,
const nsAString& aBdAddress) MOZ_OVERRIDE;
void CallHoldNotification(BluetoothHandsfreeCallHoldType aChld,
const nsAString& aBdAddress) MOZ_OVERRIDE;
void DialCallNotification(const nsAString& aNumber,
const nsAString& aBdAddress) MOZ_OVERRIDE;
void CnumNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
void CindNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
void CopsNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
void ClccNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
void UnknownAtNotification(const nsACString& aAtString,
const nsAString& aBdAddress) MOZ_OVERRIDE;
void KeyPressedNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
private:
class GetVolumeTask;