diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp index 7c958e7cc656..a212ba82c23c 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp @@ -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); } diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h index 3a70b62714e9..bccf183cc57a 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h @@ -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, diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp index bd956a6e96a7..a0dc78e6dc99 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp @@ -1318,7 +1318,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); diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.h index 6b8d4b46b0ea..69c713a2f2e0 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.h @@ -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, diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp index 316721343627..2e2e9c9713c5 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.cpp @@ -1259,6 +1259,12 @@ PackPDU(BluetoothSocketType aIn, BluetoothDaemonPDU& aPDU) return PackPDU(PackConversion(aIn), aPDU); } +nsresult +PackPDU(BluetoothTransport aIn, BluetoothDaemonPDU& aPDU) +{ + return PackPDU(PackConversion(aIn), aPDU); +} + nsresult PackPDU(ControlPlayStatus aIn, BluetoothDaemonPDU& aPDU) { diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h b/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h index c0d8cc58d643..2e4174e1497c 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h @@ -418,6 +418,9 @@ PackPDU(BluetoothSspPairingVariant aIn, BluetoothDaemonPDU& aPDU); nsresult PackPDU(BluetoothScanMode aIn, BluetoothDaemonPDU& aPDU); +nsresult +PackPDU(BluetoothTransport aIn, BluetoothDaemonPDU& aPDU); + nsresult PackPDU(ControlPlayStatus aIn, BluetoothDaemonPDU& aPDU); diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp index 4a8b24505c27..85812a31b983 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp @@ -31,13 +31,18 @@ public: // nsresult RegisterModuleCmd(uint8_t aId, uint8_t aMode, + uint32_t aMaxNumClients, BluetoothSetupResultHandler* aRes) { MOZ_ASSERT(NS_IsMainThread()); nsAutoPtr 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 pdu(new BluetoothDaemonPDU(0x01, 0x0d, 0)); +#if ANDROID_VERSION >= 21 + nsresult rv = PackPDU( + PackConversion(aBdAddr), aTransport, *pdu); +#else nsresult rv = PackPDU( PackConversion(aBdAddr), *pdu); +#endif if (NS_FAILED(rv)) { return rv; } @@ -1354,6 +1367,8 @@ private: }; +const int BluetoothDaemonCoreModule::MAX_NUM_CLIENTS = 1; + // // Protocol handling // @@ -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); } diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp index 7acfae65f502..7022d19a3f15 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp @@ -15,6 +15,8 @@ BEGIN_BLUETOOTH_NAMESPACE // Socket module // +const int BluetoothDaemonSocketModule::MAX_NUM_CLIENTS = 1; + // Commands // diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.h index 08243fa1d667..cda13c52774e 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.h @@ -20,6 +20,8 @@ class BlutoothDaemonInterface; class BluetoothDaemonSocketModule { public: + static const int MAX_NUM_CLIENTS; + virtual nsresult Send(BluetoothDaemonPDU* aPDU, void* aUserData) = 0; // Commands