зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1211948: Add interface class for Setup module to Bluetooth backend interface, r=brsun
With the new class |BluetoothSetupInterface|, Bluetooth modules can be registered and unregistered from outside the Bluetooth backend code.
This commit is contained in:
Родитель
d63e64e8de
Коммит
675ee8da68
|
@ -97,12 +97,6 @@ struct BluetoothAvrcpEventParamPair {
|
|||
const BluetoothAvrcpNotificationParam& mParam;
|
||||
};
|
||||
|
||||
struct BluetoothConfigurationParameter {
|
||||
uint8_t mType;
|
||||
uint16_t mLength;
|
||||
nsAutoArrayPtr<uint8_t> mValue;
|
||||
};
|
||||
|
||||
//
|
||||
// Conversion
|
||||
//
|
||||
|
|
|
@ -889,9 +889,21 @@ BluetoothDaemonInterface::DispatchError(BluetoothResultHandler* aRes,
|
|||
DispatchError(aRes, status);
|
||||
}
|
||||
|
||||
// Profile Interfaces
|
||||
// Service Interfaces
|
||||
//
|
||||
|
||||
BluetoothSetupInterface*
|
||||
BluetoothDaemonInterface::GetBluetoothSetupInterface()
|
||||
{
|
||||
if (mSetupInterface) {
|
||||
return mSetupInterface;
|
||||
}
|
||||
|
||||
mSetupInterface = new BluetoothDaemonSetupInterface(mProtocol);
|
||||
|
||||
return mSetupInterface;
|
||||
}
|
||||
|
||||
BluetoothSocketInterface*
|
||||
BluetoothDaemonInterface::GetBluetoothSocketInterface()
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@ class BluetoothDaemonAvrcpInterface;
|
|||
class BluetoothDaemonGattInterface;
|
||||
class BluetoothDaemonHandsfreeInterface;
|
||||
class BluetoothDaemonProtocol;
|
||||
class BluetoothDaemonSetupInterface;
|
||||
class BluetoothDaemonSocketInterface;
|
||||
|
||||
class BluetoothDaemonInterface final
|
||||
|
@ -125,8 +126,9 @@ public:
|
|||
|
||||
void ReadEnergyInfo(BluetoothResultHandler* aRes) override;
|
||||
|
||||
/* Profile Interfaces */
|
||||
/* Service Interfaces */
|
||||
|
||||
BluetoothSetupInterface* GetBluetoothSetupInterface() override;
|
||||
BluetoothSocketInterface* GetBluetoothSocketInterface() override;
|
||||
BluetoothHandsfreeInterface* GetBluetoothHandsfreeInterface() override;
|
||||
BluetoothA2dpInterface* GetBluetoothA2dpInterface() override;
|
||||
|
@ -162,6 +164,7 @@ private:
|
|||
|
||||
nsTArray<nsRefPtr<BluetoothResultHandler> > mResultHandlerQ;
|
||||
|
||||
nsAutoPtr<BluetoothDaemonSetupInterface> mSetupInterface;
|
||||
nsAutoPtr<BluetoothDaemonSocketInterface> mSocketInterface;
|
||||
nsAutoPtr<BluetoothDaemonHandsfreeInterface> mHandsfreeInterface;
|
||||
nsAutoPtr<BluetoothDaemonA2dpInterface> mA2dpInterface;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
//
|
||||
// Setup module
|
||||
//
|
||||
|
@ -167,4 +169,77 @@ BluetoothDaemonSetupModule::ConfigurationRsp(
|
|||
UnpackPDUInitOp(aPDU));
|
||||
}
|
||||
|
||||
//
|
||||
// Setup interface
|
||||
//
|
||||
|
||||
BluetoothDaemonSetupInterface::BluetoothDaemonSetupInterface(
|
||||
BluetoothDaemonSetupModule* aModule)
|
||||
: mModule(aModule)
|
||||
{ }
|
||||
|
||||
BluetoothDaemonSetupInterface::~BluetoothDaemonSetupInterface()
|
||||
{ }
|
||||
|
||||
void
|
||||
BluetoothDaemonSetupInterface::RegisterModule(
|
||||
uint8_t aId, uint8_t aMode, uint32_t aMaxNumClients,
|
||||
BluetoothSetupResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(mModule);
|
||||
|
||||
nsresult rv = mModule->RegisterModuleCmd(aId, aMode, aMaxNumClients, aRes);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchError(aRes, rv);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonSetupInterface::UnregisterModule(
|
||||
uint8_t aId,
|
||||
BluetoothSetupResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(mModule);
|
||||
|
||||
nsresult rv = mModule->UnregisterModuleCmd(aId, aRes);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchError(aRes, rv);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonSetupInterface::Configuration(
|
||||
const BluetoothConfigurationParameter* aParam, uint8_t aLen,
|
||||
BluetoothSetupResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(mModule);
|
||||
|
||||
nsresult rv = mModule->ConfigurationCmd(aParam, aLen, aRes);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchError(aRes, rv);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonSetupInterface::DispatchError(
|
||||
BluetoothSetupResultHandler* aRes, BluetoothStatus aStatus)
|
||||
{
|
||||
DaemonResultRunnable1<BluetoothSetupResultHandler, void,
|
||||
BluetoothStatus, BluetoothStatus>::Dispatch(
|
||||
aRes, &BluetoothSetupResultHandler::OnError,
|
||||
ConstantInitOp1<BluetoothStatus>(aStatus));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonSetupInterface::DispatchError(
|
||||
BluetoothSetupResultHandler* aRes, nsresult aRv)
|
||||
{
|
||||
BluetoothStatus status;
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(Convert(aRv, status)))) {
|
||||
status = STATUS_FAIL;
|
||||
}
|
||||
DispatchError(aRes, status);
|
||||
}
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
|
|
@ -86,6 +86,32 @@ private:
|
|||
BluetoothSetupResultHandler* aRes);
|
||||
};
|
||||
|
||||
class BluetoothDaemonSetupInterface final
|
||||
: public BluetoothSetupInterface
|
||||
{
|
||||
public:
|
||||
BluetoothDaemonSetupInterface(BluetoothDaemonSetupModule* aModule);
|
||||
~BluetoothDaemonSetupInterface();
|
||||
|
||||
void RegisterModule(uint8_t aId, uint8_t aMode,
|
||||
uint32_t aMaxNumClients,
|
||||
BluetoothSetupResultHandler* aRes) override;
|
||||
|
||||
void UnregisterModule(uint8_t aId,
|
||||
BluetoothSetupResultHandler* aRes) override;
|
||||
|
||||
void Configuration(const BluetoothConfigurationParameter* aParam,
|
||||
uint8_t aLen,
|
||||
BluetoothSetupResultHandler* aRes) override;
|
||||
|
||||
private:
|
||||
void DispatchError(BluetoothSetupResultHandler* aRes,
|
||||
BluetoothStatus aStatus);
|
||||
void DispatchError(BluetoothSetupResultHandler* aRes, nsresult aRv);
|
||||
|
||||
BluetoothDaemonSetupModule* mModule;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
||||
#endif // mozilla_dom_bluetooth_bluedroid_BluetoothDaemonSetupInterface_h
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "mozilla/Compiler.h"
|
||||
#include "mozilla/Observer.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
|
@ -480,6 +481,12 @@ struct BluetoothAddress {
|
|||
|
||||
};
|
||||
|
||||
struct BluetoothConfigurationParameter {
|
||||
uint8_t mType;
|
||||
uint16_t mLength;
|
||||
nsAutoArrayPtr<uint8_t> mValue;
|
||||
};
|
||||
|
||||
struct BluetoothUuid {
|
||||
uint8_t mUuid[16];
|
||||
|
||||
|
|
|
@ -39,6 +39,12 @@ void
|
|||
BluetoothSetupResultHandler::Configuration()
|
||||
{ }
|
||||
|
||||
// Interface
|
||||
//
|
||||
|
||||
BluetoothSetupInterface::~BluetoothSetupInterface()
|
||||
{ }
|
||||
|
||||
//
|
||||
// Socket Interface
|
||||
//
|
||||
|
|
|
@ -30,6 +30,25 @@ protected:
|
|||
virtual ~BluetoothSetupResultHandler() { }
|
||||
};
|
||||
|
||||
class BluetoothSetupInterface
|
||||
{
|
||||
public:
|
||||
virtual void RegisterModule(uint8_t aId,
|
||||
uint8_t aMode,
|
||||
uint32_t aMaxNumClients,
|
||||
BluetoothSetupResultHandler* aRes) = 0;
|
||||
|
||||
virtual void UnregisterModule(uint8_t aId,
|
||||
BluetoothSetupResultHandler* aRes) = 0;
|
||||
|
||||
virtual void Configuration(const BluetoothConfigurationParameter* aParam,
|
||||
uint8_t aLen,
|
||||
BluetoothSetupResultHandler* aRes) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~BluetoothSetupInterface();
|
||||
};
|
||||
|
||||
//
|
||||
// Socket Interface
|
||||
//
|
||||
|
@ -1111,6 +1130,7 @@ public:
|
|||
|
||||
/* Profile Interfaces */
|
||||
|
||||
virtual BluetoothSetupInterface* GetBluetoothSetupInterface() = 0;
|
||||
virtual BluetoothSocketInterface* GetBluetoothSocketInterface() = 0;
|
||||
virtual BluetoothHandsfreeInterface* GetBluetoothHandsfreeInterface() = 0;
|
||||
virtual BluetoothA2dpInterface* GetBluetoothA2dpInterface() = 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче