Bug 1102703: (7/10) Porting bluetooth interface of bluez 5.26 (core) r=btian, f=tzimmermann

This commit is contained in:
Bruce Sun 2015-01-09 13:38:15 +08:00
Родитель 050b6a1922
Коммит 04614aebb8
11 изменённых файлов: 52 добавлений и 7 удалений

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

@ -14,6 +14,8 @@ BEGIN_BLUETOOTH_NAMESPACE
// A2DP module
//
const int BluetoothDaemonA2dpModule::MAX_NUM_CLIENTS = 1;
BluetoothA2dpNotificationHandler*
BluetoothDaemonA2dpModule::sNotificationHandler;
@ -342,7 +344,7 @@ BluetoothDaemonA2dpInterface::Init(
}
nsresult rv = mModule->RegisterModule(BluetoothDaemonA2dpModule::SERVICE_ID,
0x00, res);
0x00, BluetoothDaemonA2dpModule::MAX_NUM_CLIENTS, res);
if (NS_FAILED(rv) && aRes) {
DispatchError(aRes, STATUS_FAIL);
}

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

@ -28,9 +28,12 @@ public:
OPCODE_DISCONNECT = 0x02
};
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(BluetoothDaemonPDU* aPDU, void* aUserData) = 0;
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
BluetoothSetupResultHandler* aRes) = 0;
virtual nsresult UnregisterModule(uint8_t aId,

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

@ -14,6 +14,8 @@ BEGIN_BLUETOOTH_NAMESPACE
// AVRCP module
//
const int BluetoothDaemonAvrcpModule::MAX_NUM_CLIENTS = 1;
BluetoothAvrcpNotificationHandler*
BluetoothDaemonAvrcpModule::sNotificationHandler;
@ -887,7 +889,8 @@ BluetoothDaemonAvrcpInterface::Init(
}
nsresult rv = mModule->RegisterModule(
BluetoothDaemonAvrcpModule::SERVICE_ID, 0x00, res);
BluetoothDaemonAvrcpModule::SERVICE_ID,
BluetoothDaemonAvrcpModule::MAX_NUM_CLIENTS, 0x00, res);
if (NS_FAILED(rv) && aRes) {
DispatchError(aRes, STATUS_FAIL);

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

@ -60,9 +60,12 @@ public:
#endif
};
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(BluetoothDaemonPDU* aPDU, void* aUserData) = 0;
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
BluetoothSetupResultHandler* aRes) = 0;
virtual nsresult UnregisterModule(uint8_t aId,

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

@ -1304,7 +1304,8 @@ BluetoothDaemonHandsfreeInterface::Init(
}
nsresult rv = mModule->RegisterModule(
BluetoothDaemonHandsfreeModule::SERVICE_ID, MODE_NARROWBAND_SPEECH, res);
BluetoothDaemonHandsfreeModule::SERVICE_ID, MODE_NARROWBAND_SPEECH,
aMaxNumClients, res);
if (NS_FAILED(rv) && aRes) {
DispatchError(aRes, STATUS_FAIL);

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

@ -43,6 +43,7 @@ public:
virtual nsresult Send(BluetoothDaemonPDU* aPDU, void* aUserData) = 0;
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
BluetoothSetupResultHandler* aRes) = 0;
virtual nsresult UnregisterModule(uint8_t aId,

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

@ -1265,6 +1265,12 @@ PackPDU(ControlPlayStatus aIn, BluetoothDaemonPDU& aPDU)
return PackPDU(PackConversion<ControlPlayStatus, uint8_t>(aIn), aPDU);
}
nsresult
PackPDU(BluetoothTransport aIn, BluetoothDaemonPDU& aPDU)
{
return PackPDU(PackConversion<BluetoothTransport, uint8_t>(aIn), aPDU);
}
//
// Unpacking
//

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

