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

This commit is contained in:
Bruce Sun 2015-01-09 13:33:53 +08:00
parent 24d9fc452a
commit f1ae948c7c
8 changed files with 126 additions and 4 deletions

View File

@ -235,6 +235,22 @@ struct BluetoothProperty {
BluetoothRemoteInfo mRemoteInfo;
};
/* 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 */
};
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 */
};
enum BluetoothSocketType {
RFCOMM = 1,
SCO = 2,

View File

@ -495,6 +495,9 @@ public:
virtual void LeTestModeNotification(BluetoothStatus aStatus,
uint16_t aNumPackets) { }
virtual void EnergyInfoNotification(const BluetoothActivityEnergyInfo& aInfo)
{ }
protected:
BluetoothNotificationHandler()
{ }
@ -535,6 +538,8 @@ public:
virtual void RemoveBond() { }
virtual void CancelBond() { }
virtual void GetConnectionState() { }
virtual void PinReply() { }
virtual void SspReply() { }
@ -542,6 +547,8 @@ public:
virtual void DutModeSend() { }
virtual void LeTestMode() { }
virtual void ReadEnergyInfo() { }
};
class BluetoothInterface
@ -591,12 +598,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,
@ -619,6 +632,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;

View File

@ -406,6 +406,7 @@ public:
}
nsresult CreateBondCmd(const nsAString& aBdAddr,
BluetoothTransport aTransport,
BluetoothResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
@ -2017,10 +2018,11 @@ BluetoothDaemonInterface::CancelDiscovery(BluetoothResultHandler* aRes)
void
BluetoothDaemonInterface::CreateBond(const nsAString& aBdAddr,
BluetoothTransport aTransport,
BluetoothResultHandler* aRes)
{
static_cast<BluetoothDaemonCoreModule*>
(mProtocol)->CreateBondCmd(aBdAddr, aRes);
(mProtocol)->CreateBondCmd(aBdAddr, aTransport, aRes);
}
void
@ -2039,6 +2041,15 @@ BluetoothDaemonInterface::CancelBond(const nsAString& aBdAddr,
(mProtocol)->CancelBondCmd(aBdAddr, aRes);
}
/* Connection */
void
BluetoothDaemonInterface::GetConnectionState(const nsAString& aBdAddr,
BluetoothResultHandler* aRes)
{
// NO-OP: no corresponding interface of current BlueZ
}
/* Authentication */
void
@ -2090,6 +2101,14 @@ BluetoothDaemonInterface::LeTestMode(uint16_t aOpcode, uint8_t* aBuf,
(mProtocol)->LeTestModeCmd(aOpcode, aBuf, aLen, aRes);
}
/* Energy Information */
void
BluetoothDaemonInterface::ReadEnergyInfo(BluetoothResultHandler* aRes)
{
// NO-OP: no corresponding interface of current BlueZ
}
void
BluetoothDaemonInterface::DispatchError(BluetoothResultHandler* aRes,
BluetoothStatus aStatus)

View File

@ -71,10 +71,16 @@ public:
/* Bonds */
void CreateBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
void CreateBond(const nsAString& aBdAddr, BluetoothTransport aTransport,
BluetoothResultHandler* aRes);
void RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
void CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
/* Connection */
void GetConnectionState(const nsAString& aBdAddr,
BluetoothResultHandler* aRes);
/* Authentication */
void PinReply(const nsAString& aBdAddr, bool aAccept,
@ -96,6 +102,10 @@ public:
void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
BluetoothResultHandler* aRes);
/* Energy Information */
void ReadEnergyInfo(BluetoothResultHandler* aRes);
/* Profile Interfaces */
BluetoothSocketInterface* GetBluetoothSocketInterface() MOZ_OVERRIDE;

View File

@ -176,6 +176,11 @@ struct BluetoothCallback
BluetoothStatus, uint16_t>
LeTestModeNotification;
typedef BluetoothNotificationHALRunnable1<NotificationHandlerWrapper, void,
BluetoothActivityEnergyInfo,
const BluetoothActivityEnergyInfo&>
EnergyInfoNotification;
// Bluedroid callbacks
static const bt_property_t*
@ -665,6 +670,7 @@ BluetoothHALInterface::CancelDiscovery(BluetoothResultHandler* aRes)
void
BluetoothHALInterface::CreateBond(const nsAString& aBdAddr,
BluetoothTransport aTransport,
BluetoothResultHandler* aRes)
{
bt_bdaddr_t bdAddr;
@ -723,6 +729,23 @@ BluetoothHALInterface::CancelBond(const nsAString& aBdAddr,
}
}
/* Connection */
void
BluetoothHALInterface::GetConnectionState(const nsAString& aBdAddr,
BluetoothResultHandler* aRes)
{
// TODO: to be implemented
int status = BT_STATUS_UNSUPPORTED;
if (aRes) {
DispatchBluetoothHALResult(aRes,
&BluetoothResultHandler::GetConnectionState,
ConvertDefault(status, STATUS_FAIL));
}
}
/* Authentication */
void
@ -831,6 +854,21 @@ BluetoothHALInterface::LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
}
}
/* Energy Information */
void
BluetoothHALInterface::ReadEnergyInfo(BluetoothResultHandler* aRes)
{
// TODO: to be implemented
int status = BT_STATUS_UNSUPPORTED;
if (aRes) {
DispatchBluetoothHALResult(aRes,
&BluetoothResultHandler::ReadEnergyInfo,
ConvertDefault(status, STATUS_FAIL));
}
}
/* Profile Interfaces */
template <class T>

View File

@ -59,10 +59,16 @@ public:
/* Bonds */
void CreateBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
void CreateBond(const nsAString& aBdAddr, BluetoothTransport aTransport,
BluetoothResultHandler* aRes);
void RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
void CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
/* Connection */
void GetConnectionState(const nsAString& aBdAddr,
BluetoothResultHandler* aRes);
/* Authentication */
void PinReply(const nsAString& aBdAddr, bool aAccept,
@ -84,6 +90,10 @@ public:
void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
BluetoothResultHandler* aRes);
/* Energy Information */
void ReadEnergyInfo(BluetoothResultHandler* aRes);
/* Profile Interfaces */
BluetoothSocketInterface* GetBluetoothSocketInterface();

View File

@ -693,7 +693,7 @@ BluetoothServiceBluedroid::CreatePairedDeviceInternal(
sBondingRunnableArray.AppendElement(aRunnable);
sBtInterface->CreateBond(aDeviceAddress,
sBtInterface->CreateBond(aDeviceAddress, TRANSPORT_AUTO,
new CreateBondResultHandler(aRunnable));
return NS_OK;
@ -1623,3 +1623,12 @@ BluetoothServiceBluedroid::LeTestModeNotification(BluetoothStatus aStatus,
// FIXME: This will be implemented in the later patchset
}
void
BluetoothServiceBluedroid::EnergyInfoNotification(
const BluetoothActivityEnergyInfo& aInfo)
{
MOZ_ASSERT(NS_IsMainThread());
// FIXME: This will be implemented in the later patchset
}

View File

@ -212,6 +212,9 @@ public:
virtual void LeTestModeNotification(BluetoothStatus aStatus,
uint16_t aNumPackets) MOZ_OVERRIDE;
virtual void EnergyInfoNotification(
const BluetoothActivityEnergyInfo& aInfo) MOZ_OVERRIDE;
protected:
static nsresult StartGonkBluetooth();
static nsresult StopGonkBluetooth();