mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1239979: Init and uninit all Bluetooth profile managers, r=shuang
The use is init and deinit methods is currently inconsistent among Bluetooth profile managers. This patch unifies all these methods and integrates them into the Bluetooth service. Instances of the manager classes are now unref'ed during Bluetooth shutdown.
This commit is contained in:
parent
67a377cc9b
commit
599768e032
@ -296,6 +296,7 @@ public:
|
||||
|
||||
sBtA2dpInterface->SetNotificationHandler(nullptr);
|
||||
sBtA2dpInterface = nullptr;
|
||||
sBluetoothA2dpManager = nullptr;
|
||||
|
||||
if (mRes) {
|
||||
mRes->OnError(NS_ERROR_FAILURE);
|
||||
@ -308,6 +309,7 @@ public:
|
||||
|
||||
sBtA2dpInterface->SetNotificationHandler(nullptr);
|
||||
sBtA2dpInterface = nullptr;
|
||||
sBluetoothA2dpManager = nullptr;
|
||||
|
||||
if (mRes) {
|
||||
mRes->Deinit();
|
||||
|
@ -317,6 +317,7 @@ public:
|
||||
|
||||
sBtAvrcpInterface->SetNotificationHandler(nullptr);
|
||||
sBtAvrcpInterface = nullptr;
|
||||
sBluetoothAvrcpManager = nullptr;
|
||||
|
||||
if (mRes) {
|
||||
mRes->OnError(NS_ERROR_FAILURE);
|
||||
@ -329,6 +330,7 @@ public:
|
||||
|
||||
sBtAvrcpInterface->SetNotificationHandler(nullptr);
|
||||
sBtAvrcpInterface = nullptr;
|
||||
sBluetoothAvrcpManager = nullptr;
|
||||
|
||||
if (mRes) {
|
||||
mRes->Deinit();
|
||||
|
@ -583,6 +583,7 @@ public:
|
||||
sBluetoothGattInterface = nullptr;
|
||||
sClients = nullptr;
|
||||
sServers = nullptr;
|
||||
sBluetoothGattManager = nullptr;
|
||||
|
||||
if (mRes) {
|
||||
mRes->Deinit();
|
||||
|
@ -133,6 +133,30 @@ BluetoothMapSmsManager::Init()
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
BluetoothMapSmsManager::InitMapSmsInterface(BluetoothProfileResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aRes) {
|
||||
aRes->Init();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
BluetoothMapSmsManager::DeinitMapSmsInterface(BluetoothProfileResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
sMapSmsManager = nullptr;
|
||||
|
||||
if (aRes) {
|
||||
aRes->Deinit();
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
BluetoothMapSmsManager*
|
||||
BluetoothMapSmsManager::Get()
|
||||
|
@ -86,7 +86,10 @@ public:
|
||||
// By defualt SMS/MMS is default supported
|
||||
static const int SDP_SMS_MMS_INSTANCE_ID = 0;
|
||||
|
||||
static void InitMapSmsInterface(BluetoothProfileResultHandler* aRes);
|
||||
static void DeinitMapSmsInterface(BluetoothProfileResultHandler* aRes);
|
||||
static BluetoothMapSmsManager* Get();
|
||||
|
||||
bool Listen();
|
||||
|
||||
/**
|
||||
|
@ -253,6 +253,30 @@ BluetoothOppManager::Init()
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
BluetoothOppManager::InitOppInterface(BluetoothProfileResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aRes) {
|
||||
aRes->Init();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
BluetoothOppManager::DeinitOppInterface(BluetoothProfileResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
sBluetoothOppManager = nullptr;
|
||||
|
||||
if (aRes) {
|
||||
aRes->Deinit();
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
BluetoothOppManager*
|
||||
BluetoothOppManager::Get()
|
||||
|
@ -40,6 +40,7 @@ class BluetoothOppManager : public BluetoothSocketObserver
|
||||
class SendSocketDataTask;
|
||||
|
||||
public:
|
||||
|
||||
BT_DECL_PROFILE_MGR_BASE
|
||||
BT_DECL_SOCKET_OBSERVER
|
||||
virtual void GetName(nsACString& aName)
|
||||
@ -49,7 +50,10 @@ public:
|
||||
|
||||
static const int MAX_PACKET_LENGTH = 0xFFFE;
|
||||
|
||||
static void InitOppInterface(BluetoothProfileResultHandler* aRes);
|
||||
static void DeinitOppInterface(BluetoothProfileResultHandler* aRes);
|
||||
static BluetoothOppManager* Get();
|
||||
|
||||
void ClientDataHandler(mozilla::ipc::UnixSocketBuffer* aMessage);
|
||||
void ServerDataHandler(mozilla::ipc::UnixSocketBuffer* aMessage);
|
||||
|
||||
|
@ -140,6 +140,30 @@ BluetoothPbapManager::Init()
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
BluetoothPbapManager::InitPbapInterface(BluetoothProfileResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aRes) {
|
||||
aRes->Init();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
BluetoothPbapManager::DeinitPbapInterface(BluetoothProfileResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
sPbapManager = nullptr;
|
||||
|
||||
if (aRes) {
|
||||
aRes->Deinit();
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
BluetoothPbapManager*
|
||||
BluetoothPbapManager::Get()
|
||||
|
@ -67,7 +67,10 @@ public:
|
||||
static const int MAX_PACKET_LENGTH = 0xFFFE;
|
||||
static const int DIGEST_LENGTH = 16;
|
||||
|
||||
static void InitPbapInterface(BluetoothProfileResultHandler* aRes);
|
||||
static void DeinitPbapInterface(BluetoothProfileResultHandler* aRes);
|
||||
static BluetoothPbapManager* Get();
|
||||
|
||||
bool Listen();
|
||||
|
||||
/**
|
||||
|
@ -138,6 +138,10 @@ public:
|
||||
void Init() override
|
||||
{
|
||||
static void (* const sInitManager[])(BluetoothProfileResultHandler*) = {
|
||||
BluetoothMapSmsManager::InitMapSmsInterface,
|
||||
BluetoothOppManager::InitOppInterface,
|
||||
BluetoothPbapManager::InitPbapInterface,
|
||||
BluetoothHidManager::InitHidInterface,
|
||||
BluetoothHfpManager::InitHfpInterface,
|
||||
BluetoothA2dpManager::InitA2dpInterface,
|
||||
BluetoothAvrcpManager::InitAvrcpInterface,
|
||||
@ -2037,7 +2041,11 @@ BluetoothServiceBluedroid::AdapterStateChangedNotification(bool aState)
|
||||
BluetoothGattManager::DeinitGattInterface,
|
||||
BluetoothAvrcpManager::DeinitAvrcpInterface,
|
||||
BluetoothA2dpManager::DeinitA2dpInterface,
|
||||
BluetoothHfpManager::DeinitHfpInterface
|
||||
BluetoothHfpManager::DeinitHfpInterface,
|
||||
BluetoothHidManager::DeinitHidInterface,
|
||||
BluetoothPbapManager::DeinitPbapInterface,
|
||||
BluetoothOppManager::DeinitOppInterface,
|
||||
BluetoothMapSmsManager::DeinitMapSmsInterface
|
||||
};
|
||||
|
||||
// Return error if BluetoothService is unavailable
|
||||
|
@ -176,6 +176,8 @@ BluetoothHfpManager::DeinitHfpInterface(BluetoothProfileResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
sBluetoothHfpManager = nullptr;
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
* Implement DeinitHfpInterface() for applications that want to create SCO
|
||||
|
@ -446,6 +446,7 @@ public:
|
||||
|
||||
sBluetoothHfpInterface->SetNotificationHandler(nullptr);
|
||||
sBluetoothHfpInterface = nullptr;
|
||||
sBluetoothHfpManager = nullptr;
|
||||
|
||||
if (mRes) {
|
||||
mRes->OnError(NS_ERROR_FAILURE);
|
||||
@ -458,6 +459,7 @@ public:
|
||||
|
||||
sBluetoothHfpInterface->SetNotificationHandler(nullptr);
|
||||
sBluetoothHfpInterface = nullptr;
|
||||
sBluetoothHfpManager = nullptr;
|
||||
|
||||
if (mRes) {
|
||||
mRes->Deinit();
|
||||
|
@ -78,6 +78,30 @@ BluetoothHidManager::~BluetoothHidManager()
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
BluetoothHidManager::InitHidInterface(BluetoothProfileResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aRes) {
|
||||
aRes->Init();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
BluetoothHidManager::DeinitHidInterface(BluetoothProfileResultHandler* aRes)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
sBluetoothHidManager = nullptr;
|
||||
|
||||
if (aRes) {
|
||||
aRes->Deinit();
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
BluetoothHidManager*
|
||||
BluetoothHidManager::Get()
|
||||
|
@ -22,6 +22,8 @@ public:
|
||||
aName.AssignLiteral("HID");
|
||||
}
|
||||
|
||||
static void InitHidInterface(BluetoothProfileResultHandler* aRes);
|
||||
static void DeinitHidInterface(BluetoothProfileResultHandler* aRes);
|
||||
static BluetoothHidManager* Get();
|
||||
|
||||
// HID-specific functions
|
||||
|
Loading…
Reference in New Issue
Block a user