Bug 1146355: Update Bluetooth backend interface for bluetooth2, r=brsun

For sharing backend code, both implementations must use similar
backend interfaces. This patch updates the interface for v2 to the
state of v1 plus GATT.
This commit is contained in:
Thomas Zimmermann 2015-04-09 15:57:40 +02:00
Родитель 7c10db75d9
Коммит 28391b811b
2 изменённых файлов: 114 добавлений и 38 удалений

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

@ -247,6 +247,13 @@ enum BluetoothBondState {
BOND_STATE_BONDED BOND_STATE_BONDED
}; };
/* Physical transport for GATT connections to remote dual-mode devices */
enum BluetoothTransport {
TRANSPORT_AUTO, /* No preference of physical transport */
TRANSPORT_BREDR, /* Prefer BR/EDR transport */
TRANSPORT_LE /* Prefer LE transport */
};
enum BluetoothTypeOfDevice { enum BluetoothTypeOfDevice {
TYPE_OF_DEVICE_BREDR, TYPE_OF_DEVICE_BREDR,
TYPE_OF_DEVICE_BLE, TYPE_OF_DEVICE_BLE,
@ -283,6 +290,15 @@ enum BluetoothSspVariant {
SSP_VARIANT_PASSKEY_NOTIFICATION SSP_VARIANT_PASSKEY_NOTIFICATION
}; };
struct BluetoothActivityEnergyInfo {
uint8_t mStatus;
uint8_t mStackState; /* stack reported state */
uint64_t mTxTime; /* in ms */
uint64_t mRxTime; /* in ms */
uint64_t mIdleTime; /* in ms */
uint64_t mEnergyUsed; /* a product of mA, V and ms */
};
struct BluetoothUuid { struct BluetoothUuid {
uint8_t mUuid[16]; uint8_t mUuid[16];
@ -438,6 +454,12 @@ enum BluetoothHandsfreeVolumeType {
HFP_VOLUME_TYPE_MICROPHONE HFP_VOLUME_TYPE_MICROPHONE
}; };
enum BluetoothHandsfreeWbsConfig {
HFP_WBS_NONE, /* Neither CVSD nor mSBC codec, but other optional codec.*/
HFP_WBS_NO, /* CVSD */
HFP_WBS_YES /* mSBC */
};
class BluetoothSignal; class BluetoothSignal;
typedef mozilla::Observer<BluetoothSignal> BluetoothSignalObserver; typedef mozilla::Observer<BluetoothSignal> BluetoothSignalObserver;

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

@ -22,8 +22,6 @@ class BluetoothSocketResultHandler
public: public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothSocketResultHandler) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothSocketResultHandler)
virtual ~BluetoothSocketResultHandler() { }
virtual void OnError(BluetoothStatus aStatus) virtual void OnError(BluetoothStatus aStatus)
{ {
BT_WARNING("Received error code %d", (int)aStatus); BT_WARNING("Received error code %d", (int)aStatus);
@ -34,6 +32,9 @@ public:
int aConnectionState) { } int aConnectionState) { }
virtual void Accept(int aSockFd, const nsAString& aBdAddress, virtual void Accept(int aSockFd, const nsAString& aBdAddress,
int aConnectionState) { } int aConnectionState) { }
protected:
virtual ~BluetoothSocketResultHandler() { }
}; };
class BluetoothSocketInterface class BluetoothSocketInterface
@ -68,8 +69,6 @@ protected:
class BluetoothHandsfreeNotificationHandler class BluetoothHandsfreeNotificationHandler
{ {
public: public:
virtual ~BluetoothHandsfreeNotificationHandler();
virtual void virtual void
ConnectionStateNotification(BluetoothHandsfreeConnectionState aState, ConnectionStateNotification(BluetoothHandsfreeConnectionState aState,
const nsAString& aBdAddr) const nsAString& aBdAddr)
@ -81,64 +80,79 @@ public:
{ } { }
virtual void virtual void
VoiceRecognitionNotification(BluetoothHandsfreeVoiceRecognitionState aState) VoiceRecognitionNotification(BluetoothHandsfreeVoiceRecognitionState aState,
const nsAString& aBdAddr)
{ } { }
virtual void virtual void
AnswerCallNotification() AnswerCallNotification(const nsAString& aBdAddr)
{ } { }
virtual void virtual void
HangupCallNotification() HangupCallNotification(const nsAString& aBdAddr)
{ } { }
virtual void virtual void
VolumeNotification(BluetoothHandsfreeVolumeType aType, int aVolume) VolumeNotification(BluetoothHandsfreeVolumeType aType,
int aVolume,
const nsAString& aBdAddr)
{ } { }
virtual void virtual void
DialCallNotification(const nsAString& aNumber) DialCallNotification(const nsAString& aNumber,
const nsAString& aBdAddr)
{ } { }
virtual void virtual void
DtmfNotification(char aDtmf) DtmfNotification(char aDtmf,
const nsAString& aBdAddr)
{ } { }
virtual void virtual void
NRECNotification(BluetoothHandsfreeNRECState aNrec) NRECNotification(BluetoothHandsfreeNRECState aNrec,
const nsAString& aBdAddr)
{ } { }
virtual void virtual void
CallHoldNotification(BluetoothHandsfreeCallHoldType aChld) WbsNotification(BluetoothHandsfreeWbsConfig aWbs,
const nsAString& aBdAddr)
{ } { }
virtual void virtual void
CnumNotification() CallHoldNotification(BluetoothHandsfreeCallHoldType aChld,
const nsAString& aBdAddr)
{ } { }
virtual void virtual void
CindNotification() CnumNotification(const nsAString& aBdAddr)
{ } { }
virtual void virtual void
CopsNotification() CindNotification(const nsAString& aBdAddr)
{ } { }
virtual void virtual void
ClccNotification() CopsNotification(const nsAString& aBdAddr)
{ } { }
virtual void virtual void
UnknownAtNotification(const nsACString& aAtString) ClccNotification(const nsAString& aBdAddr)
{ } { }
virtual void virtual void
KeyPressedNotification() UnknownAtNotification(const nsACString& aAtString,
const nsAString& aBdAddr)
{ }
virtual void
KeyPressedNotification(const nsAString& aBdAddr)
{ } { }
protected: protected:
BluetoothHandsfreeNotificationHandler() BluetoothHandsfreeNotificationHandler()
{ } { }
virtual ~BluetoothHandsfreeNotificationHandler();
}; };
class BluetoothHandsfreeResultHandler class BluetoothHandsfreeResultHandler
@ -146,8 +160,6 @@ class BluetoothHandsfreeResultHandler
public: public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothHandsfreeResultHandler) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothHandsfreeResultHandler)
virtual ~BluetoothHandsfreeResultHandler() { }
virtual void OnError(BluetoothStatus aStatus) virtual void OnError(BluetoothStatus aStatus)
{ {
BT_WARNING("Received error code %d", (int)aStatus); BT_WARNING("Received error code %d", (int)aStatus);
@ -174,6 +186,11 @@ public:
virtual void AtResponse() { } virtual void AtResponse() { }
virtual void ClccResponse() { } virtual void ClccResponse() { }
virtual void PhoneStateChange() { } virtual void PhoneStateChange() { }
virtual void ConfigureWbs() { }
protected:
virtual ~BluetoothHandsfreeResultHandler() { }
}; };
class BluetoothHandsfreeInterface class BluetoothHandsfreeInterface
@ -181,7 +198,7 @@ class BluetoothHandsfreeInterface
public: public:
virtual void Init( virtual void Init(
BluetoothHandsfreeNotificationHandler* aNotificationHandler, BluetoothHandsfreeNotificationHandler* aNotificationHandler,
BluetoothHandsfreeResultHandler* aRes) = 0; int aMaxNumClients, BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void Cleanup(BluetoothHandsfreeResultHandler* aRes) = 0; virtual void Cleanup(BluetoothHandsfreeResultHandler* aRes) = 0;
/* Connect / Disconnect */ /* Connect / Disconnect */
@ -197,12 +214,15 @@ public:
/* Voice Recognition */ /* Voice Recognition */
virtual void StartVoiceRecognition(BluetoothHandsfreeResultHandler* aRes) = 0; virtual void StartVoiceRecognition(const nsAString& aBdAddr,
virtual void StopVoiceRecognition(BluetoothHandsfreeResultHandler* aRes) = 0; BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void StopVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
/* Volume */ /* Volume */
virtual void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume, virtual void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0; BluetoothHandsfreeResultHandler* aRes) = 0;
/* Device status */ /* Device status */
@ -214,15 +234,17 @@ public:
/* Responses */ /* Responses */
virtual void CopsResponse(const char* aCops, virtual void CopsResponse(const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0; BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void CindResponse(int aSvc, int aNumActive, int aNumHeld, virtual void CindResponse(int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState, BluetoothHandsfreeCallState aCallSetupState,
int aSignal, int aRoam, int aBattChg, int aSignal, int aRoam, int aBattChg,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0; BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void FormattedAtResponse(const char* aRsp, virtual void FormattedAtResponse(const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0; BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void AtResponse(BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode, virtual void AtResponse(BluetoothHandsfreeAtResponse aResponseCode,
int aErrorCode, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0; BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir, virtual void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir,
BluetoothHandsfreeCallState aState, BluetoothHandsfreeCallState aState,
@ -230,6 +252,7 @@ public:
BluetoothHandsfreeCallMptyType aMpty, BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber, const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType, BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0; BluetoothHandsfreeResultHandler* aRes) = 0;
/* Phone State */ /* Phone State */
@ -240,6 +263,11 @@ public:
BluetoothHandsfreeCallAddressType aType, BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes) = 0; BluetoothHandsfreeResultHandler* aRes) = 0;
/* Wide Band Speech */
virtual void ConfigureWbs(const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes) = 0;
protected: protected:
BluetoothHandsfreeInterface(); BluetoothHandsfreeInterface();
virtual ~BluetoothHandsfreeInterface(); virtual ~BluetoothHandsfreeInterface();
@ -252,8 +280,6 @@ protected:
class BluetoothA2dpNotificationHandler class BluetoothA2dpNotificationHandler
{ {
public: public:
virtual ~BluetoothA2dpNotificationHandler();
virtual void virtual void
ConnectionStateNotification(BluetoothA2dpConnectionState aState, ConnectionStateNotification(BluetoothA2dpConnectionState aState,
const nsAString& aBdAddr) const nsAString& aBdAddr)
@ -264,9 +290,17 @@ public:
const nsAString& aBdAddr) const nsAString& aBdAddr)
{ } { }
virtual void
AudioConfigNotification(const nsAString& aBdAddr,
uint32_t aSampleRate,
uint8_t aChannelCount)
{ }
protected: protected:
BluetoothA2dpNotificationHandler() BluetoothA2dpNotificationHandler()
{ } { }
virtual ~BluetoothA2dpNotificationHandler();
}; };
class BluetoothA2dpResultHandler class BluetoothA2dpResultHandler
@ -274,8 +308,6 @@ class BluetoothA2dpResultHandler
public: public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothA2dpResultHandler) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothA2dpResultHandler)
virtual ~BluetoothA2dpResultHandler() { }
virtual void OnError(BluetoothStatus aStatus) virtual void OnError(BluetoothStatus aStatus)
{ {
BT_WARNING("Received error code %d", (int)aStatus); BT_WARNING("Received error code %d", (int)aStatus);
@ -285,6 +317,9 @@ public:
virtual void Cleanup() { } virtual void Cleanup() { }
virtual void Connect() { } virtual void Connect() { }
virtual void Disconnect() { } virtual void Disconnect() { }
protected:
virtual ~BluetoothA2dpResultHandler() { }
}; };
class BluetoothA2dpInterface class BluetoothA2dpInterface
@ -311,8 +346,6 @@ protected:
class BluetoothAvrcpNotificationHandler class BluetoothAvrcpNotificationHandler
{ {
public: public:
virtual ~BluetoothAvrcpNotificationHandler();
virtual void virtual void
GetPlayStatusNotification() GetPlayStatusNotification()
{ } { }
@ -369,6 +402,8 @@ public:
protected: protected:
BluetoothAvrcpNotificationHandler() BluetoothAvrcpNotificationHandler()
{ } { }
virtual ~BluetoothAvrcpNotificationHandler();
}; };
class BluetoothAvrcpResultHandler class BluetoothAvrcpResultHandler
@ -376,8 +411,6 @@ class BluetoothAvrcpResultHandler
public: public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothAvrcpResultHandler) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothAvrcpResultHandler)
virtual ~BluetoothAvrcpResultHandler() { }
virtual void OnError(BluetoothStatus aStatus) virtual void OnError(BluetoothStatus aStatus)
{ {
BT_WARNING("Received error code %d", (int)aStatus); BT_WARNING("Received error code %d", (int)aStatus);
@ -402,6 +435,9 @@ public:
virtual void RegisterNotificationRsp() { } virtual void RegisterNotificationRsp() { }
virtual void SetVolume() { } virtual void SetVolume() { }
protected:
virtual ~BluetoothAvrcpResultHandler() { }
}; };
class BluetoothAvrcpInterface class BluetoothAvrcpInterface
@ -809,8 +845,6 @@ protected:
class BluetoothNotificationHandler class BluetoothNotificationHandler
{ {
public: public:
virtual ~BluetoothNotificationHandler();
virtual void AdapterStateChangedNotification(bool aState) { } virtual void AdapterStateChangedNotification(bool aState) { }
virtual void AdapterPropertiesNotification( virtual void AdapterPropertiesNotification(
BluetoothStatus aStatus, int aNumProperties, BluetoothStatus aStatus, int aNumProperties,
@ -845,9 +879,14 @@ public:
virtual void LeTestModeNotification(BluetoothStatus aStatus, virtual void LeTestModeNotification(BluetoothStatus aStatus,
uint16_t aNumPackets) { } uint16_t aNumPackets) { }
virtual void EnergyInfoNotification(const BluetoothActivityEnergyInfo& aInfo)
{ }
protected: protected:
BluetoothNotificationHandler() BluetoothNotificationHandler()
{ } { }
virtual ~BluetoothNotificationHandler();
}; };
class BluetoothResultHandler class BluetoothResultHandler
@ -855,8 +894,6 @@ class BluetoothResultHandler
public: public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothResultHandler) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothResultHandler)
virtual ~BluetoothResultHandler() { }
virtual void OnError(BluetoothStatus aStatus) virtual void OnError(BluetoothStatus aStatus)
{ {
BT_LOGR("Received error code %d", aStatus); BT_LOGR("Received error code %d", aStatus);
@ -885,6 +922,8 @@ public:
virtual void RemoveBond() { } virtual void RemoveBond() { }
virtual void CancelBond() { } virtual void CancelBond() { }
virtual void GetConnectionState() { }
virtual void PinReply() { } virtual void PinReply() { }
virtual void SspReply() { } virtual void SspReply() { }
@ -892,6 +931,11 @@ public:
virtual void DutModeSend() { } virtual void DutModeSend() { }
virtual void LeTestMode() { } virtual void LeTestMode() { }
virtual void ReadEnergyInfo() { }
protected:
virtual ~BluetoothResultHandler() { }
}; };
class BluetoothInterface class BluetoothInterface
@ -941,12 +985,18 @@ public:
/* Bonds */ /* Bonds */
virtual void CreateBond(const nsAString& aBdAddr, virtual void CreateBond(const nsAString& aBdAddr,
BluetoothTransport aTransport,
BluetoothResultHandler* aRes) = 0; BluetoothResultHandler* aRes) = 0;
virtual void RemoveBond(const nsAString& aBdAddr, virtual void RemoveBond(const nsAString& aBdAddr,
BluetoothResultHandler* aRes) = 0; BluetoothResultHandler* aRes) = 0;
virtual void CancelBond(const nsAString& aBdAddr, virtual void CancelBond(const nsAString& aBdAddr,
BluetoothResultHandler* aRes) = 0; BluetoothResultHandler* aRes) = 0;
/* Connection */
virtual void GetConnectionState(const nsAString& aBdAddr,
BluetoothResultHandler* aRes) = 0;
/* Authentication */ /* Authentication */
virtual void PinReply(const nsAString& aBdAddr, bool aAccept, virtual void PinReply(const nsAString& aBdAddr, bool aAccept,
@ -969,6 +1019,10 @@ public:
virtual void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen, virtual void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
BluetoothResultHandler* aRes) = 0; BluetoothResultHandler* aRes) = 0;
/* Energy Info */
virtual void ReadEnergyInfo(BluetoothResultHandler* aRes) = 0;
/* Profile Interfaces */ /* Profile Interfaces */
virtual BluetoothSocketInterface* GetBluetoothSocketInterface() = 0; virtual BluetoothSocketInterface* GetBluetoothSocketInterface() = 0;