@ -421,6 +421,9 @@ PackPDU(BluetoothScanMode aIn, BluetoothDaemonPDU& aPDU);
nsresult
PackPDU(ControlPlayStatus aIn, BluetoothDaemonPDU& aPDU);
nsresult
PackPDU(BluetoothTransport aIn, BluetoothDaemonPDU& aPDU);
/* |PackConversion| is a helper for packing converted values. Pass
* an instance of this structure to |PackPDU| to convert a value from
* the input type to the output type and and write it to the PDU.

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

@ -31,13 +31,18 @@ public:
//
nsresult RegisterModuleCmd(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
BluetoothSetupResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
nsAutoPtr<BluetoothDaemonPDU> pdu(new BluetoothDaemonPDU(0x00, 0x01, 0));
#if ANDROID_VERSION >= 21
nsresult rv = PackPDU(aId, aMode, aMaxNumClients, *pdu);
#else
nsresult rv = PackPDU(aId, aMode, *pdu);
#endif
if (NS_FAILED(rv)) {
return rv;
}
@ -188,6 +193,9 @@ static BluetoothNotificationHandler* sNotificationHandler;
class BluetoothDaemonCoreModule
{
public:
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(BluetoothDaemonPDU* aPDU, void* aUserData) = 0;
nsresult EnableCmd(BluetoothResultHandler* aRes)
@ -413,8 +421,13 @@ public:
nsAutoPtr<BluetoothDaemonPDU> pdu(new BluetoothDaemonPDU(0x01, 0x0d, 0));
#if ANDROID_VERSION >= 21
nsresult rv = PackPDU(
PackConversion<nsAString, BluetoothAddress>(aBdAddr), aTransport, *pdu);
#else
nsresult rv = PackPDU(
PackConversion<nsAString, BluetoothAddress>(aBdAddr), *pdu);
#endif
if (NS_FAILED(rv)) {
return rv;
}
@ -1403,6 +1416,8 @@ private:
//
// - |HandleSvc|,
//
const int BluetoothDaemonCoreModule::MAX_NUM_CLIENTS = 1;
// which is called by |BluetoothDaemonProtcol| to hand over received
// PDUs into a module.
//
@ -1418,7 +1433,7 @@ class BluetoothDaemonProtocol MOZ_FINAL
public:
BluetoothDaemonProtocol(BluetoothDaemonConnection* aConnection);
nsresult RegisterModule(uint8_t aId, uint8_t aMode,
nsresult RegisterModule(uint8_t aId, uint8_t aMode, uint32_t aMaxNumClients,
BluetoothSetupResultHandler* aRes) MOZ_OVERRIDE;
nsresult UnregisterModule(uint8_t aId,
@ -1465,9 +1480,11 @@ BluetoothDaemonProtocol::BluetoothDaemonProtocol(
nsresult
BluetoothDaemonProtocol::RegisterModule(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
BluetoothSetupResultHandler* aRes)
{
return BluetoothDaemonSetupModule::RegisterModuleCmd(aId, aMode, aRes);
return BluetoothDaemonSetupModule::RegisterModuleCmd(aId, aMode,
aMaxNumClients, aRes);
}
nsresult
@ -1747,7 +1764,8 @@ public:
if (!mRegisteredSocketModule) {
mRegisteredSocketModule = true;
// Init, step 4: Register Socket module
mInterface->mProtocol->RegisterModuleCmd(0x02, 0x00, this);
mInterface->mProtocol->RegisterModuleCmd(0x02, 0x00,
BluetoothDaemonSocketModule::MAX_NUM_CLIENTS, this);
} else if (mRes) {
// Init, step 5: Signal success to caller
mRes->Init();
@ -1786,7 +1804,8 @@ BluetoothDaemonInterface::OnConnectSuccess(enum Channel aChannel)
// Init, step 3: Register Core module
nsresult rv = mProtocol->RegisterModuleCmd(
0x01, 0x00, new InitResultHandler(this, res));
0x01, 0x00, BluetoothDaemonCoreModule::MAX_NUM_CLIENTS,
new InitResultHandler(this, res));
if (NS_FAILED(rv) && res) {
DispatchError(res, STATUS_FAIL);
}

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

@ -15,6 +15,8 @@ BEGIN_BLUETOOTH_NAMESPACE
// Socket module
//
const int BluetoothDaemonSocketModule::MAX_NUM_CLIENTS = 1;
// Commands
//

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

@ -20,6 +20,8 @@ class BlutoothDaemonInterface;
class BluetoothDaemonSocketModule
{
public:
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(BluetoothDaemonPDU* aPDU, void* aUserData) = 0;
// Commands