mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1096266 - Avoid to create Bluetooth profiles on content process since HFP manager need permission to create setting lock. r=shuang, f=btian
This commit is contained in:
parent
c6e640af04
commit
59147d78cd
@ -94,12 +94,6 @@ StaticRefPtr<BluetoothService> sBluetoothService;
|
||||
bool sInShutdown = false;
|
||||
bool sToggleInProgress = false;
|
||||
|
||||
bool
|
||||
IsMainProcess()
|
||||
{
|
||||
return XRE_GetProcessType() == GeckoProcessType_Default;
|
||||
}
|
||||
|
||||
void
|
||||
ShutdownTimeExceeded(nsITimer* aTimer, void* aClosure)
|
||||
{
|
||||
@ -405,37 +399,6 @@ BluetoothService::StopBluetooth(bool aIsStartup,
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothProfileManagerBase* profile;
|
||||
profile = BluetoothHfpManager::Get();
|
||||
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
|
||||
if (profile->IsConnected()) {
|
||||
profile->Disconnect(nullptr);
|
||||
} else {
|
||||
profile->Reset();
|
||||
}
|
||||
|
||||
profile = BluetoothOppManager::Get();
|
||||
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
|
||||
if (profile->IsConnected()) {
|
||||
profile->Disconnect(nullptr);
|
||||
}
|
||||
|
||||
profile = BluetoothA2dpManager::Get();
|
||||
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
|
||||
if (profile->IsConnected()) {
|
||||
profile->Disconnect(nullptr);
|
||||
} else {
|
||||
profile->Reset();
|
||||
}
|
||||
|
||||
profile = BluetoothHidManager::Get();
|
||||
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
|
||||
if (profile->IsConnected()) {
|
||||
profile->Disconnect(nullptr);
|
||||
} else {
|
||||
profile->Reset();
|
||||
}
|
||||
|
||||
/* When IsEnabled() is false, we don't switch off Bluetooth but we still
|
||||
* send ToggleBtAck task. One special case happens at startup stage. At
|
||||
* startup, the initialization of BluetoothService still has to be done
|
||||
@ -444,7 +407,7 @@ BluetoothService::StopBluetooth(bool aIsStartup,
|
||||
* Please see bug 892392 for more information.
|
||||
*/
|
||||
if (aIsStartup || IsEnabled()) {
|
||||
// Switch Bluetooth off
|
||||
// Any connected Bluetooth profile would be disconnected.
|
||||
nsresult rv = StopInternal(aRunnable);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("Bluetooth service failed to stop!");
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "BluetoothA2dpManager.h"
|
||||
#include "BluetoothGattManager.h"
|
||||
#include "BluetoothHfpManager.h"
|
||||
#include "BluetoothHidManager.h"
|
||||
#include "BluetoothOppManager.h"
|
||||
#include "BluetoothProfileController.h"
|
||||
#include "BluetoothReplyRunnable.h"
|
||||
@ -335,6 +336,37 @@ BluetoothServiceBluedroid::StopInternal(BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothProfileManagerBase* profile;
|
||||
profile = BluetoothHfpManager::Get();
|
||||
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
|
||||
if (profile->IsConnected()) {
|
||||
profile->Disconnect(nullptr);
|
||||
} else {
|
||||
profile->Reset();
|
||||
}
|
||||
|
||||
profile = BluetoothOppManager::Get();
|
||||
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
|
||||
if (profile->IsConnected()) {
|
||||
profile->Disconnect(nullptr);
|
||||
}
|
||||
|
||||
profile = BluetoothA2dpManager::Get();
|
||||
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
|
||||
if (profile->IsConnected()) {
|
||||
profile->Disconnect(nullptr);
|
||||
} else {
|
||||
profile->Reset();
|
||||
}
|
||||
|
||||
profile = BluetoothHidManager::Get();
|
||||
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
|
||||
if (profile->IsConnected()) {
|
||||
profile->Disconnect(nullptr);
|
||||
} else {
|
||||
profile->Reset();
|
||||
}
|
||||
|
||||
// aRunnable will be a nullptr during starup and shutdown
|
||||
if(aRunnable) {
|
||||
sChangeAdapterStateRunnableArray.AppendElement(aRunnable);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
@ -197,4 +198,10 @@ DispatchStatusChangedEvent(const nsAString& aType,
|
||||
bs->DistributeSignal(signal);
|
||||
}
|
||||
|
||||
bool
|
||||
IsMainProcess()
|
||||
{
|
||||
return XRE_GetProcessType() == GeckoProcessType_Default;
|
||||
}
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
@ -76,6 +76,13 @@ DispatchStatusChangedEvent(const nsAString& aType,
|
||||
const nsAString& aDeviceAddress,
|
||||
bool aStatus);
|
||||
|
||||
/**
|
||||
* Test whether this function is running at b2g process.
|
||||
*
|
||||
* @return true if the function is running at b2g process, false otherwise.
|
||||
*/
|
||||
bool
|
||||
IsMainProcess();
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
||||
|
@ -223,6 +223,8 @@ BluetoothHfpManager::Reset()
|
||||
bool
|
||||
BluetoothHfpManager::Init()
|
||||
{
|
||||
// The function must run at b2g process since it would access SettingsService.
|
||||
MOZ_ASSERT(IsMainProcess());
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
|
@ -141,6 +141,38 @@ public:
|
||||
if (!IsEnabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
BluetoothProfileManagerBase* profile;
|
||||
profile = BluetoothHfpManager::Get();
|
||||
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
|
||||
if (profile->IsConnected()) {
|
||||
profile->Disconnect(nullptr);
|
||||
} else {
|
||||
profile->Reset();
|
||||
}
|
||||
|
||||
profile = BluetoothOppManager::Get();
|
||||
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
|
||||
if (profile->IsConnected()) {
|
||||
profile->Disconnect(nullptr);
|
||||
}
|
||||
|
||||
profile = BluetoothA2dpManager::Get();
|
||||
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
|
||||
if (profile->IsConnected()) {
|
||||
profile->Disconnect(nullptr);
|
||||
} else {
|
||||
profile->Reset();
|
||||
}
|
||||
|
||||
profile = BluetoothHidManager::Get();
|
||||
NS_ENSURE_TRUE(profile, NS_ERROR_FAILURE);
|
||||
if (profile->IsConnected()) {
|
||||
profile->Disconnect(nullptr);
|
||||
} else {
|
||||
profile->Reset();
|
||||
}
|
||||
|
||||
// 0 == success, -1 == error
|
||||
return !m_bt_disable();
|
||||
}
|
||||
|
@ -416,6 +416,8 @@ BluetoothHfpManager::Reset()
|
||||
bool
|
||||
BluetoothHfpManager::Init()
|
||||
{
|
||||
// The function must run at b2g process since it would access SettingsService.
|
||||
MOZ_ASSERT(IsMainProcess());
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
|
Loading…
Reference in New Issue
Block a user