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
};
/* 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 {
TYPE_OF_DEVICE_BREDR,
TYPE_OF_DEVICE_BLE,
@ -283,6 +290,15 @@ enum BluetoothSspVariant {
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 {
uint8_t mUuid[16];
@ -438,6 +454,12 @@ enum BluetoothHandsfreeVolumeType {
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;
typedef mozilla::Observer<BluetoothSignal> BluetoothSignalObserver;

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

@ -22,8 +22,6 @@ class BluetoothSocketResultHandler
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothSocketResultHandler)
virtual ~BluetoothSocketResultHandler() { }
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("Received error code %d", (int)aStatus);
@ -34,6 +32,9 @@ public:
int aConnectionState) { }
virtual void Accept(int aSockFd, const nsAString& aBdAddress,
int aConnectionState) { }
protected:
virtual ~BluetoothSocketResultHandler() { }
};
class BluetoothSocketInterface
@ -68,8 +69,6 @@ protected:
class BluetoothHandsfreeNotificationHandler
{
public:
virtual ~BluetoothHandsfreeNotificationHandler();
virtual void
ConnectionStateNotification(BluetoothHandsfreeConnectionState aState,
const nsAString& aBdAddr)
@ -81,64 +80,79 @@ 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:
BluetoothHandsfreeNotificationHandler()
{ }
virtual ~BluetoothHandsfreeNotificationHandler();
};
class BluetoothHandsfreeResultHandler
@ -146,8 +160,6 @@ class BluetoothHandsfreeResultHandler
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothHandsfreeResultHandler)
virtual ~BluetoothHandsfreeResultHandler() { }
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("Received error code %d", (int)aStatus);
@ -174,6 +186,11 @@ public:
virtual void AtResponse() { }
virtual void ClccResponse() { }
virtual void PhoneStateChange() { }
virtual void ConfigureWbs() { }
protected:
virtual ~BluetoothHandsfreeResultHandler() { }
};
class BluetoothHandsfreeInterface
@ -181,7 +198,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 */
@ -197,12 +214,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 */
@ -214,15 +234,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,
@ -230,6 +252,7 @@ public:
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
/* Phone State */
@ -240,6 +263,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();
@ -252,8 +280,6 @@ protected:
class BluetoothA2dpNotificationHandler
{
public:
virtual ~BluetoothA2dpNotificationHandler();
virtual void
ConnectionStateNotification(BluetoothA2dpConnectionState aState,
const nsAString& aBdAddr)
@ -264,9 +290,17 @@ public:
const nsAString& aBdAddr)
{ }
virtual void
AudioConfigNotification(const nsAString& aBdAddr,
uint32_t aSampleRate,
uint8_t aChannelCount)
{ }
protected:
BluetoothA2dpNotificationHandler()
{ }
virtual ~BluetoothA2dpNotificationHandler();
};
class BluetoothA2dpResultHandler
@ -274,8 +308,6 @@ class BluetoothA2dpResultHandler
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothA2dpResultHandler)
virtual ~BluetoothA2dpResultHandler() { }
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("Received error code %d", (int)aStatus);
@ -285,6 +317,9 @@ public:
virtual void Cleanup() { }
virtual void Connect() { }
virtual void Disconnect() { }
protected:
virtual ~BluetoothA2dpResultHandler() { }
};
class BluetoothA2dpInterface
@ -311,8 +346,6 @@ protected:
class BluetoothAvrcpNotificationHandler
{
public:
virtual ~BluetoothAvrcpNotificationHandler();
virtual void
GetPlayStatusNotification()
{ }
@ -369,6 +402,8 @@ public:
protected:
BluetoothAvrcpNotificationHandler()
{ }
virtual ~BluetoothAvrcpNotificationHandler();
};
class BluetoothAvrcpResultHandler
@ -376,8 +411,6 @@ class BluetoothAvrcpResultHandler
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothAvrcpResultHandler)
virtual ~BluetoothAvrcpResultHandler() { }
virtual void OnError(BluetoothStatus aStatus)
{
BT_WARNING("Received error code %d", (int)aStatus);
@ -402,6 +435,9 @@ public:
virtual void RegisterNotificationRsp() { }
virtual void SetVolume() { }
protected:
virtual ~BluetoothAvrcpResultHandler() { }
};
class BluetoothAvrcpInterface
@ -809,8 +845,6 @@ protected:
class BluetoothNotificationHandler
{
public:
virtual ~BluetoothNotificationHandler();
virtual void AdapterStateChangedNotification(bool aState) { }
virtual void AdapterPropertiesNotification(
BluetoothStatus aStatus, int aNumProperties,
@ -845,9 +879,14 @@ public:
virtual void LeTestModeNotification(BluetoothStatus aStatus,
uint16_t aNumPackets) { }
virtual void EnergyInfoNotification(const BluetoothActivityEnergyInfo& aInfo)
{ }
protected:
BluetoothNotificationHandler()
{ }
virtual ~BluetoothNotificationHandler();
};
class BluetoothResultHandler
@ -855,8 +894,6 @@ class BluetoothResultHandler
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothResultHandler)
virtual ~BluetoothResultHandler() { }
virtual void OnError(BluetoothStatus aStatus)
{
BT_LOGR("Received error code %d", aStatus);
@ -885,6 +922,8 @@ public:
virtual void RemoveBond() { }
virtual void CancelBond() { }
virtual void GetConnectionState() { }
virtual void PinReply() { }
virtual void SspReply() { }
@ -892,6 +931,11 @@ public:
virtual void DutModeSend() { }
virtual void LeTestMode() { }
virtual void ReadEnergyInfo() { }
protected:
virtual ~BluetoothResultHandler() { }
};
class BluetoothInterface
@ -941,12 +985,18 @@ public:
/* Bonds */
virtual void CreateBond(const nsAString& aBdAddr,
BluetoothTransport aTransport,
BluetoothResultHandler* aRes) = 0;
virtual void RemoveBond(const nsAString& aBdAddr,
BluetoothResultHandler* aRes) = 0;
virtual void CancelBond(const nsAString& aBdAddr,
BluetoothResultHandler* aRes) = 0;
/* Connection */
virtual void GetConnectionState(const nsAString& aBdAddr,
BluetoothResultHandler* aRes) = 0;
/* Authentication */
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,
BluetoothResultHandler* aRes) = 0;
/* Energy Info */
virtual void ReadEnergyInfo(BluetoothResultHandler* aRes) = 0;
/* Profile Interfaces */
virtual BluetoothSocketInterface* GetBluetoothSocketInterface() = 0;